mirror of
https://github.com/house-of-vanity/v2-uri-parser.git
synced 2025-12-16 06:57:52 +00:00
Generate full conifg for vless
This commit is contained in:
@@ -21,7 +21,6 @@ fn main() {
|
||||
}
|
||||
};
|
||||
println!("the uri is: {}", cli.uri);
|
||||
// let args: Vec<String> = std::env::args().collect();
|
||||
// let uri = args.get(1).unwrap();
|
||||
// parser::parse(uri);
|
||||
let json_config = parser::create_json_config(&cli.uri);
|
||||
println!("The json config is: {}" , json_config);
|
||||
}
|
||||
|
||||
@@ -107,3 +107,8 @@ pub struct Outbound {
|
||||
pub protocol: String,
|
||||
pub tag: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct Config {
|
||||
pub outbounds: Vec<Outbound>,
|
||||
}
|
||||
|
||||
@@ -1,16 +1,32 @@
|
||||
use std::process::exit;
|
||||
|
||||
use self::config_models::{Config, Outbound};
|
||||
pub mod config_models;
|
||||
mod uri_identifier;
|
||||
mod vless;
|
||||
pub fn parse(uri: &str) {
|
||||
|
||||
pub fn create_json_config(uri: &str) -> String {
|
||||
let config = create_config(uri);
|
||||
let serialized = serde_json::to_string(&config).unwrap();
|
||||
return serialized;
|
||||
}
|
||||
|
||||
pub fn create_config(uri: &str) -> Config {
|
||||
let outbound_object = create_outbound_object(uri);
|
||||
let config = Config {
|
||||
outbounds: vec![outbound_object],
|
||||
};
|
||||
return config;
|
||||
}
|
||||
|
||||
pub fn create_outbound_object(uri: &str) -> Outbound {
|
||||
let protocol = uri_identifier::get_uri_protocol(uri);
|
||||
let mut serialized: String = String::from("");
|
||||
match protocol {
|
||||
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);
|
||||
serialized = serde_json::to_string(&outbound_object).unwrap();
|
||||
return outbound_object;
|
||||
}
|
||||
Some(_) => {
|
||||
println!("The protocol was recognized but is not supported yet");
|
||||
@@ -21,5 +37,4 @@ pub fn parse(uri: &str) {
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
println!("The parsed config is :\n{}", serialized);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user