var mdnsSource, filesSource, dnsSource bool
var first string
for _, src := range srcs {
if src.source == "files" || src.source == "dns" {
if !src.standardCriteria() {
return fallbackOrder // non-standard; let libc deal with it.
}
if src.source == "files" {
filesSource = true
} else if src.source == "dns" {
dnsSource = true
}
if first == "" {
first = src.source
}
continue
}
// Some source we don't know how to deal with.
return fallbackOrder
}
// Cases where Go can handle it without cgo and C thread
// overhead.
switch {
case filesSource && dnsSource:
if first == "files" {
return hostLookupFilesDNS
} else {
return hostLookupDNSFiles
}
case filesSource:
return hostLookupFiles
case dnsSource:
return hostLookupDNS
}
所以指定 hosts: files dns,解析策略就是 hostLookupFilesDNS,即优先使用 /etc/hosts 。
详细的解析顺序请参见 hostLookupOrder。
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,如果有疑问大家可以留言交流,谢谢大家对易采站长站的支持。









