mirror of
https://github.com/house-of-vanity/v2-uri-parser.git
synced 2025-12-15 22:47:52 +00:00
chore: add protocols enum
This commit is contained in:
17
src/main.rs
17
src/main.rs
@@ -1,3 +1,18 @@
|
||||
use std::process::exit;
|
||||
|
||||
mod parser;
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
let protocol = parser::get_uri_format("vmess://");
|
||||
match protocol {
|
||||
Some(parser::protocols::Vless) => {
|
||||
println!("The protocol was Vless");
|
||||
}
|
||||
Some(_) => {
|
||||
println!("Some recognizable protocol")
|
||||
}
|
||||
None => {
|
||||
println!("The protocol is not supported");
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
18
src/parser/mod.rs
Normal file
18
src/parser/mod.rs
Normal file
@@ -0,0 +1,18 @@
|
||||
pub enum protocols {
|
||||
Vmess,
|
||||
Vless,
|
||||
Shadowsocks,
|
||||
Trojan,
|
||||
Socks,
|
||||
Http,
|
||||
}
|
||||
|
||||
pub fn get_uri_format(uri: &str) -> Option<protocols> {
|
||||
if uri.starts_with("vmess://") {
|
||||
return Some(protocols::Vmess);
|
||||
}
|
||||
if uri.starts_with("vless://") {
|
||||
return Some(protocols::Vless);
|
||||
}
|
||||
return None;
|
||||
}
|
||||
Reference in New Issue
Block a user