diff --git a/src/config.rs b/src/config.rs index 788bf79..c56bd8a 100644 --- a/src/config.rs +++ b/src/config.rs @@ -57,7 +57,8 @@ fn write_config( Ok(()) } -pub fn add_trusted_key(config_path: &str, key: Vec) -> Result<()> { +pub fn add_trusted_key(key: Vec) -> Result<()> { + let config_path = get_config_path(); let mut conf = get_all_vars().unwrap(); conf.trusted_keys.push(key); let encoded_public_key = general_purpose::STANDARD.encode(conf.public_key); @@ -69,7 +70,7 @@ pub fn add_trusted_key(config_path: &str, key: Vec) -> Result<()> { .collect(); write_config( - config_path, + &config_path, &encoded_public_key, &encoded_private_key, encoded_trusted_keys, diff --git a/src/main.rs b/src/main.rs index 0c62c95..f2c6f35 100644 --- a/src/main.rs +++ b/src/main.rs @@ -66,8 +66,9 @@ async fn main() -> Result<()> { crate::client::run_client(sock, server_addr, &filename, &auth, trusted_keys) .await?; } - Command::AddKey { key: _ } => { - todo!(); + Command::AddKey { key } => { + let decoded_key = general_purpose::STANDARD.decode(key)?; + crate::config::add_trusted_key(decoded_key)?; } }; }