Skip to main content

Module federation

Module federation 

Source
Expand description

Server-to-server federation on spoolframe/federation/1: pairing two servers, and replicating what one shares with the other (SyncLibrary and the rest).

An app does not speak this ALPN. It sees a paired server’s libraries and items through its own server, as fed: ids. The client protocol’s types for playing them directly are here too: RemoteHints, RemoteGranted, RedeemPlayToken and PlayTokenRedeemed.

Experimental (crate::experimental::FEDERATION): a server serves the ALPN only while its experimental { federation = true; } is on, and closes it at once otherwise. These messages may change without PROTOCOL_VERSION or the client protocol’s version moving.

A server’s identity is its endpoint key, which the QUIC handshake proves. Its crate::ServerId is a label with no key, which outlives a rotated key: the server that is dialled pins the pair (endpoint id, server id). Nothing here is signed; arriving on the connection is the proof.

One request per bidirectional stream, as crate::codec frames it: a PeerRequest, answered by a PeerReply. The first is always PeerRequest::Hello. An endpoint the server does not know reaches only Hello and PeerRequest::RedeemPairing; anything else resets the stream with reset::NOT_ALLOWED and is counted against it as a wrong guess at an invite code. A known server id from a new key is held until an admin confirms the key (Standing::KeyHeld), and reaches only Hello. Only a live pair reaches replication’s requests.

Modules§

reset
Stream reset codes on this ALPN.

Structs§

ArtworkFetch
Ask for one image of a shared library’s item, by the id an item’s RemoteArtwork gave. Answered with PeerReply::Artwork, written as a reply (crate::codec::write_reply) rather than a frame, as an image may be larger than one.
AssertUser
The home server vouches for its local user, who wants item of the item’s server on the device client_endpoint. Answered with Token, or AssertionRefused.
PairServer
An admin’s PairServer (client protocol): the other server’s federation invite link, with its code.
Paired
The pair is made: the dialled server pinned the dialling one, and says who it is so the other can write its own row.
PeerHello
The first request on every connection: who the dialling server says it is. Its endpoint is proved by the connection; its server id is checked against the pin for that endpoint.
PeerInfo
The answer to PeerHello: the server dialled, and what the dialling one is to it.
PeerServer
A server paired by PairServer (client protocol), as the app shows it.
PlayTokenRedeemed
What a redeemed play token opened (Reply::PlayTokenRedeemed). The session’s Debug keeps it out of logs.
RedeemPairing
Pair with the server dialled by redeeming its federation invite.
RedeemPlayToken
RedeemPlayToken: a play token, redeemed on the server that minted it.
RemoteArtwork
A piece of an item’s artwork, fetched with ArtworkFetch.
RemoteGranted
The item’s server’s token for the device (RemoteGrant): redeem it on that server’s client/1 (RedeemPlayToken) from the device that asked.
RemoteHints
Where a paired server is, as its pair keeps it (RemoteHints): what a device dials it at. The home server’s own record of the item’s server, from the pairing.
RemoteItem
One item of a shared library, as the sharing server has it. Ids are the sharing server’s own; the server that caches it names them as its origin’s (spoolframe_types::MediaId::federated).
ShareLibraries
An admin’s ShareLibraries (client protocol): share libraries of this server with a paired one, as the QR flow offers once the pair is made. Every user of the paired server may browse and watch them.
SharedLibrary
A library shared with the server asking.
SubtitleDownloadAsk
DownloadSubtitle of result result of a search for the item’s server’s item, for the home server’s user: answered with SubtitleDownloaded, or Failed.
SubtitleRemovalAsk
RemoveSubtitleDownload of download download of the item’s server’s item, for the home server’s user: answered with Done, or Failed.
SubtitleSearchAsk
SearchSubtitles of the item’s server’s item for the home server’s user: answered with SubtitleResults, or Failed.
SyncLibrary
Ask for one shared library’s changes since since.
SyncPage
One page of the answer to SyncLibrary.
TokenGranted
The item’s server’s token for an AssertUser.
Unpaired
The server sending it no longer pairs with the one it is sent to: that one revokes its own row too. Best effort: a server that is not told keeps its row until its admin revokes it.

Enums§

AssertionRefused
Why the item’s server minted no token. Each is counted against the pair.
PairingRefused
Why no pair was made, or a peer was turned away.
PeerReply
The answer to a PeerRequest.
PeerRequest
A request on spoolframe/federation/1.
RemoteArtworkKind
The role a piece of artwork plays.
RemoteKind
What an item is.
RemoteLibraryKind
What a library holds, as a sharing server says.
Standing
What the dialling server is to the one it dialled.
SyncMode
What a sync’s pages hold.
TokenScope
What a token opens. A play token opens one item’s playback; a download token opens one item’s download.

Constants§

MAX_ARTWORK_BYTES
The largest image an ArtworkFetch is answered with, in bytes.
MAX_ARTWORK_REPLY
The largest reply to an ArtworkFetch a server reads, in bytes: the image’s MAX_ARTWORK_BYTES and room for its media type and the reply around it. One announced longer is refused before any of it is held, not read to the reply’s own 64 MiB bound first.
MAX_HINTS
The most address hints, and the most relays, a redemption carries; the rest are left out, as an invite link’s are (crate::invite::MAX_HINTS).
MAX_ITEM_ARTWORK
The most artwork, external ids and genres one item carries.
MAX_ITEM_EXTERNAL_IDS
MAX_ITEM_GENRES
MAX_ITEM_SUMMARY
The longest summary an item carries, in characters.
MAX_ITEM_TEXT
The longest title, name or short text an item carries, in characters.
MAX_PAGE_ITEMS
The most items one SyncPage carries; the rest are left out.
MAX_PAGE_REMOVED
The most ids of removed items one SyncPage carries.
MAX_REQUEST
The longest request frame a server reads on this ALPN. A pairing is a code, a name and some address hints.
MAX_SHARED
The most libraries one ShareLibraries names; the rest are left out.
MAX_SHARED_LIBRARIES
The most libraries a PeerReply::Libraries lists.
PROTOCOL_VERSION
The version of spoolframe/federation/1’s messages this build speaks: the ALPN versions itself, apart from the client protocol’s crate::PROTOCOL_VERSION.
SHARES_CHANGED_EVERY
The least time between two syncs a pair’s PeerRequest::SharesChanged sets off: a pair that sends notices without end makes the receiver sync it at most this often.

Functions§

federated_id
Whether text is a fed: id of an item, a library or an image.
libraries_within_bounds
The libraries listed cut to MAX_SHARED_LIBRARIES, their texts to MAX_ITEM_TEXT: what a server keeps of a listing.
names_federated
Whether request names a paired server’s item, library or image anywhere, in any field (a fed: id): what a server refuses from a client that did not name the experimental federation feature, at one boundary rather than in each request’s handler. A crate::Request, or a resource’s request, as an image’s is. Text that only starts like one, a search’s or a name, is not an id.
pairing_refused_message
PairingRefused::message, for Swift and Kotlin. A free function, not a method: UniFFI 0.32’s Kotlin lowers a method’s receiver by the type’s Rust name, which the Kotlin rename (PairingRefusal) leaves undefined.
server_name
A server’s name cut to crate::MAX_HELLO_TEXT characters, as a PeerHello’s is: what a server keeps of another’s name, from wherever it came. Control characters go first: the name is logged, and a newline in it would forge a line of the log.