mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
net: make Dial and Listen behavior consistent across over platforms
This CL changes the behavior of Dial and Listen API family. Previous Dial and Listen allow a combo of "tcp6" and IPv4 or IPv6 IPv4-mapped address as its argument, but it also makes slightly different behaviors between Linux and other platforms. This CL fixes such differences across over platforms by tweaking IP-level socket option IPV6_V6ONLY. Consequently new Dial and Listen API family will reject arguments consists of "tcp6" and IPv4 or IPv6 IPv4-mapped address. This CL also adds a bit clarified unicast listener tests. Fixes #2581. R=rsc, minux.ma CC=golang-dev https://golang.org/cl/5677086
This commit is contained in:
parent
fae0d35043
commit
b5dc8724cb
13 changed files with 596 additions and 113 deletions
|
|
@ -60,12 +60,7 @@ func TestFileListener(t *testing.T) {
|
|||
return
|
||||
}
|
||||
testFileListener(t, "tcp", "127.0.0.1")
|
||||
testFileListener(t, "tcp", "127.0.0.1")
|
||||
if supportsIPv6 && supportsIPv4map {
|
||||
testFileListener(t, "tcp", "[::ffff:127.0.0.1]")
|
||||
testFileListener(t, "tcp", "127.0.0.1")
|
||||
testFileListener(t, "tcp", "[::ffff:127.0.0.1]")
|
||||
}
|
||||
testFileListener(t, "tcp", "[::ffff:127.0.0.1]")
|
||||
if runtime.GOOS == "linux" {
|
||||
testFileListener(t, "unix", "@gotest/net")
|
||||
testFileListener(t, "unixpacket", "@gotest/net")
|
||||
|
|
@ -125,12 +120,10 @@ func TestFilePacketConn(t *testing.T) {
|
|||
}
|
||||
testFilePacketConnListen(t, "udp", "127.0.0.1:0")
|
||||
testFilePacketConnDial(t, "udp", "127.0.0.1:12345")
|
||||
testFilePacketConnDial(t, "udp", "[::ffff:127.0.0.1]:12345")
|
||||
if supportsIPv6 {
|
||||
testFilePacketConnListen(t, "udp", "[::1]:0")
|
||||
}
|
||||
if supportsIPv6 && supportsIPv4map {
|
||||
testFilePacketConnDial(t, "udp", "[::ffff:127.0.0.1]:12345")
|
||||
}
|
||||
if runtime.GOOS == "linux" {
|
||||
testFilePacketConnListen(t, "unixgram", "@gotest1/net")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue