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.
This commit is contained in:
Cuong Manh Le
2025-02-02 11:35:49 +07:00
committed by Cuong Manh Le
parent 028475a193
commit 1560455ca3
2 changed files with 5 additions and 0 deletions

View File

@@ -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,

View File

@@ -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...)
}