Files
iroh/TRANSPORTS.md
Rüdiger Klaehn d434c85e1b feat: Implement custom transports (#3845)
## Description

Adds user defined transports.

Transports have to impl a dynable trait, currently named
CustomTransport. Implementing this requires implementing another dynable
trait CustomSender. Creating a transport requires implementing yet
another dynable trait CustomTransportFactory.

A custom addr is just an opaque blob with an u64 tranport id. Small
blobs will be inlined, but that is an implementation detail.

Formatting currently is "<id hex>-<data hex>"

Replaces https://github.com/n0-computer/iroh/pull/3707

## Breaking Changes

<!-- Optional, if there are any breaking changes document them,
including how to migrate older code. -->

## Notes & open questions

- Question: encoding of custom addrs in DNS records.
- Option 1: addr=1_a1b2c3 (tries to parse first as SocketAddr then as
custom addr)
   - Option 2: custom=1_a1b2c3 (separate IrohAttr::Custom)

- ~~Question: Feature gate or not? User transports require exposing a
bit more of the guts, e.g. transmit fields, so we might want to put this
behind a feature flag that is documented to be not part of the stable
API.~~

- ~~Question: Path selection.~~

~~Currently in select_best_path we never select an user path. For some
reason it still works, but we probably should put in some logic there.~~

    ```rust
        Some((transports::Addr::User(_), _)) => {
            // todo: when should we select an user path?
            None
        }
    ```

- DRY the different mapped addrs?
    
~~We could DRY the 2 differnet mapped addrs a bit more. But once you
start with this you get into a rabbit hole. Should relay transports just
be a special kind of custom transport? If we could abstract the logic
when to choose the relay, this might work. Maybe this is best left for
later.~~

Update: path selection is now taken care of. Basically each path gets a
2-tuple consisting of primary/secondary and biased rtt, then sort and
take the best. There is an API to add a bias for each addr type and also
to configure for each transport if it is a transport of last resort.

Here is how to bias a transport:

```rust
Endpoint::builder()
    .transport_bias(
        AddrKind::Custom(TEST_TRANSPORT_ID),
        TransportBias::primary().with_rtt_advantage(CUSTOM_TRANSPORT_RTT_ADVANTAGE))
    .build().await?;
```

I also added some tests to make sure custom transports work if the ip
transport is enabled.
2026-03-05 11:11:51 +00:00

670 B

This table contains a mapping from custom address id to the transport type.

If you want to publish a globally available custom transport, choose an id and do a PR against this repo.

transport id transport address format repo status
0x00-0x1F - - - reserved
0x20 Test Ed25519 public key (32 bytes) iroh (test-utils) internal
0x544F52 Tor Ed25519 public key (32 bytes) iroh-tor experimental
0x424C45 BLE Bluetooth MAC address (6 bytes) reserved