diff --git a/cmd/cli/prog.go b/cmd/cli/prog.go index 64728a0..2e74a98 100644 --- a/cmd/cli/prog.go +++ b/cmd/cli/prog.go @@ -194,9 +194,6 @@ func (p *prog) runWait() { } func (p *prog) preRun() { - if !service.Interactive() { - p.setDNS() - } if runtime.GOOS == "darwin" { p.onStopped = append(p.onStopped, func() { if !service.Interactive() { @@ -206,6 +203,12 @@ func (p *prog) preRun() { } } +func (p *prog) postRun() { + if !service.Interactive() { + p.setDNS() + } +} + func (p *prog) setupUpstream(cfg *ctrld.Config) { localUpstreams := make([]string, 0, len(cfg.Upstream)) ptrNameservers := make([]string, 0, len(cfg.Upstream)) @@ -388,6 +391,7 @@ func (p *prog) run(reload bool, reloadCh chan struct{}) { if p.logConn != nil { _ = p.logConn.Close() } + p.postRun() } wg.Wait() }