]> Cypherpunks repositories - gostls13.git/commitdiff
net: support IPv6 addresses in ListenMulticastUDP on Windows
authorqmuntal <quimmuntal@gmail.com>
Fri, 25 Apr 2025 13:30:53 +0000 (15:30 +0200)
committerQuim Muntal <quimmuntal@gmail.com>
Wed, 30 Apr 2025 15:34:01 +0000 (08:34 -0700)
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>
doc/next/6-stdlib/99-minor/net/63529.md [new file with mode: 0644]
src/net/listen_test.go
src/syscall/syscall_windows.go

diff --git a/doc/next/6-stdlib/99-minor/net/63529.md b/doc/next/6-stdlib/99-minor/net/63529.md
new file mode 100644 (file)
index 0000000..4cf05c9
--- /dev/null
@@ -0,0 +1 @@
+On Windows, the [ListenMulticastUDP] now supports IPv6 addresses.
index 9100b3d9f7becdba6d556584bbe88e71f868fd4c..59c1277a97966cb9e565c16e0e5968abd7dc1bf2 100644 (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" {
index 6ecdea6971aec17ef9d302db751477bc02e39e2c..c4782031a41be215efc82019e5a61d5da0251504 100644 (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()) }