mirror of
https://github.com/golang/go
synced 2024-11-16 22:54:47 -07:00
don't return cname from cgoLookupIPCNAME
This commit is contained in:
parent
02d8ebda83
commit
74a6013a9e
@ -37,7 +37,6 @@ type portLookupResult struct {
|
||||
|
||||
type ipLookupResult struct {
|
||||
addrs []IPAddr
|
||||
cname string
|
||||
err error
|
||||
}
|
||||
|
||||
@ -133,7 +132,7 @@ func cgoPortLookup(result chan<- portLookupResult, hints *_C_struct_addrinfo, ne
|
||||
result <- portLookupResult{port, err}
|
||||
}
|
||||
|
||||
func cgoLookupIPCNAME(network, name string) (addrs []IPAddr, cname string, err error) {
|
||||
func cgoLookupHostIP(network, name string) (addrs []IPAddr, err error) {
|
||||
acquireThread()
|
||||
defer releaseThread()
|
||||
|
||||
@ -175,19 +174,10 @@ func cgoLookupIPCNAME(network, name string) (addrs []IPAddr, cname string, err e
|
||||
isTemporary = addrinfoErrno(gerrno).Temporary()
|
||||
}
|
||||
|
||||
return nil, "", &DNSError{Err: err.Error(), Name: name, IsNotFound: isErrorNoSuchHost, IsTemporary: isTemporary}
|
||||
return nil, &DNSError{Err: err.Error(), Name: name, IsNotFound: isErrorNoSuchHost, IsTemporary: isTemporary}
|
||||
}
|
||||
defer _C_freeaddrinfo(res)
|
||||
|
||||
if res != nil {
|
||||
cname = _C_GoString(*_C_ai_canonname(res))
|
||||
if cname == "" {
|
||||
cname = name
|
||||
}
|
||||
if len(cname) > 0 && cname[len(cname)-1] != '.' {
|
||||
cname += "."
|
||||
}
|
||||
}
|
||||
for r := res; r != nil; r = *_C_ai_next(r) {
|
||||
// We only asked for SOCK_STREAM, but check anyhow.
|
||||
if *_C_ai_socktype(r) != _C_SOCK_STREAM {
|
||||
@ -204,17 +194,17 @@ func cgoLookupIPCNAME(network, name string) (addrs []IPAddr, cname string, err e
|
||||
addrs = append(addrs, addr)
|
||||
}
|
||||
}
|
||||
return addrs, cname, nil
|
||||
return addrs, nil
|
||||
}
|
||||
|
||||
func cgoIPLookup(result chan<- ipLookupResult, network, name string) {
|
||||
addrs, cname, err := cgoLookupIPCNAME(network, name)
|
||||
result <- ipLookupResult{addrs, cname, err}
|
||||
addrs, err := cgoLookupHostIP(network, name)
|
||||
result <- ipLookupResult{addrs, err}
|
||||
}
|
||||
|
||||
func cgoLookupIP(ctx context.Context, network, name string) (addrs []IPAddr, err error, completed bool) {
|
||||
if ctx.Done() == nil {
|
||||
addrs, _, err = cgoLookupIPCNAME(network, name)
|
||||
addrs, err = cgoLookupHostIP(network, name)
|
||||
return addrs, err, true
|
||||
}
|
||||
result := make(chan ipLookupResult, 1)
|
||||
|
@ -55,7 +55,6 @@ func _C_malloc(n uintptr) unsafe.Pointer { return C.malloc(C.size_t(n)) }
|
||||
func _C_free(p unsafe.Pointer) { C.free(p) }
|
||||
|
||||
func _C_ai_addr(ai *_C_struct_addrinfo) **_C_struct_sockaddr { return &ai.ai_addr }
|
||||
func _C_ai_canonname(ai *_C_struct_addrinfo) **_C_char { return &ai.ai_canonname }
|
||||
func _C_ai_family(ai *_C_struct_addrinfo) *_C_int { return &ai.ai_family }
|
||||
func _C_ai_flags(ai *_C_struct_addrinfo) *_C_int { return &ai.ai_flags }
|
||||
func _C_ai_next(ai *_C_struct_addrinfo) **_C_struct_addrinfo { return &ai.ai_next }
|
||||
|
@ -59,7 +59,6 @@ func _C_malloc(n uintptr) unsafe.Pointer {
|
||||
}
|
||||
|
||||
func _C_ai_addr(ai *_C_struct_addrinfo) **_C_struct_sockaddr { return &ai.Addr }
|
||||
func _C_ai_canonname(ai *_C_struct_addrinfo) **_C_char { return &ai.Canonname }
|
||||
func _C_ai_family(ai *_C_struct_addrinfo) *_C_int { return &ai.Family }
|
||||
func _C_ai_flags(ai *_C_struct_addrinfo) *_C_int { return &ai.Flags }
|
||||
func _C_ai_next(ai *_C_struct_addrinfo) **_C_struct_addrinfo { return &ai.Next }
|
||||
|
Loading…
Reference in New Issue
Block a user