mirror of
https://github.com/R0m1k3/xtremflow.git
synced 2026-10-11 17:30:00 +02:00
fix(server): add direct .ts proxy route for recordings and fix Cascade fall-through
This commit is contained in:
1 parent
2f7d709fe6
commit
a9a1127d6b
2 files changed
+29
-2
No files matched your search
@@ -81,8 +81,8 @@ class ProxyHandler {
|
|||||||
// Only handle /api/xtream/* requests
|
// Only handle /api/xtream/* requests
|
||||||
// CRITICAL: Check path BEFORE anything else so non-proxy requests fall through to static handler
|
// CRITICAL: Check path BEFORE anything else so non-proxy requests fall through to static handler
|
||||||
if (!path.startsWith('api/xtream/')) {
|
if (!path.startsWith('api/xtream/')) {
|
||||||
// Return 404 so Cascade tries next handler (staticHandler)
|
// Return 404 so Cascade tries next handler (streamingRouter)
|
||||||
return Response.notFound('Not an xtream proxy request');
|
return Response.notFound(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: Authentication REMOVED from proxy to allow browser-initiated requests (img src, etc.)
|
// NOTE: Authentication REMOVED from proxy to allow browser-initiated requests (img src, etc.)
|
||||||
|
|||||||
@@ -212,6 +212,33 @@ Handler createLiveStreamHandler(
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Route: /api/live/{streamId}.ts (Direct Proxy for internal recordings or raw playback)
|
||||||
|
router.get('/<streamId>.ts', (Request request, String streamId) async {
|
||||||
|
final playlist = await getPlaylist(request);
|
||||||
|
if (playlist == null) return Response.forbidden('No playlist');
|
||||||
|
|
||||||
|
final targetUrl =
|
||||||
|
'${playlist.dns}/live/${playlist.username}/${playlist.password}/$streamId.ts';
|
||||||
|
print('[Live Proxy] Forwarding $streamId: $targetUrl');
|
||||||
|
|
||||||
|
final client = http.Client();
|
||||||
|
final proxyRequest = http.Request('GET', Uri.parse(targetUrl));
|
||||||
|
proxyRequest.headers['User-Agent'] = 'VLC/3.0.18 LibVLC/3.0.18';
|
||||||
|
proxyRequest.headers['Accept'] = '*/*';
|
||||||
|
|
||||||
|
final response = await client.send(proxyRequest);
|
||||||
|
|
||||||
|
return Response(
|
||||||
|
response.statusCode,
|
||||||
|
body: response.stream,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'video/mp2t',
|
||||||
|
'Access-Control-Allow-Origin': '*',
|
||||||
|
'Connection': 'keep-alive',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
// Route: /api/live/{streamId}/{segment}
|
// Route: /api/live/{streamId}/{segment}
|
||||||
router.get('/<streamId>/<segment>',
|
router.get('/<streamId>/<segment>',
|
||||||
(Request request, String streamId, String segment) async {
|
(Request request, String streamId, String segment) async {
|
||||||
|
|||||||
Reference in new issue
Block a user