Skip to content

ensemble/iroh: humds peer across the internet through the n0 relay mesh - #107

Merged
adiled merged 2 commits into
mainfrom
iroh-relay-internet-p2p
Nov 12, 2026
Merged

adiled merged 2 commits into
mainfrom
iroh-relay-internet-p2p

Conversation

@adiled

@adiled adiled commented Nov 8, 2026 •

Copy link
Copy Markdown
Owner

Lets humds on separate networks, each behind its own NAT, find and reach each other through the public n0 relay mesh. No port forwarding needed.

Why turning the relay on wasn't enough. The first commit switched RelayMode::Disabled to Default, which lets a humd hold a home relay. But the dial path built its address from iroh-ip: hints only, and the Minimal preset has no address lookup. So a dialer still sent to the peer's private IP, and the dial hung there. Attaching the dialer's own relay doesn't fix it either: n0 runs separate relays per region (use1, usw1, euc1, aps1), and a relay only forwards to endpoints connected to it.

What this does

  • humd binds with iroh's presets::N0: the relay mesh plus n0's DNS address lookup (pkarr, relay URL only, no IPs published). An iroh:<node> hint alone is enough to dial a humd anywhere, and stale addresses recover through the lookup.
  • humd advertises iroh-relay:<url> alongside its iroh-ip: hints once a home relay answers, waiting at most 5s at boot. The dial path parses that hint, so the DNS lookup is skipped.
  • iroh dials every known path at once and hole-punches to a direct path when the NATs allow it. The relay is the fallback, not the steady state.
  • bind_direct() is direct-only again, so the hermetic tests stay off the network. The keyed binds humd uses are renamed bind_direct_with_key{,_on} → bind_with_key{,_on}.
  • The hint parsing is now its own function, endpoint_addr_from_hints, with unit tests.

Proof
ensemble/tests/iroh_relay.rs (#[ignore]d so CI doesn't depend on n0): two humds exchange a tone with an unroutable iroh-ip: standing in for the NAT. One reaches the other through its advertised relay, the other by node id through DNS. Both pass against the live mesh. As a negative control, the DNS case run against the first commit's endpoint config hangs on all 4 dial attempts.

cargo test -p ensemble --test iroh_relay -- --ignored --nocapture

The ensemble README still says the daemon is direct-only and the relay is unproven. That doc update is left for a follow-up.

@adiled
adiled force-pushed the iroh-relay-internet-p2p branch from aaeef0e to 6ab2e66 Compare November 8, 2026 18:33
… own relay

Turning the relay on was half of it. The dial built its address from
`iroh-ip:` hints alone, with no address lookup behind it, so a humd
behind NAT was dialled at a private IP that never answers. Attaching
the dialer's own home relay would not have helped: n0 runs separate
relays per region, and a relay only forwards to endpoints connected
to it.

- humd binds with iroh's n0 preset: the relay mesh plus n0's DNS
  address lookup. Each humd publishes its home relay under its node
  id, so an `iroh:<node>` hint alone is enough to dial it, and a
  stale IP or relay heals by lookup.
- humd advertises `iroh-relay:<url>` beside its `iroh-ip:` hints once
  a home relay answers (bounded at 5s), and the dial path reads it,
  which skips the lookup.
- `bind_direct()` is direct-only again, so the hermetic tests stay
  off the network. The keyed binds that are no longer direct are
  renamed `bind_with_key{,_on}`.
- ensemble/tests/iroh_relay.rs proves both paths against the live n0
  mesh, each with an unroutable IP hint in the NAT's place. They are
  `#[ignore]`d so CI never depends on n0. The DNS case fails on the
  original relay-only change and passes on this one.
@adiled adiled changed the title Enable iroh relay for internet P2P ensemble/iroh: humds peer across the internet through the n0 relay mesh Nov 9, 2026
@adiled
adiled merged commit 95caf9e into main Nov 12, 2026
7 checks passed
@adiled
adiled deleted the iroh-relay-internet-p2p branch November 12, 2026 14:53
adiled added a commit that referenced this pull request Nov 12, 2026
…109)

Brings the READMEs, THRUM.md and the man page in line with #107 (relay peering) and #108 (orchd 0.5, groves, orch beside orchd, iroh-relay: hints).
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