From ffe820497ffe339792c86cb7d3b92405cfcab915 Mon Sep 17 00:00:00 2001 From: Zain Kabani <77307340+zainkabani@users.noreply.github.com> Date: Fri, 25 Aug 2023 13:33:39 -0400 Subject: [PATCH] Don't unwrap stream.peer_addr() (#562) --- src/client.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/client.rs b/src/client.rs index 3f6ba13f..8ad0d47b 100644 --- a/src/client.rs +++ b/src/client.rs @@ -348,7 +348,15 @@ pub async fn startup_tls( ) -> Result>, WriteHalf>>, Error> { // Negotiate TLS. let tls = Tls::new()?; - let addr = stream.peer_addr().unwrap(); + let addr = match stream.peer_addr() { + Ok(addr) => addr, + Err(err) => { + return Err(Error::SocketError(format!( + "Failed to get peer address: {:?}", + err + ))); + } + }; let mut stream = match tls.acceptor.accept(stream).await { Ok(stream) => stream,