Terminal interface to find, download, and stream movies, TV shows, and live TV using local media players.
fix(proxy): allow subtitle host in sidecar proxy whitelist
Samir Hossains9519b9579514
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex f18ef7f..eaef2bf 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -8,6 +8,9 @@- Added multi-dub and language rip resolution supporting original, English, and localized dubs with composite subject ID routing (`{title_id}::{rip}`).- Added `ProviderKind::Dramachi` support across `MovieBoxService`, TUI search, details, stream resolution, downloads, settings, and badges (`[Dramachi]`).### Fixed+- **Stream Proxy Subtitle Whitelist & Scope Isolation**:+ - Permitted external subtitle CDN hosts in `src/proxy.rs` proxy connection validation, preventing HTTP 403 errors when media players fetch external subtitle tracks alongside DASH stream manifests.+ - Scoped authentication headers exclusively to target video hosts, preventing credential spillage to subtitle CDNs.- **Stremio Addon Mode Series Metadata Resolution & Episode Picker**:- Encoded media type hints into Addon catalog and search results (`series:{id}` and `movie:{id}`) in `src/providers/addons/adapter.rs`, preserving search intent across preview prefetching and details resolution.- Hardened metadata probing in `AddonClient::details` (`src/providers/addons/mod.rs`) to prioritize `series` queries and check for episode videos (`!videos.is_empty()`) before falling back to `movie`, resolving an issue where series (e.g. Breaking Bad) fell back to corrupted movie metadata ("Mirror") lacking episode lists.diff --git a/src/proxy.rs b/src/proxy.rsindex 478771a..d7d7d9c 100644--- a/src/proxy.rs+++ b/src/proxy.rs@@ -264,9 +264,12 @@ async fn handle_connection(return Ok(());}};+ let extracted_host = extract_host_authority(&target_url);if let Some(allowed_host) = target_host {- let extracted_host = extract_host_authority(&target_url);- if extracted_host.as_deref() != Some(allowed_host) {+ let sub_host = subtitle_url.and_then(extract_host_authority);+ let is_allowed = extracted_host.as_deref() == Some(allowed_host)+ || (sub_host.is_some() && extracted_host == sub_host);+ if !is_allowed {let response ="HTTP/1.1 403 Forbidden\r\nContent-Length: 0\r\nConnection: close\r\n\r\n";writer.write_all(response.as_bytes()).await?;@@ -279,8 +282,16 @@ async fn handle_connection(_ => client.get(&target_url),};- for (name, val) in auth_headers {- req = req.header(name.as_str(), val.as_str());+ if extracted_host.as_deref() == target_host {+ for (name, val) in auth_headers {+ req = req.header(name.as_str(), val.as_str());+ }+ } else {+ for (name, val) in auth_headers {+ if name.eq_ignore_ascii_case("user-agent") {+ req = req.header(name.as_str(), val.as_str());+ }+ }}if let Some(range) = range_header {req = req.header("Range", range);@@ -539,6 +550,22 @@ mod tests {);assert_eq!(extract_host_authority("not-a-url"), None);}+ #[test]+ fn test_host_whitelist_allows_target_and_subtitle_hosts() {+ let target_host = "video.example.com";+ let subtitle_url = "https://captions.example.com/sub.srt";+ let sub_host = extract_host_authority(subtitle_url);++ let is_allowed = |url: &str| -> bool {+ let host = extract_host_authority(url);+ host.as_deref() == Some(target_host) || (sub_host.is_some() && host == sub_host)+ };++ assert!(is_allowed("https://video.example.com/chunk.m4s"));+ assert!(is_allowed("https://captions.example.com/sub.srt"));+ assert!(!is_allowed("https://evil.example.com/steal"));+ assert!(!is_allowed("https://sub.evil.com/fake"));+ }#[test]fn test_rewrite_dash_manifest_scoped_to_target_host() {