mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-12-26 12:15:44 +08:00
18 lines
386 B
Go
18 lines
386 B
Go
package dialer
|
|
|
|
import (
|
|
"context"
|
|
"net"
|
|
"syscall"
|
|
|
|
"golang.org/x/sys/windows"
|
|
)
|
|
|
|
func addrReuseToListenConfig(lc *net.ListenConfig) {
|
|
addControlToListenConfig(lc, func(ctx context.Context, network, address string, c syscall.RawConn) error {
|
|
return c.Control(func(fd uintptr) {
|
|
windows.SetsockoptInt(windows.Handle(fd), windows.SOL_SOCKET, windows.SO_REUSEADDR, 1)
|
|
})
|
|
})
|
|
}
|