wgengine/tsdns: delegate bonjour service rdns requests
While we're here, parseQuery into a plain function. This is helpful for fuzzing. (Which I did a bit of. Didn't find anything.) And clean up a few minor things. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
This commit is contained in:
committed by
Josh Bleecher Snyder
parent
2d0ed99672
commit
1fd10061fd
@@ -684,6 +684,29 @@ func TestAllocs(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestTrimRDNSBonjourPrefix(t *testing.T) {
|
||||
tests := []struct {
|
||||
in string
|
||||
want bool
|
||||
}{
|
||||
{"b._dns-sd._udp.0.10.20.172.in-addr.arpa.", true},
|
||||
{"db._dns-sd._udp.0.10.20.172.in-addr.arpa.", true},
|
||||
{"r._dns-sd._udp.0.10.20.172.in-addr.arpa.", true},
|
||||
{"dr._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},
|
||||
{"0.10.20.172.in-addr.arpa.", false},
|
||||
{"i-have-no-dot", false},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
got := hasRDNSBonjourPrefix(test.in)
|
||||
if got != test.want {
|
||||
t.Errorf("trimRDNSBonjourPrefix(%q) = %v, want %v", test.in, got, test.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkFull(b *testing.B) {
|
||||
dnsHandleFunc("test.site.", resolveToIP(testipv4, testipv6, "dns.test.site."))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user