mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-02-03 22:18:39 +00:00
all: preserve search domains settings
So bare hostname will be resolved as expected when ctrld is running.
This commit is contained in:
committed by
Cuong Manh Le
parent
00e9d2bdd3
commit
62f73bcaa2
@@ -6,6 +6,7 @@ import (
|
||||
"net"
|
||||
|
||||
"tailscale.com/net/dns/resolvconffile"
|
||||
"tailscale.com/util/dnsname"
|
||||
)
|
||||
|
||||
const resolvconfPath = "/etc/resolv.conf"
|
||||
@@ -22,7 +23,7 @@ func NameServersWithPort() []string {
|
||||
return ns
|
||||
}
|
||||
|
||||
func NameServers(_ string) []string {
|
||||
func NameServers() []string {
|
||||
c, err := resolvconffile.ParseFile(resolvconfPath)
|
||||
if err != nil {
|
||||
return nil
|
||||
@@ -33,3 +34,12 @@ func NameServers(_ string) []string {
|
||||
}
|
||||
return ns
|
||||
}
|
||||
|
||||
// SearchDomains returns the current search domains config in /etc/resolv.conf file.
|
||||
func SearchDomains() ([]dnsname.FQDN, error) {
|
||||
c, err := resolvconffile.ParseFile(resolvconfPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return c.SearchDomains, nil
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
func TestNameServers(t *testing.T) {
|
||||
ns := NameServers("")
|
||||
ns := NameServers()
|
||||
require.NotNil(t, ns)
|
||||
t.Log(ns)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user