mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-12-06 01:00:25 +08:00
反向代理实现AutoFlush/修复配置自动加载问题
This commit is contained in:
24
internal/utils/net.go
Normal file
24
internal/utils/net.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/iwind/TeaGo/logs"
|
||||
"net"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// 监听可重用的端口
|
||||
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, SO_REUSEPORT, 1)
|
||||
if err != nil {
|
||||
logs.Println("[LISTEN]" + err.Error())
|
||||
}
|
||||
})
|
||||
},
|
||||
KeepAlive: 0,
|
||||
}
|
||||
return config.Listen(context.Background(), network, addr)
|
||||
}
|
||||
Reference in New Issue
Block a user