mirror of
https://github.com/k3s-io/k3s.git
synced 2026-04-06 18:05:05 -04:00
17 lines
411 B
Go
17 lines
411 B
Go
//go:build !windows
|
|
|
|
package util
|
|
|
|
import (
|
|
"syscall"
|
|
|
|
"golang.org/x/sys/unix"
|
|
)
|
|
|
|
// permitReuse enables port and address sharing on the socket
|
|
func permitReuse(network, addr string, conn syscall.RawConn) error {
|
|
return conn.Control(func(fd uintptr) {
|
|
syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, unix.SO_REUSEPORT, 1)
|
|
syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, unix.SO_REUSEADDR, 1)
|
|
})
|
|
}
|