260×260

科学搜查官yuchanns

咖啡、代码与键盘
  • Shenzhen, China
  • Backend Developer
Posted 8 months ago

[WIP]Replacing net.DefaultResolver with a caching DNS over TLS/HTTPS resolver

NS caching has been discussed multiple times in the past. The consensus seems to be that Go won't go there: github.com/golang/go/issues/24796

I've seen a few DNS caching solutions for Go (one, two), however, I haven't seen any implementations that allow replacing the net.DefaultResolver?

Package github.com/artyom/dot got me thinking if I could do the same for DNS caching, and also DNS over HTTPS.

So github.com/ncruces/go-dns is my attempt. Replacing net.DefaultResolver with a caching DNS over HTTPS resolver using 1.1.1.1 as the name server should be this simple:

net.DefaultResolver = dns.NewCachingResolver(dns.NewHTTPSResolver( "1.1.1.1", "2606:4700:4700::1111", "1.0.0.1", "2606:4700:4700::1001"))

What do you guys thing? Do you know of any other implementations that allow replacing net.DefaultResolver?