feat: TCP server/client mode config, protocol display in settings

This commit is contained in:
2026-07-27 19:09:53 +08:00
parent f715cb85e6
commit 759d35bc93
3 changed files with 32 additions and 7 deletions
+25 -6
View File
@@ -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: