freenet-core icon indicating copy to clipboard operation
freenet-core copied to clipboard

Transport layer fails to handle simultaneous reconnection attempts

Open sanity opened this issue 5 months ago • 0 comments

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

  1. Both peers send intro packets with their inbound keys
  2. Client tries to decrypt the gateway's intro packet as symmetric (expecting ACK)
  3. Decryption fails
  4. 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 StartOutbound state
  • 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).

sanity avatar Jun 15 '25 18:06 sanity