mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-02-03 22:18:39 +00:00
cmd/ctrld: fix reset DNS when uninstalling
The "--iface" needs to be explicitly passed, otherwise, ctrld does not know which interface to restore.
This commit is contained in:
committed by
Cuong Manh Le
parent
61156453b2
commit
44bd580e48
@@ -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",
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user