fix: correct sidebar LAN detection for public access
Deploy Dashboard (Dev) / deploy-dev (push) Successful in 2m27s

Separate Tailscale IP detection from true LAN detection so public internet users routed through VPS no longer get non-routable port links in the sidebar.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Gan, Jimmy
2026-03-01 22:46:05 +08:00
parent 50e1d779de
commit 72bb37ffe5
2 changed files with 24 additions and 3 deletions
+11 -1
View File
@@ -48,9 +48,10 @@ CHAT_SUMMARY_DB = os.environ.get("CHAT_SUMMARY_DB", "/app/data/chat-summarizer/c
OPENCLAW_GATEWAY_TOKEN = os.environ.get("OPENCLAW_GATEWAY_TOKEN", "")
# Networking configs
LAN_IP_RANGES = os.environ.get("LAN_IP_RANGES", "192.168.31.0/24,100.64.0.0/10").split(",")
LAN_IP_RANGES = os.environ.get("LAN_IP_RANGES", "192.168.31.0/24").split(",")
def is_lan_ip(ip_str: str) -> bool:
"""Check if IP is in local LAN (not Tailscale)"""
import ipaddress
try:
ip_obj = ipaddress.ip_address(ip_str)
@@ -61,6 +62,15 @@ def is_lan_ip(ip_str: str) -> bool:
except ValueError:
return False
def is_tailscale_ip(ip_str: str) -> bool:
"""Check if IP is in Tailscale CGNAT range (100.64.0.0/10)"""
import ipaddress
try:
ip_obj = ipaddress.ip_address(ip_str)
return ip_obj in ipaddress.ip_network("100.64.0.0/10")
except ValueError:
return False
TRUSTED_PROXIES = os.environ.get("TRUSTED_PROXIES", "127.0.0.1,::1,172.16.0.0/12").split(",")
def is_trusted_proxy(ip_str: str) -> bool: