GRI-1854: client sync over wss — enrolment, playlist, media cache, reconnect #86
No reviewers
Labels
No labels
Area/Backend
Area/Database
Area/Docs
Area/Frontend
Area/Infra
Area/Security
Area/Tests
Area/Tooling
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Lang/Python
Lang/Rust
Lang/Shell
Lang/SQL
Lang/TypeScript
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Routing
Auto
Routing
Hold
Routing
Human
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Grimoirix/grimoire-of-digital-signage!86
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/GRI-1854-client-sync"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Signage #20 (GRI-1854): the client syncs over
wss://. It covers enrolment, the playlist, the media download into a hash-keyed cache, and reconnecting with backoff.Stacked on #84 (the protocol envelope). This branch contains #84's commit, so merge #84 first and this diff shrinks to the client alone.
Done-when for #20, as a test.
crates/client/tests/sync_survives_restart.rsruns a fake server over a real WebSocket on loopback. The server enrols the client and sends playlist v1 plus one file in two chunks. Then it drops both the connection and the listener. A second server on the same port checks that the client comes back with its permanentdevice_idand token, sends playlist v2, and checks the cached file is accepted at its end offset, so nothing is downloaded again. A second test covers a pending device: it sendsRegistrationand reconnects with its temporary id.Modules (all in
crates/client)state.rsstate.json: identity, temporary id, pinned key, last playlist, last manifest. Write to a temp file, fsync, renamecache.rs<sha256>holds verified files,<sha256>.partholds downloads in progress (its length is the resume offset), plus a sweep down to the manifest../). A hash mismatch deletes the partial, so nothing unverified ever gets the final namesession.rssync.rswssloop: connect (15 s timeout), hello (15 s), heartbeat and ping every 30 s, closed as dead after 75 s of silence. Backoff runs 1 s → 5 min with full jitter.RejectedorUpdateRequiredwaits the capwatchchannel that is filled from disk before the first connect, so it never waits on the networkconfig.rsGRIMOIRIX_SIGNAGE_SERVER, elseserver = "https://…"in/etc/grimoirix-signage/client.toml, turned intowss://host/ws/device. Data dir fromGRIMOIRIX_SIGNAGE_DATA_DIR, else XDG, else~/.local/sharemain.rsDependencies:
tokio(current-thread),tokio-tungstenite0.28 using rustls with the native trust store (so a campus CA goes in the system store),ringas the only crypto provider, and no OpenSSL.cargo denypasses.Decisions
state.jsonplus file names as the cache index, instead of the SQLite the plan named.rusqliteis banned indeny.toml, and the directory is the index. Two-way: easy to change later.offline-first.mdis updated.spawn_blocking.Security surface, for the security checker:
state.json, mode 0600 (tested), under the user's data dir.Not in this PR: playback from the cache in the renderer is #21, next.
Tests: 72 unit tests and 2 integration tests in
client../scripts/local-gates.sh --rust-onlypasses locally.