mirror of
https://github.com/golang/go.git
synced 2025-10-19 19:13:18 +00:00
net: remove redundant cgoLookupCNAME return parameter
`completed bool` just means `err == nil` after CL 446179. While here, add a test for cgoLookupCNAME. Co-authored-by: Mateusz Poliwczak <mpoliwczak34@gmail.com> Change-Id: I6081a089fde3cb27af4fbde6f04301fc3755272c Reviewed-on: https://go-review.googlesource.com/c/go/+/698615 Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Sean Liao <sean@liao.dev> Reviewed-by: Ian Lance Taylor <iant@golang.org> Auto-Submit: Sean Liao <sean@liao.dev> Reviewed-by: Mateusz Poliwczak <mpoliwczak34@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
This commit is contained in:
parent
f74ed44ed9
commit
ba1109feb5
4 changed files with 17 additions and 7 deletions
|
@ -31,7 +31,7 @@ func cgoLookupIP(ctx context.Context, network, name string) (addrs []IPAddr, err
|
||||||
panic("cgo stub: cgo not available")
|
panic("cgo stub: cgo not available")
|
||||||
}
|
}
|
||||||
|
|
||||||
func cgoLookupCNAME(ctx context.Context, name string) (cname string, err error, completed bool) {
|
func cgoLookupCNAME(ctx context.Context, name string) (cname string, err error) {
|
||||||
panic("cgo stub: cgo not available")
|
panic("cgo stub: cgo not available")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -297,16 +297,16 @@ func cgoSockaddr(ip IP, zone string) (*_C_struct_sockaddr, _C_socklen_t) {
|
||||||
return nil, 0
|
return nil, 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func cgoLookupCNAME(ctx context.Context, name string) (cname string, err error, completed bool) {
|
func cgoLookupCNAME(ctx context.Context, name string) (cname string, err error) {
|
||||||
resources, err := resSearch(ctx, name, int(dnsmessage.TypeCNAME), int(dnsmessage.ClassINET))
|
resources, err := resSearch(ctx, name, int(dnsmessage.TypeCNAME), int(dnsmessage.ClassINET))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return "", err
|
||||||
}
|
}
|
||||||
cname, err = parseCNAMEFromResources(resources)
|
cname, err = parseCNAMEFromResources(resources)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err, false
|
return "", err
|
||||||
}
|
}
|
||||||
return cname, nil, true
|
return cname, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// resSearch will make a call to the 'res_nsearch' routine in the C library
|
// resSearch will make a call to the 'res_nsearch' routine in the C library
|
||||||
|
|
|
@ -8,6 +8,7 @@ package net
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"internal/testenv"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -67,3 +68,12 @@ func TestCgoLookupPTRWithCancel(t *testing.T) {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCgoLookupCNAME(t *testing.T) {
|
||||||
|
mustHaveExternalNetwork(t)
|
||||||
|
testenv.SkipFlakyNet(t)
|
||||||
|
defer dnsWaitGroup.Wait()
|
||||||
|
if _, err := cgoLookupCNAME(t.Context(), "www.iana.org."); err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -87,8 +87,8 @@ func (r *Resolver) lookupPort(ctx context.Context, network, service string) (int
|
||||||
func (r *Resolver) lookupCNAME(ctx context.Context, name string) (string, error) {
|
func (r *Resolver) lookupCNAME(ctx context.Context, name string) (string, error) {
|
||||||
order, conf := systemConf().hostLookupOrder(r, name)
|
order, conf := systemConf().hostLookupOrder(r, name)
|
||||||
if order == hostLookupCgo {
|
if order == hostLookupCgo {
|
||||||
if cname, err, ok := cgoLookupCNAME(ctx, name); ok {
|
if cname, err := cgoLookupCNAME(ctx, name); err == nil {
|
||||||
return cname, err
|
return cname, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return r.goLookupCNAME(ctx, name, order, conf)
|
return r.goLookupCNAME(ctx, name, order, conf)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue