package net
import (
)
var onceReadProtocols sync.Once
func () {
, := open("/etc/protocols")
if != nil {
return
}
defer .close()
for , := .readLine(); ; , = .readLine() {
if := bytealg.IndexByteString(, '#'); >= 0 {
= [0:]
}
:= getFields()
if len() < 2 {
continue
}
if , , := dtoi([1]); {
if , := protocols[[0]]; ! {
protocols[[0]] =
}
for , := range [2:] {
if , := protocols[]; ! {
protocols[] =
}
}
}
}
}
func ( context.Context, string) (int, error) {
onceReadProtocols.Do(readProtocols)
return lookupProtocolMap()
}
func ( *Resolver) ( context.Context, string) ( []string, error) {
, := systemConf().hostLookupOrder(, )
if == hostLookupCgo {
return cgoLookupHost(, )
}
return .goLookupHostOrder(, , , )
}
func ( *Resolver) ( context.Context, , string) ( []IPAddr, error) {
, := systemConf().hostLookupOrder(, )
if == hostLookupCgo {
return cgoLookupIP(, , )
}
, , := .goLookupIPCNAMEOrder(, , , , )
return ,
}
func ( *Resolver) ( context.Context, , string) (int, error) {
if !systemConf().mustUseGoResolver() {
, := cgoLookupPort(, , )
if != nil {
if , := goLookupPort(, ); == nil {
return , nil
}
}
return ,
}
return goLookupPort(, )
}
func ( *Resolver) ( context.Context, string) (string, error) {
, := systemConf().hostLookupOrder(, )
if == hostLookupCgo {
if , , := cgoLookupCNAME(, ); {
return ,
}
}
return .goLookupCNAME(, , , )
}
func ( *Resolver) ( context.Context, , , string) (string, []*SRV, error) {
return .goLookupSRV(, , , )
}
func ( *Resolver) ( context.Context, string) ([]*MX, error) {
return .goLookupMX(, )
}
func ( *Resolver) ( context.Context, string) ([]*NS, error) {
return .goLookupNS(, )
}
func ( *Resolver) ( context.Context, string) ([]string, error) {
return .goLookupTXT(, )
}
func ( *Resolver) ( context.Context, string) ([]string, error) {
, := systemConf().addrLookupOrder(, )
if == hostLookupCgo {
return cgoLookupPTR(, )
}
return .goLookupPTR(, , , )
}