Skip to content

fix(http-routing): keep browser transports in provider records - #11394

Merged
lidel merged 4 commits into
masterfrom
fix/http-router-announce-all-transports
Jul 29, 2026
Merged

fix(http-routing): keep browser transports in provider records#11394
lidel merged 4 commits into
masterfrom
fix/http-router-announce-all-transports

Conversation

@lidel

@lidel lidel commented Jul 15, 2026

Copy link
Copy Markdown
Member

Problem

A publicly reachable node with AutoTLS or webrtc-direct enabled left those addresses out of the provider records it sent to delegated HTTP routers. The record carried only tcp, quic-v1, and webtransport, none of which a browser can dial, so browser and Helia clients that found the node through a router had no way to connect, even though ipfs id showed the addresses (#11369).

Two causes:

  • kubo narrowed the record to AutoNAT-confirmed addresses, which can never include the AutoTLS /tls/ws address (AutoNAT only sees listen addresses, and p2p-forge synthesizes that one later),
  • and go-libp2p drops webrtc-direct from the confirmed set on the way out

Fix

  • provider records now carry host.Addrs(), the same set identify and the DHT announce, narrowed to public addresses when the node has any
  • AppendAnnounce entries appear exactly once and cannot evict a LAN-only node's real addresses
  • go-libp2p pinned to the head of the upstream fix: fix(basichost): sort confirmed addrs libp2p/go-libp2p#3526

Closes #11369

TODO

lidel added 2 commits July 15, 2026 23:19
Pin the head commit of libp2p/go-libp2p#3526: AutoNAT V2's
ConfirmedAddrs returned unsorted buckets, and removeNotInSource
silently dropped webrtc-direct from the confirmed set. Switch to a
master pseudo-version once the PR merges.
Provider records sent to HTTP routers were narrowed to the addresses
AutoNAT V2 confirmed reachable, which silently dropped the only two
transports a browser can dial: the AutoTLS /tls/ws address and
webrtc-direct. A publicly reachable node was invisible to browser and
Helia clients that found it through a delegated router, even though
ipfs id and the DHT both advertised those addresses.

AutoNAT only ever sees listen addresses, so the AutoTLS address, which
the AddrsFactory synthesizes afterwards, can never reach the confirmed
set. webrtc-direct does get confirmed, but go-libp2p loses it again in
getConfirmedAddrs, which feeds an unsorted slice to a scan that assumes
sorted input; that one is fixed upstream in libp2p/go-libp2p#3526.

Announce host.Addrs() instead, the same set identify sends to peers and
the DHT already publishes, narrowed to globally routable addresses so
loopback and LAN entries stay out of a public index. Nodes with no
public address keep announcing what they have, so LAN-only setups
pointing at a local router are unaffected.

- core/node/libp2p/routingopt.go: drop the ConfirmedAddrs branch from
  httpRouterAddrFunc, filter host.Addrs() with manet.IsPublicAddr;
  AppendAnnounce is emitted exactly once and does not count toward
  the public-addr check
- core/commands/swarm_addrs_autonat.go: take over the BasicHost
  compile-time assertion, now the only ConfirmedAddrs consumer

Fixes #11369
@Rinse12

Rinse12 commented Jul 16, 2026

Copy link
Copy Markdown

Seems to announce perfectly now, thanks!

@lidel

lidel commented Jul 21, 2026

Copy link
Copy Markdown
Member Author

Cool, then we wait till libp2p/go-libp2p#3526 lands, update go-libp2p to release version (or at least master commit) then merge this.

@lidel
lidel marked this pull request as ready for review July 21, 2026 11:15
@lidel
lidel requested a review from a team as a code owner July 21, 2026 11:15
@lidel lidel added the status/blocked Unable to be worked further until needs are met label Jul 21, 2026
lidel added 2 commits July 29, 2026 15:53
Master ships go-libp2p v0.49.0, which contains the sorted-confirmed-addrs
fix this branch was pinning a pseudo-version for, so the pin and its TODO
are gone.

- go.mod/go.sum: take master's dependency set (go-libp2p v0.49.0,
  boxo v0.42.1, p2p-forge v0.10.0)
