From a0c52c0d37415ee5002441a0f1ad3cd62864e585 Mon Sep 17 00:00:00 2001 From: Jason Date: Sun, 11 Aug 2019 15:07:59 +0800 Subject: [PATCH] debug only --- common/stats/stats.go | 8 ++++++++ proxy/socks/tcp.go | 1 + 2 files changed, 9 insertions(+) diff --git a/common/stats/stats.go b/common/stats/stats.go index 5e5b8a4..33d2439 100644 --- a/common/stats/stats.go +++ b/common/stats/stats.go @@ -4,6 +4,8 @@ import ( "net" "sync/atomic" "time" + + "github.com/xjasonlyu/tun2socks/common/log" ) type SessionStater interface { @@ -26,6 +28,7 @@ type Session struct { SessionClose time.Time } +// Track SessionConn type SessionConn struct { net.Conn *Session @@ -55,12 +58,15 @@ func (c *SessionConn) Write(b []byte) (n int, err error) { } func (c *SessionConn) Close() error { + log.Warnf("sessionConn close") if c.SessionClose.IsZero() { + log.Warnf("set close time") c.SessionClose = time.Now() } return c.Conn.Close() } +// Track SessionPacketConn type SessionPacketConn struct { net.PacketConn *Session @@ -90,7 +96,9 @@ func (c *SessionPacketConn) WriteTo(b []byte, addr net.Addr) (n int, err error) } func (c *SessionPacketConn) Close() error { + log.Warnf("sessionConn close") if c.SessionClose.IsZero() { + log.Warnf("set close time") c.SessionClose = time.Now() } return c.PacketConn.Close() diff --git a/proxy/socks/tcp.go b/proxy/socks/tcp.go index bbcb0d5..c759d9b 100644 --- a/proxy/socks/tcp.go +++ b/proxy/socks/tcp.go @@ -40,6 +40,7 @@ func (h *tcpHandler) relay(localConn, remoteConn net.Conn) { // Close defer func() { + log.Warnf("relay close") localConn.Close() remoteConn.Close() }()