mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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>
This commit is contained in:
parent
157ce90abe
commit
fa90f9b909
3 changed files with 44 additions and 11 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue