From 6ed57f56f5cb1e26cce504402db75acc0143d41a Mon Sep 17 00:00:00 2001 From: "Gan, Jimmy" Date: Thu, 26 Feb 2026 03:27:04 +0800 Subject: [PATCH] fix: use TCP socket probe instead of ping for LAN detection --- dashboard/backend/main.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/dashboard/backend/main.py b/dashboard/backend/main.py index b6717d5..36386ba 100644 --- a/dashboard/backend/main.py +++ b/dashboard/backend/main.py @@ -119,14 +119,14 @@ async def client_ip(request: Request): ip = request.client.host if ip.startswith("192.168.31."): return {"ip": ip, "lan": True} - # Tailscale client — check if Mac is reachable on LAN if ip.startswith("100."): + import socket try: - proc = await asyncio.create_subprocess_exec( - "ping", "-c", "1", "-W", "1", "192.168.31.1", - stdout=asyncio.subprocess.DEVNULL, stderr=asyncio.subprocess.DEVNULL, - ) - return {"ip": ip, "lan": await asyncio.wait_for(proc.wait(), 2) == 0} + s = socket.socket() + s.settimeout(1) + s.connect(("192.168.31.1", 80)) + s.close() + return {"ip": ip, "lan": True} except Exception: pass return {"ip": ip, "lan": False}