【fix】init route ip

This commit is contained in:
wujiawei
2025-05-13 11:15:21 +08:00
parent a3c88ffa9f
commit 32a641ce99
8 changed files with 119 additions and 14 deletions

View File

@ -8,7 +8,6 @@ import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyByteBuf;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.constant.ProxyMessageType;
import org.framework.lazy.cloud.network.heartbeat.common.constant.TcpMessageType;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
/**
@ -49,13 +48,13 @@ public class NettySocksServerProxyClientRealHandler extends SimpleChannelInbound
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
String visitorId = ChannelAttributeKeyUtils.getVisitorId(ctx.channel());
// 客户端真实通信通道
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(ctx.channel());
if (nextChannel != null) {
Channel transferChannel = ChannelAttributeKeyUtils.getNextChannel(ctx.channel());
if (transferChannel != null&&transferChannel.isActive()) {
// 上报关闭这个客户端的访客通道
NettyProxyMsg closeVisitorMsg = new NettyProxyMsg();
closeVisitorMsg.setType(ProxyMessageType.SOCKS_REPORT_SERVER_PROXY_CLIENT_TRANSFER_CLOSE_);
closeVisitorMsg.setVisitorId(visitorId);
nextChannel.writeAndFlush(closeVisitorMsg);
transferChannel.writeAndFlush(closeVisitorMsg);
}
super.channelInactive(ctx);

View File

@ -35,16 +35,11 @@ public class NettySocksServerProxyClientTransferHandler extends SimpleChannelInb
String clientId = ChannelAttributeKeyUtils.getClientId(ctx.channel());
String visitorId = ChannelAttributeKeyUtils.getVisitorId(ctx.channel());
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(ctx.channel());
Channel realChannel = ChannelAttributeKeyUtils.getNextChannel(ctx.channel());
log.warn("close server proxy client transfer real clientId:{} visitorId:{}", clientId, visitorId);
// 关闭访客
if (nextChannel != null) {
// 上报关闭这个客户端的访客通道
NettyProxyMsg closeVisitorMsg = new NettyProxyMsg();
closeVisitorMsg.setType(ProxyMessageType.SOCKS_REPORT_SERVER_PROXY_CLIENT_TRANSFER_CLOSE_);
closeVisitorMsg.setVisitorId(visitorId);
nextChannel.writeAndFlush(closeVisitorMsg);
// 关闭真实通道
if (realChannel != null) {
realChannel.close();
}
super.channelInactive(ctx);

View File

@ -129,6 +129,7 @@ public class NettySocksServerProxyClientRealSocket {
future.addListener((ChannelFutureListener) futureListener -> {
Channel transferChannel = futureListener.channel();
if (futureListener.isSuccess()) {
log.info("服务端代理客户端socks客户端连接服务端传输通道成功");
realChannel.config().setOption(ChannelOption.AUTO_READ, true);
// 通知服务端访客连接成功
NettyProxyMsg nettyProxyMsg = new NettyProxyMsg();