Add CONTROL_SERVER_HOST to allow external connections

- Add CONTROL_SERVER_HOST environment variable (default: 0.0.0.0)
- Server now binds to all interfaces by default for external access
- Update .env and .env.example with new host configuration
- Allows UI clients to connect from other machines on the network
This commit is contained in:
Pi User
2025-10-03 20:24:20 +13:00
parent e78a8727b2
commit aa9f892454
3 changed files with 11 additions and 4 deletions

View File

@@ -376,10 +376,11 @@ class ControlServer:
async def start_websocket_server(self):
"""Start WebSocket server for UI clients."""
host = os.getenv("CONTROL_SERVER_HOST", "0.0.0.0")
server = await websockets.serve(
self.handle_ui_client, "localhost", CONTROL_SERVER_PORT
self.handle_ui_client, host, CONTROL_SERVER_PORT
)
logging.info(f"WebSocket server listening on localhost:{CONTROL_SERVER_PORT}")
logging.info(f"WebSocket server listening on {host}:{CONTROL_SERVER_PORT}")
async def run(self):
"""Run the control server."""