From 16522a9653ba21c795e570232e2085eaf6e1a0af Mon Sep 17 00:00:00 2001 From: bnewbold Date: Thu, 2 Jun 2016 22:23:20 -0400 Subject: make client less verbose by defauilt --- src/client.rs | 28 +++++++++++++++++----------- src/main.rs | 8 ++++---- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/client.rs b/src/client.rs index 79a95f7..8697480 100644 --- a/src/client.rs +++ b/src/client.rs @@ -17,11 +17,15 @@ use udt_extras::{UdtStream}; use crypto::{SecretStream, key2string, string2key, nonce2string, string2nonce}; use sodiumoxide::crypto::secretbox; -pub fn run_client(host: &str, local_file: &str, remote_file: &str, remote_is_dir: bool, is_recv: bool, no_crypto: bool) -> Result<(), String> { - println!("\thost: {}", host); - println!("\tlocal_file: {}", local_file); - println!("\tremote_file: {}", remote_file); - println!("\tis_recv: {}", is_recv); +pub fn run_client(host: &str, local_file: &str, remote_file: &str, remote_is_dir: bool, is_recv: bool, no_crypto: bool, verbose: bool) -> Result<(), String> { + + if verbose { + println!("local details:"); + println!("\thost: {}", host); + println!("\tlocal_file: {}", local_file); + println!("\tremote_file: {}", remote_file); + println!("\tis_recv: {}", is_recv); + }; let mut ssh_cmd = Command::new("ssh"); ssh_cmd.arg(host) @@ -57,12 +61,14 @@ pub fn run_client(host: &str, local_file: &str, remote_file: &str, remote_is_dir let remote_read_nonce = words[5]; let remote_write_nonce = words[6]; - println!("Got remote details:"); - println!("\tport: {}", remote_port); - println!("\thost: {}", remote_host); - println!("\tsecret key: {}", remote_secret); - println!("\tsecret read nonce: {}", remote_read_nonce); - println!("\tsecret write nonce: {}", remote_write_nonce); + if verbose { + println!("Got remote details:"); + println!("\tport: {}", remote_port); + println!("\thost: {}", remote_host); + println!("\tsecret key: {}", remote_secret); + println!("\tsecret read nonce: {}", remote_read_nonce); + println!("\tsecret write nonce: {}", remote_write_nonce); + }; let addr = net::IpAddr::from_str(remote_host).unwrap(); let mut socket = UdtSocket::new(udt::SocketFamily::AFInet, udt::SocketType::Stream).unwrap(); diff --git a/src/main.rs b/src/main.rs index dd6f7e9..08cd67e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -42,7 +42,7 @@ fn main() { let mut opts = Options::new(); opts.optflag("h", "help", "print this help menu"); - //opts.optflag("v", "verbose", "more debugging messages"); + opts.optflag("v", "verbose", "more debugging messages"); opts.optflag("r", "recursive", "whether to recursively transfer files (directory)"); opts.optflag("", "no-crypto", "sends data in the clear (no crypto or verification)"); @@ -51,7 +51,7 @@ fn main() { Err(f) => { println!("{}", f.to_string()); usage(opts); exit(-1); } }; - //let verbose: bool = matches.opt_present("v"); + let verbose: bool = matches.opt_present("v"); let recursive: bool = matches.opt_present("r"); let no_crypto: bool = matches.opt_present("no-crypto"); @@ -87,7 +87,7 @@ fn main() { let spl: Vec<&str> = srcfile.split(":").collect(); let host = spl[0]; let remote_file = spl[1]; - ret = client::run_client(host, local_file, remote_file, recursive, is_recv, no_crypto); + ret = client::run_client(host, local_file, remote_file, recursive, is_recv, no_crypto, verbose); }, (false, true) => { let is_recv = false; @@ -95,7 +95,7 @@ fn main() { let spl: Vec<&str> = destfile.split(":").collect(); let host = spl[0]; let remote_file = spl[1]; - ret = client::run_client(host, local_file, remote_file, recursive, is_recv, no_crypto); + ret = client::run_client(host, local_file, remote_file, recursive, is_recv, no_crypto, verbose); }, } -- cgit v1.2.3