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 312fc35d..52986787 100644 --- a/rxlib/src/main/java/org/rx/net/socks/BackendRelayHandler.java +++ b/rxlib/src/main/java/org/rx/net/socks/BackendRelayHandler.java @@ -46,11 +46,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) { +// 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); } } diff --git a/rxlib/src/main/java/org/rx/net/socks/ProxyChannelIdleHandler.java b/rxlib/src/main/java/org/rx/net/socks/ProxyChannelIdleHandler.java index 82f7e669..6daf9c40 100644 --- a/rxlib/src/main/java/org/rx/net/socks/ProxyChannelIdleHandler.java +++ b/rxlib/src/main/java/org/rx/net/socks/ProxyChannelIdleHandler.java @@ -1,5 +1,6 @@ package org.rx.net.socks; +import io.netty.channel.Channel; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.timeout.IdleStateEvent; import io.netty.handler.timeout.IdleStateHandler; @@ -17,12 +18,17 @@ public ProxyChannelIdleHandler(int readerIdleTimeSeconds, int writerIdleTimeSeco @SneakyThrows @Override protected void channelIdle(ChannelHandlerContext ctx, IdleStateEvent evt) { - log.info("{} {} idle: {}", Sockets.protocolName(ctx.channel()), ctx.channel(), evt.state()); - SocksContext sc = SocksContext.ctx(ctx.channel()); + Channel channel = ctx.channel(); + if (channel == null) { + return; + } + + log.info("{} {} idle: {}", Sockets.protocolName(channel), channel, evt.state()); + SocksContext sc = SocksContext.ctx(channel); if (sc.onClose != null) { sc.onClose.invoke(); } super.channelIdle(ctx, evt); - Sockets.closeOnFlushed(ctx.channel()); + Sockets.closeOnFlushed(channel); } }