mirror of
https://github.com/xjasonlyu/tun2socks.git
synced 2025-10-07 09:41:09 +08:00
move utils
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
package proxy
|
||||
|
||||
import (
|
||||
"net"
|
||||
"time"
|
||||
)
|
||||
|
||||
type duplexConn interface {
|
||||
net.Conn
|
||||
CloseRead() error
|
||||
CloseWrite() error
|
||||
}
|
||||
|
||||
func TCPCloseRead(conn net.Conn) {
|
||||
if c, ok := conn.(duplexConn); ok {
|
||||
c.CloseRead()
|
||||
}
|
||||
}
|
||||
|
||||
func TCPCloseWrite(conn net.Conn) {
|
||||
if c, ok := conn.(duplexConn); ok {
|
||||
c.CloseWrite()
|
||||
}
|
||||
}
|
||||
|
||||
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