jiezhengj (Discord, 11-08): under Clash Verge Rev's TUN (mihomo
1.19.33, enhanced-mode fake-ip, fake-ip-range 198.18.0.1/16) every
web_fetch of `magpie mcp search` answered "it is at a private address".
#2593 already lets a name whose every answer is in 198.18.0.0/15 through,
so that wasn't it. Clash Verge Rev writes dns.ipv6: true and
fake-ip-range6: fdfe:dcba:9876::1/64 into its default config (and fills
in 2001:2::/64 when IPv6 is on without one), and mihomo then answers
AAAA from that pool too (dns/middleware.go withFakeIP, read at
v1.19.33). The resolver's answer was 198.18.x.y beside fdfe:dcba:9876::z,
the ULA is private, a fake answer beside a private one is refused, so
every name failed.
netguard.FakePaired names that AAAA: an IPv6 address in fc00::/7 or
2001:2::/48 while the same answer holds an IPv4 one in 198.18.0.0/15.
It is dropped where Loon's paired AAAA is dropped (dropLoon in the
gateway's publicTransport, iconIPs for a provider's icon, the two
places that share netguard), and the fake A is judged and pinned in its
place. 2001:2::/48 (RFC 5180 benchmarking) joins Public's special ranges;
it wasn't covered by 2001::/32 and passed as public.
Why this opens nothing new: the AAAA is never dialled. What is dialled
is the fake A, exactly as when the resolver answered the A alone, which
#2593 already allows: an address in 198.18.0.0/15, which no host on a
normal network uses, so without a TUN it goes to the default route and
reaches the internet or nothing. A hostile DNS that pairs 198.18.0.9
with fd00::<a LAN host> gets the 198.18 address dialled, never the LAN
one. Through a proxy on this computer the proxy gets the name, as for a
pure fake answer; a hostile resolver could already give a proxy another
answer for that name than it gave magpie, so the pairing adds no route.
What stays refused (tests below): a ULA or 2001:2:: alone or beside a
real A, a fake pair beside 10.0.0.1 or ::1, a fake A beside a public
address, and ULA / 2001:2:: / 198.18 address literals.
Ran (on mote; whole packages at base f1a4b5751, the -run set, vet and
gofmt again after the rebase onto the next main):
- go test ./internal/netguard ./internal/provider ./internal/gateway
-run 'FakePaired|FakeIP|Loon|Icon|Public|Fetch|Guard|Private': ok
- go test -timeout 45m ./internal/netguard ./internal/provider
./internal/gateway (whole packages): ok (netguard 0.2s, provider
130s, gateway 838s)
- go vet for darwin, GOOS=linux and GOOS=windows on those packages,
gofmt -l internal cmd: clean
Broken by hand: with netguard.go, image_fetch_guard.go and icon.go back
at origin/main, TestFakeIPWithItsIPv6Answer fails with the reporter's
own message ("couldn't fetch http://example.com/: it is at a private
address ..."), TestFakeIPRefusesTheRest lets http://[2001:2::7]/
through, and TestIconIPsLoon refuses fdfe:dcba:9876::5 + 198.18.0.5 and
keeps 2001:2::5. Green with the fix.
Not tried: a real Clash Verge Rev / mihomo TUN on mote or the Mac (the
answers are a fake resolver in the tests, nothing reaches the network);
sing-box's inet6_range is covered only as far as it is a ULA. Not run:
the full ./... suite (mote's suite.lock had five full runs queued).
Reported-by: jiezhengj (Discord)
ggbdpq's patch (gua2100 on Discord), reviewed and landed with test
changes.
What changed
- netproxy.Watch gives the dispatch's per-request check for a moved
global proxy (#4523) to transports magpie keeps for itself. The sync
(davsync) uses http.DefaultTransport, so when one of its requests
finds the proxy moved, it now drops the idle connections itself.
Before this, only a DefaultClient request dropped them, and a backup
kept going through the old proxy's HTTP/2 connection.
- FetchIcon now closes the pool of the client that only the fetch used.
Nothing closed it before.
- Review changes: the davsync test restores settings.json afterwards,
and the icon test's wait for idle is bounded at 20s, not 2s, to leave
room under load.
Run at the pushed head (on mote, base 4d55a0a02)
- go test -race passes for netproxy, davsync and provider's touched
tests.
- go test -tags nogui -count=1 -timeout 45m ./... passes every package
except two reds already filed and not touched here:
- internal/cli TestEveryRouteHasACommandOrIsNamed (#4826, red on main
since e87140242);
- internal/gateway TestCodexPoolSaysTheClientsVersion (#4807, another
test's Codex identity, passes alone).
- gofmt -l is clean. go vet ./... passes for darwin, for GOOS=linux
(-tags nogui) and for GOOS=windows, and so do the linux and windows
builds.
Broken by hand
- With stall.go's move check off, TestGlobalSwitchDialsTheSyncThroughTheNewProxy
is red: "1 connections through A, 0 through B".
- With FetchIcon's CloseIdleConnections removed,
TestFetchIconLeavesNoIdleConnection is red: "the fetch's connection is
still idle".
- With Watch never reporting a move, TestGlobalSwitchDropsTheOldProxyConnections
and TestWatchSeesTheGlobalProxyMove are red.
Not tried: a real proxy switch with a real WebDAV/S3 target or icon
host, or Windows/Linux at run time (vet and build only).
Co-authored-by: yetone <yetoneful@gmail.com>
magpie://import now takes icon=<https picture>: the vendor's logo, PNG,
JPEG, GIF, WebP, ICO or SVG. It is fetched once, when the user opens the
confirm dialog — never at parse time — into magpie's icons folder, and
falls back to the catalog's logo or a plain mark when the fetch fails.
An explicit icon= wins over whatever catalog or preset gave.
The fetch is guarded on the way out: https only, at most 1 MB, the type
checked, and the host is resolved at connect time with loopback, private,
link-local and reserved addresses refused, so a name that points back at
the user's own machine (or a DNS-rebinding trick) never connects. The
page and the dialog never load a remote picture themselves.
IconURL is a carrier between parsing and that fetch only; Save drops it,
so it never reaches providers.json.