From 9117f350688cac7b938f9f4741cf2db67bbe5968 Mon Sep 17 00:00:00 2001 From: wxm <115806199+youfanx@users.noreply.github.com> Date: Mon, 9 Dec 2024 10:39:46 +0800 Subject: [PATCH] Update BackendRelayHandler.java --- .../main/java/org/rx/net/socks/BackendRelayHandler.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/rxlib/src/main/java/org/rx/net/socks/BackendRelayHandler.java b/rxlib/src/main/java/org/rx/net/socks/BackendRelayHandler.java index 52986787..966ca2df 100644 --- a/rxlib/src/main/java/org/rx/net/socks/BackendRelayHandler.java +++ b/rxlib/src/main/java/org/rx/net/socks/BackendRelayHandler.java @@ -7,6 +7,7 @@ import io.netty.handler.proxy.ProxyConnectException; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; +import org.rx.core.Strings; import org.rx.net.Sockets; @Slf4j @@ -46,11 +47,11 @@ public void channelInactive(ChannelHandlerContext ctx) throws Exception { public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { Channel outbound = ctx.channel(); SocksContext sc = SocksContext.ctx(outbound); -// if (cause instanceof ProxyConnectException) { -// log.warn("RELAY {}[{}] => {} thrown\n{}", outbound.remoteAddress(), outbound.localAddress(), sc.inbound.remoteAddress(), cause.getMessage()); -// } else { + if (cause instanceof ProxyConnectException && Strings.lastIndexOf(cause.getMessage(), "timeout") != -1) { + log.warn("RELAY {}[{}] => {} thrown\n{}", outbound.remoteAddress(), outbound.localAddress(), sc.inbound.remoteAddress(), cause.getMessage()); + } else { log.warn("RELAY {}[{}] => {} thrown", outbound.remoteAddress(), outbound.localAddress(), sc.inbound.remoteAddress(), cause); -// } + } Sockets.closeOnFlushed(outbound); } }