2024-02-26 18:12:28 +08:00
|
|
|
mod custom_server;
|
2023-03-09 17:22:14 +08:00
|
|
|
use base64::{engine::general_purpose::URL_SAFE_NO_PAD, Engine as _};
|
2022-05-13 20:31:44 +08:00
|
|
|
use hbb_common::ResultType;
|
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> {
|
2023-04-01 10:09:35 +08:00
|
|
|
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() {
|
2023-04-01 10:23:25 +08:00
|
|
|
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 {
|
2023-07-22 14:16:41 +08:00
|
|
|
key: args[0].clone(),
|
|
|
|
host: args[1].clone(),
|
|
|
|
api,
|
2024-02-17 00:24:58 +08:00
|
|
|
relay,
|
2023-07-22 14:16:41 +08:00
|
|
|
}) {
|
2024-02-26 18:12:28 +08:00
|
|
|
Ok(name) => println!("rustdesk-custom_serverd-{}.exe", name),
|
2023-07-22 14:16:41 +08:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|