mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-15 20:10:28 +00:00
23 lines
459 B
Go
23 lines
459 B
Go
|
// +build linux darwin netbsd freebsd openbsd dragonflybsd
|
||
|
|
||
|
package yggdrasil
|
||
|
|
||
|
import "syscall"
|
||
|
import "golang.org/x/sys/unix"
|
||
|
|
||
|
func multicastReuse(network string, address string, c syscall.RawConn) error {
|
||
|
var control error
|
||
|
var reuseport error
|
||
|
|
||
|
control = c.Control(func(fd uintptr) {
|
||
|
reuseport = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_REUSEPORT, 1)
|
||
|
})
|
||
|
|
||
|
switch {
|
||
|
case reuseport != nil:
|
||
|
return reuseport
|
||
|
default:
|
||
|
return control
|
||
|
}
|
||
|
}
|