cmd/ctrld: add --iface for setting DNS on specific interface

This commit is contained in:
Cuong Manh Le
2023-01-06 00:55:21 +07:00
committed by Cuong Manh Le
parent d5344aea52
commit b00a7c34ee
13 changed files with 473 additions and 45 deletions
+2 -14
View File
@@ -3,21 +3,9 @@
package ctrld
import (
"net"
"tailscale.com/net/dns/resolvconffile"
"github.com/Control-D-Inc/ctrld/internal/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
return resolvconffile.NameServersWithPort()
}