【fix】修复客户端渗透客户端问题

This commit is contained in:
wujiawei 2024-09-22 19:22:25 +08:00
parent c04ba09763
commit 1a2b5b8c29
22 changed files with 243 additions and 112 deletions

View File

@ -146,6 +146,12 @@ public class HeartbeatClientConfiguration {
return new ClientHandleDistributeClientPermeateClientInitTypeAdvanced();
}
@Bean
public ClientHandleDistributeClientPermeateClientTransferCloseTypeAdvanced clientHandleDistributeClientPermeateClientTransferCloseTypeAdvanced() {
return new ClientHandleDistributeClientPermeateClientTransferCloseTypeAdvanced();
}
@Bean
public ClientHandleDistributeSingleClientRealConnectTypeAdvanced clientHandleDistributeSingleClientRealConnectTypeAdvanced(NettyClientProperties nettyClientProperties,
List<HandleChannelTypeAdvanced> handleChannelTypeAdvancedList) {

View File

@ -0,0 +1,42 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.advanced;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
import org.framework.lazy.cloud.network.heartbeat.client.netty.socket.NettyClientPermeateClientVisitorSocket;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.client.AbstractHandleDistributeClientPermeateClientTransferCloseTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.wu.framework.spring.utils.SpringContextHolder;
import java.util.ArrayList;
import java.util.List;
/**
* 下发客户端渗透客户端通信通道关闭
*
* @see MessageTypeEnums#DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE
*/
@Slf4j
public class ClientHandleDistributeClientPermeateClientTransferCloseTypeAdvanced extends AbstractHandleDistributeClientPermeateClientTransferCloseTypeAdvanced<NettyProxyMsg> {
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
// 关闭客户端真实通道访客通道
Channel realChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
realChannel.close();// 真实通道关闭
channel.close(); // 数据传输通道关闭
}
}

View File

