1
0
mirror of https://github.com/MetaCubeX/mihomo.git synced 2025-09-20 20:45:58 +08:00

chore: listening tcp together for dns server (#1792)

This commit is contained in:
wwqgtxx
2025-01-16 10:16:37 +08:00
parent c7661d7765
commit c99c71a969
15 changed files with 140 additions and 102 deletions

View File

@ -0,0 +1,22 @@
//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris
package sockopt
import (
"golang.org/x/sys/unix"
)
func reuseControl(fd uintptr) error {
e1 := unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_REUSEADDR, 1)
e2 := unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_REUSEPORT, 1)
if e1 != nil {
return e1
}
if e2 != nil {
return e2
}
return nil
}