mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-22 01:20:29 +00:00
Use SO_REUSEADDR
instead of SO_REUSEPORT
on Linux
This commit is contained in:
parent
c55611a478
commit
0a1a155e66
@ -15,15 +15,19 @@ func (m *Multicast) _multicastStarted() {
|
|||||||
|
|
||||||
func (m *Multicast) multicastReuse(network string, address string, c syscall.RawConn) error {
|
func (m *Multicast) multicastReuse(network string, address string, c syscall.RawConn) error {
|
||||||
var control error
|
var control error
|
||||||
var reuseport error
|
var reuseaddr error
|
||||||
|
|
||||||
control = c.Control(func(fd uintptr) {
|
control = c.Control(func(fd uintptr) {
|
||||||
reuseport = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_REUSEPORT, 1)
|
// Previously we used SO_REUSEPORT here, but that meant that machines running
|
||||||
|
// Yggdrasil nodes as different users would inevitably fail with EADDRINUSE.
|
||||||
|
// The behaviour for multicast is similar with both, so we'll use SO_REUSEADDR
|
||||||
|
// instead.
|
||||||
|
reuseaddr = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_REUSEADDR, 1)
|
||||||
})
|
})
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case reuseport != nil:
|
case reuseaddr != nil:
|
||||||
return reuseport
|
return reuseaddr
|
||||||
default:
|
default:
|
||||||
return control
|
return control
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user