Files
nebula/udp/udp_windows.go
Nate Brown 696903d6d9
Some checks failed
gofmt / Run gofmt (push) Failing after 2s
smoke-extra / freebsd-amd64 (push) Failing after 2s
smoke-extra / linux-amd64-ipv6disable (push) Failing after 3s
smoke-extra / netbsd-amd64 (push) Failing after 3s
smoke-extra / openbsd-amd64 (push) Failing after 3s
smoke-extra / linux-386 (push) Failing after 3s
smoke / Run multi node smoke test (push) Failing after 2s
Build and test / Build all and test on ubuntu-linux (push) Failing after 3s
Build and test / Build and test on linux with boringcrypto (push) Failing after 2s
Build and test / Build and test on linux with pkcs11 (push) Failing after 2s
smoke-extra / Run windows smoke test (push) Has been cancelled
Build and test / Build and test on macos-latest (push) Has been cancelled
Build and test / Build and test on windows-latest (push) Has been cancelled
Add a way to set the network type on windows + tests (#1710)
2026-05-07 20:17:38 -05:00

52 lines
1.3 KiB
Go

//go:build !e2e_testing
// +build !e2e_testing
package udp
import (
"fmt"
"log/slog"
"net"
"net/netip"
"syscall"
)
func NewListener(l *slog.Logger, ip netip.Addr, port int, multi bool, batch int) (Conn, error) {
if multi {
//NOTE: Technically we can support it with RIO but it wouldn't be at the socket level
// The udp stack would need to be reworked to hide away the implementation differences between
// Windows and Linux
return nil, fmt.Errorf("multiple udp listeners not supported on windows")
}
var conn Conn
rc, err := NewRIOListener(l, ip, port)
if err == nil {
conn = rc
} else {
l.Error("Falling back to standard udp sockets", "error", err)
conn, err = NewGenericListener(l, ip, port, multi, batch)
if err != nil {
return nil, err
}
}
return wrapWithWDFBypass(l, conn), nil
}
func NewListenConfig(multi bool) net.ListenConfig {
return net.ListenConfig{
Control: func(network, address string, c syscall.RawConn) error {
if multi {
// There is no way to support multiple listeners safely on Windows:
// https://docs.microsoft.com/en-us/windows/desktop/winsock/using-so-reuseaddr-and-so-exclusiveaddruse
return fmt.Errorf("multiple udp listeners not supported on windows")
}
return nil
},
}
}
func (u *GenericConn) Rebind() error {
return nil
}