From 7dbd94792dd77910169f9f44933d1e707838be4f Mon Sep 17 00:00:00 2001 From: euzu <33094714+euzu@users.noreply.github.com> Date: Wed, 21 Jan 2026 17:00:13 +0100 Subject: [PATCH] Fixed hls streaming from local files (#530) Fixed hls streaming from local files --- Cargo.lock | 6 ++--- backend/Cargo.toml | 2 +- backend/src/api/api_utils.rs | 35 ++++++++++++++-------------- backend/src/api/endpoints/hls_api.rs | 5 +++- frontend/Cargo.toml | 4 ++-- shared/Cargo.toml | 2 +- 6 files changed, 29 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 311bc7311..c3d1576c1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1156,7 +1156,7 @@ dependencies = [ [[package]] name = "frontend" -version = "3.2.47" +version = "3.2.48" dependencies = [ "anyhow", "base64", @@ -3994,7 +3994,7 @@ dependencies = [ [[package]] name = "shared" -version = "3.2.47" +version = "3.2.48" dependencies = [ "base64", "bitflags 2.10.0", @@ -4569,7 +4569,7 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "tuliprox" -version = "3.2.47" +version = "3.2.48" dependencies = [ "arc-swap", "async-compression", diff --git a/backend/Cargo.toml b/backend/Cargo.toml index 67473354b..b6f3cf516 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tuliprox" -version = "3.2.47" +version = "3.2.48" edition = "2021" rust-version = "1.89.0" diff --git a/backend/src/api/api_utils.rs b/backend/src/api/api_utils.rs index 961a27dca..bc7d7fb7e 100644 --- a/backend/src/api/api_utils.rs +++ b/backend/src/api/api_utils.rs @@ -1090,19 +1090,6 @@ pub async fn local_stream_response( trace!("Try to open stream {}", sanitize_sensitive_info(&pli.url)); } - let Some(library_paths) = app_state.app_config.config.load() - .library.as_ref() - .map(|lib| { - lib.scan_directories - .iter() - .map(|dir| dir.path.clone()) - .collect::>() - }) - else { - return StatusCode::NOT_FOUND.into_response(); - }; - - if connection_permission == UserConnectionPermission::Exhausted { return create_custom_video_stream_response( app_state, @@ -1122,10 +1109,24 @@ pub async fn local_stream_response( } }; - // Verify path is within allowed media directories - // (requires configuration of allowed base paths) - if check_path && !is_path_within_allowed_directories(&path, &library_paths) { - return StatusCode::FORBIDDEN.into_response(); + if check_path { + let Some(library_paths) = app_state.app_config.config.load() + .library.as_ref() + .map(|lib| { + lib.scan_directories + .iter() + .map(|dir| dir.path.clone()) + .collect::>() + }) + else { + return StatusCode::NOT_FOUND.into_response(); + }; + + // Verify path is within allowed media directories + // (requires configuration of allowed base paths) + if !is_path_within_allowed_directories(&path, &library_paths) { + return StatusCode::FORBIDDEN.into_response(); + } } let Ok(mut file) = tokio::fs::File::open(&path).await else { return StatusCode::NOT_FOUND.into_response() }; diff --git a/backend/src/api/endpoints/hls_api.rs b/backend/src/api/endpoints/hls_api.rs index 1303b6259..9ced11844 100644 --- a/backend/src/api/endpoints/hls_api.rs +++ b/backend/src/api/endpoints/hls_api.rs @@ -198,7 +198,10 @@ async fn resolve_stream_channel( ) -> StreamChannel { let unknown = "Unknown".intern(); let mut channel = match get_stream_channel(app_state, target, virtual_id).await { - Some(channel) => channel, + Some(mut channel) => { + channel.url = hls_url.clone(); + channel + }, None => StreamChannel { target_id: target.id, virtual_id, diff --git a/frontend/Cargo.toml b/frontend/Cargo.toml index 56849d1f4..db12a0b98 100644 --- a/frontend/Cargo.toml +++ b/frontend/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "frontend" -version = "3.2.47" +version = "3.2.48" edition = "2021" rust-version = "1.89.0" [dependencies] -shared = { version = "3.2.47", path = "../shared" } +shared = { version = "3.2.48", path = "../shared" } chrono = "0" yew = "0.21" yew-router = "0.18" diff --git a/shared/Cargo.toml b/shared/Cargo.toml index 898bd93c9..7e749ac14 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "shared" -version = "3.2.47" +version = "3.2.48" edition = "2021" rust-version = "1.89.0"