diff --git a/proxy/http.go b/proxy/http.go index 7e7668d7..b0dec31d 100644 --- a/proxy/http.go +++ b/proxy/http.go @@ -41,7 +41,9 @@ func (h *HTTP) DialContext(ctx context.Context, metadata *M.Metadata) (c net.Con } setKeepAlive(c) - defer safeConnClose(c, err) + defer func(c net.Conn) { + safeConnClose(c, err) + }(c) err = h.shakeHand(metadata, c) return diff --git a/proxy/shadowsocks.go b/proxy/shadowsocks.go index 4db7d88d..a64b2769 100644 --- a/proxy/shadowsocks.go +++ b/proxy/shadowsocks.go @@ -49,7 +49,9 @@ func (ss *Shadowsocks) DialContext(ctx context.Context, metadata *M.Metadata) (c } setKeepAlive(c) - defer safeConnClose(c, err) + defer func(c net.Conn) { + safeConnClose(c, err) + }(c) switch ss.obfsMode { case "tls": diff --git a/proxy/socks4.go b/proxy/socks4.go index 52c3ce5b..d8501172 100644 --- a/proxy/socks4.go +++ b/proxy/socks4.go @@ -36,7 +36,9 @@ func (ss *Socks4) DialContext(ctx context.Context, metadata *M.Metadata) (c net. } setKeepAlive(c) - defer safeConnClose(c, err) + defer func(c net.Conn) { + safeConnClose(c, err) + }(c) err = socks4.ClientHandshake(c, metadata.DestinationAddress(), socks4.CmdConnect, ss.userID) return diff --git a/proxy/socks5.go b/proxy/socks5.go index 64bf596e..bdc9b04c 100644 --- a/proxy/socks5.go +++ b/proxy/socks5.go @@ -49,7 +49,9 @@ func (ss *Socks5) DialContext(ctx context.Context, metadata *M.Metadata) (c net. } setKeepAlive(c) - defer safeConnClose(c, err) + defer func(c net.Conn) { + safeConnClose(c, err) + }(c) var user *socks5.User if ss.user != "" {