Files
v2ray-proxy/src/utils/mod.rs

29 lines
780 B
Rust
Raw Normal View History

2023-11-09 12:41:09 +03:30
pub mod inbound_generator;
2025-07-26 16:49:47 +03:30
2025-07-27 20:32:12 +03:30
pub fn url_decode_str(value: &str) -> Option<String> {
2025-12-01 01:48:36 +02:00
urlencoding::decode(value)
2025-07-27 20:32:12 +03:30
.ok()
2025-12-01 01:48:36 +02:00
.map(|decoded| decoded.into_owned())
2025-07-27 20:32:12 +03:30
}
2025-07-26 16:49:47 +03:30
pub fn url_decode(value: Option<String>) -> Option<String> {
2025-12-01 01:48:36 +02:00
value.and_then(|s| {
2025-07-26 16:49:47 +03:30
urlencoding::decode(&s)
.ok()
.map(|decoded| decoded.into_owned())
2025-12-01 01:48:36 +02:00
})
2025-07-26 16:49:47 +03:30
}
pub fn parse_raw_json(input: &str) -> Option<serde_json::Value> {
serde_json::from_str::<serde_json::Value>(input)
.ok()
.and_then(|v| match v {
serde_json::Value::Object(_) => Some(v),
_ => None,
})
}
pub fn get_parameter_value(query: &Vec<(&str, &str)>, param: &str) -> Option<String> {
2025-12-01 01:52:06 +02:00
query.iter().find(|q| q.0 == param).map(|q| q.1.to_string())
2025-07-26 16:49:47 +03:30
}