fix(dns): fix panic when using DNS_KEEP_NAMESERVER

This commit is contained in:
Quentin McGaw
2025-11-17 17:54:52 +00:00
parent c930a4e1be
commit ad8b0657cb

View File

@@ -37,7 +37,6 @@ func (l *Loop) Run(ctx context.Context, done chan<- struct{}) {
if err == nil { if err == nil {
l.backoffTime = defaultBackoffTime l.backoffTime = defaultBackoffTime
l.logger.Info("ready") l.logger.Info("ready")
l.signalOrSetStatus(constants.Running)
break break
} }
@@ -54,6 +53,7 @@ func (l *Loop) Run(ctx context.Context, done chan<- struct{}) {
l.logAndWait(ctx, err) l.logAndWait(ctx, err)
settings = l.GetSettings() settings = l.GetSettings()
} }
l.signalOrSetStatus(constants.Running)
settings = l.GetSettings() settings = l.GetSettings()
if !*settings.KeepNameserver && !*settings.DoT.Enabled { if !*settings.KeepNameserver && !*settings.DoT.Enabled {
@@ -74,15 +74,19 @@ func (l *Loop) runWait(ctx context.Context, runError <-chan error) (exitLoop boo
for { for {
select { select {
case <-ctx.Done(): case <-ctx.Done():
if !*l.GetSettings().KeepNameserver {
l.stopServer() l.stopServer()
// TODO revert OS and Go nameserver when exiting // TODO revert OS and Go nameserver when exiting
}
return true return true
case <-l.stop: case <-l.stop:
l.userTrigger = true l.userTrigger = true
l.logger.Info("stopping") l.logger.Info("stopping")
if !*l.GetSettings().KeepNameserver {
const fallback = false const fallback = false
l.useUnencryptedDNS(fallback) l.useUnencryptedDNS(fallback)
l.stopServer() l.stopServer()
}
l.stopped <- struct{}{} l.stopped <- struct{}{}
case <-l.start: case <-l.start:
l.userTrigger = true l.userTrigger = true