summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSmitty <me@smitop.com>2020-12-31 17:31:33 -0500
committerJosh Bleecher Snyder <josh@tailscale.com>2021-01-12 14:12:12 -0800
commit316ca7e31f703ab0c1320968500f334255cd9636 (patch)
treeeee6a6e38715f3be7a874c3f5156f9ad9707946a
parentb987b2ab18ff4807c9b29d77510fd9ab4c3f0779 (diff)
downloadtailscale-noerror-not-notimp.tar.xz
tailscale-noerror-not-notimp.zip
wgengine/tsdns: return NOERROR instead of NOTIMP for most recordsnoerror-not-notimp
This is what every other DNS resolver I could find does, so tsdns should do it to. This also helps avoid weird error messages about non-existent records being unimplemented, and thus fixes #848. Signed-off-by: Smitty <me@smitop.com>
-rw-r--r--wgengine/tsdns/tsdns.go16
-rw-r--r--wgengine/tsdns/tsdns_test.go4
2 files changed, 19 insertions, 1 deletions
diff --git a/wgengine/tsdns/tsdns.go b/wgengine/tsdns/tsdns.go
index c14503003..fad334539 100644
--- a/wgengine/tsdns/tsdns.go
+++ b/wgengine/tsdns/tsdns.go
@@ -228,8 +228,22 @@ func (r *Resolver) Resolve(domain string, tp dns.Type) (netaddr.IP, dns.RCode, e
// It could be IPv4, IPv6, or a zero addr.
// TODO: Return all available resolutions (A and AAAA, if we have them).
return addr, dns.RCodeSuccess, nil
- default:
+
+ // Leave some some record types explicitly unimplemented.
+ // These types relate to recursive resolution or special
+ // DNS sematics and might be implemented in the future.
+ case dns.TypeNS, dns.TypeSOA, dns.TypeAXFR, dns.TypeHINFO:
return netaddr.IP{}, dns.RCodeNotImplemented, errNotImplemented
+
+ // For everything except for the few types above that are explictly not implemented, return no records.
+ // This is what other DNS systems do: always return NOERROR
+ // without any records whenever the requested record type is unknown.
+ // You can try this with:
+ // dig -t TYPE9824 example.com
+ // and note that NOERROR is returned, despite that record type being made up.
+ default:
+ // no records exist of this type
+ return netaddr.IP{}, dns.RCodeSuccess, nil
}
}
diff --git a/wgengine/tsdns/tsdns_test.go b/wgengine/tsdns/tsdns_test.go
index 7e28b9efb..2eb0df479 100644
--- a/wgengine/tsdns/tsdns_test.go
+++ b/wgengine/tsdns/tsdns_test.go
@@ -215,6 +215,10 @@ func TestResolve(t *testing.T) {
{"nxdomain", "test3.ipn.dev.", dns.TypeA, netaddr.IP{}, dns.RCodeNameError},
{"foreign domain", "google.com.", dns.TypeA, netaddr.IP{}, dns.RCodeRefused},
{"all", "test1.ipn.dev.", dns.TypeA, testipv4, dns.RCodeSuccess},
+ {"mx-ipv4", "test1.ipn.dev.", dns.TypeMX, netaddr.IP{}, dns.RCodeSuccess},
+ {"mx-ipv6", "test2.ipn.dev.", dns.TypeMX, netaddr.IP{}, dns.RCodeSuccess},
+ {"mx-nxdomain", "test3.ipn.dev.", dns.TypeMX, netaddr.IP{}, dns.RCodeNameError},
+ {"ns-nxdomain", "test3.ipn.dev.", dns.TypeNS, netaddr.IP{}, dns.RCodeNameError},
}
for _, tt := range tests {