mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-08-23 01:27:13 +02:00
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:
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user