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

PDC: add operation canceled error handler to socks proxy dialer #1056

Merged
merged 1 commit into from
Aug 22, 2024
Merged
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
8 changes: 5 additions & 3 deletions backend/proxy/secure_socks_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,12 +312,12 @@ func (d *instrumentedSocksDialer) DialContext(ctx context.Context, n, addr strin
c, err := dialer.DialContext(ctx, n, addr)

var code string
var oppErr *net.OpError
var opErr *net.OpError

switch {
case err == nil:
code = "0"
case errors.As(err, &oppErr):
case errors.As(err, &opErr):
unknownCode := socksUnknownError.FindStringSubmatch(err.Error())

// Socks errors defined here: https://cs.opensource.google/go/x/net/+/refs/tags/v0.15.0:internal/socks/socks.go;l=40-63
Expand All @@ -344,12 +344,14 @@ func (d *instrumentedSocksDialer) DialContext(ctx context.Context, n, addr strin
code = "io_timeout_error"
case strings.HasSuffix(err.Error(), "context canceled"):
code = "context_canceled_error"
case strings.HasSuffix(err.Error(), "operation was canceled"):
code = "context_canceled_error"
case len(unknownCode) > 1:
code = unknownCode[1]
default:
code = "socks_unknown_error"
}
log.DefaultLogger.Error("received oppErr from dialer", "network", n, "addr", addr, "oppErr", oppErr, "code", code)
log.DefaultLogger.Error("received opErr from dialer", "network", n, "addr", addr, "opErr", opErr, "code", code)
default:
log.DefaultLogger.Error("received err from dialer", "network", n, "addr", addr, "err", err)
code = "dial_error"
Expand Down