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:
3
.env
3
.env
@@ -1,8 +1,9 @@
|
|||||||
# Lighting Controller Configuration
|
# Lighting Controller Configuration
|
||||||
CONTROL_SERVER_URI=ws://localhost:8765
|
CONTROL_SERVER_URI=ws://localhost:8765
|
||||||
|
CONTROL_SERVER_HOST=0.0.0.0
|
||||||
CONTROL_SERVER_PORT=8765
|
CONTROL_SERVER_PORT=8765
|
||||||
TRANSPORT=spi
|
TRANSPORT=spi
|
||||||
AUDIO_INPUT_DEVICE=7
|
AUDIO_INPUT_DEVICE=1
|
||||||
MIDI_TCP_HOST=127.0.0.1
|
MIDI_TCP_HOST=127.0.0.1
|
||||||
MIDI_TCP_PORT=65432
|
MIDI_TCP_PORT=65432
|
||||||
SOUND_CONTROL_HOST=127.0.0.1
|
SOUND_CONTROL_HOST=127.0.0.1
|
||||||
|
@@ -15,6 +15,11 @@ CONTROL_SERVER_URI=ws://10.42.0.1:8765
|
|||||||
# For custom IP (if your Pi has a different address):
|
# For custom IP (if your Pi has a different address):
|
||||||
# CONTROL_SERVER_URI=ws://YOUR_PI_IP:8765
|
# CONTROL_SERVER_URI=ws://YOUR_PI_IP:8765
|
||||||
|
|
||||||
|
# Control server WebSocket host (bind address)
|
||||||
|
# 0.0.0.0 = listen on all interfaces (allows external connections)
|
||||||
|
# localhost or 127.0.0.1 = listen only on localhost (local only)
|
||||||
|
CONTROL_SERVER_HOST=0.0.0.0
|
||||||
|
|
||||||
# Control server WebSocket port
|
# Control server WebSocket port
|
||||||
CONTROL_SERVER_PORT=8765
|
CONTROL_SERVER_PORT=8765
|
||||||
|
|
||||||
@@ -29,7 +34,7 @@ TRANSPORT=spi
|
|||||||
# Sound Detection Configuration
|
# Sound Detection Configuration
|
||||||
# ==============================
|
# ==============================
|
||||||
# Audio input device index (use sound.py to list available devices)
|
# Audio input device index (use sound.py to list available devices)
|
||||||
AUDIO_INPUT_DEVICE=7
|
AUDIO_INPUT_DEVICE=1
|
||||||
|
|
||||||
# MIDI TCP configuration
|
# MIDI TCP configuration
|
||||||
MIDI_TCP_HOST=127.0.0.1
|
MIDI_TCP_HOST=127.0.0.1
|
||||||
|
@@ -376,10 +376,11 @@ class ControlServer:
|
|||||||
|
|
||||||
async def start_websocket_server(self):
|
async def start_websocket_server(self):
|
||||||
"""Start WebSocket server for UI clients."""
|
"""Start WebSocket server for UI clients."""
|
||||||
|
host = os.getenv("CONTROL_SERVER_HOST", "0.0.0.0")
|
||||||
server = await websockets.serve(
|
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):
|
async def run(self):
|
||||||
"""Run the control server."""
|
"""Run the control server."""
|
||||||
|
Reference in New Issue
Block a user