diff --git a/core/config.py b/core/config.py index 3a772f7..118f1e3 100644 --- a/core/config.py +++ b/core/config.py @@ -84,6 +84,24 @@ class TitleConfig: return CoreConfig.get_config_field( self.__config, "core", "title", "port", default=8080 ) + + @property + def port_ssl(self) -> int: + return CoreConfig.get_config_field( + self.__config, "core", "title", "port_ssl", default=0 + ) + + @property + def ssl_key(self) -> str: + return CoreConfig.get_config_field( + self.__config, "core", "title", "ssl_key", default="cert/title.key" + ) + + @property + def ssl_cert(self) -> str: + return CoreConfig.get_config_field( + self.__config, "core", "title", "ssl_cert", default="cert/title.pem" + ) @property def reboot_start_time(self) -> str: diff --git a/docs/config.md b/docs/config.md index 9de57f9..81fb43d 100644 --- a/docs/config.md +++ b/docs/config.md @@ -13,6 +13,9 @@ - `loglevel`: Logging level for the title server. Default `info` - `hostname`: Hostname that gets sent to clients to tell them where to connect. Games must be able to connect to your server via the hostname or IP you spcify here. Note that most games will reject `localhost` or `127.0.0.1`. Default `localhost` - `port`: Port that the title server will listen for connections on. Set to 0 to use the Allnet handler to reduce the port footprint. Default `8080` +- `port_ssl`: Port that the secure title server will listen for connections on. Set to 0 to use the Allnet handler to reduce the port footprint. Default `0` +- `ssl_key`: Location of the ssl server key for the secure title server. Ignored if `port_ssl` is set to `0` or `is_develop` set to `False`. Default `cert/title.key` +- `ssl_cert`: Location of the ssl server certificate for the secure title server. Must not be a self-signed SSL. Ignored if `port_ssl` is set to `0` or `is_develop` is set to `False`. Default `cert/title.pem` - `reboot_start_time`: 24 hour JST time that clients will see as the start of maintenance period. Leave blank for no maintenance time. Default: "" - `reboot_end_time`: 24 hour JST time that clients will see as the end of maintenance period. Leave blank for no maintenance time. Default: "" ## Database diff --git a/example_config/core.yaml b/example_config/core.yaml index 7bf097e..b4aac28 100644 --- a/example_config/core.yaml +++ b/example_config/core.yaml @@ -13,6 +13,9 @@ title: loglevel: "info" hostname: "localhost" port: 8080 + port_ssl: 0 + ssl_cert: "cert/title.crt" + ssl_key: "cert/title.key" reboot_start_time: "04:00" reboot_end_time: "05:00" diff --git a/index.py b/index.py index 0c36e81..72a40fa 100644 --- a/index.py +++ b/index.py @@ -279,6 +279,7 @@ if __name__ == "__main__": allnet_server_str = f"tcp:{cfg.allnet.port}:interface={cfg.server.listen_address}" title_server_str = f"tcp:{cfg.title.port}:interface={cfg.server.listen_address}" + title_https_server_str = f"ssl:{cfg.title.port_ssl}:interface={cfg.server.listen_address}:privateKey={cfg.title.ssl_key}:certKey={cfg.title.ssl_cert}" adb_server_str = f"tcp:{cfg.aimedb.port}:interface={cfg.server.listen_address}" frontend_server_str = ( f"tcp:{cfg.frontend.port}:interface={cfg.server.listen_address}" @@ -312,6 +313,11 @@ if __name__ == "__main__": endpoints.serverFromString(reactor, title_server_str).listen( server.Site(dispatcher) ) + + if cfg.title.port_ssl > 0: + endpoints.serverFromString(reactor, title_https_server_str).listen( + server.Site(dispatcher) + ) if cfg.server.threading: Thread(target=reactor.run, args=(False,)).start()