-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.
Milestone
Description
https://go-review.googlesource.com/45088 changed the behavior such that ResolveUDPAddr("[::]") followed by DialUDP on the result dials IPv4 localhost, not IPv6 localhost, which then fails when IPv4 is not configured. This is because ResolveUDPAddr unconditionally prefers IPv4 addresses when they're present in the addrList returned by internetAddrList. Looking at the code, I expect ResolveTCPAddr will have the same problem.
package main
import (
"net"
"fmt"
"os"
"strings"
)
func main() {
addr, err := net.ResolveUDPAddr("udp", "[::]:9999")
if err != nil {
panic(err)
}
conn, err := net.DialUDP("udp", nil, addr)
if err != nil {
panic(err)
}
fmt.Printf("%s (%#v) %s (%#v)\n", addr, addr, conn.RemoteAddr(), conn.RemoteAddr())
if strings.Contains(conn.RemoteAddr().String(), "127.0.0.1") {
fmt.Printf("Fail\n")
os.Exit(1)
}
}
At d8a7990:
[::]:9999 (&net.UDPAddr{IP:net.IP{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, Port:9999, Zone:""}) [::1]:9999 (&net.UDPAddr{IP:net.IP{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1}, Port:9999, Zone:""})
At 78cf0e5:
0.0.0.0:9999 (&net.UDPAddr{IP:net.IP{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0x0, 0x0, 0x0, 0x0}, Port:9999, Zone:""}) 127.0.0.1:9999 (&net.UDPAddr{IP:net.IP{0x7f, 0x0, 0x0, 0x1}, Port:9999, Zone:""})
cc @bradfitz
dsnet
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.