Go version
all versions since go1.18
Output of go env
in your module/workspace:
see above
What did you do?
Create an IPv4 UDP socket listening on 0.0.0.0
. Call WriteMsgUDPAddrPort
with an IPv4-mapped IPv6 destination address.
What did you see happen?
write udp4 0.0.0.0:48509->[::ffff:192.168.0.162]:20221: address ::ffff:192.168.0.162: non-IPv4 address
What did you expect to see?
The write succeeds, just like WriteMsgUDP
.
Back when Go 1.18 was just out, I opened #52264 for sending to IPv4 addresses on IPv6 sockets.
This issue is about the other way around: sending to IPv4-mapped IPv6 addresses on IPv4 sockets. It's less common, as IPv4 UDP sockets are less used compared to dual-stack IPv6 sockets. But it's just as painful, as APIs like net.DefaultResolver.LookupNetIP
happily return IPv4-mapped IPv6 addresses.
I'm sending a CL to address it.
Comment From: gabyhelp
Related Issues
- net: WriteMsgUDPAddrPort should accept IPv4 destination addresses on IPv6 UDP sockets #52264 (closed)
- net: fix WriteMsgUDPAddrPort addr handling #52265 (closed)
- proposal: net: UDPAddr/TCPAddr AddrPort should map 4in6 addresses to IPv4 netip.Addrs #53607
- net: WriteMsgUDPAddrPort should accept IPv4 destination addresses on IPv6 UDP sockets [1.18 backport] #54074 (closed)
- net: net.ListenUDP() only binds to IPv4 when 127.0.0.1 is not present #61310
- net: Resolve{TCP,UDP,IP}Addr returns IPv4 address on host without IPv4 connectivity #28666
- net: Resolve*([::]) gives IPv4 zero, not IPv6 #20911 (closed)
Related Code Changes
- net: fix WriteMsgUDPAddrPort addr handling
- [release-branch.go1.18] net: fix WriteMsgUDPAddrPort addr handling
Related Discussions
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
Comment From: mknyszek
CC @neild