From 7cf8b4fd5f42ba4a8436a65dd338ec9556f12683 Mon Sep 17 00:00:00 2001 From: Kevin Trocolli Date: Sun, 14 Jan 2024 16:48:41 -0500 Subject: [PATCH] aimedb: allow listen address override --- core/aimedb.py | 3 ++- core/config.py | 6 ++++++ docs/config.md | 1 + example_config/core.yaml | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/core/aimedb.py b/core/aimedb.py index 8d2c68e..c53ffcb 100644 --- a/core/aimedb.py +++ b/core/aimedb.py @@ -66,7 +66,8 @@ class AimedbServlette(): def start(self) -> None: self.logger.info(f"Start on port {self.config.aimedb.port}") - asyncio.create_task(asyncio.start_server(self.dataReceived, self.config.server.listen_address, self.config.aimedb.port)) + addr = self.config.aimedb.listen_address if self.config.aimedb.listen_address else self.config.server.listen_address + asyncio.create_task(asyncio.start_server(self.dataReceived, addr, self.config.aimedb.port)) async def dataReceived(self, reader: asyncio.StreamReader, writer: asyncio.StreamWriter): self.logger.debug(f"Connection made from {writer.get_extra_info('peername')[0]}") diff --git a/core/config.py b/core/config.py index 3d5f6fb..a4e774e 100644 --- a/core/config.py +++ b/core/config.py @@ -320,6 +320,12 @@ class AimedbConfig: self.__config, "core", "aimedb", "enable", default=True ) + @property + def listen_address(self) -> bool: + return CoreConfig.get_config_field( + self.__config, "core", "aimedb", "listen_address", default="" + ) + @property def loglevel(self) -> int: return CoreConfig.str_to_loglevel( diff --git a/docs/config.md b/docs/config.md index f44dc62..39855dc 100644 --- a/docs/config.md +++ b/docs/config.md @@ -49,6 +49,7 @@ - `signing_key`: Location of the RSA Private key used to sign billing requests. Must match the public key distributed to users or the billing server will not connect. Default `cert/billing.key` ## Aimedb - `enable`: Whether or not aimedb should run. Default `True` +- `listen_address`: IP Address or hostname that the aimedb server will listen for connections on. Leave this blank to use the listen address under `server`. Default `""` - `loglevel`: Logging level for the aimedb server. Default `info` - `port`: Port the aimedb server should listen for connections on. Games are hardcoded to ask for port `22345` so only change if you have a proxy redirecting properly. Default `22345` - `key`: Key to encrypt/decrypt aimedb requests and responses. MUST be set or the server will not start. If set incorrectly, your server will not properly handle aimedb requests. Default `""` diff --git a/example_config/core.yaml b/example_config/core.yaml index 12e544c..758a089 100644 --- a/example_config/core.yaml +++ b/example_config/core.yaml @@ -55,6 +55,7 @@ billing: aimedb: enable: True + listen_address: "" loglevel: "info" port: 22345 key: ""