From 27bf51f9f8bf6378b348c8b39db237ecf861c0c3 Mon Sep 17 00:00:00 2001 From: Hay1tsme Date: Mon, 8 Jan 2024 18:22:09 -0500 Subject: [PATCH] chuni: add matching config, stun turn stuff --- example_config/chuni.yaml | 9 ++++++++- titles/chuni/config.py | 34 ++++++++++++++++++++++++++++++++++ titles/chuni/new.py | 15 +++++++++------ 3 files changed, 51 insertions(+), 7 deletions(-) diff --git a/example_config/chuni.yaml b/example_config/chuni.yaml index 72a1d98..2b3ae98 100644 --- a/example_config/chuni.yaml +++ b/example_config/chuni.yaml @@ -24,4 +24,11 @@ version: data: 2.15.00 crypto: - encrypted_only: False \ No newline at end of file + 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 diff --git a/titles/chuni/config.py b/titles/chuni/config.py index 05cc8ad..55689c8 100644 --- a/titles/chuni/config.py +++ b/titles/chuni/config.py @@ -89,6 +89,39 @@ class ChuniCryptoConfig: 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): def __init__(self) -> None: @@ -97,3 +130,4 @@ class ChuniConfig(dict): self.mods = ChuniModsConfig(self) self.version = ChuniVersionConfig(self) self.crypto = ChuniCryptoConfig(self) + self.matching = ChuniMatchingConfig(self) diff --git a/titles/chuni/new.py b/titles/chuni/new.py index 8a658bf..86a7b08 100644 --- a/titles/chuni/new.py +++ b/titles/chuni/new.py @@ -5,6 +5,7 @@ from typing import Dict import pytz from core.config import CoreConfig +from core.utils import Utils from titles.chuni.const import ChuniConstants from titles.chuni.database import ChuniData from titles.chuni.base import ChuniBase @@ -55,6 +56,7 @@ class ChuniNew(ChuniBase): # create strings for use in gameSetting reboot_start = reboot_start_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 { "gameSetting": { "isMaintenance": False, @@ -67,15 +69,16 @@ class ChuniNew(ChuniBase): "maxCountMusic": 300, "matchStartTime": match_start, "matchEndTime": match_end, - "matchTimeLimit": 60, - "matchErrorLimit": 9999, + "matchTimeLimit": self.game_cfg.matching.match_time_limit, + "matchErrorLimit": self.game_cfg.matching.match_error_limit, "romVersion": self.game_cfg.version.version(self.version)["rom"], "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/", - "matchingUriX": 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}:{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 - "udpHolePunchUri": f"http://{self.core_cfg.title.hostname}:{self.core_cfg.title.port}/SDHD/200/ChuniServlet/", - "reflectorUri": 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... + "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, "isAou": False,