Skip to content

Commit

Permalink
fix: print public key only when starting server
Browse files Browse the repository at this point in the history
  • Loading branch information
gotlougit committed Oct 26, 2023
1 parent 849b6f6 commit e05b298
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 0 additions & 3 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,6 @@ pub fn get_all_vars() -> Result<Config> {
.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")
Expand Down
8 changes: 7 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::config::Config;
use anyhow::Result;
use base64::{engine::general_purpose, Engine};
use clap::{Parser, Subcommand};

mod client;
Expand Down Expand Up @@ -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?;
Expand All @@ -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!();
}
};
Expand Down

0 comments on commit e05b298

Please sign in to comment.