Rework os resolver

Currently, os resolver not only handle A and AAAA records, but also does
it wrongly, since when it packs AAAA record to a dns.A record.

This commit reworks os resolver to make it works with all supported
record types.
This commit is contained in:
Cuong Manh Le
2023-01-20 21:33:17 +07:00
committed by Cuong Manh Le
parent e6d77e2586
commit e331a4113a
7 changed files with 561 additions and 150 deletions
+23
View File
@@ -0,0 +1,23 @@
//go:build !js && !windows
package ctrld
import (
"net"
"tailscale.com/net/dns/resolvconffile"
)
const resolvconfPath = "/etc/resolv.conf"
func nameservers() []string {
c, err := resolvconffile.ParseFile(resolvconfPath)
if err != nil {
return nil
}
ns := make([]string, 0, len(c.Nameservers))
for _, nameserver := range c.Nameservers {
ns = append(ns, net.JoinHostPort(nameserver.String(), "53"))
}
return ns
}