mirror of
https://github.com/tailscale/tailscale.git
synced 2025-01-07 08:07:42 +00:00
net/dns: remove config in openresolv when given an empty DNS config.
Part of #1720. Signed-off-by: David Anderson <danderson@tailscale.com>
This commit is contained in:
parent
48d4f14652
commit
ca283ac899
@ -19,7 +19,20 @@ func newOpenresolvManager() (openresolvManager, error) {
|
|||||||
return openresolvManager{}, nil
|
return openresolvManager{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m openresolvManager) deleteTailscaleConfig() error {
|
||||||
|
cmd := exec.Command("resolvconf", "-f", "-d", "tailscale")
|
||||||
|
out, err := cmd.CombinedOutput()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("running %s: %s", cmd, out)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (m openresolvManager) SetDNS(config OSConfig) error {
|
func (m openresolvManager) SetDNS(config OSConfig) error {
|
||||||
|
if config.IsZero() {
|
||||||
|
return m.deleteTailscaleConfig()
|
||||||
|
}
|
||||||
|
|
||||||
var stdin bytes.Buffer
|
var stdin bytes.Buffer
|
||||||
writeResolvConf(&stdin, config.Nameservers, config.SearchDomains)
|
writeResolvConf(&stdin, config.Nameservers, config.SearchDomains)
|
||||||
|
|
||||||
@ -75,10 +88,5 @@ func (m openresolvManager) GetBaseConfig() (OSConfig, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m openresolvManager) Close() error {
|
func (m openresolvManager) Close() error {
|
||||||
cmd := exec.Command("resolvconf", "-f", "-d", "tailscale")
|
return m.deleteTailscaleConfig()
|
||||||
out, err := cmd.CombinedOutput()
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("running %s: %s", cmd, out)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user