Expand description
LOCAL (mDNS) peer discovery (#68) — find peers on the same link with no internet at all.
§Why this exists
Peer resolution otherwise depends on external infrastructure: the pkarr publisher/resolver a relay provides, or a dialable address someone already handed over in an invite. Two machines on the same LAN with no uplink cannot find each other, though the network path between them is fine. That is the scenario where “peer to peer” earns its keep — a boat, a workshop, a failed uplink, a deliberately air-gapped network — and the commoner weak version too: a LAN where the internet is merely flaky, so peers that could talk directly fail to resolve because resolution goes out first.
§This is a DEPENDENCY, not an implementation
#68 concluded “there is no mDNS in iroh 1.0.3, so this needs an implementation”, from a correct
reading of iroh-1.0.3/src/address_lookup/ — which contains exactly dns.rs, memory.rs and
pkarr.rs. iroh 1.x did not drop mDNS; it moved it into a companion crate, and says so in the
module docs of that same file:
mDNS-based and Mainline-DHT-based Address Lookup services live in separate crates:
iroh-mdns-address-lookupandiroh-mainline-address-lookup.
So this module is thin on purpose. An mDNS responder is a multicast listener on every interface; one written here would be ours to get right and ours to keep right, against a transport whose address model it has to track. n0’s stays version-matched to the iroh we pin.
§What it discloses
Advertising multicasts this node’s endpoint id and its addresses to every device on the link,
unprompted and repeatedly, including machines that had no idea it existed. “Its addresses” means
the LAN address, the PUBLIC WAN IPv4 and global IPv6 — a café LAN learns your home/ISP address,
not merely that you are there. That is why [network].local_discovery defaults to "off", a
deliberate departure from what #68 asked for.
"resolve" is quieter, not silent. Resolving over mDNS means asking:
MdnsAddressLookup builds a Discoverer::new_interactive unconditionally (τ = 700 ms) and
advertise gates only with_addrs, so a resolving node multicasts a _mcpmesh._udp.local
query roughly once a second for as long as it runs. It publishes no identity and no addresses —
pinned on the wire — but the query itself says “an mcpmesh node is at this IP, right now”. The
docs said “listen only” until the 0.44.0 gate captured the packets.
relay_only does not restrain any of this on a stock build. AddrFilter::relay_only() is
installed only under the unstable-relay-only feature; without it the filter does not exist and
the full direct address set goes out. Boot warns, naming which of the two builds the operator
has. An earlier version of this comment asserted the filter always applied; it does not.
Constants§
- SERVICE_
NAME - The mDNS service name mcpmesh nodes announce and listen on.
Functions§
- build
- Build the local-discovery lookup for
endpoint_id.