diff options
author | Michael Fraenkel <michael.fraenkel@gmail.com> | 2017-11-26 08:22:22 -0500 |
---|---|---|
committer | Brad Fitzpatrick <bradfitz@golang.org> | 2018-06-27 21:37:24 +0000 |
commit | d144dd785f06300492754d49fb353ab9d5068919 (patch) | |
tree | d08a612ebb30e31793ad743958be552b05e28533 /src/net/lookup.go | |
parent | bafe466a9537d8ea5ac5767504628803302ebb12 (diff) | |
download | go-d144dd785f06300492754d49fb353ab9d5068919.tar.gz go-d144dd785f06300492754d49fb353ab9d5068919.zip |
net: parse IPv6 address with zone using DefaultResolver.Lookup{Host,IPAddr}
Allow a zone to be included with the ip address that is parsed when
using DefaultResolver's LookupHost or LookupIPAddr
Fixes #20790
Fixes #20767
Change-Id: I4e0baf9ade6a095af10a1b85ca6216788ba680ae
Reviewed-on: https://go-review.googlesource.com/79935
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/net/lookup.go')
-rw-r--r-- | src/net/lookup.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/net/lookup.go b/src/net/lookup.go index 1a9b4a9f08..e0f21fa9a8 100644 --- a/src/net/lookup.go +++ b/src/net/lookup.go @@ -162,11 +162,11 @@ func LookupHost(host string) (addrs []string, err error) { // It returns a slice of that host's addresses. func (r *Resolver) LookupHost(ctx context.Context, host string) (addrs []string, err error) { // Make sure that no matter what we do later, host=="" is rejected. - // ParseIP, for example, does accept empty strings. + // parseIP, for example, does accept empty strings. if host == "" { return nil, &DNSError{Err: errNoSuchHost.Error(), Name: host} } - if ip := ParseIP(host); ip != nil { + if ip, _ := parseIPZone(host); ip != nil { return []string{host}, nil } return r.lookupHost(ctx, host) @@ -190,12 +190,12 @@ func LookupIP(host string) ([]IP, error) { // It returns a slice of that host's IPv4 and IPv6 addresses. func (r *Resolver) LookupIPAddr(ctx context.Context, host string) ([]IPAddr, error) { // Make sure that no matter what we do later, host=="" is rejected. - // ParseIP, for example, does accept empty strings. + // parseIP, for example, does accept empty strings. if host == "" { return nil, &DNSError{Err: errNoSuchHost.Error(), Name: host} } - if ip := ParseIP(host); ip != nil { - return []IPAddr{{IP: ip}}, nil + if ip, zone := parseIPZone(host); ip != nil { + return []IPAddr{{IP: ip, Zone: zone}}, nil } trace, _ := ctx.Value(nettrace.TraceKey{}).(*nettrace.Trace) if trace != nil && trace.DNSStart != nil { |