From 6aab7516104269893aa1cad77c5e1dcc95ff2ff3 Mon Sep 17 00:00:00 2001 From: lqqyt2423 <974923609@qq.com> Date: Wed, 6 Jul 2022 23:04:11 +0800 Subject: [PATCH] try fix tcp not closed --- proxy/addon.go | 4 ++-- proxy/connection.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/proxy/addon.go b/proxy/addon.go index 7ed029d..84232a6 100644 --- a/proxy/addon.go +++ b/proxy/addon.go @@ -77,11 +77,11 @@ func (addon *LogAddon) ClientDisconnected(client *ClientConn) { } func (addon *LogAddon) ServerConnected(connCtx *ConnContext) { - log.Infof("%v server connect %v (%v)\n", connCtx.ClientConn.Conn.RemoteAddr(), connCtx.ServerConn.Address, connCtx.ServerConn.Conn.RemoteAddr()) + log.Infof("%v server connect %v (%v->%v)\n", connCtx.ClientConn.Conn.RemoteAddr(), connCtx.ServerConn.Address, connCtx.ServerConn.Conn.LocalAddr(), connCtx.ServerConn.Conn.RemoteAddr()) } func (addon *LogAddon) ServerDisconnected(connCtx *ConnContext) { - log.Infof("%v server disconnect %v (%v)\n", connCtx.ClientConn.Conn.RemoteAddr(), connCtx.ServerConn.Address, connCtx.ServerConn.Conn.RemoteAddr()) + log.Infof("%v server disconnect %v (%v->%v)\n", connCtx.ClientConn.Conn.RemoteAddr(), connCtx.ServerConn.Address, connCtx.ServerConn.Conn.LocalAddr(), connCtx.ServerConn.Conn.RemoteAddr()) } func (addon *LogAddon) Requestheaders(f *Flow) { diff --git a/proxy/connection.go b/proxy/connection.go index b433b8f..e808f75 100644 --- a/proxy/connection.go +++ b/proxy/connection.go @@ -235,7 +235,7 @@ func (c *wrapClientConn) Close() error { if c.closed { return c.closeErr } - log.Debugln("in wrapClientConn close") + log.Debugln("in wrapClientConn close", c.connCtx.ClientConn.Conn.RemoteAddr()) c.closed = true c.closeErr = c.Conn.Close() @@ -245,7 +245,7 @@ func (c *wrapClientConn) Close() error { } if c.connCtx.ServerConn != nil && c.connCtx.ServerConn.Conn != nil { - c.connCtx.ServerConn.Conn.(*wrapServerConn).Conn.(*net.TCPConn).CloseRead() + c.connCtx.ServerConn.Conn.Close() } return c.closeErr @@ -282,7 +282,7 @@ func (c *wrapServerConn) Close() error { if c.closed { return c.closeErr } - log.Debugln("in wrapServerConn close") + log.Debugln("in wrapServerConn close", c.connCtx.ClientConn.Conn.RemoteAddr()) c.closed = true c.closeErr = c.Conn.Close()