feat(iroh): add ability to publish and resolve relay urls in mDNS
Description
Adds the ability to resolve and publish relay URLs over mDNS. This is off by default.
RelayUrls are typically only used for hole punching, which likely is not needed when using mDNS. However, we have seen some test cases where mDNS packets get through local firewalls, but our iroh packets are blocked. In these cases, it may be prudent to also publish your relay url.
- Adds
MdnsDiscoveryBuilder::publish_relay_urlmethod
Netsim report & logs for this PR have been generated and is available at: LOGS This report will remain available for 3 days.
Last updated for commit: 8d00074
Documentation for this PR has been generated and is available at: https://n0-computer.github.io/iroh/pr/3691/docs/iroh/
Last updated: 2025-11-22T09:15:04Z
TODOS
- [ ] Add API to mDNS discovery to add a mapping function that let's users filter the kinds of addrs they want to publish, as well as order them. (takes a transport::Addr slice returns a transport::Addr vec?)
- [ ] adjust mDNS discovery publishing to map the addrs before publishing
- [ ] use match on addr to know how to format -> if IP do normal, if relay add to TXT attribute, only allow 4 txt attributes, any that don't get added log a warn with the addr
- [ ] add test that ensures we can get multiple relays
- [ ] add test that ensures we cannot add too many
- [ ] add tests that shows we respect the map filter
A note on this PR.
In prep for the ability to add custom transports, we want to re-work this PR to be a model for how to add those in the future.
We want to:
- add a map fn to the discovery service that lets you filter/order/map the addrs you want published for that particular service
- when you go to publish, run the map fn, add IP addrs as normal to mDNS
- any other addrs, add as a TXT attribute, going in the order specified by the user. Any that don't fit will get warn logged