net: support IPv6 addresses in ListenMulticastUDP on Windows

Fixes #63529.

Change-Id: Id9246af1a72beef3149af571f0891437bba2f4e0
Reviewed-on: https://go-review.googlesource.com/c/go/+/668216
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
This commit is contained in:
qmuntal 2025-04-25 15:30:53 +02:00 committed by Quim Muntal
parent 8270b858ee
commit c966f1c0c0
3 changed files with 7 additions and 3 deletions

View file

@ -0,0 +1 @@
On Windows, the [ListenMulticastUDP] now supports IPv6 addresses.

View file

@ -610,7 +610,8 @@ func TestIPv6MulticastListener(t *testing.T) {
if !supportsIPv6() {
t.Skip("IPv6 is not supported")
}
if os.Getuid() != 0 {
// On Windows, the test can be run by non-admin users.
if runtime.GOOS != "windows" && os.Getuid() != 0 {
t.Skip("must be root")
}
@ -669,7 +670,7 @@ func checkMulticastListener(c *UDPConn, ip IP) error {
func multicastRIBContains(ip IP) (bool, error) {
switch runtime.GOOS {
case "aix", "dragonfly", "netbsd", "openbsd", "plan9", "solaris", "illumos", "windows":
case "aix", "dragonfly", "netbsd", "openbsd", "plan9", "solaris", "illumos":
return true, nil // not implemented yet
case "linux":
if runtime.GOARCH == "arm" || runtime.GOARCH == "alpha" {

View file

@ -1192,7 +1192,9 @@ func SetsockoptInet4Addr(fd Handle, level, opt int, value [4]byte) (err error) {
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 EWINDOWS }
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)))
}
func Getpid() (pid int) { return int(getCurrentProcessId()) }