Initial commit (code only without large binaries)

This commit is contained in:
robin
2026-02-15 18:58:44 +08:00
commit 35df75498f
9442 changed files with 1495866 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
//go:build !freebsd && !windows
// +build !freebsd,!windows
package utils
import (
"context"
"github.com/iwind/TeaGo/logs"
"net"
"syscall"
)
// ListenReuseAddr 监听可重用的端口
func ListenReuseAddr(network string, addr string) (net.Listener, error) {
config := &net.ListenConfig{
Control: func(network, address string, c syscall.RawConn) error {
return c.Control(func(fd uintptr) {
err := syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, 15, 1) // 15 = SO_REUSEPORT on Linux
if err != nil {
logs.Println("[LISTEN]" + err.Error())
}
})
},
KeepAlive: 0,
}
return config.Listen(context.Background(), network, addr)
}