mirror of
https://github.com/xjasonlyu/tun2socks.git
synced 2025-10-08 02:00:43 +08:00
add utils.go to socks
This commit is contained in:
28
proxy/socks/utils.go
Normal file
28
proxy/socks/utils.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package socks
|
||||
|
||||
import (
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"github.com/xjasonlyu/tun2socks/common/log"
|
||||
)
|
||||
|
||||
type duplexConn interface {
|
||||
net.Conn
|
||||
CloseRead() error
|
||||
CloseWrite() error
|
||||
}
|
||||
|
||||
func tcpCloseRead(conn net.Conn) {
|
||||
if c, ok := conn.(duplexConn); ok {
|
||||
log.Warnf("ok!----")
|
||||
c.CloseRead()
|
||||
}
|
||||
}
|
||||
|
||||
func tcpKeepAlive(conn net.Conn) {
|
||||
if tcp, ok := conn.(*net.TCPConn); ok {
|
||||
tcp.SetKeepAlive(true)
|
||||
tcp.SetKeepAlivePeriod(30 * time.Second)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user