mirror of
https://github.com/euzu/tuliprox.git
synced 2026-10-12 02:42:30 +02:00
provider and user connection management
This commit is contained in:
@@ -11,6 +11,7 @@ pub struct RewriteHlsProps<'a> {
|
||||
pub virtual_id: u32,
|
||||
pub input_id: u16,
|
||||
pub provider_name: String,
|
||||
pub user_token: String,
|
||||
}
|
||||
|
||||
fn rewrite_hls_url(input: &str, replacement: &str) -> String {
|
||||
@@ -33,7 +34,7 @@ fn rewrite_uri_attrib(line: &str, props: &RewriteHlsProps) -> String {
|
||||
if let Some(caps) = CONSTANTS.re_hls_uri.captures(line) {
|
||||
let uri = &caps[1];
|
||||
let target_url = &rewrite_hls_url(&props.hls_url, uri);
|
||||
if let Some(token) = create_token_for_provider(props.secret, props.virtual_id, &props.provider_name, target_url) {
|
||||
if let Some(token) = create_token_for_provider(props.secret, &props.user_token, props.virtual_id, &props.provider_name, target_url) {
|
||||
return CONSTANTS.re_hls_uri.replace(line, format!(r#"URI="{token}""#)).to_string();
|
||||
}
|
||||
}
|
||||
@@ -58,7 +59,7 @@ pub fn rewrite_hls(user: &ProxyUserCredentials, props: &RewriteHlsProps) -> Stri
|
||||
} else {
|
||||
rewrite_hls_url(&props.hls_url, line)
|
||||
};
|
||||
if let Some(token) = create_token_for_provider(props.secret, props.virtual_id, &props.provider_name, &target_url) {
|
||||
if let Some(token) = create_token_for_provider(props.secret, &props.user_token, props.virtual_id, &props.provider_name, &target_url) {
|
||||
let url = format!(
|
||||
"{}/{HLS_PREFIX}/{}/{}/{}/{}/{}",
|
||||
props.base_url,
|
||||
|
||||
Reference in New Issue
Block a user