fix(ssh): add timeouts to SSH/WebSocket connections and per-channel state#219
Open
fix(ssh): add timeouts to SSH/WebSocket connections and per-channel state#219
Conversation
…tate Add timeout handling across the SSH connection stack to prevent indefinite hangs during connection establishment: - Add SSH_PROXY_ACCEPT_TIMEOUT (5s) and SSH_PROXY_CONNECT_TIMEOUT (10s) - Add UPSTREAM_HANDSHAKE_TIMEOUT (10s) for WebSocket upstream connections - Extract establish_upstream for cleaner connection setup - Refactor SshHandler to maintain per-channel state instead of global state, properly isolating pty_master, input_sender, and pty_request per ChannelId This prevents clients from hanging indefinitely when connection establishment fails or times out.
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
SSH_PROXY_ACCEPT_TIMEOUT(5s) andSSH_PROXY_CONNECT_TIMEOUT(10s) for SSH proxy operationsUPSTREAM_HANDSHAKE_TIMEOUT(10s) for WebSocket upstream connectionsSshHandlerto maintain per-channel state (HashMap<ChannelId, ChannelState>) instead of global state, properly isolatingpty_master,input_sender, andpty_requestper channelChanges
start_single_use_ssh_proxyfor accept and connect operationsestablish_upstreamfunction, addTunnelSetupErrorfor cleaner error handling with proper HTTP status codes (504 for timeouts, 502 for other errors)Testing
All SSH-related tests pass, including new tests for:
channel_data_routes_only_to_matching_channelchannel_eof_only_closes_matching_channel_inputcleanup_channel_removes_only_matching_stateestablish_upstream_times_out_waiting_for_handshake_responseestablish_upstream_rejects_non_ok_handshake_response