aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid du Colombier <0intro@gmail.com>2024-04-28 14:39:56 +0200
committerDavid du Colombier <0intro@gmail.com>2024-04-29 14:35:28 +0000
commit16ce8b3925deaeb72541ee96b6ee23a08fc21dea (patch)
treea7ce0405633e5d01b14dfd9a48f9b5eeb25922cd /src
parentcf164403d1ae1459bf48cb7aea3cf16f8aca5a98 (diff)
downloadgo-16ce8b3925deaeb72541ee96b6ee23a08fc21dea.tar.gz
go-16ce8b3925deaeb72541ee96b6ee23a08fc21dea.zip
net: fix lookupHost on Plan 9
CL 532217 added the newDNSError function. However, the implementation was not correct on Plan 9, which lead TestLookupNoSuchHost to fail. This change fixes lookupHost on Plan 9. Fixes #67096. Change-Id: I39271f7d588b19c1b1608f18a24d871460be09cd Reviewed-on: https://go-review.googlesource.com/c/go/+/582236 Reviewed-by: Joedian Reid <joedian@google.com> Run-TryBot: David du Colombier <0intro@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/net/lookup_plan9.go19
-rw-r--r--src/net/lookup_test.go4
2 files changed, 9 insertions, 14 deletions
diff --git a/src/net/lookup_plan9.go b/src/net/lookup_plan9.go
index 2532a0e967..588174b1fc 100644
--- a/src/net/lookup_plan9.go
+++ b/src/net/lookup_plan9.go
@@ -109,17 +109,11 @@ func queryDNS(ctx context.Context, addr string, typ string) (res []string, err e
func handlePlan9DNSError(err error, name string) error {
if stringsHasSuffix(err.Error(), "dns: name does not exist") ||
stringsHasSuffix(err.Error(), "dns: resource does not exist; negrcode 0") ||
- stringsHasSuffix(err.Error(), "dns: resource does not exist; negrcode") {
- return &DNSError{
- Err: errNoSuchHost.Error(),
- Name: name,
- IsNotFound: true,
- }
- }
- return &DNSError{
- Err: err.Error(),
- Name: name,
+ stringsHasSuffix(err.Error(), "dns: resource does not exist; negrcode") ||
+ stringsHasSuffix(err.Error(), "dns failure") {
+ err = errNoSuchHost
}
+ return newDNSError(err, name, "")
}
// toLower returns a lower-case version of in. Restricting us to
@@ -169,10 +163,7 @@ func (*Resolver) lookupHost(ctx context.Context, host string) (addrs []string, e
// host names in local network (e.g. from /lib/ndb/local)
lines, err := queryCS(ctx, "net", host, "1")
if err != nil {
- if stringsHasSuffix(err.Error(), "dns failure") {
- err = errNoSuchHost
- }
- return nil, newDNSError(err, host, "")
+ return nil, handlePlan9DNSError(err, host)
}
loop:
for _, line := range lines {
diff --git a/src/net/lookup_test.go b/src/net/lookup_test.go
index bd58498fbc..97b37f2841 100644
--- a/src/net/lookup_test.go
+++ b/src/net/lookup_test.go
@@ -1634,6 +1634,10 @@ func TestLookupNoSuchHost(t *testing.T) {
}
func TestDNSErrorUnwrap(t *testing.T) {
+ if runtime.GOOS == "plan9" {
+ // The Plan 9 implementation of the resolver doesn't use the Dial function yet. See https://go.dev/cl/409234
+ t.Skip("skipping on plan9")
+ }
rDeadlineExcceeded := &Resolver{PreferGo: true, Dial: func(ctx context.Context, network, address string) (Conn, error) {
return nil, context.DeadlineExceeded
}}