mirror of
https://github.com/house-of-vanity/v2-uri-parser.git
synced 2025-12-15 22:47:52 +00:00
Parse vless header type
This commit is contained in:
@@ -56,10 +56,15 @@ pub struct RealitySettings {
|
||||
pub spiderX: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct TCPHeader {
|
||||
pub r#type: String,
|
||||
}
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct TCPSettings {
|
||||
pub header: Option<NonHeaderObject>,
|
||||
pub header: Option<TCPHeader>,
|
||||
pub acceptProxyProtocol: Option<bool>,
|
||||
}
|
||||
|
||||
|
||||
@@ -44,8 +44,8 @@ pub fn create_outbound_object(data: models::VlessData) -> Outbound {
|
||||
},
|
||||
tcpSettings: if data.query.r#type == String::from("tcp") {
|
||||
Some(TCPSettings {
|
||||
header: Some(NonHeaderObject {
|
||||
r#type: String::from("none"),
|
||||
header: Some(TCPHeader {
|
||||
r#type: data.query.header_type.clone(),
|
||||
}),
|
||||
acceptProxyProtocol: None,
|
||||
})
|
||||
@@ -174,6 +174,22 @@ fn get_parameter_value(query: &Vec<(&str, &str)>, param: &str) -> String {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn vless_tcp_header_test() {
|
||||
let v = "vless://1010501a-ca9a-479c-84d0-1308d97789b5@104.21.25.109:443?security=reality&alpn=http%2F1.1&encryption=none&pbk=testpub&host=mehr14-n.gowow31220.workers.dev&headerType=http&fp=chrome&spx=spideex&type=tcp&flow=xtls-rprx-vision&sni=mehr14-iran-mehr14-iran-mehr14-iran-mehr14-iran-mehr14-iran.gowow31220.workers.dev&sid=testshort#%E2%AD%90%EF%B8%8F%20Telegram%20%3D%20%40z_v2ray";
|
||||
let data = create_outbound_object(get_vless_data(v));
|
||||
assert_eq!(
|
||||
data.streamSettings
|
||||
.tcpSettings
|
||||
.unwrap()
|
||||
.header
|
||||
.unwrap()
|
||||
.r#type,
|
||||
"http"
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn vless_test_2() {
|
||||
let v = "vless://2dc56709-sdfs-sdfs-2234-128904@nwarne.fast-ip.com:80/?type=ws&encryption=none&host=Shuposipet.com&path=%2Fde%3Fed%3D1048#[test]@test";
|
||||
|
||||
Reference in New Issue
Block a user