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;
|
mod parser;
|
||||||
|
|
||||||
fn main() {
|
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;
|
use std::process::exit;
|
||||||
|
pub mod config_models;
|
||||||
mod uri_identifier;
|
mod uri_identifier;
|
||||||
mod vless;
|
mod vless;
|
||||||
pub mod config_models;
|
|
||||||
pub fn parse(uri: &str) {
|
pub fn parse(uri: &str) {
|
||||||
let protocol = uri_identifier::get_uri_protocol(uri);
|
let protocol = uri_identifier::get_uri_protocol(uri);
|
||||||
match protocol {
|
match protocol {
|
||||||
Some(uri_identifier::Protocols::Vmess) => {
|
Some(uri_identifier::Protocols::Vmess) => {
|
||||||
println!("The protocol was 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(_) => {
|
Some(_) => {
|
||||||
println!("The protocol was recognized");
|
println!("The protocol was recognized");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ mod models;
|
|||||||
use crate::parser::config_models::*;
|
use crate::parser::config_models::*;
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
|
|
||||||
fn create_outbound_object(data: models::VlessData) -> Outbound {
|
pub fn create_outbound_object(data: models::VlessData) -> Outbound {
|
||||||
return Outbound {
|
return Outbound {
|
||||||
protocol: String::from("vless"),
|
protocol: String::from("vless"),
|
||||||
tag: String::from("proxy"),
|
tag: String::from("proxy"),
|
||||||
|
|||||||
Reference in New Issue
Block a user