Refactor VPN proxy routing and session handling

This commit is contained in:
2026-07-07 22:07:17 +03:00
parent 59f2264a2e
commit 7dbf786c56
25 changed files with 1921 additions and 236 deletions

View File

@@ -45,12 +45,7 @@ fn slug(value: &str, fallback: &str) -> String {
}
fn process_name(value: &str) -> String {
let base = value
.trim()
.rsplit(['\\', '/'])
.next()
.unwrap_or("")
.trim();
let base = value.trim().rsplit(['\\', '/']).next().unwrap_or("").trim();
base.strip_suffix(".exe")
.or_else(|| base.strip_suffix(".EXE"))
.unwrap_or(base)
@@ -62,7 +57,10 @@ pub fn parse_protocol(value: &str) -> Result<Protocol, ValidationError> {
match value.trim().to_ascii_uppercase().as_str() {
"TCP" => Ok(Protocol::Tcp),
"UDP" => Ok(Protocol::Udp),
_ => Err(error("protocols", format!("Неподдерживаемый протокол: {value}"))),
_ => Err(error(
"protocols",
format!("Неподдерживаемый протокол: {value}"),
)),
}
}
@@ -71,7 +69,10 @@ pub fn parse_profile_item_type(value: &str) -> Result<ProfileItemType, Validatio
"process" => Ok(ProfileItemType::Process),
"folder" => Ok(ProfileItemType::Folder),
"exe" => Ok(ProfileItemType::Exe),
_ => Err(error("items.type", format!("Неподдерживаемый тип элемента: {value}"))),
_ => Err(error(
"items.type",
format!("Неподдерживаемый тип элемента: {value}"),
)),
}
}
@@ -149,8 +150,8 @@ pub fn normalize_profile(input: ProfileInput) -> ValidationResult<Profile> {
continue;
}
let recursive = matches!(item_type, ProfileItemType::Folder)
&& raw_item.recursive.unwrap_or(true);
let recursive =
matches!(item_type, ProfileItemType::Folder) && raw_item.recursive.unwrap_or(true);
items.push(ProfileItem {
item_type,
value,