From 1560455ca3b325eec8c8c6f6f29e3029d0ec9a81 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Sun, 2 Feb 2025 11:35:49 +0700 Subject: [PATCH] Use all available nameservers in lookupIP Some systems may be configured with public DNS only, so relying solely on LAN servers could make the lookup process failed unexpectedly. --- config_internal_test.go | 4 ++++ resolver.go | 1 + 2 files changed, 5 insertions(+) diff --git a/config_internal_test.go b/config_internal_test.go index 6823686..44b7e2f 100644 --- a/config_internal_test.go +++ b/config_internal_test.go @@ -2,12 +2,16 @@ package ctrld import ( "net/url" + "os" "testing" + "github.com/rs/zerolog" "github.com/stretchr/testify/assert" ) func TestUpstreamConfig_SetupBootstrapIP(t *testing.T) { + l := zerolog.New(os.Stdout) + ProxyLogger.Store(&l) uc := &UpstreamConfig{ Name: "test", Type: ResolverTypeDOH, diff --git a/resolver.go b/resolver.go index c26560b..f036967 100644 --- a/resolver.go +++ b/resolver.go @@ -367,6 +367,7 @@ func lookupIP(domain string, timeout int, withBootstrapDNS bool) (ips []string) or = newResolverWithNameserver(defaultNameservers()) } nss := *or.lanServers.Load() + nss = append(nss, *or.publicServers.Load()...) if withBootstrapDNS { nss = append([]string{net.JoinHostPort(controldBootstrapDns, "53")}, nss...) }