Skip to content

Commit

Permalink
Don't unwrap stream.peer_addr() (#562)
Browse files Browse the repository at this point in the history
  • Loading branch information
zainkabani authored Aug 25, 2023
1 parent be549f3 commit ffe8204
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,15 @@ pub async fn startup_tls(
) -> Result<Client<ReadHalf<TlsStream<TcpStream>>, WriteHalf<TlsStream<TcpStream>>>, 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,
Expand Down

0 comments on commit ffe8204

Please sign in to comment.