fix(stalker): let media transports control seek byte ranges (#1544)

This commit is contained in:
4gray authored and GitHub committed 2026-09-05 20:51:32 +02:00
1 parent d9d6f49757
commit eb3cf89f62
7 files changed
+100 -16

No files matched your search

@@ -7,6 +7,31 @@ import {
describe('stalker playback context', () => {
const macAddress = '00:1A:79:AA:BB:CC';
it.each([
['http://range-portal.test/c/', 'http://range-cdn.test/episode.mkv'],
[
'https://range-downgrade.test/c/',
'http://range-downgrade.test/episode.mkv',
],
['http://range-owned.test/c/', 'http://range-owned.test/episode.mkv'],
])(
'leaves seek byte ranges to the player for %s → %s',
(portalUrl, streamUrl) => {
rememberStalkerPlaybackContext({
streamUrl,
portalUrl,
macAddress,
});
const headers = getStalkerPlaybackContextHeaders(streamUrl);
expect(headers).not.toBeNull();
expect(
Object.keys(headers ?? {}).map((name) => name.toLowerCase())
).not.toContain('range');
}
);
function rememberSameOriginContext(
name: string,
serialNumber?: string
@@ -135,7 +160,8 @@ describe('stalker playback context', () => {
// token; the lookup keys on origin+path so the second link still
// finds its portal headers instead of playing bare.
const firstLink = 'http://tmp-link2.example.test/ch/7?token=first';
const secondLink = 'http://tmp-link2.example.test/ch/7?token=second';
const secondLink =
'http://tmp-link2.example.test/ch/7?token=second';
rememberStalkerPlaybackContext({
streamUrl: firstLink,
portalUrl:
@@ -6,7 +6,6 @@ import {
} from '@iptvnator/shared/interfaces';
const STALKER_STREAM_USER_AGENT = 'KSPlayer';
const STALKER_STREAM_RANGE_HEADER = 'bytes=0-';
const CONTEXT_TTL_MS = 15 * 60 * 1000;
@@ -111,10 +110,10 @@ export function rememberStalkerPlaybackContext(input: {
const headers: Record<string, string> = crossOriginStream
? {
// Align with known working clients for direct tokenized stream URLs.
// Match the renderer's direct profile; the player owns Range
// so each seek can request its own byte offset.
'User-Agent': STALKER_STREAM_USER_AGENT,
Accept: '*/*',
Range: STALKER_STREAM_RANGE_HEADER,
'Icy-MetaData': '1',
Connection: 'keep-alive',
}