From 676fb458c3042f41d0449f9cb474f5587f5c6874 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Wed, 13 Oct 2021 15:44:20 -0700 Subject: [PATCH] net/dns/resolver: make hasRDNSBonjourPrefix match shorter queries too Fixes tailscale/corp#2886 Updates tailscale/corp#2820 Updates #2442 Signed-off-by: Brad Fitzpatrick --- net/dns/resolver/tsdns.go | 5 ----- net/dns/resolver/tsdns_test.go | 1 + 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/net/dns/resolver/tsdns.go b/net/dns/resolver/tsdns.go index 4331fcdb6..b4d4b7c1a 100644 --- a/net/dns/resolver/tsdns.go +++ b/net/dns/resolver/tsdns.go @@ -598,11 +598,6 @@ const ( // dr._dns-sd._udp.. // lb._dns-sd._udp.. 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() dot := strings.IndexByte(s, '.') if dot == -1 { diff --git a/net/dns/resolver/tsdns_test.go b/net/dns/resolver/tsdns_test.go index 900dc9682..5809ce798 100644 --- a/net/dns/resolver/tsdns_test.go +++ b/net/dns/resolver/tsdns_test.go @@ -985,6 +985,7 @@ func TestTrimRDNSBonjourPrefix(t *testing.T) { {"lb._dns-sd._udp.0.10.20.172.in-addr.arpa.", true}, {"qq._dns-sd._udp.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 {