mirror of
https://github.com/tailscale/tailscale.git
synced 2025-06-14 12:08:35 +00:00
net/dns/resolver: have quad100 respond to suffix-less magicdns requests
This is an attempt to fix WSL2. Unfortunately, it doesn't work in our new fancy split-dns mode. If we went back to overriding all DNS on windows we could fix this.
This commit is contained in:
parent
525eb5ce41
commit
30550fc539
@ -236,9 +236,27 @@ func (r *Resolver) resolveLocal(domain dnsname.FQDN, typ dns.Type) (netaddr.IP,
|
|||||||
return netaddr.IP{}, dns.RCodeNameError
|
return netaddr.IP{}, dns.RCodeNameError
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if strings.IndexByte(string(domain), '.') != len(domain)-1 {
|
||||||
|
// This is a real domain lookup.
|
||||||
// Not authoritative, signal that forwarding is advisable.
|
// Not authoritative, signal that forwarding is advisable.
|
||||||
return netaddr.IP{}, dns.RCodeRefused
|
return netaddr.IP{}, dns.RCodeRefused
|
||||||
}
|
}
|
||||||
|
// Consider this as a MagicDNS query put directly to us.
|
||||||
|
var magicDNSDomain dnsname.FQDN
|
||||||
|
for _, suffix := range localDomains {
|
||||||
|
if dnsname.FQDN("tailscale.net.").Contains(suffix) || dnsname.FQDN("ts.net.").Contains(suffix) {
|
||||||
|
magicDNSDomain = suffix
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if magicDNSDomain != "" {
|
||||||
|
addrs, found = hosts[domain+magicDNSDomain]
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
|
// Not authoritative, signal that forwarding is advisable.
|
||||||
|
return netaddr.IP{}, dns.RCodeRefused
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Refactoring note: this must happen after we check suffixes,
|
// Refactoring note: this must happen after we check suffixes,
|
||||||
// otherwise we will respond with NOTIMP to requests that should be forwarded.
|
// otherwise we will respond with NOTIMP to requests that should be forwarded.
|
||||||
|
@ -20,13 +20,15 @@ import (
|
|||||||
|
|
||||||
var testipv4 = netaddr.MustParseIP("1.2.3.4")
|
var testipv4 = netaddr.MustParseIP("1.2.3.4")
|
||||||
var testipv6 = netaddr.MustParseIP("0001:0203:0405:0607:0809:0a0b:0c0d:0e0f")
|
var testipv6 = netaddr.MustParseIP("0001:0203:0405:0607:0809:0a0b:0c0d:0e0f")
|
||||||
|
var test3ipv4 = netaddr.MustParseIP("1.2.4.5")
|
||||||
|
|
||||||
var dnsCfg = Config{
|
var dnsCfg = Config{
|
||||||
Hosts: map[dnsname.FQDN][]netaddr.IP{
|
Hosts: map[dnsname.FQDN][]netaddr.IP{
|
||||||
"test1.ipn.dev.": []netaddr.IP{testipv4},
|
"test1.ipn.dev.": []netaddr.IP{testipv4},
|
||||||
"test2.ipn.dev.": []netaddr.IP{testipv6},
|
"test2.ipn.dev.": []netaddr.IP{testipv6},
|
||||||
|
"test3.mytailnet.ts.net.": []netaddr.IP{test3ipv4},
|
||||||
},
|
},
|
||||||
LocalDomains: []dnsname.FQDN{"ipn.dev."},
|
LocalDomains: []dnsname.FQDN{"mytailnet.ts.net.", "ipn.dev."},
|
||||||
}
|
}
|
||||||
|
|
||||||
func dnspacket(domain dnsname.FQDN, tp dns.Type) []byte {
|
func dnspacket(domain dnsname.FQDN, tp dns.Type) []byte {
|
||||||
@ -234,6 +236,8 @@ func TestResolveLocal(t *testing.T) {
|
|||||||
{"mx-nxdomain", "test3.ipn.dev.", dns.TypeMX, netaddr.IP{}, dns.RCodeNameError},
|
{"mx-nxdomain", "test3.ipn.dev.", dns.TypeMX, netaddr.IP{}, dns.RCodeNameError},
|
||||||
{"ns-nxdomain", "test3.ipn.dev.", dns.TypeNS, netaddr.IP{}, dns.RCodeNameError},
|
{"ns-nxdomain", "test3.ipn.dev.", dns.TypeNS, netaddr.IP{}, dns.RCodeNameError},
|
||||||
{"onion-domain", "footest.onion.", dns.TypeA, netaddr.IP{}, dns.RCodeNameError},
|
{"onion-domain", "footest.onion.", dns.TypeA, netaddr.IP{}, dns.RCodeNameError},
|
||||||
|
{"magic", "test3.", dns.TypeA, test3ipv4, dns.RCodeSuccess},
|
||||||
|
{"nomagic", "test1.", dns.TypeA, netaddr.IP{}, dns.RCodeRefused},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user