From: Mateusz Poliwczak Date: Fri, 27 Sep 2024 19:57:12 +0000 (+0000) Subject: net: improve GODEBUG=netdns=1 debug messages X-Git-Tag: go1.24rc1~800 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=6536c207c2309da7c1c21e3669f8ddf491e31f5b;p=gostls13.git net: improve GODEBUG=netdns=1 debug messages Fixes #69680 Change-Id: I73b0506c7a3245ba282cffabe47543f5fce86692 GitHub-Last-Rev: 4c6a1a4c706f39d2756c65b72b78896cd4881302 GitHub-Pull-Request: golang/go#69684 Reviewed-on: https://go-review.googlesource.com/c/go/+/616263 LUCI-TryBot-Result: Go LUCI Reviewed-by: Ian Lance Taylor Reviewed-by: Michael Knyszek Auto-Submit: Ian Lance Taylor --- diff --git a/src/net/conf.go b/src/net/conf.go index 1b48546f1b..92c5618d1e 100644 --- a/src/net/conf.go +++ b/src/net/conf.go @@ -93,19 +93,30 @@ func initConfVal() { if confVal.dnsDebugLevel > 1 { println("go package net: confVal.netCgo =", confVal.netCgo, " netGo =", confVal.netGo) } + if dnsMode != "go" && dnsMode != "cgo" && dnsMode != "" { + println("go package net: GODEBUG=netdns contains an invalid dns mode, ignoring it") + } switch { - case confVal.netGo: - if netGoBuildTag { - println("go package net: built with netgo build tag; using Go's DNS resolver") + case netGoBuildTag || !cgoAvailable: + if dnsMode == "cgo" { + println("go package net: ignoring GODEBUG=netdns=cgo as the binary was compiled without support for the cgo resolver") + } else { + println("go package net: using the Go DNS resolver") + } + case netCgoBuildTag: + if dnsMode == "go" { + println("go package net: GODEBUG setting forcing use of the Go resolver") } else { - println("go package net: GODEBUG setting forcing use of Go's resolver") + println("go package net: using the cgo DNS resolver") } - case !cgoAvailable: - println("go package net: cgo resolver not supported; using Go's DNS resolver") - case confVal.netCgo || confVal.preferCgo: - println("go package net: using cgo DNS resolver") default: - println("go package net: dynamic selection of DNS resolver") + if dnsMode == "go" { + println("go package net: GODEBUG setting forcing use of the Go resolver") + } else if dnsMode == "cgo" { + println("go package net: GODEBUG setting forcing use of the cgo resolver") + } else { + println("go package net: dynamic selection of DNS resolver") + } } }() }