From 27a4c7e79c85830d3922533ec7334407137a6aba Mon Sep 17 00:00:00 2001 From: rustdesk Date: Fri, 13 May 2022 20:31:44 +0800 Subject: [PATCH] missed --- src/naming.rs | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/naming.rs diff --git a/src/naming.rs b/src/naming.rs new file mode 100644 index 000000000..38b514f86 --- /dev/null +++ b/src/naming.rs @@ -0,0 +1,40 @@ +mod license; +use hbb_common::ResultType; +use license::*; + +fn gen_name(lic: &License) -> ResultType { + let tmp = serde_json::to_vec::(lic)?; + let tmp = base64::encode_config(tmp, base64::URL_SAFE_NO_PAD); + let tmp: String = tmp.chars().rev().collect(); + Ok(tmp) +} + +fn main() { + let mut args = Vec::new(); + let mut i = 0; + for arg in std::env::args() { + if i > 0 { + args.push(arg); + } + i += 1; + } + let api = if args.len() < 3 { + "".to_owned() + } else { + args[2].clone() + }; + if args.len() >= 2 { + println!( + "rustdesk-licensed-{}.exe", + gen_name(&License { + key: args[0].clone(), + host: args[1].clone(), + api, + }) + .unwrap() + ); + } + if args.len() == 1 { + println!("{:?}", get_license_from_string(&args[0])); + } +}