Initializing default os resolver during upstream bootstrap

Since calling defaultNameservers may block the whole bootstrap process
if there's no valid DNS servers available.
This commit is contained in:
Cuong Manh Le
2025-06-11 22:23:24 +07:00
committed by Cuong Manh Le
parent 7cea5305e1
commit c4efa1ab97

View File

@@ -437,8 +437,9 @@ func (uc *UpstreamConfig) UID() string {
func (uc *UpstreamConfig) SetupBootstrapIP() {
b := backoff.NewBackoff("setupBootstrapIP", func(format string, args ...any) {}, 10*time.Second)
isControlD := uc.IsControlD()
nss := initDefaultOsResolver()
for {
uc.bootstrapIPs = lookupIP(uc.Domain, uc.Timeout, defaultNameservers())
uc.bootstrapIPs = lookupIP(uc.Domain, uc.Timeout, nss)
// For ControlD upstream, the bootstrap IPs could not be RFC 1918 addresses,
// filtering them out here to prevent weird behavior.
if isControlD {