Skip to main content

Module relay_access

Module relay_access 

Source
Expand description

Who a relay of the server’s own lets through.

The relay runs as a process of its own (spoolframe-server relay), with no users of its own: it asks the main server, over an Iroh connection on RELAY_ACCESS_ALPN, which tier an endpoint that connects to it is in. The main server answers only the relays its config names. One bidirectional stream per question: an AccessQuery frame, answered by an AccessAnswer frame.

A device redeeming an invite is no one’s yet: it proves it holds the code with an invite_token, which the relay reads from the Authorization header of its connection and passes in the question. A device about to play a paired server’s item proves it holds that server’s play token the same way, with a play_relay_token.

The main server tells its relays when an answer no longer holds: on a unidirectional stream it opens on the relay’s connection, an AccessRevoked frame. A relay forgets what it kept for that endpoint and asks again about those it carries.

Structs§

AccessAnswer
The tier of the endpoint asked about.
AccessQuery
Which tier endpoint is in.
AccessRevoked
The main server’s word that what it answered for endpoint no longer holds: a paired server unpaired, or moved to a new key.

Enums§

Tier
Who an endpoint is to the main server, for its relay.

Constants§

INVITE_TOKEN_PREFIX
What an invite holder’s token starts with: its scheme and version.
MAX_FRAME
The most bytes an access frame takes, on either side: a query, an answer or a revocation is a key and some framing, so anything larger is not one.
PLAY_TOKEN_PREFIX
What a play token holder’s relay token starts with.
RELAY_ACCESS_ALPN
The ALPN a relay asks the main server on.

Functions§

invite_mac
What a token for the invite whose code hashes to code_hash carries, as endpoint: the server keeps only the hash, and checks with this.
invite_token
The token whoever holds invite code connects to the server’s relay with, as endpoint (its key’s bytes): sf-invite.1. and the base64url of BLAKE3 keyed with the code’s hash, over the key. It proves the code without carrying it, and admits no other endpoint: the relay’s handshake proved the key it was made for. None for a code that cannot be one.
is_relay_token
Whether token is one a relay passes on: an invite holder’s or a play token holder’s.
parse_invite_token
The MAC token carries, if it is an invite holder’s token at all. The relay passes on only these, and play token holders’ (is_relay_token): anything else is no token.
parse_play_token
The MAC token carries, if it is a play token holder’s relay token.
play_relay_token
The token whoever holds paired-server play token token connects to that server’s relay with, as endpoint: sf-play.1. and the base64url of BLAKE3 keyed with the play token’s hash, over the key, as an invite holder’s is made with the code’s. The server keeps only the play token’s hash, and checks with it.