Reference
iroh-live-relay reference
iroh-live-relay is the media relay server. It serves broadcasts to browsers
over WebTransport and to iroh clients over iroh.
iroh relays and media relays explains what a media
relay does, and Run a media relay how to deploy one.
cargo run -p iroh-live-relay -- [FLAGS]
On start, the media relay prints its endpoint id and the addresses it listens at:
iroh endpoint: <ENDPOINT_ID>
http port: 4443
iroh-live relay listening at http://localhost:4443
WebTransport on UDP 4443; the page above connects to it for you
needs a browser with WebTransport: Chromium, or Firefox 153+
The first SIGINT or SIGTERM drains the browser sessions, and a second one ends the media relay at once.
Flags
| Flag | Default | Description |
|---|---|---|
--bind <ADDR> | [::]:4443 | WebTransport bind address, over UDP. With port 0, the media relay picks a port that is free over both UDP and TCP, so the web viewer can share it |
--http-bind <ADDR> | the address --bind bound, over TCP | HTTP bind address for the web viewer. The page connects to its own origin, so another port needs ?url= |
--open-pulls | off | Lets any session make the media relay pull a ticket, see Pulls. For local and development use |
--auth-key <PATH> | none | Verifies JWTs from browsers and iroh clients with the keys in this file, a JWK or a JWK set as moq auth writes them |
--auth-url <URL> | none | Asks this auth server about every browser session, as moq-relay does |
--auth-public <PREFIX> | none | Lets every browser session publish and subscribe under these prefixes |
--auth-public-publish <PREFIX> | none | Lets every browser session publish under these prefixes |
--auth-public-subscribe <PREFIX> | none | Lets every browser session subscribe under these prefixes |
-h, --help | Prints the flags |
The prefix flags take a comma-separated list, such as anon,demo. A prefix
covers its path and every path beneath it, and the empty prefix "" covers
every path. A wildcard such as anon/** is refused.
--auth-key conflicts with --auth-url and the three --auth-public flags.
--auth-url conflicts with the --auth-public flags.
TLS certificates are self-signed and generated at startup. There is no ACME.
Access
The media relay decides browsers and iroh clients separately, since only iroh clients have an endpoint id.
Without auth flags:
- An iroh client may read the whole media relay, and publish at the paths that
name its endpoint id,
live/<id>/...androoms/<id>/.... - A browser may read anything, and publish under
anon/, which keeps it out oflive/androoms/.
With --auth-key:
- A session with a valid JWT gets what the token’s claims grant, in place of the rules above, and an invalid token is refused.
- A session without a token keeps the rules above. Anonymous browsers and
iroh clients still read every broadcast, and anonymous browsers can still
publish under
anon/.--auth-keychanges what token holders may do. It takes nothing from sessions without a token. - Browsers are decided by moq-auth’s reference policy,
moq_auth::serve::Policy, and iroh clients by aVerifyover the same key file, withrelay_policy()as the fallback. - The media relay reads the key file again when it changes, for browsers and iroh clients alike. A rotated or removed key takes effect for the next session without a restart. A file that is gone or holds no key refuses every token. Sessions already admitted keep their authorization until it expires.
A browser presents its JWT as ?jwt=<token> in the URL or as a SETUP token,
and a session that presents two different JWTs is refused. An iroh client
presents it through RelayConfig::tokens. The media relay decides an iroh
client once, and closes its session when the authorization expires. The
client’s relay link then redials with the tokens set on it last.
With --auth-url or an --auth-public flag, moq-relay’s own auth decides
browser sessions, and iroh clients keep the default rules. A binary that
embeds the media relay sets another iroh policy in Config::iroh_policy.
Pulls
A session that names a broadcast ticket as its path asks the media relay to pull it. The media relay then dials the ticket’s publisher over iroh, and serves the broadcast under that name. The media relay pulls only for:
- a session whose JWT, verified with
--auth-key, grants reading the ticket’s path, or - any session, with
--open-pulls.
A media relay without either pulls nothing, and refuses a session that asks.
With --auth-url or --auth-public, browsers pull nothing.
The media relay pulls only a ticket whose path is the publisher’s own, such as
live/<peer>/<name> or rooms/<peer>/<topic>/<name>, and refuses others with
NotOwner. A pull ends ten seconds after the last session that named it.
| Pull limit | Default |
|---|---|
| Pulls the media relay holds at once | 256 |
| Pulls one client holds at once (a browser by IP address, an iroh client by endpoint id) | 16 |
| New dials one client may start in a burst | 8 |
| Time to earn one more dial | 5 s |
A binary that embeds the media relay sets other limits in Config::pull_limits.
Ports
| Port | Protocol | Carries |
|---|---|---|
| 4443 | UDP | WebTransport over HTTP/3, for browsers |
| 4443 | TCP | The web viewer and /certificate.sha256, over plain HTTP |
| chosen by iroh | UDP | The media relay’s iroh endpoint, for nodes |
The iroh endpoint also announces itself over mDNS, so a node on the same LAN finds it by endpoint id without internet access.
HTTP endpoints
| Path | Serves |
|---|---|
GET / | The web viewer. ?name=<TICKET or name> opens a broadcast |
GET /certificate.sha256 | The TLS certificate’s fingerprint, which the page pins |
GET /{path} | Static files of the viewer, with CORS |
Environment variables
| Variable | Effect |
|---|---|
IROH_LIVE_RELAY_DATA | The directory of the media relay’s secret key file |
RUST_LOG | The log filter. Without it, the media relay logs at info |
The media relay does not read IROH_SECRET. Its key lives in a file, see
Files. RUST_LOG takes the same filters as for irl, see
RUST_LOG.
Files
| File | Holds |
|---|---|
$IROH_LIVE_RELAY_DATA/iroh_secret_key, or <data dir>/iroh-live-relay/iroh_secret_key | The media relay’s secret key, which fixes its endpoint id |
<data dir> is the platform’s data directory, such as ~/.local/share on
Linux. The media relay makes the directory and the key on its first start. A
file that does not hold a key is an error, never a reason to make a new one,
since every ticket through the media relay names its endpoint id. On Unix,
the file is readable by its user only.
Examples
Run a media relay for local development, which pulls any ticket:
cargo run -p iroh-live-relay -- --open-pulls
Run a media relay that grants token holders more, with its key in a persistent directory:
export IROH_LIVE_RELAY_DATA=/var/lib/iroh-live-relay
iroh-live-relay --auth-key keys.jwk
Let every browser publish and subscribe under anon/ and demo/, through
moq-relay’s own auth:
iroh-live-relay --auth-public anon,demo