The cgo resolver sends DNS queries for .local subdomain
lookups, just as we do in the go resolver.
We don't need to fallback to the cgo resolver for this
domains when nsswitch.conf uses only file and dns modules.
This has a benefit that we select a consistent resolver,
that is only based on the system configuration, regardless
of the queried domain.
Updates #63978
Change-Id: I9166103adb94d7ab52992925f413f361130e7c52
GitHub-Last-Rev:
e2bc5874cb5c9165e3cc058e9effe36d0ce68cd6
GitHub-Pull-Request: golang/go#63986
Reviewed-on: https://go-review.googlesource.com/c/go/+/540555
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
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
- }
nss := getSystemNSS()
srcs := nss.sources["hosts"]
}
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.
+ 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
hostTests: []nssHostTest{
{"x.com", "myhostname", hostLookupFilesDNS},
{"x", "myhostname", hostLookupFilesDNS},
- {"x.local", "myhostname", hostLookupCgo},
+ {"x.local", "myhostname", hostLookupFilesDNS},
},
},
{
hostTests: []nssHostTest{
{"x.com", "myhostname", hostLookupDNSFiles},
{"x", "myhostname", hostLookupDNSFiles},
- {"x.local", "myhostname", hostLookupCgo},
+ {"x.local", "myhostname", hostLookupDNSFiles},
},
},
{
when the RES_OPTIONS or HOSTALIASES environment variable is non-empty,
when the ASR_CONFIG environment variable is non-empty (OpenBSD only),
when /etc/resolv.conf or /etc/nsswitch.conf specify the use of features that the
-Go resolver does not implement, and when the name being looked up ends in .local
-or is an mDNS name.
+Go resolver does not implement.
On all systems (except Plan 9), when the cgo resolver is being used
this package applies a concurrent cgo lookup limit to prevent the system