diff --git a/README.md b/README.md index 9f9a63a..e92bfd6 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,16 @@ The frontend broker exposes the following API endpoints for use: /api/v1/wg/key/exchange ``` +The listen address and port for the Flask server can be configured in `wgkex.yaml` under the `broker_listen` key: + +```yaml +broker_listen: + # host defaults to 127.0.0.1 if unspecified + host: 0.0.0.0 + # port defaults to 5000 if unspecified + port: 5000 +``` + #### POST /api/v1/wg/key/exchange JSON POST'd to this endpoint should be in this format: diff --git a/wgkex.yaml.example b/wgkex.yaml.example index 5bceb6e..f318b0c 100644 --- a/wgkex.yaml.example +++ b/wgkex.yaml.example @@ -18,6 +18,9 @@ mqtt: password: SECRET keepalive: 5 tls: False +broker_listen: + host: 0.0.0.0 + port: 5000 domain_prefix: myprefix- logging_config: formatters: @@ -31,4 +34,4 @@ logging_config: handlers: - console level: DEBUG - version: 1 \ No newline at end of file + version: 1 diff --git a/wgkex/broker/app.py b/wgkex/broker/app.py index 484f39b..e82497b 100644 --- a/wgkex/broker/app.py +++ b/wgkex/broker/app.py @@ -160,4 +160,12 @@ def is_valid_domain(domain: str) -> str: if __name__ == "__main__": - app.run() + listen_host = None + listen_port = None + + listen_config = config.fetch_from_config("broker_listen") + if listen_config is not None: + listen_host = listen_config.get("host") + listen_port = listen_config.get("port") + + app.run(host=listen_host, port=listen_port)