Expand description
A media relay that serves iroh-live broadcasts to browsers.
Browsers connect over WebTransport, iroh clients over iroh. Anyone may
subscribe to anything. An iroh client may publish only at paths that name
its endpoint id (relay_policy), and a browser only at names of one
segment.
A session that names a broadcast ticket gets it pulled, see pull: the
media relay dials the ticket’s publisher over iroh. Since that makes the media relay
dial an endpoint the client chose, only a session whose token grants
reading the ticket’s path may pull, and a media relay without --auth-key
pulls nothing. --open-pulls lets any session pull, which suits a local
or development media relay and is unsafe on a public one. Either way the pulls
are capped in total and per client, and each client’s new dials are rate
limited (pull::Limits).
With --auth-key, a session that presents a valid JWT gets what the token
grants instead. A session without a token keeps the rules above, so the
flag grants token holders more but does not make the media relay private. Browsers are decided by moq-auth’s reference policy, and
iroh clients by a KeyFile. Both read the key file again when it
changes, so a rotated or removed key takes effect for new sessions without
a restart. --auth-url and the --auth-public flags hand browser
sessions to moq-relay’s own auth, which then pulls no tickets.
Another CLI can embed the media relay by flattening Config into its arguments.
§Examples
use clap::Parser;
#[derive(Parser)]
struct Cli {
#[command(flatten)]
relay: iroh_live_relay::Config,
}
iroh_live_relay::run(Cli::parse().relay).awaitrun returns once a drain started by SIGINT or SIGTERM ends, after
closing its listeners. Dropping its future stops the listeners and the
accepted connections. The tasks that dial and hold a pull end with the
last clone of their Pulls: a linger window after
the last session that named the ticket, or later while a dial or a resolve
is in flight.
Modules§
- pull
- Pull mode: serving a broadcast ticket’s broadcast from the media relay.
Structs§
- Config
- Configuration for the media relay server, as clap arguments.
- Iroh
Sessions - The protocol handler that accepts iroh clients’ MoQ sessions into the cluster.
- KeyFile
- A
TokenVerifierof JWTs with the keys in a file, read again when the file changes.
Enums§
- Error
- An error from running the media relay, pulling a broadcast, or loading a key.
Constants§
- ANON
- The prefix a browser without a token publishes under, as moq-relay’s anonymous rules name it.
Functions§
- admit
- Answers the media relay’s admissions until the media relay drops its auth.
- browser_
grant - Returns the grant for a browser that dialed
path: subscribe anywhere, publish underANON. - relay_
policy - Returns the media relay’s default policy for iroh clients.
- run
- Runs the media relay server until a shutdown signal or an error.