aboutsummaryrefslogtreecommitdiff
path: root/src/encoding
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@golang.org>2017-07-05 22:00:21 -0700
committerBrad Fitzpatrick <bradfitz@golang.org>2017-07-06 05:39:42 +0000
commita5179bd0a56d8fae91e860f585cef143ce5ec89b (patch)
treef5ca6261a9a9d369c651231bf44e9f2108dba210 /src/encoding
parent53d318330839b904674dd365f216f62150fe6763 (diff)
downloadgo-a5179bd0a56d8fae91e860f585cef143ce5ec89b.tar.xz
net: don't return IPv4 unspecified addr for Resolve*Addr of [::] or [::]:n
ResolveTCPAddr, ResolveUDPAddr, and ResolveIPAddr return at most one address. When given a name like "golang.org" to resolve that might have more than 1 address, the net package has historically preferred IPv4 addresses, with the assumption that many users don't yet have IPv6 connectivity and randomly selecting between an IPv4 address and an IPv6 address at runtime wouldn't be a good experience for IPv4-only users. In CL 45088 (78cf0e56) I modified the resolution of the unspecified/empty address to internally resolve to both IPv6 "::" and 0.0.0.0 to fix issue #18806. That code has 3 other callers I hadn't considered, though: the Resolve*Addr functions. Since they preferred IPv4, any Resolve*Addr of "[::]:port" or "::" (for ResolveIPAddr) would internally resolve both "::" and 0.0.0.0 and then prefer 0.0.0.0, even though the user was looking up an IPv6 literal. Add tests and fix it, not by undoing the fix to #18806 but by selecting the preference function for Resolve*Addr more explicitly: we still prefer IPv4, but if the address being looked up was an IPv6 literal, prefer IPv6. The tests are skipped on machines without IPv6. Fixes #20911 Change-Id: Ib7036cc43182ae4118cd1390c254e17c04a251a3 Reviewed-on: https://go-review.googlesource.com/47554 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/encoding')
0 files changed, 0 insertions, 0 deletions