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:
@@ -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 = {}
|
||||
|
||||
@@ -333,7 +333,8 @@ still deleted (below).
|
||||
characters, new by its id or link); `search` keeps each new web search result (title and link) for
|
||||
the words, from DuckDuckGo's lite page, which needs no key (its bot challenge is a failed run, not "no results").
|
||||
- Every request checks its address like the web search (`web_search.spec.md`): only http(s), and
|
||||
every address the name resolves to must be public; the connection goes only to the checked
|
||||
every address the name resolves to must be public (for IPv6 only global unicast `2000::/3`, without
|
||||
6to4); the connection goes only to the checked
|
||||
addresses in their order (TLS still checks the name), so a second lookup cannot lead into the
|
||||
local network. Every redirect is checked the same way. At most 1 MB and 15 s in all: the name lookup,
|
||||
connecting, TLS, the headers and the body of every redirect count, and a server that sends
|
||||
|
||||
Reference in New Issue
Block a user