Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: defer func for safeConnClose #309

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion proxy/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion proxy/shadowsocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
4 changes: 3 additions & 1 deletion proxy/socks4.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion proxy/socks5.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 != "" {
Expand Down
Loading