mirror of
https://github.com/mjl-/mox.git
synced 2025-07-12 16:24:37 +03:00
update to latest github.com/mjl-/adns, synced to go1.24.1
This commit is contained in:
58
vendor/github.com/mjl-/adns/conf.go
generated
vendored
58
vendor/github.com/mjl-/adns/conf.go
generated
vendored
@ -11,8 +11,8 @@ import (
|
||||
"io/fs"
|
||||
"os"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
|
||||
"github.com/mjl-/adns/internal/bytealg"
|
||||
)
|
||||
@ -99,19 +99,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: GODEBUG setting forcing use of Go's resolver")
|
||||
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: 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")
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
@ -143,7 +154,7 @@ func initConfVal() {
|
||||
// prefer the cgo resolver.
|
||||
// Note that LOCALDOMAIN can change behavior merely by being
|
||||
// specified with the empty string.
|
||||
_, localDomainDefined := syscall.Getenv("LOCALDOMAIN")
|
||||
_, localDomainDefined := os.LookupEnv("LOCALDOMAIN")
|
||||
if localDomainDefined || os.Getenv("RES_OPTIONS") != "" || os.Getenv("HOSTALIASES") != "" {
|
||||
confVal.preferCgo = true
|
||||
return
|
||||
@ -324,16 +335,7 @@ func (c *conf) lookupOrder(r *Resolver, hostname string) (ret hostLookupOrder, d
|
||||
}
|
||||
|
||||
// Canonicalize the hostname by removing any trailing dot.
|
||||
if stringsHasSuffix(hostname, ".") {
|
||||
hostname = hostname[:len(hostname)-1]
|
||||
}
|
||||
if canUseCgo && stringsHasSuffixFold(hostname, ".local") {
|
||||
// Per RFC 6762, the ".local" TLD is special. And
|
||||
// because Go's native resolver doesn't do mDNS or
|
||||
// similar local resolution mechanisms, assume that
|
||||
// libc might (via Avahi, etc) and use cgo.
|
||||
return hostLookupCgo, dnsConf
|
||||
}
|
||||
hostname = strings.TrimSuffix(hostname, ".")
|
||||
|
||||
nss := getSystemNSS()
|
||||
srcs := nss.sources["hosts"]
|
||||
@ -392,10 +394,14 @@ func (c *conf) lookupOrder(r *Resolver, hostname string) (ret hostLookupOrder, d
|
||||
return hostLookupCgo, dnsConf
|
||||
}
|
||||
continue
|
||||
case hostname != "" && stringsHasPrefix(src.source, "mdns"):
|
||||
// e.g. "mdns4", "mdns4_minimal"
|
||||
// We already returned true before if it was *.local.
|
||||
// libc wouldn't have found a hit on this anyway.
|
||||
case hostname != "" && strings.HasPrefix(src.source, "mdns"):
|
||||
if stringsHasSuffixFold(hostname, ".local") {
|
||||
// Per RFC 6762, the ".local" TLD is special. And
|
||||
// because Go's native resolver doesn't do mDNS or
|
||||
// similar local resolution mechanisms, assume that
|
||||
// libc might (via Avahi, etc) and use cgo.
|
||||
return hostLookupCgo, dnsConf
|
||||
}
|
||||
|
||||
// We don't parse mdns.allow files. They're rare. If one
|
||||
// exists, it might list other TLDs (besides .local) or even
|
||||
@ -492,7 +498,7 @@ func isGateway(h string) bool {
|
||||
return stringsEqualFold(h, "_gateway")
|
||||
}
|
||||
|
||||
// isOutbound reports whether h should be considered a "outbound"
|
||||
// isOutbound reports whether h should be considered an "outbound"
|
||||
// name for the myhostname NSS module.
|
||||
func isOutbound(h string) bool {
|
||||
return stringsEqualFold(h, "_outbound")
|
||||
|
Reference in New Issue
Block a user