Skip to main content
Local discovery adds the ability to use physical radios to discover other iroh endpoints. This is useful for local networks where the internet may not be available or reliable. Local connections can be faster and more reliable than internet-based connections, especially in environments with poor connectivity. They also enhance privacy by keeping communications within a local area.

mDNS

Local Discovery is not enabled by default, and must be enabled by the user. You’ll need to add the discovery-local-network feature flag to your Cargo.toml to use it.
[dependencies]
# Make sure to use the most recent version here instead of nn. (at the time of writing: 0.32)
iroh = { version = "0.nn", features = ["discovery-local-network"] }
Then configure your endpoint to use local discovery concurrently with the default DNS discovery:
use iroh::Endpoint;

let mdns = iroh::discovery::mdns::MdnsDiscovery::builder();
let ep = Endpoint::builder()
    .discovery(mdns)
    .bind()
    .await?;
The mDNS discovery mechanism will automatically broadcast your endpoint’s presence on the local network, and listen for other endpoints doing the same. When another endpoint is discovered, the dialing information is exchanged, and a connection can be established directly over the local network without needing a relay. For more information on how mDNS discovery works, see the mDNS documentation.

Bluetooth

Bluetooth discovery is currently under development and will be available in a future release of iroh. For more information, please contact us.