mirror of
https://github.com/tailscale/tailscale.git
synced 2024-12-12 03:04:40 +00:00
net/dns/resolver: make hasRDNSBonjourPrefix match shorter queries too
Fixes tailscale/corp#2886
Updates tailscale/corp#2820
Updates #2442
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
(cherry picked from commit 676fb458c3
)
This commit is contained in:
parent
6421ee22f6
commit
784ce7c97c
@ -598,11 +598,6 @@ func marshalResponse(resp *response) ([]byte, error) {
|
|||||||
// dr._dns-sd._udp.<domain>.
|
// dr._dns-sd._udp.<domain>.
|
||||||
// lb._dns-sd._udp.<domain>.
|
// lb._dns-sd._udp.<domain>.
|
||||||
func hasRDNSBonjourPrefix(name dnsname.FQDN) bool {
|
func hasRDNSBonjourPrefix(name dnsname.FQDN) bool {
|
||||||
// Even the shortest name containing a Bonjour prefix is long,
|
|
||||||
// so check length (cheap) and bail early if possible.
|
|
||||||
if len(name) < len("*._dns-sd._udp.0.0.0.0.in-addr.arpa.") {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
s := name.WithTrailingDot()
|
s := name.WithTrailingDot()
|
||||||
dot := strings.IndexByte(s, '.')
|
dot := strings.IndexByte(s, '.')
|
||||||
if dot == -1 {
|
if dot == -1 {
|
||||||
|
@ -985,6 +985,7 @@ func TestTrimRDNSBonjourPrefix(t *testing.T) {
|
|||||||
{"lb._dns-sd._udp.0.10.20.172.in-addr.arpa.", true},
|
{"lb._dns-sd._udp.0.10.20.172.in-addr.arpa.", true},
|
||||||
{"qq._dns-sd._udp.0.10.20.172.in-addr.arpa.", false},
|
{"qq._dns-sd._udp.0.10.20.172.in-addr.arpa.", false},
|
||||||
{"0.10.20.172.in-addr.arpa.", false},
|
{"0.10.20.172.in-addr.arpa.", false},
|
||||||
|
{"lb._dns-sd._udp.ts-dns.test.", true},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
|
Loading…
Reference in New Issue
Block a user