- changelog: move the delegated-router highlight into v0.44.md, the file
  master renamed vTBD.md to
The fix ships in v0.43, so the entry moves out of v0.44.md and in
next to the other browser-retrieval highlights.

- names the config it applies to: Routing.Type=custom with a provide
  method on an HTTP router. Default auto provides over the DHT alone
  and is unaffected, since constructDefaultHTTPRouters leaves
  ProvideRouter as a noop.
- cites bitsocial.net, which runs libp2p in the browser and uses
  delegated routers to find peers, as the app the gap broke
@lidel lidel mentioned this pull request Jul 29, 2026
52 tasks
@lidel

lidel commented Jul 29, 2026

Copy link
Copy Markdown
Member Author

go-libp2p shipped with fix, so i'll fold this into 0.43.0-rc2 (eta later this week)

@lidel
lidel merged commit 4b7a94f into master Jul 29, 2026
24 checks passed
@lidel
lidel deleted the fix/http-router-announce-all-transports branch July 29, 2026 14:17
lidel added a commit that referenced this pull request Jul 29, 2026
* chore: bump go-libp2p for sorted confirmed addrs

Pin the head commit of libp2p/go-libp2p#3526: AutoNAT V2's
ConfirmedAddrs returned unsorted buckets, and removeNotInSource
silently dropped webrtc-direct from the confirmed set. Switch to a
master pseudo-version once the PR merges.

* fix: keep browser transports in provider records

Provider records sent to HTTP routers were narrowed to the addresses
AutoNAT V2 confirmed reachable, which silently dropped the only two
transports a browser can dial: the AutoTLS /tls/ws address and
webrtc-direct. A publicly reachable node was invisible to browser and
Helia clients that found it through a delegated router, even though
ipfs id and the DHT both advertised those addresses.

AutoNAT only ever sees listen addresses, so the AutoTLS address, which
the AddrsFactory synthesizes afterwards, can never reach the confirmed
set. webrtc-direct does get confirmed, but go-libp2p loses it again in
getConfirmedAddrs, which feeds an unsorted slice to a scan that assumes
sorted input; that one is fixed upstream in libp2p/go-libp2p#3526.

Announce host.Addrs() instead, the same set identify sends to peers and
the DHT already publishes, narrowed to globally routable addresses so
loopback and LAN entries stay out of a public index. Nodes with no
public address keep announcing what they have, so LAN-only setups
pointing at a local router are unaffected.

- core/node/libp2p/routingopt.go: drop the ConfirmedAddrs branch from
  httpRouterAddrFunc, filter host.Addrs() with manet.IsPublicAddr;
  AppendAnnounce is emitted exactly once and does not count toward
  the public-addr check
- core/commands/swarm_addrs_autonat.go: take over the BasicHost
  compile-time assertion, now the only ConfirmedAddrs consumer

Fixes #11369

* docs: move highlight to v0.43 and scope it

The fix ships in v0.43, so the entry moves out of v0.44.md and in
next to the other browser-retrieval highlights.

- names the config it applies to: Routing.Type=custom with a provide
  method on an HTTP router. Default auto provides over the DHT alone
  and is unaffected, since constructDefaultHTTPRouters leaves
  ProvideRouter as a noop.
- cites bitsocial.net, which runs libp2p in the browser and uses
  delegated routers to find peers, as the app the gap broke

(cherry picked from commit 4b7a94f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status/blocked Unable to be worked further until needs are met

Projects

None yet

Development

Successfully merging this pull request may close these issues.

webrtc-direct and AutoTLS /tls/ws missing from provider records announced to delegated HTTP routers on AutoNAT-confirmed-public nodes

2 participants