2023-10-10 15:01:12 +03:30
|
|
|
use std::process::exit;
|
2023-10-20 17:14:56 +03:30
|
|
|
pub mod config_models;
|
2023-10-10 15:01:12 +03:30
|
|
|
mod uri_identifier;
|
2023-10-10 16:21:20 +03:30
|
|
|
mod vless;
|
2023-10-10 15:01:12 +03:30
|
|
|
pub fn parse(uri: &str) {
|
|
|
|
|
let protocol = uri_identifier::get_uri_protocol(uri);
|
2023-10-23 19:16:58 +03:30
|
|
|
let mut serialized: String = String::from("");
|
2023-10-10 15:01:12 +03:30
|
|
|
match protocol {
|
2023-10-20 17:14:56 +03:30
|
|
|
Some(uri_identifier::Protocols::Vless) => {
|
|
|
|
|
println!("The protocol is Vless");
|
|
|
|
|
let vless_data = vless::get_vless_data(uri);
|
|
|
|
|
let outbound_object = vless::create_outbound_object(vless_data);
|
2023-10-23 19:16:58 +03:30
|
|
|
serialized = serde_json::to_string(&outbound_object).unwrap();
|
2023-10-20 17:14:56 +03:30
|
|
|
}
|
2023-10-10 15:01:12 +03:30
|
|
|
Some(_) => {
|
2023-10-23 19:16:58 +03:30
|
|
|
println!("The protocol was recognized but is not supported yet");
|
|
|
|
|
exit(0);
|
2023-10-10 15:01:12 +03:30
|
|
|
}
|
|
|
|
|
None => {
|
|
|
|
|
println!("The protcol is not supported");
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
2023-10-09 17:59:25 +03:30
|
|
|
}
|
2023-10-23 19:16:58 +03:30
|
|
|
println!("The parsed config is :\n{}", serialized);
|
2023-10-08 21:11:49 +03:30
|
|
|
}
|