netguard: a fake-IP resolver's own AAAA beside its fake A is left out, not refused
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)
This commit is contained in:
@@ -2506,7 +2506,7 @@ the row of the entry that id reaches, with its label, under the bare id.
|
||||
[`bare_ids_test.go`](../../internal/gateway/bare_ids_test.go),
|
||||
`TestBareModelIDsSetting` in `internal/gui`, and
|
||||
`internal/gui/tests/bare-ids.test.cjs`.
|
||||
- A URL magpie downloads but didn't choose itself is downloaded from public addresses only, wherever the request came from ([`image_fetch_guard.go`](../../internal/gateway/image_fetch_guard.go)). That is an image a caller names (an `/v1/images/edits` or `/v1/images/generations` reference image, for an images API that takes files, Gemini's own API or Code Assist: `fetchPicture` in [`draw.go`](../../internal/gateway/draw.go), `publicClient`), a page `web_fetch` reads (`webFetchClient`), and an image or video a vendor answers by URL, which what the model was asked to draw or do can steer (the inline download for a `b64_json` caller in `draw.go` and `/v1/videos/{id}/content` in [`video.go`](../../internal/gateway/video.go), `vendorClient`; generate_image's own download in [`internal/imagemcp`](../../internal/imagemcp/imagemcp.go), `PublicClient`). Every address the host resolves to must be public (`publicAddr`, which is [`internal/netguard`](../../internal/netguard/netguard.go)'s `Public`, the rule a provider's icon uses too: not loopback, RFC 1918, fc00::/7, link-local with 169.254.169.254, CGNAT 100.64/10, unspecified, multicast, documentation, reserved, benchmarking, Teredo, nor an IPv4-mapped, NAT64 or 6to4 form of one; an AAAA record Loon synthesizes for an A answer in the same reply, `fd27:712::/96` with that IPv4 address inside, is left out and the A answer judged in its place, `dropLoon`), and the request goes to the address checked, so a name that resolves elsewhere the second time changes nothing; a direct connection is checked again on the address dialled (`guardDialer`). Through a proxy the proxy is sent that address, never the name (an `https://` CONNECT or SOCKS keeps the name for TLS and Host; a plain `http://` URL through an HTTP proxy is asked for by the address in Host too). A fake-IP resolver's answer is the one shape let past that (#2593; ggbdpq, with h4rk8s's and TomXPRIME's reports): Clash's TUN with fake-ip, Clash Verge, Surge's enhanced mode and Loon answer every name in 198.18.0.0/15 (`netguard.FakeIP`), so with one on every download was refused as a private address. A name (never an address literal) whose every answer is in that range is fetched: with no proxy (pure TUN) its fake address is pinned and dialled, the dial guard letting that one address in, and the TUN carries it; through a proxy on this computer (a loopback address or `localhost`, `onThisComputer`) the proxy is given the name, never the fake address, which a real proxy can't route (h4rk8s: a CONNECT by the name went through where one by its 198.18 address failed), and a plain `http://` request's Host is the checked name, never the caller's own; through a proxy elsewhere it is refused. An answer with any other address beside the fake ones (private or public) is judged as any, so a fake one beside 192.168.x is refused. The trust this asks for is the fake-IP resolver's: which host the name stands for, and so where the TUN or the proxy connects, is decided where magpie can't see, and a name that really points at the user's network is reached if that resolver's rules send it there. A provider's icon was already fetched this way (`publicIP` in [`internal/provider/icon.go`](../../internal/provider/icon.go), #252), and shares the rule. `TestFakeIPNameGoesToALocalProxyByName`, `TestFakeIPNameDialledThroughTheTUN`, `TestFakeIPRefusesTheRest` in [`fakeip_test.go`](../../internal/gateway/fakeip_test.go). Each redirect, up to 5, is checked the same, and a caller's image must sniff as an image. A request from this computer gets nothing more: a reverse proxy or relay in front of magpie on the same host makes every request it carries arrive from loopback, so where a request came from is never a reason to reach a private address. Two things are: settings.json's `fetchPrivate` (`settings.FetchPrivate`, none by default, no Settings page, this computer's own and never brought by a sync or restore), a list of names, `name:port`s, IPs and CIDR ranges the user lets magpie download from (`allowFor`; a settings.json that can't be read lets nothing extra in), and for a vendor's URL the `host:port` of that provider's own endpoints, which the user named themselves (a provider on the LAN that serves its images from itself). A vendor's image that can't be downloaded is answered by its URL, never dropped; its video is a 502 naming why. A URL left for the vendor to fetch (a chat model's message) is the vendor's to fetch.
|
||||
- A URL magpie downloads but didn't choose itself is downloaded from public addresses only, wherever the request came from ([`image_fetch_guard.go`](../../internal/gateway/image_fetch_guard.go)). That is an image a caller names (an `/v1/images/edits` or `/v1/images/generations` reference image, for an images API that takes files, Gemini's own API or Code Assist: `fetchPicture` in [`draw.go`](../../internal/gateway/draw.go), `publicClient`), a page `web_fetch` reads (`webFetchClient`), and an image or video a vendor answers by URL, which what the model was asked to draw or do can steer (the inline download for a `b64_json` caller in `draw.go` and `/v1/videos/{id}/content` in [`video.go`](../../internal/gateway/video.go), `vendorClient`; generate_image's own download in [`internal/imagemcp`](../../internal/imagemcp/imagemcp.go), `PublicClient`). Every address the host resolves to must be public (`publicAddr`, which is [`internal/netguard`](../../internal/netguard/netguard.go)'s `Public`, the rule a provider's icon uses too: not loopback, RFC 1918, fc00::/7, link-local with 169.254.169.254, CGNAT 100.64/10, unspecified, multicast, documentation, reserved, benchmarking, Teredo, nor an IPv4-mapped, NAT64 or 6to4 form of one; an AAAA record Loon synthesizes for an A answer in the same reply, `fd27:712::/96` with that IPv4 address inside, is left out and the A answer judged in its place, `dropLoon`), and the request goes to the address checked, so a name that resolves elsewhere the second time changes nothing; a direct connection is checked again on the address dialled (`guardDialer`). Through a proxy the proxy is sent that address, never the name (an `https://` CONNECT or SOCKS keeps the name for TLS and Host; a plain `http://` URL through an HTTP proxy is asked for by the address in Host too). A fake-IP resolver's answer is the one shape let past that (#2593; ggbdpq, with h4rk8s's and TomXPRIME's reports): Clash's TUN with fake-ip, Clash Verge, Surge's enhanced mode and Loon answer every name in 198.18.0.0/15 (`netguard.FakeIP`), so with one on every download was refused as a private address. A name (never an address literal) whose every answer is in that range is fetched: with no proxy (pure TUN) its fake address is pinned and dialled, the dial guard letting that one address in, and the TUN carries it; through a proxy on this computer (a loopback address or `localhost`, `onThisComputer`) the proxy is given the name, never the fake address, which a real proxy can't route (h4rk8s: a CONNECT by the name went through where one by its 198.18 address failed), and a plain `http://` request's Host is the checked name, never the caller's own; through a proxy elsewhere it is refused. The fake-IP resolver's own AAAA beside its fake A answer (an IPv6 address in fc00::/7 or 2001:2::/48 while an A answer is in 198.18.0.0/15, `netguard.FakePaired`: mihomo's `fake-ip-range6`, which Clash Verge Rev turns on by default as `fdfe:dcba:9876::1/64` or fills in as `2001:2::/64`; jiezhengj, whose every `web_fetch` was refused) is left out by `dropLoon` and never dialled, the fake A answer judged and pinned in its place. An answer with any other address beside the fake ones (private or public) is judged as any, so a fake one beside 192.168.x is refused. The trust this asks for is the fake-IP resolver's: which host the name stands for, and so where the TUN or the proxy connects, is decided where magpie can't see, and a name that really points at the user's network is reached if that resolver's rules send it there. A provider's icon was already fetched this way (`publicIP` in [`internal/provider/icon.go`](../../internal/provider/icon.go), #252), and shares the rule. `TestFakeIPNameGoesToALocalProxyByName`, `TestFakeIPNameDialledThroughTheTUN`, `TestFakeIPWithItsIPv6Answer`, `TestFakeIPRefusesTheRest` in [`fakeip_test.go`](../../internal/gateway/fakeip_test.go). Each redirect, up to 5, is checked the same, and a caller's image must sniff as an image. A request from this computer gets nothing more: a reverse proxy or relay in front of magpie on the same host makes every request it carries arrive from loopback, so where a request came from is never a reason to reach a private address. Two things are: settings.json's `fetchPrivate` (`settings.FetchPrivate`, none by default, no Settings page, this computer's own and never brought by a sync or restore), a list of names, `name:port`s, IPs and CIDR ranges the user lets magpie download from (`allowFor`; a settings.json that can't be read lets nothing extra in), and for a vendor's URL the `host:port` of that provider's own endpoints, which the user named themselves (a provider on the LAN that serves its images from itself). A vendor's image that can't be downloaded is answered by its URL, never dropped; its video is a 502 naming why. A URL left for the vendor to fetch (a chat model's message) is the vendor's to fetch.
|
||||
|
||||
### Instruction roles on translated Responses turns
|
||||
|
||||
|
||||
@@ -203,6 +203,47 @@ func TestFakeIPNameDialledThroughTheTUN(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// Clash Verge Rev turns on IPv6 with mihomo's fake-ip-range6 by default
|
||||
// (fdfe:dcba:9876::1/64, or 2001:2::/64 it fills in), so the resolver
|
||||
// answers a fake AAAA beside the fake A, and every web_fetch was refused
|
||||
// as a private address (jiezhengj on Discord, mihomo 1.19.33's TUN). The
|
||||
// AAAA is never dialled: the fake A is pinned, through the TUN, and a
|
||||
// proxy on this computer is given the name.
|
||||
func TestFakeIPWithItsIPv6Answer(t *testing.T) {
|
||||
fresh(t)
|
||||
useProxy(t, "direct")
|
||||
page := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
w.Write([]byte("through the tun " + r.Host))
|
||||
}))
|
||||
t.Cleanup(page.Close)
|
||||
dialled := tun(t, page)
|
||||
answers(t, map[string][]string{
|
||||
"example.com": {"fdfe:dcba:9876::7", "198.18.0.7"},
|
||||
"filled.test": {"198.18.0.8", "2001:2::8"},
|
||||
})
|
||||
h := lanGuard(New().Handler())
|
||||
got, isErr := fetchText_(t, h, fetchCall("http://example.com/", ""))
|
||||
if isErr || !strings.Contains(got, "through the tun example.com") {
|
||||
t.Fatalf("web_fetch of a name with a fake A and AAAA, no proxy: %v %q", isErr, got)
|
||||
}
|
||||
if err := guardedGet("http://filled.test/"); err != nil {
|
||||
t.Fatalf("2001:2::/64 beside the fake A: %v", err)
|
||||
}
|
||||
if d := dialled(); len(d) != 2 || d[0] != "198.18.0.7:80" || d[1] != "198.18.0.8:80" {
|
||||
t.Fatalf("dialled %q, want the fake A answers only", d)
|
||||
}
|
||||
proxy, asked := fakeProxy(t, "<html><body><p>fetched by name</p></body></html>")
|
||||
useProxy(t, proxy.URL)
|
||||
got, isErr = fetchText_(t, h, fetchCall("http://example.com/", ""))
|
||||
if isErr || !strings.Contains(got, "fetched by name") {
|
||||
t.Fatalf("web_fetch through a local proxy: %v %q", isErr, got)
|
||||
}
|
||||
if a := asked(); len(a) != 1 || a[0] != "http://example.com:80/ Host=example.com:80" {
|
||||
t.Fatalf("the proxy was asked %q, want the name", a)
|
||||
}
|
||||
}
|
||||
|
||||
// What stays refused, with a proxy on this computer and without: a
|
||||
// private answer, a fake answer beside a private (or any real) one, a
|
||||
// fake address written as the URL, and a fake answer through a proxy
|
||||
@@ -224,12 +265,18 @@ func TestFakeIPRefusesTheRest(t *testing.T) {
|
||||
"mixedpub.test": {"198.18.0.9", "93.184.216.34"},
|
||||
"loonlan.test": {"fd27:712::a00:1", "10.0.0.1"},
|
||||
"loonbare.test": {"fd27:712::c612:139"},
|
||||
"ulabare.test": {"fdfe:dcba:9876::7"},
|
||||
"ulapub.test": {"fdfe:dcba:9876::7", "93.184.216.34"},
|
||||
"fake6lan.test": {"198.18.0.9", "fdfe:dcba:9876::7", "10.0.0.1"},
|
||||
"fake6lo.test": {"198.18.0.9", "fdfe:dcba:9876::7", "::1"},
|
||||
})
|
||||
refused := []string{
|
||||
"http://lan.test/", "http://loop.test/", "http://meta.test/latest/meta-data/", "http://cgnat.test/",
|
||||
"http://ten.test/", "http://mixed.test/", "http://mixed6.test/", "http://mixedpub.test/",
|
||||
"http://loonlan.test/", "http://loonbare.test/", "http://198.18.0.7/", "https://198.18.0.7/",
|
||||
"http://[::ffff:198.18.0.7]/",
|
||||
"http://ulabare.test/", "http://ulapub.test/", "http://fake6lan.test/", "http://fake6lo.test/",
|
||||
"http://[fdfe:dcba:9876::7]/", "http://[2001:2::7]/",
|
||||
}
|
||||
proxy, asked := fakeProxy(t, "reached")
|
||||
for _, p := range []string{"direct", proxy.URL, "http://localhost:" + proxy.URL[strings.LastIndex(proxy.URL, ":")+1:]} {
|
||||
|
||||
@@ -59,7 +59,9 @@ import (
|
||||
// the fake address is pinned and dialled, and the TUN carries it to the
|
||||
// host the name stands for. Through a proxy on this computer (loopback or
|
||||
// localhost), the proxy is given the name, never the fake address, which
|
||||
// it can't route; through a proxy elsewhere it is refused. An address
|
||||
// it can't route; through a proxy elsewhere it is refused. The fake-IP
|
||||
// resolver's own AAAA beside its fake A (netguard.FakePaired, mihomo's
|
||||
// fake-ip-range6) is left out and never dialled. An address
|
||||
// literal in the range, or an answer with any other address beside the
|
||||
// fake ones, is judged as ever. What the name stands for is then the
|
||||
// fake-IP resolver's to decide, where magpie can't see: a name that
|
||||
@@ -313,12 +315,14 @@ func fakeAnswer(addrs []netip.Addr) bool {
|
||||
}
|
||||
|
||||
// dropLoon leaves out the AAAA records Loon synthesizes for an A answer
|
||||
// in the same reply (netguard.LoonPaired): the A answer is judged, and
|
||||
// pinned, in their place.
|
||||
// in the same reply (netguard.LoonPaired), and the fake AAAA a fake-IP
|
||||
// resolver answers beside its fake A (netguard.FakePaired: mihomo's
|
||||
// fake-ip-range6, on by default in Clash Verge Rev): the A answer is
|
||||
// judged, and pinned, in their place.
|
||||
func dropLoon(addrs []netip.Addr) []netip.Addr {
|
||||
var out []netip.Addr
|
||||
for _, a := range addrs {
|
||||
if !netguard.LoonPaired(a, addrs) {
|
||||
if !netguard.LoonPaired(a, addrs) && !netguard.FakePaired(a, addrs) {
|
||||
out = append(out, a)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ var specialNets = func() []netip.Prefix {
|
||||
"::/96", // IPv4-compatible (deprecated)
|
||||
"100::/64", // discard
|
||||
"2001::/32", // Teredo
|
||||
"2001:2::/48", // benchmarking (RFC 5180); a fake-IP resolver's AAAA (FakePaired)
|
||||
"2001:db8::/32", // documentation
|
||||
"fec0::/10", // site-local (deprecated)
|
||||
"64:ff9b:1::/48", // local-use NAT64
|
||||
@@ -36,6 +37,8 @@ var (
|
||||
nat64 = netip.MustParsePrefix("64:ff9b::/96")
|
||||
fakeNet = netip.MustParsePrefix("198.18.0.0/15")
|
||||
loonNet = netip.MustParsePrefix("fd27:712::/96")
|
||||
ulaNet = netip.MustParsePrefix("fc00::/7")
|
||||
bench6 = netip.MustParsePrefix("2001:2::/48")
|
||||
)
|
||||
|
||||
// Public says a is on the open internet: not loopback, RFC 1918, fc00::/7,
|
||||
@@ -95,3 +98,27 @@ func LoonPaired(a netip.Addr, answers []netip.Addr) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// FakePaired says a is the AAAA answer a fake-IP resolver gives beside
|
||||
// its fake A answer: an IPv6 address in fc00::/7 or 2001:2::/48 (RFC
|
||||
// 5180's benchmarking range) while answers hold an IPv4 one in
|
||||
// 198.18.0.0/15 (FakeIP). mihomo answers AAAA from its fake-ip-range6
|
||||
// when IPv6 is on, and Clash Verge Rev turns it on by default with
|
||||
// fdfe:dcba:9876::1/64, or fills in 2001:2::/64; sing-box's inet6_range
|
||||
// is a ULA as a rule (jiezhengj on Discord, 11-08: every web_fetch
|
||||
// refused under Clash Verge Rev's TUN). Such an a is not dialled: the
|
||||
// fake A answer is judged, and pinned, in its place, so it reaches
|
||||
// nothing a fake A answer alone wouldn't. Without a fake A answer
|
||||
// beside it, a ULA is private as ever.
|
||||
func FakePaired(a netip.Addr, answers []netip.Addr) bool {
|
||||
a = a.Unmap()
|
||||
if !a.Is6() || !ulaNet.Contains(a) && !bench6.Contains(a) {
|
||||
return false
|
||||
}
|
||||
for _, o := range answers {
|
||||
if o = o.Unmap(); o.Is4() && FakeIP(o) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -61,3 +61,36 @@ func TestLoonPaired(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestFakePaired(t *testing.T) {
|
||||
addrs := func(ss ...string) []netip.Addr {
|
||||
var out []netip.Addr
|
||||
for _, s := range ss {
|
||||
out = append(out, netip.MustParseAddr(s))
|
||||
}
|
||||
return out
|
||||
}
|
||||
for _, c := range []struct {
|
||||
name string
|
||||
a string
|
||||
answers []netip.Addr
|
||||
want bool
|
||||
}{
|
||||
{"Clash Verge Rev's default range6", "fdfe:dcba:9876::7", addrs("198.18.0.7", "fdfe:dcba:9876::7"), true},
|
||||
{"its filled-in 2001:2::/64", "2001:2::7", addrs("2001:2::7", "198.18.0.7"), true},
|
||||
{"a sing-box fc00::/18", "fc00::7", addrs("198.19.0.7"), true},
|
||||
{"the A IPv4-mapped", "fdfe:dcba:9876::7", addrs("::ffff:198.18.0.7"), true},
|
||||
{"beside a real A", "fdfe:dcba:9876::7", addrs("93.184.216.34"), false},
|
||||
{"beside a private A", "fdfe:dcba:9876::7", addrs("10.0.0.1"), false},
|
||||
{"alone", "fdfe:dcba:9876::7", addrs("fdfe:dcba:9876::7"), false},
|
||||
{"loopback", "::1", addrs("198.18.0.7"), false},
|
||||
{"link-local", "fe80::1", addrs("198.18.0.7"), false},
|
||||
{"outside 2001:2::/48", "2001:3::7", addrs("198.18.0.7"), false},
|
||||
{"an IPv4 address", "10.0.0.1", addrs("198.18.0.7"), false},
|
||||
{"the fake A itself", "198.18.0.7", addrs("198.18.0.7"), false},
|
||||
} {
|
||||
if got := FakePaired(netip.MustParseAddr(c.a), c.answers); got != c.want {
|
||||
t.Errorf("%s: %v, want %v", c.name, got, c.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,8 +138,9 @@ func publicHost(ctx context.Context, host string) error {
|
||||
}
|
||||
|
||||
// iconIPs is ips without the AAAA records Loon synthesizes for an A
|
||||
// answer beside them (netguard.LoonPaired; that A answer is judged in
|
||||
// their place), or an error when any other is not public.
|
||||
// answer beside them (netguard.LoonPaired), nor a fake-IP resolver's
|
||||
// fake AAAA beside its fake A (netguard.FakePaired); that A answer is
|
||||
// judged in their place. It is an error when any other is not public.
|
||||
func iconIPs(host string, ips []net.IPAddr) ([]net.IPAddr, error) {
|
||||
all := make([]netip.Addr, len(ips))
|
||||
for i, ip := range ips {
|
||||
@@ -151,7 +152,7 @@ func iconIPs(host string, ips []net.IPAddr) ([]net.IPAddr, error) {
|
||||
allowed = append(allowed, ip)
|
||||
continue
|
||||
}
|
||||
if netguard.LoonPaired(all[i].Unmap(), all) {
|
||||
if netguard.LoonPaired(all[i].Unmap(), all) || netguard.FakePaired(all[i], all) {
|
||||
continue
|
||||
}
|
||||
return nil, errorf("the icon host %s resolves to %s, which is not public", host, ip.IP)
|
||||
|
||||
@@ -147,6 +147,13 @@ func TestIconIPsLoon(t *testing.T) {
|
||||
{"loopback pair", []string{"fd27:712::7f00:1", "127.0.0.1"}, nil},
|
||||
{"other ula", []string{"fd27:712:1::c600:1061", "198.0.16.97"}, nil},
|
||||
{"mixed private", []string{"fd27:712::c600:1061", "198.0.16.97", "192.168.1.1"}, nil},
|
||||
// mihomo's fake-ip-range6 beside its fake A: Clash Verge Rev's
|
||||
// default (jiezhengj); the fake A is dialled in its place
|
||||
{"clash verge fake aaaa", []string{"fdfe:dcba:9876::5", "198.18.0.5"}, []string{"198.18.0.5"}},
|
||||
{"clash verge filled-in range6", []string{"198.18.0.5", "2001:2::5"}, []string{"198.18.0.5"}},
|
||||
{"fake aaaa, no fake a", []string{"fdfe:dcba:9876::5", "8.8.8.8"}, nil},
|
||||
{"fake aaaa alone", []string{"fdfe:dcba:9876::5"}, nil},
|
||||
{"fake pair beside private", []string{"fdfe:dcba:9876::5", "198.18.0.5", "10.0.0.1"}, nil},
|
||||
} {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
var ips []net.IPAddr
|
||||
|
||||
Reference in New Issue
Block a user