From 94c326a27dfb5944866f7b057c1ca4740845dad7 Mon Sep 17 00:00:00 2001 From: Hay1tsme Date: Wed, 8 Nov 2023 21:42:53 -0500 Subject: [PATCH] ongeki: add option to use https for red and beyond --- example_config/ongeki.yaml | 1 + titles/ongeki/config.py | 6 ++++++ titles/ongeki/index.py | 17 ++++++++++------- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/example_config/ongeki.yaml b/example_config/ongeki.yaml index e4088c0..9af5efe 100644 --- a/example_config/ongeki.yaml +++ b/example_config/ongeki.yaml @@ -1,6 +1,7 @@ server: enable: True loglevel: "info" + use_https: False gachas: enabled_gachas: diff --git a/titles/ongeki/config.py b/titles/ongeki/config.py index 2321af6..b952b2d 100644 --- a/titles/ongeki/config.py +++ b/titles/ongeki/config.py @@ -21,6 +21,12 @@ class OngekiServerConfig: self.__config, "ongeki", "server", "loglevel", default="info" ) ) + + @property + def use_https(self) -> bool: + return CoreConfig.get_config_field( + self.__config, "ongeki", "server", "use_https", default=False + ) class OngekiGachaConfig: diff --git a/titles/ongeki/index.py b/titles/ongeki/index.py index 2e928f6..bdfd8d5 100644 --- a/titles/ongeki/index.py +++ b/titles/ongeki/index.py @@ -127,15 +127,18 @@ class OngekiServlet(BaseServlet): ) def get_allnet_info(self, game_code: str, game_ver: int, keychip: str) -> Tuple[str, str]: - if not self.core_cfg.server.is_using_proxy and Utils.get_title_port(self.core_cfg) != 80: - return ( - f"http://{self.core_cfg.title.hostname}:{Utils.get_title_port(self.core_cfg)}/{game_code}/{game_ver}/", - f"{self.core_cfg.title.hostname}:{Utils.get_title_port(self.core_cfg)}/", - ) + title_port_int = Utils.get_title_port(self.core_cfg) + proto = "https" if self.game_cfg.server.use_https and game_ver >= 120 else "http" + + if proto == "https": + t_port = f":{title_port_int}" if title_port_int != 443 and not self.core_cfg.server.is_using_proxy else "" + + else: + t_port = f":{title_port_int}" if title_port_int != 80 and not self.core_cfg.server.is_using_proxy else "" return ( - f"http://{self.core_cfg.title.hostname}/{game_code}/{game_ver}/", - f"{self.core_cfg.title.hostname}/", + f"{proto}://{self.core_cfg.title.hostname}{t_port}/{game_code}/{game_ver}/", + f"{self.core_cfg.title.hostname}{t_port}/", ) def render_POST(self, request: Request, game_code: str, matchers: Dict) -> bytes: