rustdesk/src/naming.rs

29 lines
897 B
Rust
Raw Normal View History

2024-02-26 18:12:28 +08:00
mod custom_server;
use hbb_common::{ResultType, base64::{engine::general_purpose::URL_SAFE_NO_PAD, Engine as _}};
2024-02-26 18:12:28 +08:00
use custom_server::*;
2022-05-13 20:31:44 +08:00
2024-02-26 18:12:28 +08:00
fn gen_name(lic: &CustomServer) -> ResultType<String> {
let tmp = URL_SAFE_NO_PAD.encode(&serde_json::to_vec(lic)?);
Ok(tmp.chars().rev().collect())
2022-05-13 20:31:44 +08:00
}
fn main() {
let args: Vec<_> = std::env::args().skip(1).collect();
let api = args.get(2).cloned().unwrap_or_default();
2024-02-17 00:24:58 +08:00
let relay = args.get(3).cloned().unwrap_or_default();
2022-05-13 20:31:44 +08:00
if args.len() >= 2 {
2024-02-26 18:12:28 +08:00
match gen_name(&CustomServer {
key: args[0].clone(),
host: args[1].clone(),
api,
2024-02-17 00:24:58 +08:00
relay,
}) {
2024-02-26 18:12:28 +08:00
Ok(name) => println!("rustdesk-custom_serverd-{}.exe", name),
Err(e) => println!("{:?}", e),
}
2022-05-13 20:31:44 +08:00
}
if args.len() == 1 {
2024-02-26 18:12:28 +08:00
println!("{:?}", get_custom_server_from_string(&args[0]));
2022-05-13 20:31:44 +08:00
}
}