aboutsummaryrefslogtreecommitdiff
path: root/src/net/dnsclient_unix.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2016-10-19 16:48:21 -0400
committerRuss Cox <rsc@golang.org>2016-10-24 15:37:26 +0000
commitfa90f9b909286dc815fde1f83f77b80bd686127d (patch)
tree09cda7e12e6ff7a189f1ae5c104031c449563c12 /src/net/dnsclient_unix.go
parent157ce90abe24e7ff8ac51b05660eb7190101138c (diff)
downloadgo-fa90f9b909286dc815fde1f83f77b80bd686127d.tar.gz
go-fa90f9b909286dc815fde1f83f77b80bd686127d.zip
net: there are no invalid domain names anymore
The Go resolver reports invalid domain name for '!!!.local', but that is allowed by multicast DNS. In general we can't predict what future relaxations might come along, and libc resolvers do not distinguish 'no such host' from 'invalid name', so stop making that distinction here too. Always use 'no such host'. Fixes #12421. Change-Id: I8f22604767ec9e270434e483da52b337833bad71 Reviewed-on: https://go-review.googlesource.com/31468 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/net/dnsclient_unix.go')
-rw-r--r--src/net/dnsclient_unix.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/net/dnsclient_unix.go b/src/net/dnsclient_unix.go
index 130e4c958a0..dd39a78f45b 100644
--- a/src/net/dnsclient_unix.go
+++ b/src/net/dnsclient_unix.go
@@ -316,7 +316,12 @@ func (conf *resolverConfig) releaseSema() {
func lookup(ctx context.Context, name string, qtype uint16) (cname string, rrs []dnsRR, err error) {
if !isDomainName(name) {
- return "", nil, &DNSError{Err: "invalid domain name", Name: name}
+ // We used to use "invalid domain name" as the error,
+ // but that is a detail of the specific lookup mechanism.
+ // Other lookups might allow broader name syntax
+ // (for example Multicast DNS allows UTF-8; see RFC 6762).
+ // For consistency with libc resolvers, report no such host.
+ return "", nil, &DNSError{Err: errNoSuchHost.Error(), Name: name}
}
resolvConf.tryUpdate("/etc/resolv.conf")
resolvConf.mu.RLock()
@@ -469,7 +474,8 @@ func goLookupIPOrder(ctx context.Context, name string, order hostLookupOrder) (a
}
}
if !isDomainName(name) {
- return nil, &DNSError{Err: "invalid domain name", Name: name}
+ // See comment in func lookup above about use of errNoSuchHost.
+ return nil, &DNSError{Err: errNoSuchHost.Error(), Name: name}
}
resolvConf.tryUpdate("/etc/resolv.conf")
resolvConf.mu.RLock()