From b2bfc5602164162fc8be0ba3b48f919e0b972534 Mon Sep 17 00:00:00 2001 From: Michael SCHAL Date: Sat, 6 Dec 2025 10:15:41 +0100 Subject: [PATCH] feat: implement a Dart web server with API routing, static file serving, Xtream proxy, and authentication. --- bin/server.dart | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/bin/server.dart b/bin/server.dart index 51e9d35..775165a 100644 --- a/bin/server.dart +++ b/bin/server.dart @@ -153,16 +153,26 @@ Handler _createXtreamProxyHandler() { print('Proxying request to: $targetUrl'); - // Use simple http.get/post with timeout + // Headers to simulate a legitimate IPTV client + // Many IPTV servers check User-Agent and Referer to prevent unauthorized access + final proxyHeaders = { + 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36', + 'Accept': '*/*', + 'Accept-Language': 'en-US,en;q=0.9', + 'Referer': baseUrl, + 'Origin': baseUrl, + }; + + // Use simple http.get/post with timeout and proper headers http.Response response; if (request.method == 'GET') { - response = await http.get(targetUrl).timeout( + response = await http.get(targetUrl, headers: proxyHeaders).timeout( const Duration(seconds: 30), onTimeout: () => http.Response('Request timeout', 504), ); } else if (request.method == 'POST') { final body = await request.readAsString(); - response = await http.post(targetUrl, body: body).timeout( + response = await http.post(targetUrl, headers: proxyHeaders, body: body).timeout( const Duration(seconds: 30), onTimeout: () => http.Response('Request timeout', 504), );