Add resilience when peer_addr() fails
This commit is contained in:
parent
9e38b82edc
commit
6ccf3a8495
2 changed files with 6 additions and 3 deletions
|
@ -46,7 +46,7 @@ impl ServerConn {
|
||||||
let peer_id = handshake.peer_pk.clone();
|
let peer_id = handshake.peer_pk.clone();
|
||||||
|
|
||||||
let tokio_socket = asyncstd_socket.into_inner();
|
let tokio_socket = asyncstd_socket.into_inner();
|
||||||
let remote_addr = tokio_socket.peer_addr().unwrap();
|
let remote_addr = tokio_socket.peer_addr()?;
|
||||||
|
|
||||||
debug!(
|
debug!(
|
||||||
"Handshake complete (server) with {}@{}",
|
"Handshake complete (server) with {}@{}",
|
||||||
|
@ -160,7 +160,7 @@ impl ClientConn {
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let tokio_socket = asyncstd_socket.into_inner();
|
let tokio_socket = asyncstd_socket.into_inner();
|
||||||
let remote_addr = tokio_socket.peer_addr().unwrap();
|
let remote_addr = tokio_socket.peer_addr()?;
|
||||||
|
|
||||||
debug!(
|
debug!(
|
||||||
"Handshake complete (client) with {}@{}",
|
"Handshake complete (client) with {}@{}",
|
||||||
|
|
|
@ -210,7 +210,10 @@ impl NetApp {
|
||||||
let (socket, _) = listener.accept().await.unwrap();
|
let (socket, _) = listener.accept().await.unwrap();
|
||||||
info!(
|
info!(
|
||||||
"Incoming connection from {}, negotiating handshake...",
|
"Incoming connection from {}, negotiating handshake...",
|
||||||
socket.peer_addr().unwrap()
|
match socket.peer_addr() {
|
||||||
|
Ok(x) => format!("{}", x),
|
||||||
|
Err(e) => format!("<invalid addr: {}>", e),
|
||||||
|
}
|
||||||
);
|
);
|
||||||
let self2 = self.clone();
|
let self2 = self.clone();
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
|
|
Loading…
Reference in a new issue