mirror of
https://github.com/xjasonlyu/tun2socks.git
synced 2025-10-10 11:10:17 +08:00
update tcp.go
This commit is contained in:
@@ -52,13 +52,15 @@ func (h *tcpHandler) relay(localConn, remoteConn net.Conn) {
|
||||
// Up Link
|
||||
go func() {
|
||||
io.Copy(remoteConn, localConn)
|
||||
//closeOnce()
|
||||
tcpCloseRead(localConn)
|
||||
tcpCloseWrite(remoteConn)
|
||||
wg.Done()
|
||||
}()
|
||||
|
||||
// Down Link
|
||||
io.Copy(localConn, remoteConn)
|
||||
tcpCloseRead(localConn)
|
||||
tcpCloseRead(remoteConn)
|
||||
tcpCloseWrite(localConn)
|
||||
|
||||
wg.Wait() // Wait for Up Link done
|
||||
|
||||
|
@@ -20,6 +20,13 @@ func tcpCloseRead(conn net.Conn) {
|
||||
}
|
||||
}
|
||||
|
||||
func tcpCloseWrite(conn net.Conn) {
|
||||
if c, ok := conn.(duplexConn); ok {
|
||||
log.Warnf("ok!++++")
|
||||
c.CloseWrite()
|
||||
}
|
||||
}
|
||||
|
||||
func tcpKeepAlive(conn net.Conn) {
|
||||
if tcp, ok := conn.(*net.TCPConn); ok {
|
||||
tcp.SetKeepAlive(true)
|
||||
|
Reference in New Issue
Block a user