增加序列号
This commit is contained in:
@@ -41,3 +41,4 @@ server_encrypt=["vnt/server_encrypt"]
|
|||||||
ip_proxy=["vnt/ip_proxy"]
|
ip_proxy=["vnt/ip_proxy"]
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
embed-manifest = "1.4.0"
|
embed-manifest = "1.4.0"
|
||||||
|
rand = "0.9.0-alpha.0"
|
||||||
+14
-7
@@ -1,10 +1,17 @@
|
|||||||
// use embed_manifest::{embed_manifest, new_manifest};
|
use std::fs::File;
|
||||||
// use embed_manifest::manifest::ExecutionLevel;
|
use std::io::Write;
|
||||||
|
use rand::Rng;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
////强制用管理员运行貌似体验更差了
|
// 生成随机序列号
|
||||||
// if std::env::var_os("CARGO_CFG_WINDOWS").is_some() {
|
let serial_number = format!("{}-{}-{}",rand::thread_rng().gen_range(100..1000)
|
||||||
// embed_manifest(new_manifest("vnt")
|
,rand::thread_rng().gen_range(100..1000)
|
||||||
// .requested_execution_level(ExecutionLevel::RequireAdministrator)).expect("unable to embed manifest file");
|
,rand::thread_rng().gen_range(100..1000));
|
||||||
// }
|
let generated_code = format!(
|
||||||
|
r#"pub const SERIAL_NUMBER: &str = "{}";"#,
|
||||||
|
serial_number
|
||||||
|
);
|
||||||
|
let dest_path = "src/generated_serial_number.rs";
|
||||||
|
let mut file = File::create(&dest_path).unwrap();
|
||||||
|
file.write_all(generated_code.as_bytes()).unwrap();
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-6
@@ -16,6 +16,7 @@ mod command;
|
|||||||
mod config;
|
mod config;
|
||||||
mod console_out;
|
mod console_out;
|
||||||
mod root_check;
|
mod root_check;
|
||||||
|
mod generated_serial_number;
|
||||||
|
|
||||||
pub fn app_home() -> io::Result<PathBuf> {
|
pub fn app_home() -> io::Result<PathBuf> {
|
||||||
let root_path = match std::env::current_exe() {
|
let root_path = match std::env::current_exe() {
|
||||||
@@ -336,7 +337,7 @@ fn main() {
|
|||||||
(config, cmd)
|
(config, cmd)
|
||||||
};
|
};
|
||||||
println!("version {}", vnt::VNT_VERSION);
|
println!("version {}", vnt::VNT_VERSION);
|
||||||
|
println!("Serial:{}", generated_serial_number::SERIAL_NUMBER);
|
||||||
main0(config, cmd);
|
main0(config, cmd);
|
||||||
std::process::exit(0);
|
std::process::exit(0);
|
||||||
}
|
}
|
||||||
@@ -346,11 +347,14 @@ mod callback;
|
|||||||
fn main0(config: Config, show_cmd: bool) {
|
fn main0(config: Config, show_cmd: bool) {
|
||||||
let vnt_util = Vnt::new(config, callback::VntHandler {}).unwrap();
|
let vnt_util = Vnt::new(config, callback::VntHandler {}).unwrap();
|
||||||
let vnt_c = vnt_util.clone();
|
let vnt_c = vnt_util.clone();
|
||||||
thread::spawn(move || {
|
thread::Builder::new()
|
||||||
if let Err(e) = command::server::CommandServer::new().start(vnt_c) {
|
.name("CommandServer".into())
|
||||||
log::warn!("cmd:{:?}", e);
|
.spawn(move || {
|
||||||
}
|
if let Err(e) = command::server::CommandServer::new().start(vnt_c) {
|
||||||
});
|
log::warn!("cmd:{:?}", e);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.expect("CommandServer");
|
||||||
if show_cmd {
|
if show_cmd {
|
||||||
let mut cmd = String::new();
|
let mut cmd = String::new();
|
||||||
loop {
|
loop {
|
||||||
@@ -406,6 +410,7 @@ fn command(cmd: &str, vnt: &Vnt) -> bool {
|
|||||||
fn print_usage(program: &str, _opts: Options) {
|
fn print_usage(program: &str, _opts: Options) {
|
||||||
println!("Usage: {} [options]", program);
|
println!("Usage: {} [options]", program);
|
||||||
println!("version:{}", vnt::VNT_VERSION);
|
println!("version:{}", vnt::VNT_VERSION);
|
||||||
|
println!("Serial:{}", generated_serial_number::SERIAL_NUMBER);
|
||||||
println!("Options:");
|
println!("Options:");
|
||||||
println!(
|
println!(
|
||||||
" -k <token> {}",
|
" -k <token> {}",
|
||||||
|
|||||||
Reference in New Issue
Block a user