test: expand coverage (graceful shutdown, pure fns, SOCKS5 TCP) + client auto-reconnect#28
Merged
Merged
Conversation
Adds graceful-shutdown coverage across the cancellation chain, fills pure-function test gaps, exercises the SOCKS5 TCP/auth path end-to-end, and implements a configurable client auto-reconnect for the TUIC outbound with tests. Graceful shutdown: - Unit tests for the server-core `acceptor_loop` cancellation primitive plus `is_tuic_prefix`/`read_prefix` (wind-tuic server core). - Integration tests that the TUIC inbound listen loop and per-connection tasks drain on cancel; same for the SOCKS5 inbound accept loop and the tuic-client TCP/UDP forwarders. Pure-function coverage: - wind-core `is_private_ip`, `StackPrefer::from_str`, `pick_addr_by_preference`, `filter_addrs_by_preference`. - wind-socks `parse_udp_request_sync`, `unmap_v4_mapped`, `target_addr_to_socket`, `convert_addr`/`convert_to_socks_addr` round-trips. - wind-base `resolve_target` (IP-literal bypass + domain via resolver). SOCKS5 TCP end-to-end (dependency-free client): no-auth + password auth (right/wrong), IPv4 and domain CONNECT with echo round-trip, unsupported-command. Client reconnect (new feature): - TuicOutbound now holds the connection in an `ArcSwap`; a supervisor task runs one session until the connection drops, then reconnects with exponential backoff and swaps the fresh connection in. Shutdown is honored even mid- handshake. In-flight streams are not resurrected (callers retry). - Reconnect is configurable via `ReconnectConfig` (enabled + backoff bounds), wired from the client `Relay` config with serde defaults (backward compatible). - Tests: pure `next_backoff`, reconnect-after-restart, shutdown-while-reconnecting, reconnect-disabled, and config parsing/defaults. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
'CONNECTed' tokenizes as 'CONNEC'+'Ted'; the typos CI flagged 'CONNEC'. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Overview
Expands test coverage across the workspace and adds a new configurable client auto-reconnect feature for the TUIC outbound (with tests). No production behavior changes other than the reconnect feature, which is on by default and backward-compatible.
What changed
Graceful shutdown
acceptor_loopcancellation primitive (cancel mid-accept, pre-cancelled, benign close, timed-out, fatal error) plusis_tuic_prefix/read_prefix.listenloop + per-connection tasks drain on cancel (idle and with a live connection).Pure-function coverage (filling gaps)
is_private_ip,StackPrefer::from_str,pick_addr_by_preference,filter_addrs_by_preference.parse_udp_request_sync(all ATYPs + malformed headers),unmap_v4_mapped,target_addr_to_socket,convert_addr/convert_to_socks_addrround-trips.resolve_target— IP-literal bypass and domain-via-resolver.SOCKS5 TCP end-to-end
Dependency-free hand-rolled SOCKS5 client: no-auth and RFC 1929 password auth (correct/incorrect), IPv4 and domain CONNECT with echo round-trip, and the unsupported-command path.
Client auto-reconnect (new feature)
TuicOutboundnow stores its connection in anArcSwap. A supervisor task runs one session (heartbeat + incoming handling) until the connection drops, then reconnects with exponential backoff and swaps the fresh connection in —handle_tcp/handle_udptransparently use the new connection. Connection loss is detected promptly viaconn.closed().ReconnectConfig { enabled, initial_backoff, max_backoff }, wired from the clientRelayconfig (reconnect,reconnect_initial_backoff,reconnect_max_backoff) with serde defaults — existing configs keep working unchanged.next_backoff, reconnect-after-server-restart, shutdown-while-reconnecting, reconnect-disabled, and config parsing/defaults.Reviewer notes
Relayuses#[serde(default)]with per-field educe defaults, so the three new fields are backward-compatible; oneRelayliteral intuic-teststhat didn't use..Default::default()was updated.cargo build --workspace,cargo +nightly fmt --check, andcargo clippy --testsare clean (no new warnings). Test suites green, including the tuic-tests end-to-end integration suite (full client+server) and 5× stable reruns of the timing-sensitive reconnect test.🤖 Generated with Claude Code