From 6c65232d741229635151671708556b9af7ef75ac Mon Sep 17 00:00:00 2001 From: hozan23 Date: Thu, 4 Jul 2024 14:01:44 +0200 Subject: jsonrpc/server: Remove panic on peer endpoint retrieval during incoming connection handling --- jsonrpc/src/server/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'jsonrpc/src') diff --git a/jsonrpc/src/server/mod.rs b/jsonrpc/src/server/mod.rs index 50a4a8e..ed027f5 100644 --- a/jsonrpc/src/server/mod.rs +++ b/jsonrpc/src/server/mod.rs @@ -113,8 +113,8 @@ impl Server { /// Handles a new connection async fn handle_conn(self: &Arc, conn: Conn) -> Result<()> { - let endpoint = conn.peer_endpoint().expect("get peer endpoint"); - debug!("Handle a new connection {endpoint}"); + let endpoint: Option = conn.peer_endpoint().ok(); + debug!("Handle a new connection {:?}", endpoint); let conn = Arc::new(conn); @@ -171,9 +171,9 @@ impl Server { let chan = channel.clone(); let on_complete = |result: TaskResult>| async move { if let TaskResult::Completed(Err(err)) = result { - error!("Connection {} dropped: {}", endpoint, err); + error!("Connection {:?} dropped: {err}", endpoint); } else { - warn!("Connection {} dropped", endpoint); + warn!("Connection {:?} dropped", endpoint); } // Close the connection channel when the connection dropped chan.close(); -- cgit v1.2.3