feat: Implement Xtream proxy handler with SSRF protection and M3U8 URL rewriting, resolving 502 proxy errors.

This commit is contained in:
Michael committed 2026-03-09 14:00:28 +01:00
1 parent c9a212ec4f
commit d0a2a1ee6a
2 files changed
+17 -2

No files matched your search

+16 -2
View File
@@ -13,9 +13,7 @@ class ProxyHandler {
static const _allowedHeaders = [
'content-type',
'content-length',
'content-range',
'transfer-encoding',
'accept-ranges',
'cache-control',
];
@@ -134,6 +132,7 @@ class ProxyHandler {
final client = http.Client();
try {
print('[Proxy] Forwarding to: $targetUrl');
final proxyRequest = http.Request(request.method, targetUrl);
proxyRequest.headers.addAll(proxyHeaders);
proxyRequest.followRedirects = true;
@@ -157,6 +156,21 @@ class ProxyHandler {
}
}
// Special case for API requests (JSON list of channels etc.)
// If it's not a Range request and looks like JSON, read it fully
final isJson =
response.headers['content-type']?.contains('json') == true;
final isRange = request.headers.containsKey('range');
if (isJson && !isRange) {
final bytes = await response.stream.toBytes();
return Response(
response.statusCode,
body: bytes,
headers: responseHeaders,
);
}
return Response(
response.statusCode,
body: response.stream,
+1
View File
@@ -22,6 +22,7 @@ Refonte du Guide TV pour inclure les catégories et corriger l'EPG.
- [x] Correction Connectivité Mobile (Auto-origin + Manuel Override)
- [x] Compatibilité Streaming iOS (HLS Live + Proxy Streaming)
- [x] Correction Chemins HLS Relatifs (Bug chemins absolus FFmpeg)
- [x] Résolution Erreur 502 Proxy (Nettoyage Headers + API Buffer)
## Progress Log