freenet-core
freenet-core copied to clipboard
Transport layer fails to handle simultaneous reconnection attempts
Problem
When both peers detect a connection drop and attempt to reconnect simultaneously, they both send intro packets. The client in StartOutbound state expects a symmetric ACK response but receives an asymmetric intro packet from the gateway, causing decryption failures.
Current Behavior
- Both peers send intro packets with their inbound keys
- Client tries to decrypt the gateway's intro packet as symmetric (expecting ACK)
- Decryption fails
- Connection cannot be re-established
Expected Behavior
The protocol should handle the case where both sides simultaneously try to reconnect, perhaps by:
- Recognizing intro packets in the
StartOutboundstate - Implementing a tie-breaking mechanism based on peer IDs
- Or accepting the incoming intro packet and transitioning appropriately
Code Location
crates/core/src/transport/connection_handler.rs - traverse_nat() function, specifically the StartOutbound state handling around line 763.
Related Issue
This is a secondary issue discovered while investigating #1653 (keep-alive mechanism failures).