diff --git a/src/client.rs b/src/client.rs index f8672e5..f237fe5 100644 --- a/src/client.rs +++ b/src/client.rs @@ -21,6 +21,7 @@ pub struct ClientParams<'a> { pub modem_port: Option<&'a str>, pub modem_baud: Option, pub modem_init: Option<&'a str>, + pub rate_limit_sleep: u64, } fn connect(params: &ClientParams) -> Connection { @@ -101,6 +102,7 @@ pub fn client(params: ClientParams) { let mut id = 0; let mut last_keep_alive = SystemTime::now(); loop { + thread::sleep(Duration::from_millis(params.rate_limit_sleep)); let mut did_anything = false; if last_keep_alive.elapsed().unwrap().as_secs() >= 60 { diff --git a/src/main.rs b/src/main.rs index 97dd997..fde1010 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,21 +4,18 @@ use revpfw3::{client, server, ClientParams}; fn main() { let args: Vec<_> = env::args().skip(1).collect(); - if (6..=10).contains(&args.len()) && args[0] == "client" { + if (6..=11).contains(&args.len()) && args[0] == "client" { client(ClientParams { server_ip: &args[1], server_port: args[2].parse().unwrap(), dest_ip: &args[3], dest_port: args[4].parse().unwrap(), key: &args[5], - sleep_delay_ms: if args.len() == 7 { - args[6].parse().unwrap() - } else { - 1 - }, + sleep_delay_ms: args.get(6).map(|x| x.parse().unwrap()).unwrap_or(1), modem_port: args.get(7).map(|x| x.as_str()), modem_baud: args.get(8).map(|x| x.parse().unwrap()), modem_init: args.get(9).map(|x| x.as_str()), + rate_limit_sleep: args.get(10).map(|x| x.parse().unwrap()).unwrap_or(0), }); } if (3..=4).contains(&args.len()) && args[0] == "server" {