fix(app): the proxy refuses IPv6 outside global unicast and its stop closes open tunnels

- IPv6 counts as public only in 2000::/3 (without 2001::/23, documentation and 6to4), so site
  local fec0::/10 and IPv4-compatible addresses are refused; the collector uses the same rule
- every proxy connection is a task of one set: a stop ends the open CONNECT tunnels and waits
  until their sockets are gone

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-13 22:07:50 +09:00
parent b20b5795b6
commit 55d19364a0
5 changed files with 111 additions and 23 deletions

View File

@@ -54,10 +54,21 @@ def load_config(path) -> Config:
def _is_public_ip(ip) -> bool:
if ip.version == 6:
if ip.ipv4_mapped:
return _is_public_ip(ip.ipv4_mapped)
# Only global unicast 2000::/3 is routed on the internet (leaves out site local fec0::/10,
# IPv4-compatible ::a.b.c.d and the rest); 6to4 can embed any IPv4 address.
if ip not in _GLOBAL_UNICAST or ip in _SIX_TO_FOUR:
return False
return not (ip.is_private or ip.is_loopback or ip.is_link_local or ip.is_reserved
or ip.is_multicast or ip.is_unspecified)
_GLOBAL_UNICAST = ipaddress.ip_network("2000::/3")
_SIX_TO_FOUR = ipaddress.ip_network("2002::/16")
def _resolve(host: str, port: int, deadline: float) -> list:
"""getaddrinfo on a daemon thread, waited for only until `deadline` (a late answer is dropped)."""
out: dict = {}