Repository navigation
feat(nfxd): --mesh-public, the mesh endpoint's public address behind a DNAT (#71) - #86
SovereignTechnology wants to merge 7 commits into
Conversation
…a DNAT (#71) A seeder in a VM behind a DNAT gets no useful mesh candidate: STUN cannot report its public address when the STUN server is its own (that would take a UDP hairpin), and a guest has no gateway to map a port. So it offered only its private address, and browsers could not reach it. --mesh-public <ip:port> names the DNAT's public address, as --bridge-public does for the ICE-lite bridge: - It needs --mesh-relay, and --mesh-bind with a fixed port (the one the DNAT forwards to). It must be a public unicast address (node::is_public, fail-closed) of --mesh-bind's family. - It is the first host candidate. Every datagram on the bound socket is presented to str0m as sent to it (Receive.destination), so checks addressed to the public address are accepted. - With it set, no candidate whose address is not public is offered, as --iroh-external filters iroh's: not the bound address behind the DNAT, nor a private STUN or gateway mapping. A public bound address is kept. - --mesh-stun stays optional: both candidates are kept, and a srflx equal to the public address is offered once. Server-reflexive candidates take the public address as their base, so str0m's foundation hash never derives from the private one. - nfxd prints "mesh public: udp <ip:port>" at start, and the status line's candidates begin with it. The library takes it as MeshConfig::public (dialable, the bind's family, a valid str0m host candidate), with Mesh::public_addr(). Tests: - the candidate set and the SDPs with and without it; - a simulated DNAT punch, and its control; - a loopback integration test where a str0m browser reaches the endpoint only through a DNAT in the test and fetches segment 0 (sha256 checked), in both glare directions; - the library's and nfxd's refusals, flag parsing, and a daemon offering exactly the public candidate. README and usage text, plus a one-sentence non-normative note in NFX-10 §6. Nothing changes on the wire. Cargo.lock and the money crates are untouched.
|
Adds an opt-in Risks:
Looks fine to merge |
RUSTSEC-2026-0486 (published 2026-11-16) marks rustix 1.1.5 unsound: its xattr functions mark unwritten bytes initialized when given a zero-length buffer. nfx reaches rustix through iroh-blobs > reflink-copy and never calls the xattr functions, but cargo deny fails every CI check on the advisory. Fixed in 1.1.6. crates/desktop/Cargo.lock also gains cipher 0.5.2 and inout 0.2.6: nfx-proto has needed them since #75 (chacha20 0.10 for NIP-44), and the desktop workspace's lock had not been refreshed. No manifest changes; the money crates' locked closure (crates/ci/locked-compiled.txt) has no rustix and is unchanged.
…c so check can pass
|
CI diagnosis — run 43788310088
|
|
CI diagnosis for run 43793965522
Both logs report: The remaining additions are the Smallest fix: revert the unrelated |
|
CI diagnosis — run 43793960624
Both logs report (long package lines abbreviated): The remaining additions are eight Smallest fix: Keep the |
…2), so the money crates' closure is unchanged cargo update -p rustix --precise 1.1.6 had moved rustix's windows-sys to 0.52.0, which brought windows-sys 0.52 and windows-targets 0.52.6 into what the money crates are built from, and the lock job refused it. Both locks are validated with cargo metadata --locked --offline.
…sktop lock's missing cipher/inout) 093f469 still left errno 0.3.14, rustls-platform-verifier 0.7.0 and winapi-util 0.1.11 on windows-sys 0.52.0 (moved by the same cargo update), so the money crates' closure still differed. Now crates/Cargo.lock differs from main in rustix's version and checksum only, and crates/desktop/Cargo.lock adds cipher 0.5.2 and inout 0.2.6 and the same rustix bump, with no windows-sys line changed. Both validated with cargo metadata --locked --offline.
…anged) into nfxd/mesh-public
|
CI diagnosis — run 43799892042
Both logs report (long package fields abbreviated): The remaining additions are the eight Smallest fix: Keep |
…a DNAT (#71) (#86) A seeder in a VM behind a DNAT gets no useful mesh candidate: STUN cannot report its public address when the STUN server is its own (that would take a UDP hairpin), and a guest has no gateway to map a port. So it offered only its private address, and browsers could not reach it. --mesh-public <ip:port> names the DNAT's public address, as --bridge-public does for the ICE-lite bridge: - It needs --mesh-relay, and --mesh-bind with a fixed port (the one the DNAT forwards to). It must be a public unicast address (node::is_public, fail-closed) of --mesh-bind's family. - It is the first host candidate. Every datagram on the bound socket is presented to str0m as sent to it (Receive.destination), so checks addressed to the public address are accepted. - With it set, no candidate whose address is not public is offered, as --iroh-external filters iroh's: not the bound address behind the DNAT, nor a private STUN or gateway mapping. A public bound address is kept. - --mesh-stun stays optional: both candidates are kept, and a srflx equal to the public address is offered once. Server-reflexive candidates take the public address as their base, so str0m's foundation hash never derives from the private one. - nfxd prints "mesh public: udp <ip:port>" at start, and the status line's candidates begin with it. The library takes it as MeshConfig::public (dialable, the bind's family, a valid str0m host candidate), with Mesh::public_addr(). Tests: - the candidate set and the SDPs with and without it; - a simulated DNAT punch, and its control; - a loopback integration test where a str0m browser reaches the endpoint only through a DNAT in the test and fetches segment 0 (sha256 checked), in both glare directions; - the library's and nfxd's refusals, flag parsing, and a daemon offering exactly the public candidate. README and usage text, plus a one-sentence non-normative note in NFX-10 §6. Nothing changes on the wire. Cargo.lock and the money crates are untouched.
|
Squash-merged as 2df9bc4 |
Part of #71.
Why
nfxd's mesh endpoint (#82) is a full-ICE str0m peer signaled over Nostr (NFX-10 §6). Its candidates are its host address, server-reflexive mappings from
--mesh-stun, and a gateway port mapping. A seeder in a VM behind a DNAT gets none of the useful ones:--stunon the same public address, asking it would take a UDP hairpin, so STUN cannot report the public address.So the endpoint offers only its private address and browsers cannot reach it, even with the public UDP port forwarded. The ICE-lite bridge already solved this with
--bridge-public(N2): the advertised candidate is the public address, and received datagrams are presented to str0m as destined to it.What
nfxd run --mesh-public <ip:port>(needs--mesh-relay, and--mesh-bindwith a fixed port, the one the DNAT forwards to):nfx_node::node::is_public, fail-closed: private, shared, loopback, link-local, documentation, multicast, port 0 and so on are refused), of--mesh-bind's family.--iroh-externalfilters iroh's direct addresses: not the bound address behind the DNAT, nor a private STUN or gateway mapping. A public bound address is still offered.raddr.Receive.destination), as the bridge does, so connectivity checks to it are accepted.mesh public: udp <ip:port>line at start; the status line's candidate list starts withhost <public>.nfx_node::mesh::MeshConfig::publicandMesh::public_addr()in the library. The library checks only that the address is dialable, of the bind's family, and one str0m accepts as a host candidate; whether it is public is the caller's check (nfxd makes it), so tests can use loopback and documentation addresses.Docs: the usage text, the nfxd module docs, the README (with an example), and a one-sentence non-normative note in NFX-10 §6 (plus its changelog line). Nothing changes on the wire.
Tests
nfx-node unit (
mesh/tests.rs):nfx-node integration (
tests/mesh.rs): the endpoint bound on loopback and told a public address. The str0m browser peer reaches it only through a DNAT in the test: datagrams to the public address go to the bind with the browser's own source, and replies come back as from the public address, only after the browser has sent there. Through the relay, in both glare directions, the browser:Settings the library refuses are tested too: wrong family, port 0, unspecified, multicast, broadcast, link-local.
nfxd:
--mesh-publicparsing (form, given twice, missing value);--mesh-relay, needs--mesh-bind, port 0 bind, private, documentation, multicast, port 0, wrong family;--mesh-publicoffers exactlyhost <public>.The money crates and
Cargo.lockare untouched.Merge
One commit; squash.
Summary by CodeRabbit
--mesh-publicoption for setting the address. It requires a fixed mesh bind port and a public unicast address matching the bind address family.