From 06d2cdef7802db7362f425f389144e4d73ffb831 Mon Sep 17 00:00:00 2001 From: Alexey <247128645+axkurcom@users.noreply.github.com> Date: Sat, 21 Feb 2026 16:12:19 +0300 Subject: [PATCH] ME Connection lost fixes --- src/main.rs | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/src/main.rs b/src/main.rs index 7c30aab..a9b0e0a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -940,42 +940,39 @@ match crate::transport::middle_proxy::fetch_proxy_secret(proxy_secret_path).awai .run() .await { - let peer_closed = match &e { - crate::error::ProxyError::Io(ioe) => { - matches!( + let peer_closed = matches!( + &e, + crate::error::ProxyError::Io(ioe) + if matches!( ioe.kind(), std::io::ErrorKind::ConnectionReset | std::io::ErrorKind::ConnectionAborted | std::io::ErrorKind::BrokenPipe | std::io::ErrorKind::NotConnected ) - } + ) || matches!( + &e, crate::error::ProxyError::Stream( - crate::error::StreamError::Io(ioe), - ) => { - matches!( + crate::error::StreamError::Io(ioe) + ) + if 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" - ); + let me_closed = matches!( + &e, + crate::error::ProxyError::Proxy(msg) if msg == "ME connection lost" + ); + + match (peer_closed, me_closed) { + (true, _) => debug!(peer = %peer_addr, error = %e, "Connection closed by client"), + (_, true) => warn!(peer = %peer_addr, error = %e, "Connection closed: Middle-End dropped session"), + _ => warn!(peer = %peer_addr, error = %e, "Connection closed with error"), } } });