IP addresses break, dial keys instead. A library that adds QUIC + NAT Traversal to your apps. https://iroh.computer
  • Rust 99.6%
  • Shell 0.3%
Find a file
Rüdiger Klaehn a05c9c4142
fix: Use random mapped addrs instead of a counter. (#4469)
## Description

Use random mapped addrs instead of a counter. This makes our mapped
addrs unpredictable, so nobody external can guess our internal mapped
addresses.

## Breaking Changes

None

## Notes & open questions

Note: we lose an atomic counter, but gain one call to rng per new entry.

## Change checklist
<!-- Remove any that are not relevant. -->
- [ ] Self-review.
- [ ] Documentation updates following the [style
guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text),
if relevant.
- [ ] Tests if relevant.
- [ ] All breaking changes documented.
- [ ] This PR was created by a human that thought critically about the
      proposed change and wrote an as clear and concise description as
      they could.
- [ ] This PR isn't slop, and is carefully crafted to do have the
      intented effect.
2026-08-21 10:27:39 +00:00
.cargo fix: handle wine properly (#3902) 2026-04-07 18:38:38 +02:00
.config feat: update noq and net-tools to latest (#4088) 2026-04-08 15:34:34 +02:00
.github ci(secruity): hardening + lock files + dependabot cooldown (#4480) 2026-08-21 10:24:02 +00:00
.img docs: update root, iroh, iroh-metrics readmes (#1258) 2023-07-17 21:48:09 +00:00
docker refactor(iroh)!: rework net_report (#3314) 2025-06-24 13:31:24 +00:00
iroh fix: Use random mapped addrs instead of a counter. (#4469) 2026-08-21 10:27:39 +00:00
iroh-base fix!: Fix serialization of CustomAddr so that the data serializes the same as a Vec<u8> (#4465) 2026-08-10 16:53:19 +00:00
iroh-dns chore(deps): bump simple-dns from 0.11.3 to 0.12.0 (#4451) 2026-07-30 12:16:45 +00:00
iroh-dns-server chore(iroh-dns-server): replace mainline with n0-mainline and update lru (#4470) 2026-08-14 07:40:22 +00:00
iroh-relay feat(iroh-relay, iroh): inform clients when they are rate-limited and warn log in iroh (#4455) 2026-08-18 16:01:05 +00:00
.dockerignore feat: docker images for iroh (#2404) 2024-07-08 11:17:31 +00:00
.gitattributes fix(ci): release builds (#2219) 2024-04-29 10:08:12 +00:00
.gitignore tests: add patchbay tests (#3986) 2026-04-02 10:21:54 +02:00
.pinact.yaml ci(secruity): hardening + lock files + dependabot cooldown (#4480) 2026-08-21 10:24:02 +00:00
.typos.toml chore: introduce crate-ci/typos (#2430) 2024-06-30 20:33:56 +00:00
Cargo.lock ci(secruity): hardening + lock files + dependabot cooldown (#4480) 2026-08-21 10:24:02 +00:00
Cargo.toml ci: Update semver checks for 1.0 stability (#4401) 2026-07-13 16:40:01 +00:00
CHANGELOG.md chore: Release 2026-07-20 15:27:40 -04:00
CHANGELOG_old.md chore: Fix typos (#1964) 2024-01-23 14:36:54 +00:00
cliff.toml chore(*): add release configuration for generating the changelog 2026-07-06 16:32:28 -04:00
code_of_conduct.md chore: Fix typos (#1964) 2024-01-23 14:36:54 +00:00
CONTRIBUTING.md docs: fix typos discovered by codespell (#2534) 2024-07-25 09:34:46 +00:00
deny.toml ci(secruity): hardening + lock files + dependabot cooldown (#4480) 2026-08-21 10:24:02 +00:00
example.config.toml refactor!: rename Node to Endpoint in all cases (#3542) 2025-10-15 13:31:01 +00:00
LICENSE-APACHE chore: update copyright dates (#3543) 2025-10-15 15:14:32 +00:00
LICENSE-MIT chore: update copyright dates (#3543) 2025-10-15 15:14:32 +00:00
Makefile.toml ci(secruity): hardening + lock files + dependabot cooldown (#4480) 2026-08-21 10:24:02 +00:00
README.md docs: update license links to HTTPS (#4365) 2026-06-23 09:31:47 +02:00
release.toml chore: switch to git-cliff for changelog generation 2023-11-08 11:46:12 +01:00
TRANSPORTS.md feat: Implement custom transports (#3845) 2026-03-05 11:11:51 +00:00
zizmor.yml ci(secruity): hardening + lock files + dependabot cooldown (#4480) 2026-08-21 10:24:02 +00:00

iroh

less net work for networks

Documentation Crates.io downloads Chat Youtube License: MIT License: Apache 2.0 CI


What is iroh?

Iroh gives you an API for dialing by public key. You say “connect to that phone”, iroh will find & maintain the fastest connection for you, regardless of where it is.

Hole-punching

The fastest route is a direct connection, so if necessary, iroh tries to hole-punch. Should this fail, it can fall back to an open ecosystem of public relay servers. To ensure these connections are as fast as possible, we continuously measure iroh.

Built on QUIC

Iroh uses noq to establish QUIC connections between endpoints. This way you get authenticated encryption, concurrent streams with stream priorities, a datagram transport and avoid head-of-line-blocking out of the box.

Compose Protocols

Use pre-existing protocols built on iroh instead of writing your own:

  • iroh-blobs for BLAKE3-based content-addressed blob transfer scaling from kilobytes to terabytes
  • iroh-gossip for establishing publish-subscribe overlay networks that scale, requiring only resources that your average phone can handle
  • iroh-docs for an eventually-consistent key-value store of iroh-blobs blobs

Getting Started

Rust Library

It's easiest to use iroh from rust. Install it using cargo add iroh, then on the connecting side:

const ALPN: &[u8] = b"iroh-example/echo/0";

let endpoint = Endpoint::bind().await?;

// Open a connection to the accepting endpoint
let conn = endpoint.connect(addr, ALPN).await?;

// Open a bidirectional QUIC stream
let (mut send, mut recv) = conn.open_bi().await?;

// Send some data to be echoed
send.write_all(b"Hello, world!").await?;
send.finish()?;

// Receive the echo
let response = recv.read_to_end(1000).await?;
assert_eq!(&response, b"Hello, world!");

// As the side receiving the last application data - say goodbye
conn.close(0u32.into(), b"bye!");

// Close the endpoint and all its connections
endpoint.close().await;

And on the accepting side:

let endpoint = Endpoint::bind().await?;

let router = Router::builder(endpoint)
    .accept(ALPN.to_vec(), Arc::new(Echo))
    .spawn()
    .await?;

// The protocol definition:
#[derive(Debug, Clone)]
struct Echo;

impl ProtocolHandler for Echo {
    async fn accept(&self, connection: Connection) -> Result<()> {
        let (mut send, mut recv) = connection.accept_bi().await?;

        // Echo any bytes received back directly.
        let bytes_sent = tokio::io::copy(&mut recv, &mut send).await?;

        send.finish()?;
        connection.closed().await;

        Ok(())
    }
}

The full example code with more comments can be found at echo.rs.

Or use one of the pre-existing protocols, e.g. iroh-blobs or iroh-gossip.

Other Languages

If you want to use iroh from other languages, make sure to check out iroh-ffi, the repository for FFI bindings.

Repository Structure

This repository contains a workspace of crates:

  • iroh: The core library for hole-punching & communicating with relays.
  • iroh-relay: The relay client and server implementation. This is the code we run in production for the public relays (and you can, too!).
  • iroh-base: Common types like EndpointId or RelayUrl.
  • iroh-dns-server: DNS server implementation powering the DNS/Pkarr address lookup for EndpointIds, running at dns.iroh.link.

License

Copyright 2025 N0, INC.

This project is licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.