|
@@ -204,19 +204,19 @@ func UpdatePeers(client mqtt.Client, msg mqtt.Message) {
|
|
|
return
|
|
|
}
|
|
|
if cfg.Node.DNSOn == "yes" {
|
|
|
- if err := setHostDNS(peerUpdate.DNS, cfg.Node.Network, ncutils.IsWindows()); err != nil {
|
|
|
+ if err := setHostDNS(peerUpdate.DNS, cfg.Node.Interface, ncutils.IsWindows()); err != nil {
|
|
|
ncutils.Log("error updating /etc/hosts " + err.Error())
|
|
|
return
|
|
|
}
|
|
|
} else {
|
|
|
- if err := removeHostDNS(cfg.Node.Network, ncutils.IsWindows()); err != nil {
|
|
|
+ if err := removeHostDNS(cfg.Node.Interface, ncutils.IsWindows()); err != nil {
|
|
|
ncutils.Log("error removing profile from /etc/hosts " + err.Error())
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func setHostDNS(dns, network string, windows bool) error {
|
|
|
+func setHostDNS(dns, iface string, windows bool) error {
|
|
|
etchosts := "/etc/hosts"
|
|
|
if windows {
|
|
|
etchosts = "c:\\windows\\system32\\drivers\\etc\\hosts"
|
|
@@ -230,7 +230,7 @@ func setHostDNS(dns, network string, windows bool) error {
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
- profile.Name = network
|
|
|
+ profile.Name = iface
|
|
|
profile.Status = types.Enabled
|
|
|
if err := hosts.ReplaceProfile(profile); err != nil {
|
|
|
return err
|
|
@@ -241,7 +241,7 @@ func setHostDNS(dns, network string, windows bool) error {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
-func removeHostDNS(network string, windows bool) error {
|
|
|
+func removeHostDNS(iface string, windows bool) error {
|
|
|
etchosts := "/etc/hosts"
|
|
|
if windows {
|
|
|
etchosts = "c:\\windows\\system32\\drivers\\etc\\hosts"
|
|
@@ -250,7 +250,10 @@ func removeHostDNS(network string, windows bool) error {
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
- if err := hosts.RemoveProfile(network); err != nil {
|
|
|
+ if err := hosts.RemoveProfile(iface); err != nil {
|
|
|
+ if err == types.ErrUnknownProfile {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
return err
|
|
|
}
|
|
|
if err := hosts.Flush(); err != nil {
|