mirror of
https://github.com/golang/go
synced 2024-11-25 12:07:56 -07:00
net: fix lookup of AAAA-only hosts without cgo
Fixes #3762. R=rsc CC=golang-dev https://golang.org/cl/6303106
This commit is contained in:
parent
ec6b5123fe
commit
dfbd42e4f8
@ -237,24 +237,30 @@ func goLookupIP(name string) (addrs []IP, err error) {
|
||||
}
|
||||
var records []dnsRR
|
||||
var cname string
|
||||
cname, records, err = lookup(name, dnsTypeA)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
var err4, err6 error
|
||||
cname, records, err4 = lookup(name, dnsTypeA)
|
||||
addrs = convertRR_A(records)
|
||||
if cname != "" {
|
||||
name = cname
|
||||
}
|
||||
_, records, err = lookup(name, dnsTypeAAAA)
|
||||
if err != nil && len(addrs) > 0 {
|
||||
// Ignore error because A lookup succeeded.
|
||||
err = nil
|
||||
_, records, err6 = lookup(name, dnsTypeAAAA)
|
||||
if err4 != nil && err6 == nil {
|
||||
// Ignore A error because AAAA lookup succeeded.
|
||||
err4 = nil
|
||||
}
|
||||
if err != nil {
|
||||
return
|
||||
if err6 != nil && len(addrs) > 0 {
|
||||
// Ignore AAAA error because A lookup succeeded.
|
||||
err6 = nil
|
||||
}
|
||||
if err4 != nil {
|
||||
return nil, err4
|
||||
}
|
||||
if err6 != nil {
|
||||
return nil, err6
|
||||
}
|
||||
|
||||
addrs = append(addrs, convertRR_AAAA(records)...)
|
||||
return
|
||||
return addrs, nil
|
||||
}
|
||||
|
||||
// goLookupCNAME is the native Go implementation of LookupCNAME.
|
||||
|
Loading…
Reference in New Issue
Block a user