mirror of
https://github.com/R0m1k3/xtremflow.git
synced 2026-10-11 17:30:00 +02:00
feat: Implement Xtream proxy handler with SSRF protection and M3U8 URL rewriting, resolving 502 proxy errors.
This commit is contained in:
1 parent
c9a212ec4f
commit
d0a2a1ee6a
2 files changed
+17
-2
No files matched your search
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user