print("go package net: hostLookupOrder(", hostname, ") = ", ret.String(), "\n")
}()
}
+ fallbackOrder := hostLookupCgo
if c.netGo {
- return hostLookupFilesDNS
+ fallbackOrder = hostLookupFilesDNS
}
if c.forceCgoLookupHost || c.resolv.unknownOpt || c.goos == "android" {
- return hostLookupCgo
+ return fallbackOrder
}
if byteIndex(hostname, '\\') != -1 || byteIndex(hostname, '%') != -1 {
// Don't deal with special form hostnames with backslashes
// or '%'.
- return hostLookupCgo
+ return fallbackOrder
}
// OpenBSD is unique and doesn't use nsswitch.conf.
return hostLookupDNSFiles
}
if len(lookup) < 1 || len(lookup) > 2 {
- return hostLookupCgo
+ return fallbackOrder
}
switch lookup[0] {
case "bind":
if lookup[1] == "file" {
return hostLookupDNSFiles
}
- return hostLookupCgo
+ return fallbackOrder
}
return hostLookupDNS
case "file":
if lookup[1] == "bind" {
return hostLookupFilesDNS
}
- return hostLookupCgo
+ return fallbackOrder
}
return hostLookupFiles
default:
- return hostLookupCgo
+ return fallbackOrder
}
}
// 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
+ return fallbackOrder
}
nss := c.nss
if os.IsNotExist(nss.err) || (nss.err == nil && len(srcs) == 0) {
if c.goos == "solaris" {
// illumos defaults to "nis [NOTFOUND=return] files"
- return hostLookupCgo
+ return fallbackOrder
}
if c.goos == "linux" {
// glibc says the default is "dns [!UNAVAIL=return] files"
// We failed to parse or open nsswitch.conf, so
// conservatively assume we should use cgo if it's
// available.
- return hostLookupCgo
+ return fallbackOrder
}
var mdnsSource, filesSource, dnsSource bool
if hasDot {
continue
}
- return hostLookupCgo
+ return fallbackOrder
}
if src.source == "files" || src.source == "dns" {
if !src.standardCriteria() {
- return hostLookupCgo // non-standard; let libc deal with it.
+ return fallbackOrder // non-standard; let libc deal with it.
}
if src.source == "files" {
filesSource = true
continue
}
// Some source we don't know how to deal with.
- return hostLookupCgo
+ return fallbackOrder
}
// We don't parse mdns.allow files. They're rare. If one
// exists, it might list other TLDs (besides .local) or even
// '*', so just let libc deal with it.
if mdnsSource && c.hasMDNSAllow {
- return hostLookupCgo
+ return fallbackOrder
}
// Cases where Go can handle it without cgo and C thread
}
// Something weird. Let libc deal with it.
- return hostLookupCgo
+ return fallbackOrder
}
// goDebugNetDNS parses the value of the GODEBUG "netdns" value.
{"google.com", hostLookupCgo},
},
},
+ {
+ name: "netgo_dns_before_files",
+ c: &conf{
+ netGo: true,
+ nss: nssStr("hosts: dns files"),
+ resolv: defaultResolvConf,
+ },
+ hostTests: []nssHostTest{
+ {"x.com", hostLookupDNSFiles},
+ },
+ },
+ {
+ name: "netgo_fallback_on_cgo",
+ c: &conf{
+ netGo: true,
+ nss: nssStr("hosts: dns files something_custom"),
+ resolv: defaultResolvConf,
+ },
+ hostTests: []nssHostTest{
+ {"x.com", hostLookupFilesDNS},
+ },
+ },
{
name: "ubuntu_trusty_avahi",
c: &conf{