Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
RockyLOMO committed Dec 8, 2024
1 parent c293773 commit e377477
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
8 changes: 4 additions & 4 deletions rxlib/src/main/java/org/rx/net/socks/BackendRelayHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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);
}
}

0 comments on commit e377477

Please sign in to comment.