diff --git a/src/main.rs b/src/main.rs index 0e635de..4bd165d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -938,7 +938,43 @@ match crate::transport::middle_proxy::fetch_proxy_secret(proxy_secret_path).awai .run() .await { - warn!(peer = %peer_addr, error = %e, "Connection closed with error"); + let peer_closed = match &e { + crate::error::ProxyError::Io(ioe) => { + matches!( + ioe.kind(), + std::io::ErrorKind::ConnectionReset + | std::io::ErrorKind::ConnectionAborted + | std::io::ErrorKind::BrokenPipe + | std::io::ErrorKind::NotConnected + ) + } + crate::error::ProxyError::Stream( + crate::error::StreamError::Io(ioe), + ) => { + matches!( + ioe.kind(), + std::io::ErrorKind::ConnectionReset + | std::io::ErrorKind::ConnectionAborted + | std::io::ErrorKind::BrokenPipe + | std::io::ErrorKind::NotConnected + ) + } + _ => false, + }; + + if peer_closed { + debug!( + peer = %peer_addr, + error = %e, + "Connection closed by peer" + ); + } else { + warn!( + peer = %peer_addr, + error = %e, + "Connection closed with error" + ); + } } }); }