mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-08-10 13:20:33 +02:00
cmd/cli: silent un-necessary error for physical interfaces loop
The loop is run after the main interface DNS was set, thus the error would make noise to users. This commit removes the noise, by making currentStaticDNS returns an additional error, so it's up to the caller to decive whether to emit the error or not. Further, the physical interface loop will now only log when the callback function runs successfully. Emitting the callback error can be done in the future, until we can figure out how to detect physical interfaces in Go portably.
This commit is contained in:
@@ -63,15 +63,12 @@ func currentDNS(_ *net.Interface) []string {
|
||||
}
|
||||
|
||||
// currentStaticDNS returns the current static DNS settings of given interface.
|
||||
func currentStaticDNS(iface *net.Interface) []string {
|
||||
func currentStaticDNS(iface *net.Interface) ([]string, error) {
|
||||
cmd := "networksetup"
|
||||
args := []string{"-getdnsservers", iface.Name}
|
||||
out, err := exec.Command(cmd, args...).Output()
|
||||
if err != nil {
|
||||
if ifaceUp(iface) {
|
||||
mainLog.Load().Error().Err(err).Msg("could not get current static DNS")
|
||||
}
|
||||
return nil
|
||||
return nil, err
|
||||
}
|
||||
scanner := bufio.NewScanner(bytes.NewReader(out))
|
||||
var ns []string
|
||||
@@ -81,5 +78,5 @@ func currentStaticDNS(iface *net.Interface) []string {
|
||||
ns = append(ns, ip.String())
|
||||
}
|
||||
}
|
||||
return ns
|
||||
return ns, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user