Find peers by public key when IP addresses change
Imagine a scenario where you can continue to find a peer device and exchange data even when the network environment changes. iroh is a library that uses public keys as identifiers instead of IP addresses to find and maintain the fastest path between two devices. If a direct connection is not possible, it falls back to a public relay server to keep the connection alive.
How it finds peers by public key
Traditional internet connections are prone to dropping because IP addresses change frequently. iroh attempts connections using public keys instead of IP addresses. It tries NAT hole-punching to establish a direct connection, which is the fastest path, and falls back to a public relay server if that fails. During this process, it continuously measures connection speed to maintain the optimal state.
QUIC-based transport structure
iroh uses noq to establish QUIC connections. This supports authenticated encryption, concurrent stream processing, and datagram transmission. It avoids the head-of-line blocking problem, so a delay in one part of the data does not block the entire transmission when sending and receiving multiple data streams simultaneously.
Using ready-made protocols
You can utilize existing modules without building protocols from scratch. iroh-blobs supports file transfers ranging from gigabytes to terabytes using a BLAKE3-based content-addressing scheme. iroh-gossip builds a publish-subscribe overlay network that operates on resources typical of a standard smartphone. iroh-docs is a final consistency key-value store that manages iroh-blobs data.
Rust-centric usage and repository structure
In Rust, you install it with cargo add iroh, then bind endpoints on both the connecting and receiving sides and open streams. If you want to use it in other languages, you need to check the FFI bindings in the iroh-ffi repository. The repository is divided into the core library, relay server implementation, common types, and DNS server implementation. The relay server code is used for operating public relay servers, and users can also run it directly.
Things to check before use
It works most naturally in the Rust ecosystem, while users of other languages should check the status of the bindings. Depending on the network environment, direct connections may fail and require a relay server, so you should consider latency and bandwidth requirements. The license is available under either Apache 2.0 or MIT. The project is maintained by N0, INC., and contributions are subject to dual licensing.