2025-07-26 16:49:47 +03:30
|
|
|
pub mod data;
|
2023-10-17 17:27:24 +03:30
|
|
|
mod models;
|
2025-07-26 16:49:47 +03:30
|
|
|
use crate::{config_models::*, utils::parse_raw_json};
|
2023-10-14 11:01:28 +03:30
|
|
|
|
2023-10-20 17:14:56 +03:30
|
|
|
pub fn create_outbound_object(data: models::VlessData) -> Outbound {
|
2025-07-26 13:46:08 +03:30
|
|
|
let network_type = data.query.r#type.clone().unwrap_or(String::from(""));
|
2023-10-14 11:30:03 +03:30
|
|
|
return Outbound {
|
2023-10-14 11:01:28 +03:30
|
|
|
protocol: String::from("vless"),
|
|
|
|
|
tag: String::from("proxy"),
|
2023-10-19 10:04:12 +03:30
|
|
|
streamSettings: StreamSettings {
|
2023-10-19 11:53:28 +03:30
|
|
|
network: data.query.r#type.clone(),
|
2023-10-19 10:04:12 +03:30
|
|
|
security: data.query.security.clone(),
|
2025-07-26 13:46:08 +03:30
|
|
|
tlsSettings: if network_type == String::from("tls") {
|
2023-10-19 10:04:12 +03:30
|
|
|
Some(TlsSettings {
|
2025-07-26 13:46:08 +03:30
|
|
|
alpn: data.query.alpn.map(|alpn| vec![alpn]),
|
2023-10-19 10:04:12 +03:30
|
|
|
rejectUnknownSni: None,
|
|
|
|
|
enableSessionResumption: None,
|
|
|
|
|
minVersion: None,
|
|
|
|
|
maxVersion: None,
|
|
|
|
|
cipherSuites: None,
|
|
|
|
|
disableSystemRoot: None,
|
|
|
|
|
preferServerCipherSuites: None,
|
2025-07-26 13:46:08 +03:30
|
|
|
fingerprint: data.query.fp.clone(),
|
|
|
|
|
serverName: data.query.sni.clone(),
|
2023-10-19 10:04:12 +03:30
|
|
|
allowInsecure: Some(false),
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
None
|
|
|
|
|
},
|
2025-07-26 13:46:08 +03:30
|
|
|
wsSettings: if network_type == String::from("ws") {
|
2023-10-19 11:53:28 +03:30
|
|
|
Some(WsSettings {
|
2025-07-26 16:32:53 +03:30
|
|
|
Host: data.query.host.clone(),
|
|
|
|
|
path: data.query.path.clone(),
|
2023-10-19 11:53:28 +03:30
|
|
|
acceptProxyProtocol: None,
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
None
|
|
|
|
|
},
|
2025-07-26 13:46:08 +03:30
|
|
|
tcpSettings: if network_type == String::from("tcp") {
|
2023-10-19 11:57:44 +03:30
|
|
|
Some(TCPSettings {
|
2025-07-23 21:00:07 +03:30
|
|
|
header: Some(TCPHeader {
|
2025-07-26 13:46:08 +03:30
|
|
|
r#type: Some(data.query.header_type.unwrap_or(String::from("none"))),
|
2023-10-19 11:57:44 +03:30
|
|
|
}),
|
|
|
|
|
acceptProxyProtocol: None,
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
None
|
|
|
|
|
},
|
2025-07-26 13:46:08 +03:30
|
|
|
realitySettings: if network_type == String::from("reality") {
|
2023-10-19 15:26:41 +03:30
|
|
|
Some(RealitySettings {
|
|
|
|
|
publicKey: data.query.pbk,
|
|
|
|
|
serverName: data.query.sni.clone(),
|
|
|
|
|
shortId: data.query.sid,
|
2025-07-26 13:46:08 +03:30
|
|
|
spiderX: Some(String::from("")),
|
|
|
|
|
fingerprint: data.query.fp.clone(),
|
2023-10-19 15:26:41 +03:30
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
None
|
|
|
|
|
},
|
2025-07-26 13:46:08 +03:30
|
|
|
grpcSettings: if network_type == String::from("grpc") {
|
2023-10-21 11:42:12 +03:30
|
|
|
Some(GRPCSettings {
|
2025-07-26 13:46:08 +03:30
|
|
|
authority: data.query.authority,
|
|
|
|
|
multiMode: Some(false),
|
2023-10-21 11:42:12 +03:30
|
|
|
serviceName: data.query.service_name,
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
None
|
|
|
|
|
},
|
2025-07-26 13:46:08 +03:30
|
|
|
quicSettings: if network_type == String::from("quic") {
|
2023-10-23 19:13:16 +03:30
|
|
|
Some(QuicSettings {
|
|
|
|
|
header: Some(NonHeaderObject {
|
2025-07-26 13:46:08 +03:30
|
|
|
r#type: Some(String::from("none")),
|
2023-10-23 19:13:16 +03:30
|
|
|
}),
|
2025-07-26 13:46:08 +03:30
|
|
|
security: Some(String::from("none")),
|
|
|
|
|
key: Some(String::from("")),
|
2023-10-23 19:13:16 +03:30
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
None
|
|
|
|
|
},
|
2025-07-26 16:08:27 +03:30
|
|
|
kcpSettings: if network_type == String::from("kcp") {
|
|
|
|
|
Some(KCPSettings {
|
|
|
|
|
mtu: None,
|
|
|
|
|
tti: None,
|
|
|
|
|
congestion: None,
|
|
|
|
|
uplinkCapacity: None,
|
|
|
|
|
readBufferSize: None,
|
|
|
|
|
writeBufferSize: None,
|
|
|
|
|
downlinkCapacity: None,
|
|
|
|
|
seed: data.query.seed,
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
None
|
|
|
|
|
},
|
2025-07-26 16:32:53 +03:30
|
|
|
xhttpSettings: if network_type == String::from("xhttp") {
|
|
|
|
|
Some(XHTTPSettings {
|
|
|
|
|
host: data.query.host.clone(),
|
|
|
|
|
path: data.query.path.clone(),
|
|
|
|
|
mode: data.query.mode,
|
|
|
|
|
extra: data.query.extra.and_then(|e| parse_raw_json(e.as_str())),
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
None
|
|
|
|
|
},
|
2023-10-19 10:04:12 +03:30
|
|
|
},
|
2023-10-14 11:30:03 +03:30
|
|
|
settings: OutboundSettings::Vless(VlessOutboundSettings {
|
2023-10-14 11:01:28 +03:30
|
|
|
vnext: vec![VlessServerObject {
|
|
|
|
|
port: data.address_data.port,
|
|
|
|
|
address: data.address_data.address,
|
|
|
|
|
users: vec![VlessUser {
|
|
|
|
|
id: data.address_data.uuid,
|
|
|
|
|
flow: data.query.flow,
|
2025-07-26 13:46:08 +03:30
|
|
|
encryption: data.query.encryption.unwrap_or(String::from("none")),
|
|
|
|
|
level: Some(0),
|
2023-10-14 11:01:28 +03:30
|
|
|
}],
|
2023-10-12 18:34:01 +03:30
|
|
|
}],
|
2023-10-14 11:30:03 +03:30
|
|
|
}),
|
2023-10-12 18:34:01 +03:30
|
|
|
};
|
|
|
|
|
}
|