feat: TCP server/client mode config, protocol display in settings
This commit is contained in:
@@ -107,13 +107,32 @@ class TelemetryListener:
|
||||
self._current_protocol = "udp"
|
||||
|
||||
if self._current_protocol == "tcp":
|
||||
self._tcp = TCPListener(self._handle_packet)
|
||||
ok = await self._tcp.start(host, port)
|
||||
if ok:
|
||||
import json as _json
|
||||
mode = "server"
|
||||
tcp_path = "/"
|
||||
if selected_game:
|
||||
gp = game_plugin_manager.get(selected_game)
|
||||
if gp and gp.manifest_path:
|
||||
try:
|
||||
with open(f"{gp.manifest_path}/manifest.json", "r") as f:
|
||||
m = _json.load(f)
|
||||
mode = m.get("mode", "server")
|
||||
tcp_path = m.get("path", "/")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if mode == "server":
|
||||
self._tcp = TCPListener(self._handle_packet)
|
||||
ok = await self._tcp.start(host, port)
|
||||
if ok:
|
||||
self._running = True
|
||||
self.forwarder.reload_targets()
|
||||
logger.info("TCP server started on %s:%d [game=%s]", host, port, selected_game or "none")
|
||||
return ok
|
||||
else:
|
||||
logger.info("TCP client mode - awaiting manual connection to upstream")
|
||||
self._running = True
|
||||
self.forwarder.reload_targets()
|
||||
logger.info("TCP listener started on %s:%d [game=%s]", host, port, selected_game or "none")
|
||||
return ok
|
||||
return True
|
||||
else:
|
||||
loop = asyncio.get_event_loop()
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user