From 3429ee8bd636c3fd807fb2534973d91c4c117b71 Mon Sep 17 00:00:00 2001 From: lubeilin <1791778603@qq.com> Date: Wed, 20 Sep 2023 16:03:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnt-cli/src/main.rs | 15 +++++++++++---- vnt/src/cipher/cipher.rs | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/vnt-cli/src/main.rs b/vnt-cli/src/main.rs index 26d12b6..ea7adba 100644 --- a/vnt-cli/src/main.rs +++ b/vnt-cli/src/main.rs @@ -214,10 +214,16 @@ fn main() { return; } - let cipher_model = matches - .opt_get::("model") - .unwrap() - .unwrap_or(CipherModel::AesGcm); + let cipher_model = match matches + .opt_get::("model") { + Ok(model) => { + model.unwrap_or(CipherModel::AesGcm) + } + Err(e) => { + println!("'--model ' invalid,{}", e); + return; + } + }; let finger = matches.opt_present("finger"); let punch_model = matches @@ -250,6 +256,7 @@ fn main() { main0(config, !unused_cmd); std::process::exit(0); } + #[tokio::main] async fn main0(config: Config, show_cmd: bool) { let server_encrypt = config.server_encrypt; diff --git a/vnt/src/cipher/cipher.rs b/vnt/src/cipher/cipher.rs index 5dd4840..9998300 100644 --- a/vnt/src/cipher/cipher.rs +++ b/vnt/src/cipher/cipher.rs @@ -28,7 +28,7 @@ impl FromStr for CipherModel { "aes_gcm" => Ok(CipherModel::AesGcm), "aes_cbc" => Ok(CipherModel::AesCbc), "aes_ecb" => Ok(CipherModel::AesEcb), - _ => Err(format!("not match '{}'", s)), + _ => Err(format!("not match '{}', enum:aes_gcm/aes_cbc/aes_ecb", s)), } } }