Open bt90 opened 1 year ago
(CC @golang/windows)
Looks like ListenMulticastUDP
calls listenIPv6MulticastUDP
to handle ipv6 addresses, which calls joinIPv6Group
:
joinIPv6Group
then calls fd.pfd.SetsockoptIPv6Mreq
which in turn calls syscall.SetsockoptIPv6Mreq
:
SetsockoptIPv6Mreq
for windows just returns EWINDOWS
(aka not supported by windows
):
Well I decided to just copy what SetsockoptIPMreq
does
func SetsockoptIPMreq(fd Handle, level, opt int, mreq *IPMreq) (err error) {
return Setsockopt(fd, int32(level), int32(opt), (*byte)(unsafe.Pointer(mreq)), int32(unsafe.Sizeof(*mreq)))
}
func SetsockoptIPv6Mreq(fd Handle, level, opt int, mreq *IPv6Mreq) (err error) {
return Setsockopt(fd, int32(level), int32(opt), (*byte)(unsafe.Pointer(mreq)), int32(unsafe.Sizeof(*mreq)))
}
It appears to have worked
.\udp.exe
Listening on VirtualBox Host-Only Network
Listening on Ethernet
Skipping interface Wi-Fi
Listening on vEthernet (Default Switch)
Listening on vEthernet (WSL)
tbh I don't known why it is marked as not supported.
Also wondering why the test here didn't catch this
https://github.com/golang/go/blob/go1.21.3/src/net/listen_test.go#L603
Also wondering why the test here didn't catch this
Because os.Getuid
always returns -1 on Windows:
https://github.com/golang/go/blob/883f062fc0a097bf561030ad453fd3e300896975/src/net/listen_test.go#L613-L615
@mauri870 is your patch working?
@bt90 I just tried to run the example OP provided, it seemed to enumerate the interfaces correctly, I'm not sure about the actual state of IPv6 on windows
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
What did you expect to see?
Example output on a Linux host:
What did you see instead?
This fails for regular interfaces on Windows 10 and Windows 11 hosts: