From fc689b998ae6806fc7b92f439edd5303b55f3d95 Mon Sep 17 00:00:00 2001 From: Pizza <33816021+PizzaCow@users.noreply.github.com> Date: Wed, 1 Apr 2026 20:40:07 -0600 Subject: [PATCH] feat: scan all advertised subnets, not just the first --- main.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/main.py b/main.py index 63eaa4d..29fa0e6 100644 --- a/main.py +++ b/main.py @@ -126,32 +126,35 @@ def api_scan(request: Request): log.info("Starting scan (stream)...") geo = scanner.get_wan_geo() current_exit = tailscale.get_current_exit_node() - subnet = scanner.detect_lan_subnet(exit_node_ip=current_exit) if current_exit else None - log.info(f"Exit: {current_exit!r}, subnet: {subnet!r}") + subnets = scanner.detect_lan_subnets(exit_node_ip=current_exit) if current_exit else [] + log.info(f"Exit: {current_exit!r}, subnets: {subnets!r}") meta = { "type": "meta", "connected": bool(current_exit), "exit_node_ip": current_exit, "geo": geo, - "subnet": subnet or "unknown", + "subnet": ", ".join(subnets) if subnets else "unknown", } yield f"data: {json.dumps(meta)}\n\n" if not current_exit: return - if not subnet: + if not subnets: yield f"data: {json.dumps({'type': 'error', 'message': 'Could not detect LAN subnet. Enable subnet routes on the exit node.'})}\n\n" return count = 0 - for device in scanner.scan_lan_stream(subnet): - if "error" in device: - yield f"data: {json.dumps({'type': 'error', 'message': device['error']})}\n\n" - return - device["type"] = "device" - count += 1 + for subnet in subnets: + log.info(f"Scanning subnet {subnet}") + for subnet in subnets: + for device in scanner.scan_lan_stream(subnet): + if "error" in device: + yield f"data: {json.dumps({'type': 'error', 'message': device['error']})}\n\n" + return + device["type"] = "device" + count += 1 log.info(f"Device: {device.get('ip')} ({device.get('hostname')})") yield f"data: {json.dumps(device)}\n\n"