3
2
forked from Dniel97/artemis

chuni: add matching config, stun turn stuff

This commit is contained in:
Hay1tsme 2024-01-08 18:22:09 -05:00
parent 343424e26a
commit 27bf51f9f8
3 changed files with 51 additions and 7 deletions

View File

@ -24,4 +24,11 @@ version:
data: 2.15.00 data: 2.15.00
crypto: crypto:
encrypted_only: False encrypted_only: False
matching:
enable: False
stun_uri: "stun:stunserver.stunprotocol.org:3478"
turn_uri: "turn:stunserver.stunprotocol.org:3478"
match_time_limit: 60
match_error_limit: 9999

View File

@ -89,6 +89,39 @@ class ChuniCryptoConfig:
self.__config, "chuni", "crypto", "encrypted_only", default=False self.__config, "chuni", "crypto", "encrypted_only", default=False
) )
class ChuniMatchingConfig:
def __init__(self, parent_config: "ChuniConfig") -> None:
self.__config = parent_config
@property
def enable(self) -> bool:
return CoreConfig.get_config_field(
self.__config, "chuni", "matching", "enable", default=False
)
@property
def stun_uri(self) -> str:
return CoreConfig.get_config_field(
self.__config, "chuni", "matching", "stun_uri", default="stun:stunserver.stunprotocol.org:3478"
)
@property
def turn_uri(self) -> str:
return CoreConfig.get_config_field(
self.__config, "chuni", "matching", "turn_uri", default="turn:stunserver.stunprotocol.org:3478"
)
@property
def match_time_limit(self) -> int:
return CoreConfig.get_config_field(
self.__config, "chuni", "matching", "match_time_limit", default=60
)
@property
def match_error_limit(self) -> int:
return CoreConfig.get_config_field(
self.__config, "chuni", "matching", "match_error_limit", default=9999
)
class ChuniConfig(dict): class ChuniConfig(dict):
def __init__(self) -> None: def __init__(self) -> None:
@ -97,3 +130,4 @@ class ChuniConfig(dict):
self.mods = ChuniModsConfig(self) self.mods = ChuniModsConfig(self)
self.version = ChuniVersionConfig(self) self.version = ChuniVersionConfig(self)
self.crypto = ChuniCryptoConfig(self) self.crypto = ChuniCryptoConfig(self)
self.matching = ChuniMatchingConfig(self)

View File

@ -5,6 +5,7 @@ from typing import Dict
import pytz import pytz
from core.config import CoreConfig from core.config import CoreConfig
from core.utils import Utils
from titles.chuni.const import ChuniConstants from titles.chuni.const import ChuniConstants
from titles.chuni.database import ChuniData from titles.chuni.database import ChuniData
from titles.chuni.base import ChuniBase from titles.chuni.base import ChuniBase
@ -55,6 +56,7 @@ class ChuniNew(ChuniBase):
# create strings for use in gameSetting # create strings for use in gameSetting
reboot_start = reboot_start_time.strftime(self.date_time_format) reboot_start = reboot_start_time.strftime(self.date_time_format)
reboot_end = reboot_end_time.strftime(self.date_time_format) reboot_end = reboot_end_time.strftime(self.date_time_format)
t_port = Utils.get_title_port(self.core_cfg)
return { return {
"gameSetting": { "gameSetting": {
"isMaintenance": False, "isMaintenance": False,
@ -67,15 +69,16 @@ class ChuniNew(ChuniBase):
"maxCountMusic": 300, "maxCountMusic": 300,
"matchStartTime": match_start, "matchStartTime": match_start,
"matchEndTime": match_end, "matchEndTime": match_end,
"matchTimeLimit": 60, "matchTimeLimit": self.game_cfg.matching.match_time_limit,
"matchErrorLimit": 9999, "matchErrorLimit": self.game_cfg.matching.match_error_limit,
"romVersion": self.game_cfg.version.version(self.version)["rom"], "romVersion": self.game_cfg.version.version(self.version)["rom"],
"dataVersion": self.game_cfg.version.version(self.version)["data"], "dataVersion": self.game_cfg.version.version(self.version)["data"],
"matchingUri": f"http://{self.core_cfg.title.hostname}:{self.core_cfg.title.port}/SDHD/200/ChuniServlet/", "matchingUri": f"http://{self.core_cfg.title.hostname}:{t_port}/SDHD/200/ChuniServlet/" if self.game_cfg.matching.enable else "",
"matchingUriX": f"http://{self.core_cfg.title.hostname}:{self.core_cfg.title.port}/SDHD/200/ChuniServlet/", "matchingUriX": f"http://{self.core_cfg.title.hostname}:{t_port}/SDHD/200/ChuniServlet/" if self.game_cfg.matching.enable else "",
# might be really important for online battle to connect the cabs via UDP port 50201 # might be really important for online battle to connect the cabs via UDP port 50201
"udpHolePunchUri": f"http://{self.core_cfg.title.hostname}:{self.core_cfg.title.port}/SDHD/200/ChuniServlet/", # Hay1tsme 01/08/2023: Pretty sure this is a stun and turn server respectivly...
"reflectorUri": f"http://{self.core_cfg.title.hostname}:{self.core_cfg.title.port}/SDHD/200/ChuniServlet/", "udpHolePunchUri": self.game_cfg.matching.stun_uri if self.game_cfg.matching.enable else "",
"reflectorUri": self.game_cfg.matching.turn_uri if self.game_cfg.matching.enable else "",
}, },
"isDumpUpload": False, "isDumpUpload": False,
"isAou": False, "isAou": False,