mirror of
https://github.com/slackhq/nebula.git
synced 2025-11-22 16:34:25 +01:00
Use registered io on Windows when possible (#905)
This commit is contained in:
@@ -3,14 +3,31 @@
|
||||
|
||||
package udp
|
||||
|
||||
// Windows support is primarily implemented in udp_generic, besides NewListenConfig
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"syscall"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func NewListener(l *logrus.Logger, ip net.IP, 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")
|
||||
}
|
||||
|
||||
rc, err := NewRIOListener(l, ip, port)
|
||||
if err == nil {
|
||||
return rc, nil
|
||||
}
|
||||
|
||||
l.WithError(err).Error("Falling back to standard udp sockets")
|
||||
return NewGenericListener(l, ip, port, multi, batch)
|
||||
}
|
||||
|
||||
func NewListenConfig(multi bool) net.ListenConfig {
|
||||
return net.ListenConfig{
|
||||
Control: func(network, address string, c syscall.RawConn) error {
|
||||
|
||||
Reference in New Issue
Block a user