Fix: defer func for safeConnClose (#309)

This commit is contained in:
Jason Lyu
2023-10-24 09:13:36 +08:00
committed by GitHub
parent 2283f82bbc
commit 47913b549f
4 changed files with 12 additions and 4 deletions

View File

@@ -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