Skip to content

Commit

Permalink
Merge pull request #358 from xiaods/dev
Browse files Browse the repository at this point in the history
fix: update util/net module
  • Loading branch information
xiaods authored Oct 21, 2024
2 parents 3784134 + b9d4892 commit 7d549b8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pkg/util/net_unix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//go:build !windows
// +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)
})
}
11 changes: 11 additions & 0 deletions pkg/util/net_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//go:build windows
// +build windows

package util

import "syscall"

// permitReuse is a no-op; port and address reuse is not supported on Windows
func permitReuse(network, addr string, conn syscall.RawConn) error {
return nil
}

0 comments on commit 7d549b8

Please sign in to comment.