From 5bc1ecb70e568f2d91d61d7e821c765e10b0b87a Mon Sep 17 00:00:00 2001 From: Kevin Cotugno Date: Fri, 30 Nov 2018 11:24:57 -0800 Subject: [PATCH] Fix handling client socket errors --- src/ripper/lib.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/ripper/lib.rs b/src/ripper/lib.rs index c14f05a..a123f42 100644 --- a/src/ripper/lib.rs +++ b/src/ripper/lib.rs @@ -76,18 +76,14 @@ fn parse_ip(host: &str) -> Result { } fn do_request(dest: SocketAddr, socket: &UdpSocket) -> Result { - if socket.connect(dest).is_err() { - return Err(format!( - "Unable to connect: {}", - socket.take_error().unwrap().unwrap() - )); + match socket.connect(dest) { + Ok(_) => (), + Err(err) => return Err(format!("Unable to connect: {}", err)), } - if socket.send(&[]).is_err() { - return Err(format!( - "Failed to send request: {}", - socket.take_error().unwrap().unwrap() - )); + match socket.send(&[]) { + Ok(_) => (), + Err(err) => return Err(format!("Failed to send request: {}", err)), } let mut buf = [0; 1024];