mirror of
https://github.com/TeamPiped/piped-proxy.git
synced 2024-08-14 23:50:45 +00:00
Don't include /range/ in hash
See https://github.com/TeamPiped/Piped/issues/3211
This commit is contained in:
parent
19dca8bdd0
commit
e90eebcbd7
1 changed files with 15 additions and 1 deletions
14
src/main.rs
14
src/main.rs
|
@ -4,6 +4,7 @@ use once_cell::sync::Lazy;
|
||||||
use qstring::QString;
|
use qstring::QString;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use reqwest::{Body, Client, Request, Url};
|
use reqwest::{Body, Client, Request, Url};
|
||||||
|
use std::borrow::Cow;
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::io::ErrorKind;
|
use std::io::ErrorKind;
|
||||||
|
@ -184,7 +185,20 @@ async fn index(req: HttpRequest) -> Result<HttpResponse, Box<dyn Error>> {
|
||||||
hasher.update(&value);
|
hasher.update(&value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let range_marker = b"/range/";
|
||||||
|
|
||||||
|
// Find the slice before "/range/"
|
||||||
|
if let Some(position) = path
|
||||||
|
.windows(range_marker.len())
|
||||||
|
.position(|window| window == range_marker)
|
||||||
|
{
|
||||||
|
// Update the hasher with the part of the path before "/range/"
|
||||||
|
// We add +1 to include the "/" in the hash
|
||||||
|
// This is done for DASH streams for the manifests provided by YouTube
|
||||||
|
hasher.update(&path[..(position + 1)]);
|
||||||
|
} else {
|
||||||
hasher.update(&path);
|
hasher.update(&path);
|
||||||
|
}
|
||||||
|
|
||||||
hasher.update(secret.as_bytes());
|
hasher.update(secret.as_bytes());
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue