Skip to content

fix(basichost): sort confirmed addrs#3526

Open
lidel wants to merge 1 commit into
masterfrom
fix/autonatv2-sorted-confirmed-addrs
Open

fix(basichost): sort confirmed addrs#3526
lidel wants to merge 1 commit into
masterfrom
fix/autonatv2-sorted-confirmed-addrs

Conversation

@lidel

@lidel lidel commented Jul 15, 2026

Copy link
Copy Markdown
Member

Problem

AutoNAT v2 keeps a list of the node's addresses that are confirmed reachable from the internet. The list is built in two parts: primary transports (tcp, quic-v1) first, then secondary ones (webrtc-direct, websocket, webtransport). Each part is sorted, but the combined list is not.

The consumer of that list, removeNotInSource, assumes fully sorted input and silently drops entries when it is not. webrtc-direct is the common victim: on a shared UDP port its address sorts before quic-v1, so it lands out of order and gets dropped. ConfirmedAddrs() then says the node is not reachable over webrtc-direct even though AutoNAT just confirmed it was, undoing the inheritance from #3435. Kubo announces confirmed addresses to HTTP routers, so browsers never saw the webrtc-direct address (ipfs/kubo#11369) 🙈

Fix

  • sort the list before returning it from the probe manager
  • experience existential dread
  • add regression tests at two levels; both fail without the fix

probeManager.AppendConfirmedAddrs emits primary addrs followed by
secondary addrs. Each half is sorted, the concatenation is not, and
both consumers require input sorted by Multiaddr.Compare:
addrsManager.getConfirmedAddrs feeds the buckets to removeNotInSource,
and Addrs() subtracts the unreachable bucket via removeInSource.

Unsorted input makes removeNotInSource silently drop confirmed addrs:
a webrtc-direct secondary sorts before its quic-v1 primary and gets
nil'd, so ConfirmedAddrs() under-reports secondary transports even
though the tracker confirmed them, defeating the reachability
inheritance added in #3435. removeInSource fails the other way and
retains confirmed-unreachable addrs in Addrs().

Sort the three buckets before returning them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant