From 73eba2a0d687edab5d91e6f35e7262ca2fe5a6c1 Mon Sep 17 00:00:00 2001 From: TudbuT Date: Sat, 13 Aug 2022 04:06:42 +0200 Subject: [PATCH] add option to select bitrate --- src/main.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 697e392..8e23e7a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -233,7 +233,10 @@ fn helper(args: &Vec) { fn sender(args: &Vec) { let connection = holepunch(args); - let mut buf = [0 as u8; 1024]; + let br = u32::from_str_radix(args.get(5).unwrap_or(&"256".to_string()), 10).expect("This is not a correct number"); + let mut buf: Vec = Vec::new(); + buf.resize(br as usize, 0); + let mut buf = buf.leak(); let mut file = File::open(args.get(4).unwrap_or_else(|| { print_args(args); panic!("unreachable") @@ -259,7 +262,10 @@ fn sender(args: &Vec) { fn receiver(args: &Vec) { let connection = holepunch(args); - let mut buf: &[u8] = &[0 as u8; 1024]; + let br = u32::from_str_radix(args.get(5).unwrap_or(&"256".to_string()), 10).expect("This is not a correct number"); + let mut buf: Vec = Vec::new(); + buf.resize(br as usize, 0); + let mut buf: &[u8] = buf.leak(); let mut file = File::create(args.get(4).unwrap_or_else(|| { print_args(args); panic!("unreachable") @@ -343,8 +349,8 @@ fn print_args(args: &Vec) { println!( "No arguments. Needed: \n\ | {} helper \n\ - | {} sender : \n\ - | {} receiver : ", + | {} sender : [bitrate]\n\ + | {} receiver : [bitrate]", f, f, f ); panic!("No arguments");