diff --git a/cmd/ctrld/cli.go b/cmd/ctrld/cli.go index f83d281..dc8470d 100644 --- a/cmd/ctrld/cli.go +++ b/cmd/ctrld/cli.go @@ -323,11 +323,13 @@ func initCLI() { } initLogging() if doTasks(tasks) { + prog.resetDNS() mainLog.Info().Msg("Service uninstalled") return } }, } + uninstallCmd.Flags().StringVarP(&iface, "iface", "", "auto", `Reset DNS setting for iface, "auto" means the default interface gateway`) listIfacesCmd := &cobra.Command{ Use: "list", diff --git a/cmd/ctrld/os_linux.go b/cmd/ctrld/os_linux.go index 110a23b..582ae3c 100644 --- a/cmd/ctrld/os_linux.go +++ b/cmd/ctrld/os_linux.go @@ -72,9 +72,10 @@ func setDNS(iface *net.Interface, nameservers []string) error { } currentNS := currentDNS(iface) if reflect.DeepEqual(currentNS, nameservers) { - break + return nil } } + mainLog.Debug().Msg("DNS was not set for some reason") return nil } @@ -105,7 +106,6 @@ func resetDNS(iface *net.Interface) error { conversation, err := c.Exchange(iface.Name) if err != nil { mainLog.Debug().Err(err).Msg("could not exchange DHCPv6") - return nil } for _, packet := range conversation { if packet.Type() == dhcpv6.MessageTypeReply { diff --git a/cmd/ctrld/prog.go b/cmd/ctrld/prog.go index fa11dfc..532f57e 100644 --- a/cmd/ctrld/prog.go +++ b/cmd/ctrld/prog.go @@ -174,11 +174,6 @@ func (p *prog) Stop(s service.Service) error { return nil } -func (p *prog) Uninstall(s service.Service) error { - p.resetDNS() - return nil -} - func (p *prog) allocateIP(ip string) error { if !p.cfg.Service.AllocateIP { return nil