feat(stream): debrid passthrough for mode=stream tasks (external players)

handleStreamTask now serves a mode=stream task FROM a resolved debrid HTTPS link
(when the web set preferredMethod=debrid + the torrent is cached) instead of
joining the P2P swarm — served over the SAME /stream endpoint so VLC and other
external players consume it identically (and far faster). No HLS transcode:
external players handle any container. Falls through to the P2P StreamEngine
when there is no direct URL. Uses the mutex-safe SetStreamURL setter.

Also widen the debrid HEAD size-probe timeout 10s -> 15s to match the transport's
TLS handshake budget, so a slow CDN no longer trips it and falls back to a
guessed size.

Bump 1.0.2-beta.
This commit is contained in:
Deivid Soto 2026-06-03 22:43:43 +02:00
parent 8e37293b7d
commit aba20e2078
4 changed files with 64 additions and 2 deletions

View file

@ -304,7 +304,10 @@ func (r *debridRangeReader) reopen() error {
// size the web reported. A short timeout keeps a slow/HEAD-hostile CDN from
// stalling session setup — the fallback size is good enough to start.
func debridHeadSize(ctx context.Context, url string) (int64, bool) {
hctx, cancel := context.WithTimeout(ctx, 10*time.Second)
// 15s (not 10s): the transport's TLS handshake budget alone is 15s, so a
// slow debrid CDN could trip the old 10s timeout before headers arrived,
// needlessly falling back to a guessed size.
hctx, cancel := context.WithTimeout(ctx, 15*time.Second)
defer cancel()
req, err := http.NewRequestWithContext(hctx, http.MethodHead, url, nil)
if err != nil {