Commit graph

1 commit

Author SHA1 Message Date
torlando-tech
9a0a4963e8 fix: verify connection is still alive before rejecting duplicate identity
When a peer disconnects, identity_to_address is NOT cleaned up immediately -
it's only removed after a 2-second grace period. However, _check_duplicate_identity
was not checking if the existing address is still connected before rejecting.

This caused legitimate reconnections from the same identity (after MAC rotation
or reconnection) to be incorrectly rejected as "duplicates" during the grace
period or when cleanup was delayed.

The fix adds two checks before rejecting:
1. If pending_detach exists for this identity (old connection already gone)
2. If existing address is not in connected_peers or peers dict

Also adds TDD tests that demonstrate the bug and verify the fix.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 03:34:17 -05:00