]> Cypherpunks repositories - gostls13.git/commit
net: apply tcp4/tcp6 restrictions to literals in ResolveTCPAddr
authorRuss Cox <rsc@golang.org>
Thu, 27 Oct 2016 00:44:26 +0000 (20:44 -0400)
committerRuss Cox <rsc@golang.org>
Fri, 11 Nov 2016 17:07:07 +0000 (17:07 +0000)
commit866e01457f69b58b31ccb95f223aac80e1285332
tree4001a1ff7c0a8132df42aa9d30f11939866cfc6b
parentc4099c7593fea9c594ad0e8969452a741acba4c7
net: apply tcp4/tcp6 restrictions to literals in ResolveTCPAddr

The restrictions were already being applied to the IP addresses
received from the host resolver. Apply the same restrictions to
literal IP addresses not passed to the host resolver.

For example, ResolveTCPAddr("tcp4", "[2001:db8::1]:http") used
to succeed and now does not (that's not an IPv4 address).

Perhaps a bit surprisingly,
ResolveTCPAddr("tcp4", "[::ffff:127.0.0.1]:http") succeeds,
behaving identically to ResolveTCPAddr("tcp4", "127.0.0.1:http"), and
ResolveTCPAddr("tcp6", "[::ffff:127.0.0.1]:http") fails,
behaving identically to ResolveTCPAddr("tcp6", "127.0.0.1:http").
Even so, it seems right to match (by reusing) the existing filtering
as applied to addresses resolved by the host C library.
If anyone can make a strong argument for changing the filtering
of IPv4-inside-IPv6 addresses, the fix can be applied to all
the code paths in a separate CL.

Fixes #14037.

Change-Id: I690dfdcbe93d730e11e00ea387fa7484cd524341
Reviewed-on: https://go-review.googlesource.com/32100
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/net/dial.go
src/net/error_test.go
src/net/ipsock.go
src/net/ipsock_test.go
src/net/net.go
src/net/tcpsock_test.go