mirror of
https://github.com/euzu/tuliprox.git
synced 2026-10-11 18:32:24 +02:00
IPCheck and config refactor
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
use crate::model::api_proxy::ProxyUserCredentials;
|
||||
use crate::utils::constants::{CONSTANTS, HLS_PREFIX};
|
||||
use crate::utils::crypto_utils::{deobfuscate_text, obfuscate_text};
|
||||
use crate::utils::hash_utils;
|
||||
use crate::model::ProxyUserCredentials;
|
||||
use crate::utils::{CONSTANTS, HLS_PREFIX};
|
||||
use crate::utils::{deobfuscate_text, obfuscate_text, u32_to_base64, base64_to_u32};
|
||||
use std::str;
|
||||
|
||||
fn create_hls_session_token_and_url(secret: &[u8], session_token: u32, stream_url: &str) -> Option<String> {
|
||||
let token = hash_utils::u32_to_base64(session_token);
|
||||
let token = u32_to_base64(session_token);
|
||||
if let Ok(cookie_value) = obfuscate_text(secret, &format!("{token}{stream_url}")) {
|
||||
return Some(cookie_value);
|
||||
}
|
||||
@@ -17,7 +16,7 @@ pub fn get_hls_session_token_and_url_from_token(secret: &[u8], token: &str) -> O
|
||||
if let Ok(decrypted) = deobfuscate_text(secret, token) {
|
||||
let session_token: String = decrypted.chars().take(TOKEN_LEN).collect();
|
||||
let stream_url: String = decrypted.chars().skip(TOKEN_LEN).collect();
|
||||
return Some((hash_utils::base64_to_u32(&session_token), stream_url));
|
||||
return Some((base64_to_u32(&session_token), stream_url));
|
||||
}
|
||||
None
|
||||
}
|
||||
@@ -102,13 +101,13 @@ pub fn rewrite_hls(user: &ProxyUserCredentials, props: &RewriteHlsProps) -> Stri
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use rand::RngCore;
|
||||
use crate::utils::hash_utils;
|
||||
use crate::utils::u32_to_base64;
|
||||
|
||||
#[test]
|
||||
fn test_token_size() {
|
||||
for _i in 0..10_000 {
|
||||
let session_token = rand::rng().next_u32();
|
||||
assert_eq!(hash_utils::u32_to_base64(session_token).len(), 6);
|
||||
assert_eq!(u32_to_base64(session_token).len(), 6);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
use std::borrow::BorrowMut;
|
||||
use crate::model::config::{Config, ConfigInput};
|
||||
use crate::model::playlist::{PlaylistGroup, PlaylistItem, PlaylistItemHeader, PlaylistItemType, XtreamCluster};
|
||||
use crate::utils::hash_utils::extract_id_from_url;
|
||||
use crate::utils::string_utils;
|
||||
use crate::model::{Config, ConfigInput};
|
||||
use crate::model::{PlaylistGroup, PlaylistItem, PlaylistItemHeader, PlaylistItemType, XtreamCluster};
|
||||
use crate::utils::{extract_id_from_url, get_title_group};
|
||||
|
||||
#[inline]
|
||||
fn token_value(stack: &mut String, it: &mut std::str::Chars) -> String {
|
||||
@@ -190,7 +189,7 @@ where
|
||||
header.group = group_value;
|
||||
} else {
|
||||
let current_title = header.title.clone();
|
||||
header.group = string_utils::get_title_group(current_title.as_str());
|
||||
header.group = get_title_group(current_title.as_str());
|
||||
}
|
||||
}
|
||||
visit(item);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use crate::model::config::{EpgNamePrefix, EpgSmartMatchConfig};
|
||||
use crate::model::xmltv::{Epg, TVGuide, XmlTag, EPG_ATTRIB_CHANNEL, EPG_ATTRIB_ID, EPG_TAG_CHANNEL, EPG_TAG_DISPLAY_NAME, EPG_TAG_ICON, EPG_TAG_PROGRAMME, EPG_TAG_TV};
|
||||
use crate::model::{EpgNamePrefix, EpgSmartMatchConfig};
|
||||
use crate::model::{Epg, TVGuide, XmlTag, EPG_ATTRIB_CHANNEL, EPG_ATTRIB_ID, EPG_TAG_CHANNEL, EPG_TAG_DISPLAY_NAME, EPG_TAG_ICON, EPG_TAG_PROGRAMME, EPG_TAG_TV};
|
||||
use crate::processing::processor::epg::EpgIdCache;
|
||||
use crate::utils::compression::compressed_file_reader::CompressedFileReader;
|
||||
use crate::utils::constants::CONSTANTS;
|
||||
use crate::utils::compressed_file_reader::CompressedFileReader;
|
||||
use crate::utils::CONSTANTS;
|
||||
use deunicode::deunicode;
|
||||
use quick_xml::events::{BytesStart, BytesText, Event};
|
||||
use quick_xml::Reader;
|
||||
@@ -439,7 +439,7 @@ pub fn flatten_tvguide(tv_guides: &[Epg]) -> Option<Epg> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::model::config::{EpgNamePrefix, EpgSmartMatchConfig};
|
||||
use crate::model::{EpgNamePrefix, EpgSmartMatchConfig};
|
||||
use crate::processing::parser::xmltv::normalize_channel_name;
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
use crate::m3u_filter_error::{create_m3u_filter_error_result, M3uFilterError, M3uFilterErrorKind};
|
||||
use crate::model::config::ConfigInput;
|
||||
use crate::model::playlist::{PlaylistGroup, PlaylistItem, PlaylistItemHeader, PlaylistItemType, XtreamCluster};
|
||||
use crate::model::xtream::{XtreamCategory, XtreamSeriesInfo, XtreamSeriesInfoEpisode, XtreamStream};
|
||||
use crate::utils::hash_utils::generate_playlist_uuid;
|
||||
use crate::utils::network::xtream::{get_xtream_stream_url_base};
|
||||
use crate::model::ConfigInput;
|
||||
use crate::model::{PlaylistGroup, PlaylistItem, PlaylistItemHeader, PlaylistItemType, XtreamCluster};
|
||||
use crate::model::{XtreamCategory, XtreamSeriesInfo, XtreamSeriesInfoEpisode, XtreamStream};
|
||||
use crate::utils::generate_playlist_uuid;
|
||||
use crate::utils::xtream::{get_xtream_stream_url_base};
|
||||
use serde_json::Value;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use crate::model::xtream_const;
|
||||
|
||||
fn map_to_xtream_category(categories: &Value) -> Result<Vec<XtreamCategory>, M3uFilterError> {
|
||||
match serde_json::from_value::<Vec<XtreamCategory>>(categories.to_owned()) {
|
||||
@@ -92,7 +91,7 @@ pub fn get_xtream_url(xtream_cluster: XtreamCluster, url: &str,
|
||||
format!("{url}/movie/{username}/{password}/{stream_id}.{ext}")
|
||||
}
|
||||
XtreamCluster::Series =>
|
||||
format!("{}&action={}&series_id={stream_id}", get_xtream_stream_url_base(url, username, password), xtream_const::XC_ACTION_GET_SERIES_INFO)
|
||||
format!("{}&action={}&series_id={stream_id}", get_xtream_stream_url_base(url, username, password), crate::model::XC_ACTION_GET_SERIES_INFO)
|
||||
};
|
||||
stream_base_url
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user