Repository navigation
Description
Problem
Silo has no way to stop a stream once it has started. Concurrency limits (users.max_streams) are checked only at admission, in the local API process, and only for streams that ask permission through the normal front door. That leaves three classes of misbehavior we cannot currently answer:
- Bad actors / re-streamers (e.g. Stremio-style). A client can hold a valid 24h stream token and pull bytes indefinitely. If it never reports playback progress — or reports false progress — the server today has no independent, authoritative record that the stream even exists, let alone a way to stop it. "Please stop" is a request the client is free to ignore.
- Concurrency-cap violations across nodes. The admission check lives in one process's memory. In a multi-node deployment (edge proxy/transcode nodes) or with several central replicas, a single user can open more concurrent streams than their
max_streamsallows, because no one is counting the live picture across the whole fleet. - Admin termination doesn't stick. When an operator terminates a session, we send a cooperative realtime "stop" command. A cooperative client stops; an abusive or badly-coded one keeps pulling segments. There is no server-side enforcement that makes a terminate actually terminate.
An operator watching their deployment cannot reliably answer "who is streaming what right now" (integrated single-node deployments were effectively blind to their own sessions), and cannot make a stream stop against a client's will.
Goal
Gain control over stream abuse — concurrency-cap violations, admin termination, and re-streaming abuse — without putting the central database on the per-segment hot path and without changing the client-facing token protocol.
The strategy is deliberately two-part, in order:
-
First-class monitoring first — know about every stream, none hidden, and never trust the client. The server is the one serving the bytes, so it inherently knows a stream is alive. Existence is server-observed on every playback path (integrated + multi-node, native + jellycompat, direct/remux/transcode); it is never gated by a client progress report, so a disguised re-streamer that withholds or falsifies progress is still counted. Monitoring reports to central asynchronously — central (or an edge node) serves the session first, then tells the monitor — so it stays off the hot path. We accept that a stream can run for a few seconds before it shows up; that is fine for a media server.
-
Then a kill switch — stop anything that should be stopped, and keep it dead. Once monitoring is authoritative, enforcement collapses to one action: write a revocation to a small kill list. The kill list lives in memory (integrated) or Redis (multi-node) so that neither integrated nor multi-node deployments have to consult the database on the hot path — the only per-segment addition is an in-memory set-membership check. On a hit the serve surface refuses the request and cuts any in-flight connection. Kills propagate to edges via pub/sub (+ a poll safety net) and take effect within ~120s, which is acceptable.
An async decision engine (the "brain") sits fully off the hot path: it reads the live monitoring picture, compares each user's live count to max_streams, and revokes over-cap victims. Admin terminate and account-session revocation write into the same kill list. Every reason — over-cap, admin terminate, re-streaming heuristic — collapses to the same primitive.
Acceptance criteria
- Authoritative monitoring: a stream that plays while sending no client progress reports still appears in the live picture and still counts against the cap; it ages out on its own once it stops pulling bytes. Coverage is complete across server layout × playback type × route.
- Enforcement off the hot path: the only per-segment cost is an in-memory lookup; no per-segment Redis or Postgres. Existing playback is unaffected when nothing is revoked.
- Kills stick and stay dead: a revoked session stops within ~one poll interval and a reconnect with the same still-valid token is refused. A kill survives a server restart or a Redis flush (otherwise restart-resilient playback would reconstruct and re-serve an already-killed stream).
- Over-cap enforcement: start N+1 concurrent streams for a capped user → the over-cap stream(s) are killed within ~120s and stay dead; under-cap users are untouched; the enforcer fails open on lookup errors (never kills on uncertainty).
- Admin terminate is enforced, not merely requested; account-session revocation also kills the user's live streams.
Non-goals / out of scope
- Turning the 24h stream token into a short-lived play ticket (rejected: Silo's
master.m3u8is a VOD playlist fetched once, so short tickets would expire mid-movie; and flipping the global token TTL is a break-all-playback change that can't be behaviorally verified without real clients). - Replacing the DB-backed
opslogadmin log viewer (see the observability epic Epic: clean, persistent monitoring & observability #265). - Enabling the re-streaming abuse heuristic by default — it ships disabled until tuned against real traffic to avoid false kills.
Related
- Motivating example: [v1] Stremio API Support [v1] Stremio API Support #287.
- Builds on the restart-resilient playback work (PR feat(playback): unified restart-resilient playback (native + jellycompat) #174): the kill list must be at least as durable as the session it kills.
- Touches the sensitive session-reaping path shared with fix(playback): stop seek-restart churn and premature paused-session reaping #279.
- Adjacent operator-visibility work: monitoring & observability epic Epic: clean, persistent monitoring & observability #265.
Activity
bakes82 commentedon Jul 5, 2026
Concurrency limits for things like Stremio do not always make sense because, depending on the client, someone could have a very large cache and download the entire file in seconds or minutes, depending on their internet speed and peering to the server.
I do agree with using short-lived tokens, though. If the goal is to manage or sell Stremio streams, concurrency does not seem like the best way to control usage. Since there is no transcoding involved, traffic-based limits would likely make more sense.
For reference, there are large providers that sell appboxes and also offer Stremio access. From what I have seen, they use short-lived tokens, usually around five minutes give or take. As long as the stream remains active and continues pulling data, it works fine. But if someone tries to reuse the same link after that five-minute window, the key is no longer valid.
fix(playback): user stream revocation is a cutoff, not a 24h ban
fix(jellycompat): close kill-switch coverage holes on compat serve su…
fix(playback): terminate-by-id, admin-list dedupe, real sendfile chai…
fix(playback): latch the revocation cut against rolling write deadlines
fix(playback): close the serve-path monitoring and kill-switch gaps
feat(api): advertise stream monitoring and revocation capabilities
docs(playback): score the serve-path fixes and record the settled dec…
fix(playback): make edge tracking lifecycle-safe and session identity…
docs(playback): score the tracker-lifecycle batch and correct the asy…
fix(playback): make revocation state converge and cutoffs credential-…
docs(playback): score the revocation batch and record its accepted li…
fix(playback): make session liveness server-observed
fix(playback): share the live-stream picture across replicas
test(playback): assert the admin session view omits an unserved last_…
fix(playback): fail closed on transfer-registry saturation
docs(playback): score the liveness/replica batch and record its accep…
docs(playback): correct the claim that restream fingerprints are read…
fix(proxy): resolve edge client IP through the trusted-proxy boundary
Rhainland commentedon Oct 11, 2026
Reproduced the cross-replica part of this on current
main(a6a620cb1) during the #1216 validation, with two API replicas sharing one Postgres and Redis and no remote nodes:POST /api/v2/playback/startfor that account on replica A:playable.capacity_unavailable, as expected.playable.GET /api/v2/admin/sessionson either replica then lists two live sessions for the account. Admission counts only the sessions in the receiving process'sSessionManager(activeCountLocked/transcodeCountLockedininternal/playback/session.go), so each replica grants the account its full allowance. Max transcodes works the same way.#1216 records this as a known limitation for 1.0 and points here instead of opening a separate issue.
[-]Protect against stream abuse: authoritative monitoring + kill switch for cap violations, admin terminate, and re-streaming[/-][+]Stream abuse: enforce stream caps across replicas, and a kill switch for over-cap and terminated sessions[/+]CoffeeKnyte commentedon Oct 28, 2026
Narrowing this to what is left. #306 was closed unmerged, and #667 landed the monitoring half on its own.
Done on
main(564b906):internal/streamtelemetrymeasures bytes on every serving path and merges records across publishers, so a stream shows up whether or not the client reports progress.playback_session_ended.Still missing:
activeCountLockedandtranscodeCountLocked,internal/playback/session.go:1861and:1885), so each API replica grants the fullmax_streamsandmax_transcodes. This is the gap reproduced above and recorded in [v1] Server limits & audit logs #1216.Re-stream detection was closed as a rare edge case in #522. #2283 (admin commands landing on another replica) is related but separate.