fix(dns): prevent dns restart crash if DOT=off and DNS_KEEP_NAMESERVER=off

This commit is contained in:
Quentin McGaw 2025-11-24 16:43:24 +00:00
parent 7450424849
commit cba6070300
No known key found for this signature in database

View File

@ -74,7 +74,8 @@ 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 { settings := l.GetSettings()
if !*settings.KeepNameserver && *settings.DoT.Enabled {
l.stopServer() l.stopServer()
// TODO revert OS and Go nameserver when exiting // TODO revert OS and Go nameserver when exiting
} }
@ -82,7 +83,8 @@ func (l *Loop) runWait(ctx context.Context, runError <-chan error) (exitLoop boo
case <-l.stop: case <-l.stop:
l.userTrigger = true l.userTrigger = true
l.logger.Info("stopping") l.logger.Info("stopping")
if !*l.GetSettings().KeepNameserver { settings := l.GetSettings()
if !*settings.KeepNameserver && *settings.DoT.Enabled {
const fallback = false const fallback = false
l.useUnencryptedDNS(fallback) l.useUnencryptedDNS(fallback)
l.stopServer() l.stopServer()