← Back to Pull requests

router, sdk/js: a browser reaches a router by IP over WebTransport #920

Closed
unknown closed this pull request without merging on Nov 20, 2026 16:17 UTC
View on GitHub
unknown unknown commented on Nov 19, 2026 20:53 UTC
Author

A browser can now join the testnets. A page reaches a router only over WebSocket or WebTransport, and the testnet routers offered neither: they listen on TCP and QUIC and lease only their --external-addr /dnsaddr, whose TXT records hold TCP and QUIC addresses. wss would need a hostname and a CA certificate per router.

WebTransport needs neither. The browser checks the router's self-signed certificate against the certhash in the router's address, so it dials the router by IP.

What changes

  • Router. With --external-addr, the router also leases a /webtransport address for each of its external QUIC addresses. It appends the /webtransport/certhash/… end of its own WebTransport listen address to the QUIC address. The certhash changes with the certificate about every two weeks, so no operator can configure the address. The relay circuit addresses the router hands to members follow the lease, so they carry this address too.

  • Router. An external QUIC address is one given in --external-addr, by IP or by name, or one found under the router's peer ID in a /dnsaddr --external-addr. The router looks up the /dnsaddr before each lease, with a 5-second limit. A failed lookup keeps the last result, so a DNS outage does not withdraw a leased address.

  • Testnet routers listen on /udp/4501/quic-v1/webtransport. It shares the QUIC socket, so no new port or firewall rule is needed.

  • JS SDK. The browser build dials WebTransport beside WebSocket (@libp2p/webtransport).

  • Docs. The router flag reference and the SDK browser guide.
  • Nothing changes for a router that does not listen on WebTransport: it makes no DNS lookup and leases the same addresses as before. The router's default --listen is TCP only. A router without --external-addr leases all its host addresses as before, and those include its WebTransport listen addresses.

    Testing

  • TestRouterLeasesWebTransportForItsExternalQUICAddrs checks the leased WebTransport addresses for an external QUIC address by public IP, by private IP and by name, for the router's own entry in a /dnsaddr, and for the same address given twice. It also checks that the router leases none for a /dnsaddr without a record, for TCP-only addresses, for an IPv6 address with an IPv4 listener, and without a WebTransport listener. TestRouterCircuitAddrsFollowTheExternalAddrs checks that the circuit addresses carry the WebTransport address.

  • A local run with a control plane (agentmesh-one) and one agentmesh-router that listens on QUIC and WebTransport on one UDP port, with --external-addr /ip4/<LAN IP>/udp/<port>/quic-v1 and no other member. The router log and /info listed /ip4/<LAN IP>/udp/<port>/quic-v1/webtransport/certhash/…. A headless Chromium 158 page running the JS SDK browser example joined, held an open WebTransport connection to that router and passed the mesh handshake.

  • Not run on a testnet. The /dnsaddr path is covered by the unit test with a mock resolver only. The JS transport change has no automated test.
  • Notes

  • The router does not lease an address that peers report. go-libp2p can infer a public WebTransport address from identify observations, but only while 4 peers on distinct IPs hold QUIC connections to the router. A mesh of browsers and TCP-only members would never get the address, and identify runs before /mesh/auth, so unauthenticated peers would count as observers.

  • A lease stays valid across a certificate rotation. go-libp2p puts the certhash of the next certificate in the address before it switches to that certificate, and the router renews its lease every --control-plane-sync-interval.

  • A new testnet router gets its WebTransport address at the first lease after the DNS sync job has published its /dnsaddr record.

  • The router assumes that an external QUIC address maps to the QUIC listener that shares its socket with the WebTransport listener.

  • @libp2p/webtransport depends on @libp2p/noise, the same project as @chainsafe/libp2p-noise under its new name, so the browser bundle carries both.

  • A page with a Content Security Policy needs https: in connect-src: WebTransport dials https://<ip>:<port>.
  • Diff: 525 lines (+393 / -132) across 6 files Reviewer: aojea Review duration: 1163m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.48) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 525 lines diff across 6 files
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.375
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #920"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 47.8% (MEDIUM) · Higher = larger blast radius
    47.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 18.9% · Safe to merge
    18.9%