A friend's server can now read what an admin chose to share.
- A library has a shared flag, off by default (migration 0024), set with
PATCH /libraries/{id}. Changing it never waits for a scan.
- Requests between friends are signed with each server's Ed25519 key: the
method, the path and query from /api/v1/peer on, a date, a nonce and the
hash of the empty body. A date more than two minutes off, a nonce used
before, an unknown or removed key and a bad signature all get the same
401. A friend still waiting for approval gets 403, and while federation is
off the routes are missing.
- Routes under /api/v1/peer: info, artists, albums, tracks, covers and
streaming with Range. The catalogue, the counts and the format come from
the shared libraries only, and the file served is the one in a shared
library. No path, library id, listen, taste, user or provider data is part
of an answer.
- A friend never makes this server build a cover, read an audio file or ask
a provider: only covers already built from the audio files are served.
- Per-friend limits, set by the admin: parallel streams (default 3) and KiB
a second (default 4096, 0 for none), shared by all the streams of a friend.
- A log of the last requests friends made (route, status, bytes; never the
query), kept for 7 days, in GET /federation/requests.
- POST /federation/friends/{id}/check lets the side that pasted an invite
find out that the other admin approved; a signed call from a friend this
server is waiting for makes it active too.
- Admin: a Shared with friends switch on each library, which asks first, and
limits, recent requests and a Check button in the Federation section, in
English and Italian.
- OpenAPI paths and schemas, contract test, two real servers checked end to
end with tagged audio files.
17 lines
694 B
SQL
17 lines
694 B
SQL
-- PostgreSQL flavour of sqlite/0024_federation_sharing.sql.
|
|
|
|
ALTER TABLE libraries ADD COLUMN shared BOOLEAN NOT NULL DEFAULT FALSE;
|
|
|
|
ALTER TABLE federation_settings ADD COLUMN max_streams INTEGER NOT NULL DEFAULT 3;
|
|
ALTER TABLE federation_settings ADD COLUMN max_kib_per_sec INTEGER NOT NULL DEFAULT 4096;
|
|
|
|
CREATE TABLE federation_requests (
|
|
id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|
friend_id BIGINT NOT NULL REFERENCES federation_friends(id) ON DELETE CASCADE,
|
|
at BIGINT NOT NULL,
|
|
route TEXT NOT NULL,
|
|
status INTEGER NOT NULL,
|
|
bytes BIGINT NOT NULL
|
|
);
|
|
|
|
CREATE INDEX idx_federation_requests_at ON federation_requests(at);
|