Repository navigation
fix: close failed TCP dial results in proxy frontends - #36
Merged
Merged
Conversation
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused implementation is consistent across frontends and comprehensively covers failure and success paths.
Review effort: Balanced
Findings: None
What changed in this PR
Closes failed custom TCP dial results across proxy frontends while preserving original error classification and successful connection behavior.
Changes:
- Close non-nil connections returned with dial errors.
- Reject
(nil, nil)dial results. - Add ownership, reuse, half-close, and error-preservation tests and documentation.
| File | Description |
|---|---|
internal/proxy/socks5.go |
Handles invalid and failed SOCKS5 dial results safely. |
internal/proxy/http.go |
Handles failed HTTP upstream dial results safely. |
internal/proxy/tcp_dial_error_ownership_test.go |
Verifies cleanup ownership and original errors. |
internal/proxy/tcp_dial_result_preserve_test.go |
Verifies successful tunnel and reuse behavior. |
docs/DEPLOYMENT.md |
Documents failed-result ownership semantics. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Close a non-nil TCP connection returned alongside a custom Dialer's setup error, before discarding that failed result. Cover SOCKS5 CONNECT, HTTP CONNECT and ordinary HTTP forwarding.
(nil, nil)results before a success reply or invalid connection wrapper.Validation completed on
dae73c6a7e84e30a0b9b1c6e390d4536e4f4265emake checkandmake race: full repository, exit 0.1dd6fdf846682b560a64749cea014116c90961451c330275ffee73e88cdc6127.Exact-head GitHub verification completed on attempt 1:
Post-merge main verification
PR #36 is squash-merged as
a6c878ae2c4121155e1b2506c31a9a50343bd754. Local main, origin/main and the live remote main ref match; main tree03136e2b3ea04fc1985681867acc27f966188715matches the tested PR head exactly. Working tree is clean.The next independently reproduced ownership gap is on the custom destination Dialer; it is not fixed in this frontend patch. No new release/tag is published.
Evidence limits and fixture corrections
The triggering
(conn, error)combination was produced by a custom Dialer after a real successful TCP dial; no built-in transport was demonstrated to return that combination, and no indefinite descriptor leak is claimed.Two exploratory fixtures incorrectly expected SOCKS TTL-expired for DNS or generic Timeout errors. Those logs are retained. The final tests use a typed net.OpError wrapping the existing deadline sentinel, with no production mapping change.
An original diagnostic also encountered the existing HTTP duplicate-listener-close Shutdown return before its ownership oracle. The final fixture explicitly logs/accepts only closed-listener error leaves; a deadline or unrelated joined error still fails. This patch does not change Shutdown semantics. Independent endpoint cleanup and completion joins remain required.
This is source-build behavior, not included in v1.0.1. No dependency, release/tag, remote host or large capture campaign is changed; no traffic-equivalence or comparative-performance claim is made.