fix: add timeouts to handshake I/O operations (#11)#17
Open
Conversation
- Add timeout(60s) to read_framed in handle_incoming for reading HANDSHAKE_INIT - Add timeout(30s) to write_framed in handle_incoming for sending HANDSHAKE_ACK - Add timeout(30s) to write_framed in initiate_session for sending HANDSHAKE_INIT - Add timeout(60s) to read_framed in initiate_session for reading HANDSHAKE_ACK - Emit connection_error event with user-visible error message on handshake failures - All timeouts use Duration from tokio::time to prevent indefinite hangs on degraded I2P tunnels This fixes issue #11 where peer connections would hang indefinitely when I2P tunnels are degraded and handshake I/O operations have no timeouts.
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.
Fix: Add timeouts to handshake I/O operations
Closes #11
Problem
When I2P tunnels are degraded (frequent during bootstrapping or network instability), peer connection establishment hangs indefinitely because the handshake I/O operations (
read_framed/write_framed) have no timeouts.The I2P streaming layer accepts the inbound connection, but the application-level handshake never completes because data can't flow through broken tunnels — and nothing ever times out to report the failure.
Solution
Added timeouts to all handshake I/O operations:
In
handle_incoming(responder side):In
initiate_session(initiator side):Emit user-visible errors:
connection_errorevent with a descriptive messageSecurity considerations
Implementation details
tokio::time::timeoutwith appropriateDurationvalues