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§
- Artwork
Fetch - Ask for one image of a shared library’s item, by the id an item’s
RemoteArtworkgave. Answered withPeerReply::Artwork, written as a reply (crate::codec::write_reply) rather than a frame, as an image may be larger than one. - Assert
User - The home server vouches for its local
user, who wantsitemof the item’s server on the deviceclient_endpoint. Answered withToken, orAssertionRefused. - Pair
Server - An admin’s
PairServer(client protocol): the other server’sfederationinvite 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.
- Peer
Hello - 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.
- Peer
Info - The answer to
PeerHello: the server dialled, and what the dialling one is to it. - Peer
Server - A server paired by
PairServer(client protocol), as the app shows it. - Play
Token Redeemed - What a redeemed play token opened (
Reply::PlayTokenRedeemed). The session’sDebugkeeps it out of logs. - Redeem
Pairing - Pair with the server dialled by redeeming its
federationinvite. - Redeem
Play Token RedeemPlayToken: a play token, redeemed on the server that minted it.- Remote
Artwork - A piece of an item’s artwork, fetched with
ArtworkFetch. - Remote
Granted - The item’s server’s token for the device (
RemoteGrant): redeem it on that server’sclient/1(RedeemPlayToken) from the device that asked. - Remote
Hints - 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. - Remote
Item - 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). - Share
Libraries - 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. - Shared
Library - A library shared with the server asking.
- Subtitle
Download Ask DownloadSubtitleof resultresultof a search for the item’s server’sitem, for the home server’suser: answered withSubtitleDownloaded, orFailed.- Subtitle
Removal Ask RemoveSubtitleDownloadof downloaddownloadof the item’s server’sitem, for the home server’suser: answered withDone, orFailed.- Subtitle
Search Ask SearchSubtitlesof the item’s server’sitemfor the home server’suser: answered withSubtitleResults, orFailed.- Sync
Library - Ask for one shared library’s changes since
since. - Sync
Page - One page of the answer to
SyncLibrary. - Token
Granted - 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§
- Assertion
Refused - Why the item’s server minted no token. Each is counted against the pair.
- Pairing
Refused - Why no pair was made, or a peer was turned away.
- Peer
Reply - The answer to a
PeerRequest. - Peer
Request - A request on
spoolframe/federation/1. - Remote
Artwork Kind - The role a piece of artwork plays.
- Remote
Kind - What an item is.
- Remote
Library Kind - What a library holds, as a sharing server says.
- Standing
- What the dialling server is to the one it dialled.
- Sync
Mode - What a sync’s pages hold.
- Token
Scope - 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
ArtworkFetchis answered with, in bytes. - MAX_
ARTWORK_ REPLY - The largest reply to an
ArtworkFetcha server reads, in bytes: the image’sMAX_ARTWORK_BYTESand 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
SyncPagecarries; the rest are left out. - MAX_
PAGE_ REMOVED - The most ids of removed items one
SyncPagecarries. - 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
ShareLibrariesnames; the rest are left out. - MAX_
SHARED_ LIBRARIES - The most libraries a
PeerReply::Librarieslists. - PROTOCOL_
VERSION - The version of
spoolframe/federation/1’s messages this build speaks: the ALPN versions itself, apart from the client protocol’scrate::PROTOCOL_VERSION. - SHARES_
CHANGED_ EVERY - The least time between two syncs a pair’s
PeerRequest::SharesChangedsets off: a pair that sends notices without end makes the receiver sync it at most this often.
Functions§
- federated_
id - Whether
textis afed:id of an item, a library or an image. - libraries_
within_ bounds - The libraries listed cut to
MAX_SHARED_LIBRARIES, their texts toMAX_ITEM_TEXT: what a server keeps of a listing. - names_
federated - Whether
requestnames a paired server’s item, library or image anywhere, in any field (afed:id): what a server refuses from a client that did not name the experimentalfederationfeature, at one boundary rather than in each request’s handler. Acrate::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. - server_
name - A server’s
namecut tocrate::MAX_HELLO_TEXTcharacters, as aPeerHello’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.