mirror of
https://github.com/house-of-vanity/v2-uri-parser.git
synced 2025-12-16 06:57:52 +00:00
Parse uri from cmd args
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
mod parser;
|
||||
|
||||
fn main() {
|
||||
parser::parse("vmess://test");
|
||||
let args: Vec<String> = std::env::args().collect();
|
||||
let uri = args.get(1).unwrap();
|
||||
dbg!(uri);
|
||||
parser::parse(uri);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,20 @@
|
||||
use std::process::exit;
|
||||
pub mod config_models;
|
||||
mod uri_identifier;
|
||||
mod vless;
|
||||
pub mod config_models;
|
||||
pub fn parse(uri: &str) {
|
||||
let protocol = uri_identifier::get_uri_protocol(uri);
|
||||
match protocol {
|
||||
Some(uri_identifier::Protocols::Vmess) => {
|
||||
println!("The protocol was vmess");
|
||||
}
|
||||
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);
|
||||
let serialized = serde_json::to_string(&outbound_object).unwrap();
|
||||
println!("The parsed config is :\n{}", serialized);
|
||||
}
|
||||
Some(_) => {
|
||||
println!("The protocol was recognized");
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ mod models;
|
||||
use crate::parser::config_models::*;
|
||||
use std::process::exit;
|
||||
|
||||
fn create_outbound_object(data: models::VlessData) -> Outbound {
|
||||
pub fn create_outbound_object(data: models::VlessData) -> Outbound {
|
||||
return Outbound {
|
||||
protocol: String::from("vless"),
|
||||
tag: String::from("proxy"),
|
||||
|
||||
Reference in New Issue
Block a user