@ -14,7 +14,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeK
* 下发客户端渗透客户端数据传输
*
*
* @see MessageTypeEnums#DISTRIBUTE_CLIENT_TRANSFER_CLIENT_REQUEST
* @see MessageTypeEnums#DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_REQUEST
*/
@Slf4j
public class ClientHandleDistributeClientTransferClientRequestTypeAdvanced extends AbstractHandleDistributeClientTransferClientRequestTypeAdvanced<NettyProxyMsg> {

View File

@ -14,7 +14,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeK
* 下发客户端渗透客户端数据传输响应
*
*
* @see MessageTypeEnums#DISTRIBUTE_CLIENT_TRANSFER_CLIENT_RESPONSE
* @see MessageTypeEnums#DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_RESPONSE
*/
@Slf4j
public class ClientHandleDistributeClientTransferClientResponseTypeAdvanced extends AbstractHandleDistributeClientTransferClientResponseTypeAdvanced<NettyProxyMsg> {

View File

@ -30,7 +30,6 @@ public class NettyClientPermeateClientRealHandler extends SimpleChannelInboundHa
Integer visitorPort = ChannelAttributeKeyUtils.getVisitorPort(ctx.channel());
String clientId = ChannelAttributeKeyUtils.getClientId(ctx.channel());
// 访客通信通道 上报服务端代理完成
Channel visitorChannel = NettyCommunicationIdContext.getVisitor(visitorId);
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(ctx.channel());
NettyProxyMsg returnMessage = new NettyProxyMsg();
returnMessage.setType(MessageType.REPORT_CLIENT_TRANSFER_CLIENT_RESPONSE);
@ -50,16 +49,15 @@ public class NettyClientPermeateClientRealHandler extends SimpleChannelInboundHa
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
String clientId = ChannelAttributeKeyUtils.getClientId(ctx.channel());
String visitorId = ChannelAttributeKeyUtils.getVisitorId(ctx.channel());
// 客户端真实通信通道
Channel visitor = NettyCommunicationIdContext.getVisitor(visitorId);
if (visitor != null) {
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(ctx.channel());
if (nextChannel != null) {
// 上报关闭这个客户端的访客通道
NettyProxyMsg closeVisitorMsg = new NettyProxyMsg();
closeVisitorMsg.setType(MessageType.REPORT_SINGLE_CLIENT_CLOSE_VISITOR);
closeVisitorMsg.setType(MessageType.REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE);
closeVisitorMsg.setVisitorId(visitorId);
visitor.writeAndFlush(closeVisitorMsg);
nextChannel.writeAndFlush(closeVisitorMsg);
}
super.channelInactive(ctx);
@ -68,16 +66,14 @@ public class NettyClientPermeateClientRealHandler extends SimpleChannelInboundHa
@Override
public void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception {
// 获取访客的传输通道
String visitorId = ChannelAttributeKeyUtils.getVisitorId(ctx.channel());
if(ObjectUtils.isEmpty(visitorId)) {
super.channelWritabilityChanged(ctx);
return;
}
Channel visitorCommunicationChannel = NettyCommunicationIdContext.getVisitor(visitorId);
if (visitorCommunicationChannel != null) {
log.debug("visitorId:{} transfer AUTO_READ:{} ",visitorId,ctx.channel().isWritable());
visitorCommunicationChannel.config().setOption(ChannelOption.AUTO_READ, ctx.channel().isWritable());
if (ctx.channel().isWritable()) {
log.debug("Channel is writable again");
// 恢复之前暂停的操作如写入数据
} else {
log.debug("Channel is not writable");
// 暂停写入操作等待可写状态
}
log.info("channelWritabilityChanged!");
}

View File

@ -43,14 +43,13 @@ public class NettyClientPermeateClientTransferHandler extends SimpleChannelInbou
String clientId = ChannelAttributeKeyUtils.getClientId(ctx.channel());
String visitorId = ChannelAttributeKeyUtils.getVisitorId(ctx.channel());
// 关闭访客
ChannelContext.ClientChannel clientChannel = ChannelContext.get(clientId);
if (clientChannel != null) {
Channel channel = clientChannel.getChannel();
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(ctx.channel());
if (nextChannel != null) {
// 上报关闭这个客户端的访客通道
NettyProxyMsg closeVisitorMsg = new NettyProxyMsg();
closeVisitorMsg.setType(MessageType.REPORT_SINGLE_CLIENT_CLOSE_VISITOR);
closeVisitorMsg.setType(MessageType.REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE);
closeVisitorMsg.setVisitorId(visitorId);
channel.writeAndFlush(closeVisitorMsg);
nextChannel.writeAndFlush(closeVisitorMsg);
}
super.channelInactive(ctx);
@ -58,18 +57,14 @@ public class NettyClientPermeateClientTransferHandler extends SimpleChannelInbou
@Override
public void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception {
// 处理客户端本地真实通道问题
String visitorId = ChannelAttributeKeyUtils.getVisitorId(ctx.channel());
if(ObjectUtils.isEmpty(visitorId)) {
super.channelWritabilityChanged(ctx);
return;
}
Channel realChannel = NettyRealIdContext.getReal(visitorId);
if (realChannel != null) {
log.debug("visitorId:{} transfer AUTO_READ:{} ",visitorId,ctx.channel().isWritable());
realChannel.config().setOption(ChannelOption.AUTO_READ, ctx.channel().isWritable());
if (ctx.channel().isWritable()) {
log.debug("Channel is writable again");
// 恢复之前暂停的操作如写入数据
} else {
log.debug("Channel is not writable");
// 暂停写入操作等待可写状态
}
log.info("channelWritabilityChanged!");
}
@Override

View File

@ -47,7 +47,7 @@ public class NettyClientPermeateClientTransferRealHandler extends SimpleChannelI
// 上报关闭这个客户端的访客通道
NettyProxyMsg closeVisitorMsg = new NettyProxyMsg();
closeVisitorMsg.setType(MessageType.REPORT_CLIENT_PERMEATE_CLIENT_CLOSE);
closeVisitorMsg.setType(MessageType.REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE);
closeVisitorMsg.setVisitorId(visitorId);
nextChannel.writeAndFlush(closeVisitorMsg);
}
@ -58,17 +58,14 @@ public class NettyClientPermeateClientTransferRealHandler extends SimpleChannelI
@Override
public void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception {
// 处理客户端本地真实通道问题
String visitorId = ChannelAttributeKeyUtils.getVisitorId(ctx.channel());
if(ObjectUtils.isEmpty(visitorId)) {
super.channelWritabilityChanged(ctx);
return;
}
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(ctx.channel());
if (nextChannel != null) {
log.debug("visitorId:{} transfer AUTO_READ:{} ",visitorId,ctx.channel().isWritable());
nextChannel.config().setOption(ChannelOption.AUTO_READ, ctx.channel().isWritable());
if (ctx.channel().isWritable()) {
log.debug("Channel is writable again");
// 恢复之前暂停的操作如写入数据
} else {
log.debug("Channel is not writable");
// 暂停写入操作等待可写状态
}
log.info("channelWritabilityChanged!");
}
@Override

View File

@ -17,7 +17,6 @@ import org.framework.lazy.cloud.network.heartbeat.common.NettyCommunicationIdCon
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.NettyRealIdContext;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.wu.framework.core.utils.ObjectUtils;
import java.util.UUID;
@ -77,7 +76,7 @@ public class NettyClientPermeateClientVisitorHandler extends SimpleChannelInboun
Integer visitorPort = internalNetworkClientPermeateClientVisitor.getVisitorPort();
String clientId = internalNetworkClientPermeateClientVisitor.getNettyClientProperties().getClientId();
NettyProxyMsg nettyProxyMsg = new NettyProxyMsg();
nettyProxyMsg.setType(MessageType.REPORT_CLIENT_TRANSFER_CLIENT_REQUEST);
nettyProxyMsg.setType(MessageType.REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_REQUEST);
nettyProxyMsg.setVisitorId(visitorId);
nettyProxyMsg.setClientId(clientId);
nettyProxyMsg.setVisitorPort(visitorPort);
@ -100,11 +99,11 @@ public class NettyClientPermeateClientVisitorHandler extends SimpleChannelInboun
if (nextChannel != null && nextChannel.isActive()) {
nextChannel.config().setOption(ChannelOption.AUTO_READ, true);
// nextChannel.config().setOption(ChannelOption.AUTO_READ, true);
// 通知客户端 关闭访问通道真实通道
NettyProxyMsg myMsg = new NettyProxyMsg();
myMsg.setType(MessageType.REPORT_CLIENT_PERMEATE_CLIENT_CLOSE);
myMsg.setType(MessageType.REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE);
nextChannel.writeAndFlush(myMsg);
}
// 关闭 访客通信通道访客真实通道
@ -117,18 +116,6 @@ public class NettyClientPermeateClientVisitorHandler extends SimpleChannelInboun
@Override
public void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception {
// 获取访客的传输通道
String visitorId = ChannelAttributeKeyUtils.getVisitorId(ctx.channel());
if(ObjectUtils.isEmpty(visitorId)) {
super.channelWritabilityChanged(ctx);
return;
}
Channel visitorCommunicationChannel = NettyCommunicationIdContext.getVisitor(visitorId);
if (visitorCommunicationChannel != null) {
log.debug("visitorId:{} transfer AUTO_READ:{} ",visitorId,ctx.channel().isWritable());
visitorCommunicationChannel.config().setOption(ChannelOption.AUTO_READ, ctx.channel().isWritable());
}
if (ctx.channel().isWritable()) {
log.debug("Channel is writable again");
// 恢复之前暂停的操作如写入数据
@ -136,28 +123,11 @@ public class NettyClientPermeateClientVisitorHandler extends SimpleChannelInboun
log.debug("Channel is not writable");
// 暂停写入操作等待可写状态
}
log.info("visitorId:{} channelWritabilityChanged!",visitorId);
log.info("channelWritabilityChanged!");
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
log.error("exceptionCaught");
Channel channel = ctx.channel();
String clientId = ChannelAttributeKeyUtils.getClientId(channel);
String visitorId = ChannelAttributeKeyUtils.getVisitorId(channel);
// 使用通信通道 下发关闭访客
Channel visitorChannel = NettyCommunicationIdContext.getVisitor(visitorId);
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(ctx.channel());
if (nextChannel != null) {
// 下发关闭访客
NettyProxyMsg closeRealClient = new NettyProxyMsg();
closeRealClient.setType(MessageType.DISTRIBUTE_SINGLE_CLIENT_REAL_CONNECT_AUTO_READ);
closeRealClient.setClientId(clientId);
closeRealClient.setVisitorId(visitorId);
nextChannel.writeAndFlush(closeRealClient);
}
ctx.close();
}
}

View File

@ -141,7 +141,7 @@ public class NettyClientPermeateClientRealSocket {
nettyProxyMsg.setClientTargetIp(clientTargetIp);
nettyProxyMsg.setClientTargetPort(clientTargetPort);
nettyProxyMsg.setVisitorPort(visitorPort);
nettyProxyMsg.setType(MessageType.REPORT_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_INIT_SUCCESSFUL);
nettyProxyMsg.setType(MessageType.REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CHANNEL_INIT_SUCCESSFUL);
visitorChannel.writeAndFlush(nettyProxyMsg);
ChannelAttributeKeyUtils.buildNextChannel(visitorChannel, realChannel);

View File

@ -177,27 +177,36 @@ public class MessageType {
*
* @see MessageTypeEnums#REPORT_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_INIT_SUCCESSFUL
* @see AbstractHandleReportClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced
* @see MessageType#DISTRIBUTE_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_INIT_SUCCESSFUL
* @see MessageType#DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_CHANNEL_INIT_SUCCESSFUL
*/
public static final byte REPORT_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_INIT_SUCCESSFUL = 0X22;
public static final byte REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CHANNEL_INIT_SUCCESSFUL = 0X22;
/**
* 上报客户端渗透客户端数据传输请求
*
* @see MessageTypeEnums#REPORT_CLIENT_TRANSFER_CLIENT_REQUEST
* @see AbstractHandleReportClientTransferClientTypeAdvanced
* @see MessageType#DISTRIBUTE_CLIENT_TRANSFER_CLIENT_REQUEST
* @see MessageType#DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_REQUEST
*/
public static final byte REPORT_CLIENT_TRANSFER_CLIENT_REQUEST = 0X23;
public static final byte REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_REQUEST = 0X23;
/**
* 上报客户端渗透客户端数据传输结果
*
* @see MessageTypeEnums#REPORT_CLIENT_TRANSFER_CLIENT_RESPONSE
* @see AbstractHandleReportClientTransferClientResponseTypeAdvanced
* @see MessageType#DISTRIBUTE_CLIENT_TRANSFER_CLIENT_RESPONSE
* @see MessageType#DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_RESPONSE
*/
public static final byte REPORT_CLIENT_TRANSFER_CLIENT_RESPONSE = 0X24;
/**
* 上报客户端渗透客户端通信通道关闭
*
* @see MessageTypeEnums#REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE
* @see AbstractHandleReportClientPermeateClientTransferCloseTypeAdvanced
* @see MessageType#DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE
*/
public static final byte REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE = 0X25;
/**
* 下发 客户端接收连接成功通知
*
@ -354,26 +363,36 @@ public class MessageType {
/**
* 下发 客户端渗透客户端数据传输通道init 成功
*
* @see MessageTypeEnums#DISTRIBUTE_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_INIT_SUCCESSFUL
* @see MessageTypeEnums#DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_CHANNEL_INIT_SUCCESSFUL
* @see AbstractHandleDistributeClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced
* @see MessageType#DISTRIBUTE_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_INIT_SUCCESSFUL
* @see MessageType#DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_CHANNEL_INIT_SUCCESSFUL
*/
public static final byte DISTRIBUTE_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_INIT_SUCCESSFUL = -0X22;
public static final byte DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_CHANNEL_INIT_SUCCESSFUL = -0X22;
/**
* 下发 客户端渗透客户端数据传输请求
*
* @see MessageTypeEnums#DISTRIBUTE_CLIENT_TRANSFER_CLIENT_REQUEST
* @see MessageTypeEnums#DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_REQUEST
* @see AbstractHandleDistributeClientTransferClientRequestTypeAdvanced
* @see MessageType#REPORT_CLIENT_TRANSFER_CLIENT_REQUEST
* @see MessageType#REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_REQUEST
*/
public static final byte DISTRIBUTE_CLIENT_TRANSFER_CLIENT_REQUEST = -0X23;
public static final byte DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_REQUEST = -0X23;
/**
* 下发客户端渗透客户端数据传输响应
*
* @see MessageTypeEnums#DISTRIBUTE_CLIENT_TRANSFER_CLIENT_RESPONSE
* @see MessageTypeEnums#DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_RESPONSE
* @see AbstractHandleDistributeClientTransferClientResponseTypeAdvanced
* @see MessageType#REPORT_CLIENT_TRANSFER_CLIENT_RESPONSE
*/
public static final byte DISTRIBUTE_CLIENT_TRANSFER_CLIENT_RESPONSE = -0X24;
public static final byte DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_RESPONSE = -0X24;
/**
* 下发客户端渗透客户端通信通道关闭
*
* @see MessageTypeEnums#DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE
* @see AbstractHandleDistributeClientPermeateClientTransferCloseTypeAdvanced
* @see MessageType#REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE
*/
public static final byte DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE = -0X25;
}

View File

@ -0,0 +1,28 @@
package org.framework.lazy.cloud.network.heartbeat.common.advanced.client;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.AbstractHandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
/**
* 下发客户端渗透客户端通信通道关闭
*
* @see MessageTypeEnums#DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE
*/
public abstract class AbstractHandleDistributeClientPermeateClientTransferCloseTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {
/**
* 是否支持当前类型
*
* @param msg 通道数据
* @return 布尔类型
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE.getTypeByte() == msg.getType();
}
}

View File

@ -23,6 +23,6 @@ public abstract class AbstractHandleDistributeClientTransferClientPermeateChanne
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.DISTRIBUTE_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_INIT_SUCCESSFUL.getTypeByte() == msg.getType();
return MessageTypeEnums.DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_CHANNEL_INIT_SUCCESSFUL.getTypeByte() == msg.getType();
}
}

View File

@ -10,7 +10,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
/**
* 下发客户端渗透客户端数据传输
*
* @see MessageTypeEnums#DISTRIBUTE_CLIENT_TRANSFER_CLIENT_REQUEST
* @see MessageTypeEnums#DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_REQUEST
*/
public abstract class AbstractHandleDistributeClientTransferClientRequestTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {
@ -23,6 +23,6 @@ public abstract class AbstractHandleDistributeClientTransferClientRequestTypeAdv
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.DISTRIBUTE_CLIENT_TRANSFER_CLIENT_REQUEST.getTypeByte() == msg.getType();
return MessageTypeEnums.DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_REQUEST.getTypeByte() == msg.getType();
}
}

View File

@ -10,7 +10,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
/**
* 下发客户端渗透客户端数据传输响应
*
* @see MessageTypeEnums#DISTRIBUTE_CLIENT_TRANSFER_CLIENT_RESPONSE
* @see MessageTypeEnums#DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_RESPONSE
*/
public abstract class AbstractHandleDistributeClientTransferClientResponseTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {
@ -23,6 +23,6 @@ public abstract class AbstractHandleDistributeClientTransferClientResponseTypeAd
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.DISTRIBUTE_CLIENT_TRANSFER_CLIENT_RESPONSE.getTypeByte() == msg.getType();
return MessageTypeEnums.DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_RESPONSE.getTypeByte() == msg.getType();
}
}

View File

@ -0,0 +1,27 @@
package org.framework.lazy.cloud.network.heartbeat.common.advanced.server;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.AbstractHandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
/**
* 上报客户端渗透客户端通信通道关闭
*@see MessageTypeEnums#REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE
*/
public abstract class AbstractHandleReportClientPermeateClientTransferCloseTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {
/**
* 是否支持当前类型
*
* @param msg 通道数据
* @return 布尔类型
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE.getTypeByte() == msg.getType();
}
}

View File

@ -9,7 +9,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
/**
* 上报 客户端渗透客户端数据传输通道init
* REPORT_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_INIT_SUCCESSFUL
* REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CHANNEL_INIT_SUCCESSFUL
*/
public abstract class AbstractHandleReportClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {

View File

@ -9,7 +9,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
/**
* 上报客户端渗透客户端数据传输
* REPORT_CLIENT_TRANSFER_CLIENT_REQUEST
* REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_REQUEST
*/
public abstract class AbstractHandleReportClientTransferClientTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {

View File

@ -104,17 +104,23 @@ public enum MessageTypeEnums {
* 上报 客户端渗透客户端数据传输通道init 成功
* @see AbstractHandleReportClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced
*/
REPORT_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_INIT_SUCCESSFUL(MessageType.REPORT_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_INIT_SUCCESSFUL, "上报 客户端渗透客户端数据传输通道init成功"),
REPORT_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_INIT_SUCCESSFUL(MessageType.REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CHANNEL_INIT_SUCCESSFUL, "上报 客户端渗透客户端数据传输通道init成功"),
/**
* 上报 上报客户端渗透客户端数据传输
* @see AbstractHandleReportClientTransferClientTypeAdvanced
*/
REPORT_CLIENT_TRANSFER_CLIENT_REQUEST(MessageType.REPORT_CLIENT_TRANSFER_CLIENT_REQUEST, "上报客户端渗透客户端数据传输"),
REPORT_CLIENT_TRANSFER_CLIENT_REQUEST(MessageType.REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_REQUEST, "上报客户端渗透客户端数据传输"),
/**
* 上报客户端渗透客户端数据传输结果
* @see AbstractHandleReportClientTransferClientResponseTypeAdvanced
*/
REPORT_CLIENT_TRANSFER_CLIENT_RESPONSE(MessageType.REPORT_CLIENT_TRANSFER_CLIENT_RESPONSE, "上报客户端渗透客户端数据传输结果"),
/**
* 上报客户端渗透客户端通信通道关闭
*
* @see AbstractHandleReportClientPermeateClientTransferCloseTypeAdvanced
*/
REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE(MessageType.REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE, "上报客户端渗透客户端通信通道关闭"),
/**
* @see AbstractHandleDistributeConnectSuccessNotificationTypeAdvancedHandle
*/
@ -202,17 +208,24 @@ public enum MessageTypeEnums {
* 下发 客户端渗透客户端数据传输通道init 成功
* @see AbstractHandleDistributeClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced
*/
DISTRIBUTE_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_INIT_SUCCESSFUL(MessageType.DISTRIBUTE_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_INIT_SUCCESSFUL, "下发 客户端渗透客户端数据传输通道init 成功"),
DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_CHANNEL_INIT_SUCCESSFUL(MessageType.DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_CHANNEL_INIT_SUCCESSFUL, "下发 客户端渗透客户端数据传输通道init 成功"),
/**
* 下发客户端渗透客户端数据传输
* @see AbstractHandleDistributeClientTransferClientRequestTypeAdvanced
*/
DISTRIBUTE_CLIENT_TRANSFER_CLIENT_REQUEST(MessageType.DISTRIBUTE_CLIENT_TRANSFER_CLIENT_REQUEST, "下发客户端渗透客户端数据传输"),
/**
* 下发客户端渗透客户端数据传输响应
DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_REQUEST(MessageType.DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_REQUEST, "下发客户端渗透客户端数据传输"),
/**
* 下发客户端渗透客户端数据传输
* @see AbstractHandleDistributeClientTransferClientResponseTypeAdvanced
*/
DISTRIBUTE_CLIENT_TRANSFER_CLIENT_RESPONSE(MessageType.DISTRIBUTE_CLIENT_TRANSFER_CLIENT_RESPONSE, "下发客户端渗透客户端数据传输响应"),
DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_RESPONSE(MessageType.DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_RESPONSE, "下发客户端渗透客户端数据传输"),
/**
* 下发客户端渗透客户端通信通道关闭
*
* @see MessageTypeEnums#DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE
* @see AbstractHandleDistributeClientPermeateClientTransferCloseTypeAdvanced
*/
DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE(MessageType.DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE, "下发客户端渗透客户端通信通道关闭"),
;
private final byte typeByte;

View File

@ -0,0 +1,41 @@
package org.framework.lazy.cloud.network.heartbeat.server.netty.advanced;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.MessageType;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.server.AbstractHandleReportClientPermeateClientTransferCloseTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.springframework.stereotype.Component;
/**
* 上报客户端渗透客户端通信通道关闭
*/
@Slf4j
@Component
public class ServerHandleReportClientPermeateClientTransferCloseTypeAdvanced extends AbstractHandleReportClientPermeateClientTransferCloseTypeAdvanced<NettyProxyMsg> {
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
// 关闭 nextnext transfer 通道
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
Channel transferNextChannel = ChannelAttributeKeyUtils.getTransferNextChannel(channel);
// 下发关闭客户端真实通道
NettyProxyMsg closeTransferNettyProxyMsg = new NettyProxyMsg();
closeTransferNettyProxyMsg.setType(MessageType.DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE);
transferNextChannel.writeAndFlush(closeTransferNettyProxyMsg);
channel.close();
nextChannel.close();
transferNextChannel.close();
}
}

View File

@ -2,11 +2,9 @@ package org.framework.lazy.cloud.network.heartbeat.server.netty.advanced;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.ChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.MessageType;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.NettyTransferChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.server.AbstractHandleReportClientTransferClientPermeateChannelConnectionSuccessfulTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.server.AbstractHandleReportClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.springframework.stereotype.Component;
@ -46,7 +44,7 @@ public class ServerHandleReportClientTransferClientPermeateChannelInitSuccessful
clientConnectTagetNettyProxyMsg.setClientTargetIp(msgClientTargetIp);
clientConnectTagetNettyProxyMsg.setClientTargetPort(msgClientTargetPort);
clientConnectTagetNettyProxyMsg.setClientId(clientId);
clientConnectTagetNettyProxyMsg.setType(MessageType.DISTRIBUTE_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_INIT_SUCCESSFUL);
clientConnectTagetNettyProxyMsg.setType(MessageType.DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_CHANNEL_INIT_SUCCESSFUL);
if (nextChannel != null) {
nextChannel.writeAndFlush(clientConnectTagetNettyProxyMsg);
}else {

View File

@ -4,7 +4,6 @@ import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.MessageType;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.server.AbstractHandleReportClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.server.AbstractHandleReportClientTransferClientResponseTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.springframework.stereotype.Component;
@ -40,7 +39,7 @@ public class ServerHandleReportClientTransferClientResponseTypeAdvanced extends
clientConnectTagetNettyProxyMsg.setClientTargetPort(msgClientTargetPort);
clientConnectTagetNettyProxyMsg.setClientId(clientId);
clientConnectTagetNettyProxyMsg.setData(nettyProxyMsg.getData());
clientConnectTagetNettyProxyMsg.setType(MessageType.DISTRIBUTE_CLIENT_TRANSFER_CLIENT_RESPONSE);
clientConnectTagetNettyProxyMsg.setType(MessageType.DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_RESPONSE);
if (nextChannel != null) {
nextChannel.writeAndFlush(clientConnectTagetNettyProxyMsg);
}else {

View File

@ -39,7 +39,7 @@ public class ServerHandleReportClientTransferClientTypeAdvanced extends Abstract
clientConnectTagetNettyProxyMsg.setClientTargetPort(msgClientTargetPort);
clientConnectTagetNettyProxyMsg.setClientId(clientId);
clientConnectTagetNettyProxyMsg.setData(nettyProxyMsg.getData());
clientConnectTagetNettyProxyMsg.setType(MessageType.DISTRIBUTE_CLIENT_TRANSFER_CLIENT_REQUEST);
clientConnectTagetNettyProxyMsg.setType(MessageType.DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_REQUEST);
if (nextChannel != null) {
nextChannel.writeAndFlush(clientConnectTagetNettyProxyMsg);
}else {