]> Cypherpunks repositories - gostls13.git/commitdiff
net: improve GODEBUG=netdns=1 debug messages
authorMateusz Poliwczak <mpoliwczak34@gmail.com>
Fri, 27 Sep 2024 19:57:12 +0000 (19:57 +0000)
committerGopher Robot <gobot@golang.org>
Mon, 30 Sep 2024 12:39:31 +0000 (12:39 +0000)
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 <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

src/net/conf.go

index 1b48546f1bd89348b5042f7d321e7bc2c261f9d1..92c5618d1ec2217ff50bdffe38a63d5b19773ed6 100644 (file)
@@ -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")
+                               }
                        }
                }()
        }