From ad8b0657cb6a4865750c1f7cbb9d59b7ebde1e82 Mon Sep 17 00:00:00 2001 From: Quentin McGaw Date: Mon, 17 Nov 2025 17:54:52 +0000 Subject: [PATCH] fix(dns): fix panic when using DNS_KEEP_NAMESERVER --- internal/dns/run.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/internal/dns/run.go b/internal/dns/run.go index f5d05e44..b8cef81f 100644 --- a/internal/dns/run.go +++ b/internal/dns/run.go @@ -37,7 +37,6 @@ func (l *Loop) Run(ctx context.Context, done chan<- struct{}) { if err == nil { l.backoffTime = defaultBackoffTime l.logger.Info("ready") - l.signalOrSetStatus(constants.Running) break } @@ -54,6 +53,7 @@ func (l *Loop) Run(ctx context.Context, done chan<- struct{}) { l.logAndWait(ctx, err) settings = l.GetSettings() } + l.signalOrSetStatus(constants.Running) settings = l.GetSettings() if !*settings.KeepNameserver && !*settings.DoT.Enabled { @@ -74,15 +74,19 @@ func (l *Loop) runWait(ctx context.Context, runError <-chan error) (exitLoop boo for { select { case <-ctx.Done(): - l.stopServer() - // TODO revert OS and Go nameserver when exiting + if !*l.GetSettings().KeepNameserver { + l.stopServer() + // TODO revert OS and Go nameserver when exiting + } return true case <-l.stop: l.userTrigger = true l.logger.Info("stopping") - const fallback = false - l.useUnencryptedDNS(fallback) - l.stopServer() + if !*l.GetSettings().KeepNameserver { + const fallback = false + l.useUnencryptedDNS(fallback) + l.stopServer() + } l.stopped <- struct{}{} case <-l.start: l.userTrigger = true