From e05b298c3b81fe0c7141dc3dd93eb7b2c63b203b Mon Sep 17 00:00:00 2001 From: Saksham Mittal Date: Thu, 26 Oct 2023 14:26:20 +0530 Subject: [PATCH] fix: print public key only when starting server --- src/config.rs | 3 --- src/main.rs | 8 +++++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/config.rs b/src/config.rs index 1c59238..788bf79 100644 --- a/src/config.rs +++ b/src/config.rs @@ -97,9 +97,6 @@ pub fn get_all_vars() -> Result { .unwrap() .replace('\"', ""); - println!("Your public key is: {}", encoded_public_key); - println!("Please share this key to recipients for establishing a secure connection"); - let public_key = general_purpose::STANDARD.decode(encoded_public_key)?; let encoded_private_key = conf .get("private_key") diff --git a/src/main.rs b/src/main.rs index 5bfb071..0c62c95 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,6 @@ use crate::config::Config; use anyhow::Result; +use base64::{engine::general_purpose, Engine}; use clap::{Parser, Subcommand}; mod client; @@ -51,6 +52,11 @@ async fn main() -> Result<()> { } = crate::config::get_all_vars()?; match cmd { Command::Server { filename, auth } => { + let encoded_public_key = general_purpose::STANDARD.encode(&public_key); + println!("Your public key is: {}", encoded_public_key); + println!( + "Please share this key to recipients for establishing a secure connection" + ); let (serversock, _addr) = crate::nat::get_nat_traversed_socket().await.unwrap(); crate::server::run_server(serversock, &filename, &auth, public_key, private_key) .await?; @@ -60,7 +66,7 @@ async fn main() -> Result<()> { crate::client::run_client(sock, server_addr, &filename, &auth, trusted_keys) .await?; } - Command::AddKey { key } => { + Command::AddKey { key: _ } => { todo!(); } };