[fix] 优化tcp架构

This commit is contained in:
wujiawei 2024-12-13 14:29:11 +08:00
parent 41a81133f1
commit 42bc37c712
113 changed files with 3617 additions and 300 deletions

View File

@ -208,7 +208,7 @@ public class NettyClientSocket {
log.info("连接服务端成功");
// 告诉服务端这条连接是client的连接
NettyProxyMsg nettyMsg = new NettyProxyMsg();
nettyMsg.setType(MessageType.REPORT_CLIENT_CONNECT_SUCCESS);
nettyMsg.setType(MessageType.TCP_REPORT_CLIENT_CONNECT_SUCCESS);
nettyMsg.setClientId(clientId);
nettyMsg.setData((clientId).getBytes());
ChannelAttributeKeyUtils.buildClientId(channel, clientId);

View File

@ -9,7 +9,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.advanced.tcp.AbstractTc
/**
* 服务端 处理客户端心跳
* TYPE_HEARTBEAT
* TCP_TYPE_HEARTBEAT
*/
public class ClientTcpHandleChannelHeartbeatTypeAdvanced extends AbstractTcpHandleChannelHeartbeatTypeAdvanced<NettyProxyMsg> {
@ -22,7 +22,7 @@ public class ClientTcpHandleChannelHeartbeatTypeAdvanced extends AbstractTcpHand
@Override
public void doHandler(Channel channel, NettyProxyMsg msg) {
NettyProxyMsg hb = new NettyProxyMsg();
hb.setType(MessageType.TYPE_HEARTBEAT);
hb.setType(MessageType.TCP_TYPE_HEARTBEAT);
// channel.writeAndFlush(hb);
}

View File

@ -97,7 +97,7 @@ public class NettyClientHandler extends SimpleChannelInboundHandler<NettyProxyMs
if (IdleState.WRITER_IDLE.equals(event.state())) { //如果写通道处于空闲状态,就发送心跳命令
String clientId = nettyClientSocket.getClientId();
NettyProxyMsg nettyMsg = new NettyProxyMsg();
nettyMsg.setType(MessageType.TYPE_HEARTBEAT);
nettyMsg.setType(MessageType.TCP_TYPE_HEARTBEAT);
nettyMsg.setData(clientId.getBytes(StandardCharsets.UTF_8));
nettyMsg.setClientId(clientId.getBytes(StandardCharsets.UTF_8));
ctx.writeAndFlush(nettyMsg);// 发送心跳数据

View File

@ -32,7 +32,7 @@ public class NettyClientPermeateClientRealHandler extends SimpleChannelInboundHa
// 访客通信通道 上报服务端代理完成
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(ctx.channel());
NettyProxyMsg returnMessage = new NettyProxyMsg();
returnMessage.setType(MessageType.REPORT_CLIENT_TRANSFER_CLIENT_RESPONSE);
returnMessage.setType(MessageType.TCP_REPORT_CLIENT_TRANSFER_CLIENT_RESPONSE);
returnMessage.setVisitorId(visitorId);
returnMessage.setClientId(clientId);
returnMessage.setVisitorPort(visitorPort);
@ -55,7 +55,7 @@ public class NettyClientPermeateClientRealHandler extends SimpleChannelInboundHa
if (nextChannel != null) {
// 上报关闭这个客户端的访客通道
NettyProxyMsg closeVisitorMsg = new NettyProxyMsg();
closeVisitorMsg.setType(MessageType.REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE);
closeVisitorMsg.setType(MessageType.TCP_REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE);
closeVisitorMsg.setVisitorId(visitorId);
nextChannel.writeAndFlush(closeVisitorMsg);
}

View File

@ -47,7 +47,7 @@ public class NettyClientPermeateClientTransferHandler extends SimpleChannelInbou
if (nextChannel != null) {
// 上报关闭这个客户端的访客通道
NettyProxyMsg closeVisitorMsg = new NettyProxyMsg();
closeVisitorMsg.setType(MessageType.REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE);
closeVisitorMsg.setType(MessageType.TCP_REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE);
closeVisitorMsg.setVisitorId(visitorId);
nextChannel.writeAndFlush(closeVisitorMsg);
}

View File

@ -48,7 +48,7 @@ public class NettyClientPermeateClientTransferRealHandler extends SimpleChannelI
// 上报关闭这个客户端的访客通道
NettyProxyMsg closeVisitorMsg = new NettyProxyMsg();
closeVisitorMsg.setType(MessageType.REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE);
closeVisitorMsg.setType(MessageType.TCP_REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE);
closeVisitorMsg.setVisitorId(visitorId);
nextChannel.writeAndFlush(closeVisitorMsg);
}

View File

@ -75,7 +75,7 @@ public class NettyClientPermeateClientVisitorHandler extends SimpleChannelInbou
Integer visitorPort = internalNetworkClientPermeateClientVisitor.getVisitorPort();
String clientId = internalNetworkClientPermeateClientVisitor.getNettyClientProperties().getClientId();
NettyProxyMsg nettyProxyMsg = new NettyProxyMsg();
nettyProxyMsg.setType(MessageType.REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_REQUEST);
nettyProxyMsg.setType(MessageType.TCP_REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_REQUEST);
nettyProxyMsg.setVisitorId(visitorId);
nettyProxyMsg.setClientId(clientId);
nettyProxyMsg.setVisitorPort(visitorPort);
@ -102,7 +102,7 @@ public class NettyClientPermeateClientVisitorHandler extends SimpleChannelInbou
// 通知客户端 关闭访问通道真实通道
NettyProxyMsg myMsg = new NettyProxyMsg();
myMsg.setType(MessageType.REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE);
myMsg.setType(MessageType.TCP_REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE);
nextChannel.writeAndFlush(myMsg);
}
// 关闭 访客通信通道访客真实通道

View File

@ -47,7 +47,7 @@ public class NettyClientPermeateServerTransferHandler extends SimpleChannelInbou
if (nextChannel != null) {
// 上报关闭服务端客户端真实通道
NettyProxyMsg closeVisitorMsg = new NettyProxyMsg();
closeVisitorMsg.setType(MessageType.REPORT_CLIENT_PERMEATE_SERVER_TRANSFER_CLOSE);
closeVisitorMsg.setType(MessageType.TCP_TCP_REPORT_CLIENT_PERMEATE_SERVER_TRANSFER_CLOSE);
closeVisitorMsg.setVisitorId(visitorId);
nextChannel.writeAndFlush(closeVisitorMsg);
}
@ -79,7 +79,7 @@ public class NettyClientPermeateServerTransferHandler extends SimpleChannelInbou
if (obj instanceof IdleStateEvent event) {
if (IdleState.WRITER_IDLE.equals(event.state())) { //如果写通道处于空闲状态,就发送心跳命令
NettyProxyMsg nettyMsg = new NettyProxyMsg();
nettyMsg.setType(MessageType.TYPE_HEARTBEAT);
nettyMsg.setType(MessageType.TCP_TYPE_HEARTBEAT);
ctx.writeAndFlush(nettyMsg);// 发送心跳数据
} else if (event.state() == IdleState.WRITER_IDLE) { // 如果检测到写空闲状态关闭连接
// 离线暂存通知

View File

@ -70,7 +70,7 @@ public class NettyClientPermeateServerVisitorHandler extends SimpleChannelInboun
Integer visitorPort = internalNetworkClientPermeateServerVisitor.getVisitorPort();
String clientId = internalNetworkClientPermeateServerVisitor.getNettyClientProperties().getClientId();
NettyProxyMsg nettyProxyMsg = new NettyProxyMsg();
nettyProxyMsg.setType(MessageType.REPORT_CLIENT_PERMEATE_SERVER_TRANSFER);
nettyProxyMsg.setType(MessageType.TCP_REPORT_CLIENT_PERMEATE_SERVER_TRANSFER);
nettyProxyMsg.setVisitorId(visitorId);
nettyProxyMsg.setClientId(clientId);
nettyProxyMsg.setVisitorPort(visitorPort);
@ -95,7 +95,7 @@ public class NettyClientPermeateServerVisitorHandler extends SimpleChannelInboun
if (nextChannel != null && nextChannel.isActive()) {
// 通知服务端 关闭访问通道真实通道
NettyProxyMsg myMsg = new NettyProxyMsg();
myMsg.setType(MessageType.REPORT_CLIENT_PERMEATE_SERVER_TRANSFER_CLOSE);
myMsg.setType(MessageType.TCP_TCP_REPORT_CLIENT_PERMEATE_SERVER_TRANSFER_CLOSE);
myMsg.setVisitorId(visitorId);
nextChannel.writeAndFlush(myMsg);
//通信通道
@ -136,7 +136,7 @@ public class NettyClientPermeateServerVisitorHandler extends SimpleChannelInboun
if (nextChannel != null) {
// 下发关闭访客
NettyProxyMsg closeRealClient = new NettyProxyMsg();
closeRealClient.setType(MessageType.REPORT_CLIENT_PERMEATE_SERVER_TRANSFER_CLOSE);
closeRealClient.setType(MessageType.TCP_TCP_REPORT_CLIENT_PERMEATE_SERVER_TRANSFER_CLOSE);
closeRealClient.setClientId(clientId);
closeRealClient.setVisitorId(visitorId);
nextChannel.writeAndFlush(closeRealClient);

View File

@ -31,7 +31,7 @@ public class NettyServerPermeateClientRealHandler extends SimpleChannelInboundHa
// 访客通信通道 上报服务端代理完成
Channel visitor = ChannelAttributeKeyUtils.getNextChannel(ctx.channel());
NettyProxyMsg returnMessage = new NettyProxyMsg();
returnMessage.setType(MessageType.REPORT_CLIENT_TRANSFER);
returnMessage.setType(MessageType.TCP_REPORT_CLIENT_TRANSFER);
returnMessage.setVisitorId(visitorId);
returnMessage.setClientId(clientId);
returnMessage.setVisitorPort(visitorPort);
@ -55,7 +55,7 @@ public class NettyServerPermeateClientRealHandler extends SimpleChannelInboundHa
if (visitor != null) {
// 上报关闭这个客户端的访客通道
NettyProxyMsg closeVisitorMsg = new NettyProxyMsg();
closeVisitorMsg.setType(MessageType.REPORT_SERVICE_PERMEATE_CLIENT_CLIENT_CLOSE_VISITOR);
closeVisitorMsg.setType(MessageType.TCP_REPORT_SERVICE_PERMEATE_CLIENT_CLIENT_CLOSE_VISITOR);
closeVisitorMsg.setVisitorId(visitorId);
visitor.writeAndFlush(closeVisitorMsg);
}

View File

@ -44,7 +44,7 @@ public class NettyServerPermeateClientTransferHandler extends SimpleChannelInbou
if (nextChannel != null) {
// 上报关闭这个客户端的访客通道
NettyProxyMsg closeVisitorMsg = new NettyProxyMsg();
closeVisitorMsg.setType(MessageType.REPORT_SERVICE_PERMEATE_CLIENT_CLIENT_CLOSE_VISITOR);
closeVisitorMsg.setType(MessageType.TCP_REPORT_SERVICE_PERMEATE_CLIENT_CLIENT_CLOSE_VISITOR);
closeVisitorMsg.setVisitorId(visitorId);
nextChannel.writeAndFlush(closeVisitorMsg);
}

View File

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

View File

@ -69,7 +69,7 @@ public class NettyClientPermeateClientVisitorTransferSocket {
if (futureListener.isSuccess()) {
NettyProxyMsg nettyProxyMsg = new NettyProxyMsg();
nettyProxyMsg.setType(MessageType.REPORT_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL);
nettyProxyMsg.setType(MessageType.TCP_REPORT_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL);
// other clientId
nettyProxyMsg.setClientId(toClientId);
nettyProxyMsg.setVisitorPort(visitorPort);

View File

@ -71,7 +71,7 @@ public class NettyClientPermeateServerVisitorTransferSocket {
if (futureListener.isSuccess()) {
NettyProxyMsg myMsg = new NettyProxyMsg();
myMsg.setType(MessageType.REPORT_CLIENT_TRANSFER_SERVER_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL);
myMsg.setType(MessageType.TCP_REPORT_CLIENT_TRANSFER_SERVER_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL);
myMsg.setClientId(clientId);
myMsg.setVisitorPort(visitorPort);
myMsg.setClientTargetIp(targetIp);

View File

@ -101,7 +101,7 @@ public class NettyClientSocket {
log.info("clientId:{},connect to server IP:{},server port :{} isSuccess ", clientId, inetHost, inetPort);
// 告诉服务端这条连接是client的连接
NettyProxyMsg nettyMsg = new NettyProxyMsg();
nettyMsg.setType(MessageType.REPORT_CLIENT_CONNECT_SUCCESS);
nettyMsg.setType(MessageType.TCP_REPORT_CLIENT_CONNECT_SUCCESS);
nettyMsg.setClientId(clientId);
String hostAddress = InetAddress.getLocalHost().getHostAddress();
nettyMsg.setOriginalIpString(hostAddress);

View File

@ -176,7 +176,7 @@ public class NettyServerPermeateClientRealSocket {
if (futureListener.isSuccess()) {
NettyProxyMsg myMsg = new NettyProxyMsg();
myMsg.setType(MessageType.REPORT_SINGLE_CLIENT_REAL_CONNECT);
myMsg.setType(MessageType.TCP_REPORT_SINGLE_CLIENT_REAL_CONNECT);
myMsg.setClientId(visitorClientId);
myMsg.setVisitorPort(visitorPort);
myMsg.setClientTargetIp(clientTargetIp);

View File

@ -29,7 +29,7 @@
// Channel channel = clientChannel.getChannel();
//
// NettyProxyMsg nettyMsg = new NettyProxyMsg();
// nettyMsg.setType(MessageType.REPORT_CLIENT_STAGING_OPENED);
// nettyMsg.setType(MessageType.TCP_REPORT_CLIENT_STAGING_OPENED);
// nettyMsg.setData((clientId
// .getBytes(StandardCharsets.UTF_8)));
// nettyMsg.setClientId((clientId
@ -52,7 +52,7 @@
// // 上报 当前通道暂存关闭了
// Channel channel = clientChannel.getChannel();
// NettyProxyMsg nettyMsg = new NettyProxyMsg();
// nettyMsg.setType(MessageType.REPORT_CLIENT_STAGING_CLOSED);
// nettyMsg.setType(MessageType.TCP_REPORT_CLIENT_STAGING_CLOSED);
// nettyMsg.setData((clientId
// .getBytes(StandardCharsets.UTF_8)));
// nettyMsg.setClientId((clientId

View File

@ -14,86 +14,86 @@ public class MessageType {
/**
* 心跳
*
* @see MessageTypeEnums#TYPE_HEARTBEAT
* @see MessageTypeEnums#TCP_TYPE_HEARTBEAT
* @see AbstractTcpHandleChannelHeartbeatTypeAdvanced
*/
public static final byte TYPE_HEARTBEAT = 0X00;
public static final byte TCP_TYPE_HEARTBEAT = 0X00;
/**
* 客户端上报连接成功
*
* @see MessageTypeEnums#REPORT_CLIENT_CONNECT_SUCCESS
* @see MessageTypeEnums#TCP_REPORT_CLIENT_CONNECT_SUCCESS
* @see AbstractHandleTcpClientConnectSuccessTypeAdvanced
*/
public static final byte REPORT_CLIENT_CONNECT_SUCCESS = 0X01;
public static final byte TCP_REPORT_CLIENT_CONNECT_SUCCESS = 0X01;
/**
* 上报 客户端断开连接
*
* @see MessageTypeEnums#REPORT_CLIENT_DISCONNECTION
* @see MessageTypeEnums#TCP_REPORT_CLIENT_DISCONNECTION
* @see AbstractHandleTcpReportDisconnectTypeAdvanced
*/
public static final byte REPORT_CLIENT_DISCONNECTION = 0X02;
public static final byte TCP_REPORT_CLIENT_DISCONNECTION = 0X02;
/**
* 客户端上报暂存开启
*
* @see MessageTypeEnums#REPORT_CLIENT_STAGING_OPENED
* @see MessageTypeEnums#TCP_REPORT_CLIENT_STAGING_OPENED
* @see AbstractHandleTcpReportStagingOpenedTypeAdvanced
*/
public static final byte REPORT_CLIENT_STAGING_OPENED = 0X03;
public static final byte TCP_REPORT_CLIENT_STAGING_OPENED = 0X03;
/**
* 客户端上报暂存关闭
*
* @see MessageTypeEnums#REPORT_CLIENT_STAGING_CLOSED
* @see MessageTypeEnums#TCP_REPORT_CLIENT_STAGING_CLOSED
* @see AbstractHandleTcpReportStagingClosedTypeAdvanced
*/
public static final byte REPORT_CLIENT_STAGING_CLOSED = 0X04;
public static final byte TCP_REPORT_CLIENT_STAGING_CLOSED = 0X04;
/**
* 上报 客户端数据传输内网穿透数据回传
*
* @see MessageTypeEnums#REPORT_CLIENT_TRANSFER
* @see MessageTypeEnums#TCP_REPORT_CLIENT_TRANSFER
* @see AbstractHandleTcpReportServicePermeateClientTransferTypeAdvanced
*/
public static final byte REPORT_CLIENT_TRANSFER = 0X05;
public static final byte TCP_REPORT_CLIENT_TRANSFER = 0X05;
/**
* 上报 客户端创建需要代理的真实端口成功
*
* @see MessageTypeEnums#REPORT_SINGLE_CLIENT_REAL_CONNECT
* @see MessageTypeEnums#TCP_REPORT_SINGLE_CLIENT_REAL_CONNECT
* @see AbstractHandleTcpReportServicePermeateClientRealConnectTypeAdvanced
*/
public static final byte REPORT_SINGLE_CLIENT_REAL_CONNECT = 0X06;
public static final byte TCP_REPORT_SINGLE_CLIENT_REAL_CONNECT = 0X06;
/**
* 上报 客户端关闭一个访客通道
*
* @see MessageTypeEnums#REPORT_SINGLE_CLIENT_CLOSE_VISITOR
* @see AbstractHandleTcpReportServicePermeateClientCloseVisitorTypeAdvanced
*/
public static final byte REPORT_SERVICE_PERMEATE_CLIENT_CLIENT_CLOSE_VISITOR = 0X08;
public static final byte TCP_REPORT_SERVICE_PERMEATE_CLIENT_CLIENT_CLOSE_VISITOR = 0X08;
/**
* 上报 客户端消息到另一个客户端
*
* @see MessageTypeEnums#REPORT_SINGLE_CLIENT_MESSAGE
* @see MessageTypeEnums#TCP_REPORT_SINGLE_CLIENT_MESSAGE
* @see AbstractHandleTcpReportSingleClientMessage2OtherClientTypeAdvanced
*/
public static final byte REPORT_SINGLE_CLIENT_MESSAGE = 0X09;
public static final byte TCP_REPORT_SINGLE_CLIENT_MESSAGE = 0X09;
/**
* 服务端通道 is active
*
* @see MessageTypeEnums#SERVER_CHANNEL_ACTIVE
* @see MessageTypeEnums#TCP_SERVER_CHANNEL_ACTIVE
* @see AbstractHandleTcpReportServerChannelActiveTypeAdvanced
*/
public static final byte SERVER_CHANNEL_ACTIVE = 0X10;
public static final byte TCP_SERVER_CHANNEL_ACTIVE = 0X10;
/**
* 上报 集群注册
*
* @see MessageTypeEnums#REPORT_CLUSTER_NODE_REGISTER_MESSAGE
* @see MessageTypeEnums#TCP_REPORT_CLUSTER_NODE_REGISTER_MESSAGE
* @see AbstractHandleTcpReportClusterNodeRegisterTypeAdvanced
*/
public static final byte REPORT_CLUSTER_NODE_REGISTER_MESSAGE = 0X11;
public static final byte TCP_REPORT_CLUSTER_NODE_REGISTER_MESSAGE = 0X11;
/**
@ -104,40 +104,40 @@ public class MessageType {
/**
* 上报 客户端渗透服务端数据传输通道连接成功
*
* @see MessageTypeEnums#REPORT_CLIENT_TRANSFER_SERVER_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL
* @see MessageTypeEnums#TCP_REPORT_CLIENT_TRANSFER_SERVER_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL
* @see AbstractHandleTcpReportClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced
*/
public static final byte REPORT_CLIENT_TRANSFER_SERVER_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL = 0X12;
public static final byte TCP_REPORT_CLIENT_TRANSFER_SERVER_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL = 0X12;
/**
* 上报 客户端渗透服务端init信息
*
* @see MessageTypeEnums#REPORT_CLIENT_PERMEATE_SERVER_INIT
* @see MessageTypeEnums#TCP_REPORT_CLIENT_PERMEATE_SERVER_INIT
* @see AbstractHandleTcpReportClientPermeateServerInitTypeAdvanced
*/
public static final byte REPORT_CLIENT_PERMEATE_SERVER_INIT = 0X13;
public static final byte TCP_REPORT_CLIENT_PERMEATE_SERVER_INIT = 0X13;
/**
* 上报 客户端渗透服务端init close 信息
*
* @see MessageTypeEnums#REPORT_CLIENT_PERMEATE_SERVER_CLOSE
* @see MessageTypeEnums#TCP_REPORT_CLIENT_PERMEATE_SERVER_CLOSE
* @see AbstractHandleTcpReportClientPermeateServerCloseTypeAdvanced
*/
public static final byte REPORT_CLIENT_PERMEATE_SERVER_CLOSE = 0X14;
public static final byte TCP_REPORT_CLIENT_PERMEATE_SERVER_CLOSE = 0X14;
/**
* 上报 客户端渗透服务端通信通道关闭
*
* @see MessageTypeEnums#REPORT_CLIENT_PERMEATE_SERVER_TRANSFER_CLOSE
* @see MessageTypeEnums#TCP_TCP_REPORT_CLIENT_PERMEATE_SERVER_TRANSFER_CLOSE
* @see AbstractHandleTcpReportClientPermeateServerTransferCloseTypeAdvanced
*/
public static final byte REPORT_CLIENT_PERMEATE_SERVER_TRANSFER_CLOSE = 0X15;
public static final byte TCP_TCP_REPORT_CLIENT_PERMEATE_SERVER_TRANSFER_CLOSE = 0X15;
/**
* 上报 客户端渗透服务端通信传输
*
* @see MessageTypeEnums#REPORT_CLIENT_PERMEATE_SERVER_TRANSFER
* @see MessageTypeEnums#TCP_REPORT_CLIENT_PERMEATE_SERVER_TRANSFER
* @see AbstractHandleTcpReportClientPermeateServerTransferTypeAdvanced
*/
public static final byte REPORT_CLIENT_PERMEATE_SERVER_TRANSFER = 0X16;
public static final byte TCP_REPORT_CLIENT_PERMEATE_SERVER_TRANSFER = 0X16;
@ -151,61 +151,61 @@ public class MessageType {
/**
* 上报 客户端渗透客户端init信息
*
* @see MessageTypeEnums#REPORT_CLIENT_PERMEATE_CLIENT_INIT
* @see MessageTypeEnums#TCP_REPORT_CLIENT_PERMEATE_CLIENT_INIT
* @see AbstractHandleTcpReportClientPermeateClientInitTypeAdvanced
*/
public static final byte REPORT_CLIENT_PERMEATE_CLIENT_INIT = 0X19;
public static final byte TCP_REPORT_CLIENT_PERMEATE_CLIENT_INIT = 0X19;
/**
* 上报 客户端渗透客户端init close 信息
*
* @see MessageTypeEnums#REPORT_CLIENT_PERMEATE_CLIENT_CLOSE
* @see MessageTypeEnums#TCP_REPORT_CLIENT_PERMEATE_CLIENT_CLOSE
* @see AbstractHandleTcpReportClientPermeateClientCloseTypeAdvanced
*/
public static final byte REPORT_CLIENT_PERMEATE_CLIENT_CLOSE = 0X20;
public static final byte TCP_REPORT_CLIENT_PERMEATE_CLIENT_CLOSE = 0X20;
/**
* 上报 客户端渗透客户端数据传输通道连接成功
*
* @see MessageTypeEnums#REPORT_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL
* @see MessageTypeEnums#TCP_REPORT_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL
* @see AbstractHandleTcpReportClientTransferClientPermeateChannelConnectionSuccessfulTypeAdvanced
* @see MessageType#DISTRIBUTE_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL
*/
public static final byte REPORT_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL = 0X21;
public static final byte TCP_REPORT_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL = 0X21;
/**
* 上报 客户端渗透客户端数据传输通道init 成功
*
* @see MessageTypeEnums#REPORT_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_INIT_SUCCESSFUL
* @see MessageTypeEnums#TCP_REPORT_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_INIT_SUCCESSFUL
* @see AbstractHandleTcpReportClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced
* @see MessageType#DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_CHANNEL_INIT_SUCCESSFUL
*/
public static final byte REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CHANNEL_INIT_SUCCESSFUL = 0X22;
public static final byte TCP_REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CHANNEL_INIT_SUCCESSFUL = 0X22;
/**
* 上报客户端渗透客户端数据传输请求
*
* @see MessageTypeEnums#REPORT_CLIENT_TRANSFER_CLIENT_REQUEST
* @see MessageTypeEnums#TCP_REPORT_CLIENT_TRANSFER_CLIENT_REQUEST
* @see AbstractHandleTcpReportClientTransferClientTypeAdvanced
* @see MessageType#DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_REQUEST
*/
public static final byte REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_REQUEST = 0X23;
public static final byte TCP_REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_REQUEST = 0X23;
/**
* 上报客户端渗透客户端数据传输结果
*
* @see MessageTypeEnums#REPORT_CLIENT_TRANSFER_CLIENT_RESPONSE
* @see MessageTypeEnums#TCP_REPORT_CLIENT_TRANSFER_CLIENT_RESPONSE
* @see AbstractHandleTcpReportClientTransferClientResponseTypeAdvanced
* @see MessageType#DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_RESPONSE
*/
public static final byte REPORT_CLIENT_TRANSFER_CLIENT_RESPONSE = 0X24;
public static final byte TCP_REPORT_CLIENT_TRANSFER_CLIENT_RESPONSE = 0X24;
/**
* 上报客户端渗透客户端通信通道关闭
*
* @see MessageTypeEnums#REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE
* @see MessageTypeEnums#TCP_REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE
* @see AbstractHandleTcpReportClientPermeateClientTransferCloseTypeAdvanced
* @see MessageType#DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE
*/
public static final byte REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE = 0X25;
public static final byte TCP_REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE = 0X25;
@ -360,7 +360,7 @@ public class MessageType {
*
* @see MessageTypeEnums#DISTRIBUTE_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL
* @see AbstractHandleTcpDistributeClientTransferClientPermeateChannelConnectionSuccessfulTypeAdvanced
* @see MessageType#REPORT_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL
* @see MessageType#TCP_REPORT_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL
*/
public static final byte DISTRIBUTE_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL = -0X21;
@ -379,7 +379,7 @@ public class MessageType {
*
* @see MessageTypeEnums#DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_REQUEST
* @see AbstractHandleTcpDistributeClientTransferClientRequestTypeAdvanced
* @see MessageType#REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_REQUEST
* @see MessageType#TCP_REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_REQUEST
*/
public static final byte DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_REQUEST = -0X23;
/**
@ -387,7 +387,7 @@ public class MessageType {
*
* @see MessageTypeEnums#DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_RESPONSE
* @see AbstractHandleTcpDistributeServicePermeateClientTransferClientResponseTypeAdvanced
* @see MessageType#REPORT_CLIENT_TRANSFER_CLIENT_RESPONSE
* @see MessageType#TCP_REPORT_CLIENT_TRANSFER_CLIENT_RESPONSE
*/
public static final byte DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_RESPONSE = -0X24;
@ -397,7 +397,7 @@ public class MessageType {
*
* @see MessageTypeEnums#DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE
* @see AbstractHandleTcpDistributeClientPermeateClientTransferCloseTypeAdvanced
* @see MessageType#REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE
* @see MessageType#TCP_REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE
*/
public static final byte DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE = -0X25;
}

View File

@ -9,7 +9,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
/**
* 服务端 处理客户端心跳
* TYPE_HEARTBEAT
* TCP_TYPE_HEARTBEAT
*/
public abstract class AbstractTcpHandleChannelHeartbeatTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {
@ -23,6 +23,6 @@ public abstract class AbstractTcpHandleChannelHeartbeatTypeAdvanced<MSG> extends
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.TYPE_HEARTBEAT.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_TYPE_HEARTBEAT.getTypeByte() == msg.getType();
}
}

View File

@ -20,6 +20,6 @@ public abstract class AbstractHandleTcpClientConnectSuccessTypeAdvanced<MSG> ext
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.REPORT_CLIENT_CONNECT_SUCCESS.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_REPORT_CLIENT_CONNECT_SUCCESS.getTypeByte() == msg.getType();
}
}

View File

@ -9,7 +9,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
/**
* 上报 客户端渗透客户端init close 信息
* REPORT_CLIENT_PERMEATE_CLIENT_CLOSE
* TCP_REPORT_CLIENT_PERMEATE_CLIENT_CLOSE
*/
public abstract class AbstractHandleTcpReportClientPermeateClientCloseTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {
@ -22,6 +22,6 @@ public abstract class AbstractHandleTcpReportClientPermeateClientCloseTypeAdvanc
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.REPORT_CLIENT_PERMEATE_CLIENT_CLOSE.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_REPORT_CLIENT_PERMEATE_CLIENT_CLOSE.getTypeByte() == msg.getType();
}
}

View File

@ -9,7 +9,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
/**
* 上报 客户端渗透客户端init信息
* REPORT_CLIENT_PERMEATE_CLIENT_INIT
* TCP_REPORT_CLIENT_PERMEATE_CLIENT_INIT
*/
public abstract class AbstractHandleTcpReportClientPermeateClientInitTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {
@ -22,6 +22,6 @@ public abstract class AbstractHandleTcpReportClientPermeateClientInitTypeAdvance
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.REPORT_CLIENT_PERMEATE_CLIENT_INIT.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_REPORT_CLIENT_PERMEATE_CLIENT_INIT.getTypeByte() == msg.getType();
}
}

View File

@ -9,7 +9,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
/**
* 上报客户端渗透客户端通信通道关闭
*@see MessageTypeEnums#REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE
*@see MessageTypeEnums#TCP_REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE
*/
public abstract class AbstractHandleTcpReportClientPermeateClientTransferCloseTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {
@ -22,6 +22,6 @@ public abstract class AbstractHandleTcpReportClientPermeateClientTransferCloseTy
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_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 close 信息
* REPORT_CLIENT_PERMEATE_SERVER_CLOSE
* TCP_REPORT_CLIENT_PERMEATE_SERVER_CLOSE
*/
public abstract class AbstractHandleTcpReportClientPermeateServerCloseTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {
@ -22,6 +22,6 @@ public abstract class AbstractHandleTcpReportClientPermeateServerCloseTypeAdvanc
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.REPORT_CLIENT_PERMEATE_SERVER_CLOSE.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_REPORT_CLIENT_PERMEATE_SERVER_CLOSE.getTypeByte() == msg.getType();
}
}

View File

@ -9,7 +9,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
/**
* 上报 客户端渗透服务端init信息
* REPORT_CLIENT_PERMEATE_SERVER_INIT
* TCP_REPORT_CLIENT_PERMEATE_SERVER_INIT
*/
public abstract class AbstractHandleTcpReportClientPermeateServerInitTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {
@ -22,6 +22,6 @@ public abstract class AbstractHandleTcpReportClientPermeateServerInitTypeAdvance
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.REPORT_CLIENT_PERMEATE_SERVER_INIT.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_REPORT_CLIENT_PERMEATE_SERVER_INIT.getTypeByte() == msg.getType();
}
}

View File

@ -9,7 +9,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
/**
* 上报 客户端渗透服务端通信通道关闭
* REPORT_CLIENT_PERMEATE_SERVER_TRANSFER_CLOSE
* TCP_TCP_REPORT_CLIENT_PERMEATE_SERVER_TRANSFER_CLOSE
*/
public abstract class AbstractHandleTcpReportClientPermeateServerTransferCloseTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {
@ -22,6 +22,6 @@ public abstract class AbstractHandleTcpReportClientPermeateServerTransferCloseTy
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.REPORT_CLIENT_PERMEATE_SERVER_TRANSFER_CLOSE.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_TCP_REPORT_CLIENT_PERMEATE_SERVER_TRANSFER_CLOSE.getTypeByte() == msg.getType();
}
}

View File

@ -9,7 +9,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
/**
* 上报 客户端渗透服务端通信
* REPORT_CLIENT_PERMEATE_SERVER_TRANSFER
* TCP_REPORT_CLIENT_PERMEATE_SERVER_TRANSFER
*/
public abstract class AbstractHandleTcpReportClientPermeateServerTransferTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {
@ -22,6 +22,6 @@ public abstract class AbstractHandleTcpReportClientPermeateServerTransferTypeAdv
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.REPORT_CLIENT_PERMEATE_SERVER_TRANSFER.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_REPORT_CLIENT_PERMEATE_SERVER_TRANSFER.getTypeByte() == msg.getType();
}
}

View File

@ -9,7 +9,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
/**
* 上报 客户端渗透客户端数据传输通道连接成功
* REPORT_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL
* TCP_REPORT_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL
*/
public abstract class AbstractHandleTcpReportClientTransferClientPermeateChannelConnectionSuccessfulTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {
@ -22,6 +22,6 @@ public abstract class AbstractHandleTcpReportClientTransferClientPermeateChannel
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.REPORT_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_REPORT_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL.getTypeByte() == msg.getType();
}
}

View File

@ -9,7 +9,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
/**
* 上报 客户端渗透客户端数据传输通道init
* REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CHANNEL_INIT_SUCCESSFUL
* TCP_REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CHANNEL_INIT_SUCCESSFUL
*/
public abstract class AbstractHandleTcpReportClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {
@ -22,6 +22,6 @@ public abstract class AbstractHandleTcpReportClientTransferClientPermeateChannel
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.REPORT_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_INIT_SUCCESSFUL.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_REPORT_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_INIT_SUCCESSFUL.getTypeByte() == msg.getType();
}
}

View File

@ -9,7 +9,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
/**
* 上报客户端渗透客户端数据传输结果
* REPORT_CLIENT_TRANSFER_CLIENT_RESPONSE
* TCP_REPORT_CLIENT_TRANSFER_CLIENT_RESPONSE
*/
public abstract class AbstractHandleTcpReportClientTransferClientResponseTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {
@ -22,6 +22,6 @@ public abstract class AbstractHandleTcpReportClientTransferClientResponseTypeAdv
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.REPORT_CLIENT_TRANSFER_CLIENT_RESPONSE.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_REPORT_CLIENT_TRANSFER_CLIENT_RESPONSE.getTypeByte() == msg.getType();
}
}

View File

@ -9,7 +9,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
/**
* 上报客户端渗透客户端数据传输
* REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_REQUEST
* TCP_REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_REQUEST
*/
public abstract class AbstractHandleTcpReportClientTransferClientTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {
@ -22,6 +22,6 @@ public abstract class AbstractHandleTcpReportClientTransferClientTypeAdvanced<MS
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.REPORT_CLIENT_TRANSFER_CLIENT_REQUEST.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_REPORT_CLIENT_TRANSFER_CLIENT_REQUEST.getTypeByte() == msg.getType();
}
}

View File

@ -9,7 +9,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
/**
* 上报 客户端渗透服务端数据传输通道连接成功
* REPORT_CLIENT_TRANSFER_SERVER_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL
* TCP_REPORT_CLIENT_TRANSFER_SERVER_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL
*/
public abstract class AbstractHandleTcpReportClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {
@ -22,6 +22,6 @@ public abstract class AbstractHandleTcpReportClientTransferServerPermeateChannel
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.REPORT_CLIENT_TRANSFER_SERVER_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_REPORT_CLIENT_TRANSFER_SERVER_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL.getTypeByte() == msg.getType();
}
}

View File

@ -9,7 +9,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
/**
* 上报 集群注册
* REPORT_CLUSTER_NODE_REGISTER_MESSAGE
* TCP_REPORT_CLUSTER_NODE_REGISTER_MESSAGE
*/
public abstract class AbstractHandleTcpReportClusterNodeRegisterTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {
@ -22,6 +22,6 @@ public abstract class AbstractHandleTcpReportClusterNodeRegisterTypeAdvanced<MSG
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.REPORT_CLUSTER_NODE_REGISTER_MESSAGE.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_REPORT_CLUSTER_NODE_REGISTER_MESSAGE.getTypeByte() == msg.getType();
}
}

View File

@ -22,6 +22,6 @@ public abstract class AbstractHandleTcpReportDisconnectTypeAdvanced<MSG> extends
@Override
public boolean doSupport(NettyProxyMsg msg) {
// 下发 客户端断开连接通知
return MessageTypeEnums.REPORT_CLIENT_DISCONNECTION.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_REPORT_CLIENT_DISCONNECTION.getTypeByte() == msg.getType();
}
}

View File

@ -9,7 +9,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
/**
* 服务端通道 is active
* SERVER_CHANNEL_ACTIVE
* TCP_SERVER_CHANNEL_ACTIVE
*/
public abstract class AbstractHandleTcpReportServerChannelActiveTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {
@ -22,6 +22,6 @@ public abstract class AbstractHandleTcpReportServerChannelActiveTypeAdvanced<MSG
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.SERVER_CHANNEL_ACTIVE.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_SERVER_CHANNEL_ACTIVE.getTypeByte() == msg.getType();
}
}

View File

@ -9,7 +9,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
/**
* 服务端处理客户端 关闭一个访客
* REPORT_SERVICE_PERMEATE_CLIENT_CLIENT_CLOSE_VISITOR
* TCP_REPORT_SERVICE_PERMEATE_CLIENT_CLIENT_CLOSE_VISITOR
*/
public abstract class AbstractHandleTcpReportServicePermeateClientCloseVisitorTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {

View File

@ -9,7 +9,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
/**
* 服务端处理客户端绑定真实服务成功
* REPORT_SINGLE_CLIENT_REAL_CONNECT
* TCP_REPORT_SINGLE_CLIENT_REAL_CONNECT
*/
public abstract class AbstractHandleTcpReportServicePermeateClientRealConnectTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {
@ -22,6 +22,6 @@ public abstract class AbstractHandleTcpReportServicePermeateClientRealConnectTyp
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.REPORT_SINGLE_CLIENT_REAL_CONNECT.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_REPORT_SINGLE_CLIENT_REAL_CONNECT.getTypeByte() == msg.getType();
}
}

View File

@ -9,7 +9,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
/**
* 服务端处理客户端上报数据
* REPORT_CLIENT_STAGING_CLOSED
* TCP_REPORT_CLIENT_STAGING_CLOSED
*/
public abstract class AbstractHandleTcpReportServicePermeateClientTransferTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {
@ -22,6 +22,6 @@ public abstract class AbstractHandleTcpReportServicePermeateClientTransferTypeAd
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.REPORT_CLIENT_TRANSFER.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_REPORT_CLIENT_TRANSFER.getTypeByte() == msg.getType();
}
}

View File

@ -9,7 +9,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
/**
* 服务端处理客户端 关闭一个访客
* REPORT_SERVICE_PERMEATE_CLIENT_CLIENT_CLOSE_VISITOR
* TCP_REPORT_SERVICE_PERMEATE_CLIENT_CLIENT_CLOSE_VISITOR
*/
public abstract class AbstractHandleTcpReportSingleClientMessage2OtherClientTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {
@ -22,6 +22,6 @@ public abstract class AbstractHandleTcpReportSingleClientMessage2OtherClientType
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.REPORT_SINGLE_CLIENT_MESSAGE.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_REPORT_SINGLE_CLIENT_MESSAGE.getTypeByte() == msg.getType();
}
}

View File

@ -24,6 +24,6 @@ public abstract class AbstractHandleTcpReportStagingClosedTypeAdvanced<MSG> exte
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.REPORT_CLIENT_STAGING_CLOSED.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_REPORT_CLIENT_STAGING_CLOSED.getTypeByte() == msg.getType();
}
}

View File

@ -20,6 +20,6 @@ public abstract class AbstractHandleTcpReportStagingOpenedTypeAdvanced<MSG> exte
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.REPORT_CLIENT_STAGING_OPENED.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_REPORT_CLIENT_STAGING_OPENED.getTypeByte() == msg.getType();
}
}

View File

@ -9,7 +9,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
/**
* 服务端 处理客户端心跳
* TYPE_HEARTBEAT
* TCP_TYPE_HEARTBEAT
*/
public abstract class AbstractUdpHandleChannelHeartbeatTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {
@ -23,6 +23,6 @@ public abstract class AbstractUdpHandleChannelHeartbeatTypeAdvanced<MSG> extends
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.TYPE_HEARTBEAT.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_TYPE_HEARTBEAT.getTypeByte() == msg.getType();
}
}

View File

@ -20,6 +20,6 @@ public abstract class AbstractHandleUdpClientConnectSuccessTypeAdvanced<MSG> ext
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.REPORT_CLIENT_CONNECT_SUCCESS.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_REPORT_CLIENT_CONNECT_SUCCESS.getTypeByte() == msg.getType();
}
}

View File

@ -9,7 +9,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
/**
* 上报 客户端渗透客户端init close 信息
* REPORT_CLIENT_PERMEATE_CLIENT_CLOSE
* TCP_REPORT_CLIENT_PERMEATE_CLIENT_CLOSE
*/
public abstract class AbstractHandleUdpReportClientPermeateClientCloseTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {
@ -22,6 +22,6 @@ public abstract class AbstractHandleUdpReportClientPermeateClientCloseTypeAdvanc
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.REPORT_CLIENT_PERMEATE_CLIENT_CLOSE.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_REPORT_CLIENT_PERMEATE_CLIENT_CLOSE.getTypeByte() == msg.getType();
}
}

View File

@ -9,7 +9,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
/**
* 上报 客户端渗透客户端init信息
* REPORT_CLIENT_PERMEATE_CLIENT_INIT
* TCP_REPORT_CLIENT_PERMEATE_CLIENT_INIT
*/
public abstract class AbstractHandleUdpReportClientPermeateClientInitTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {
@ -22,6 +22,6 @@ public abstract class AbstractHandleUdpReportClientPermeateClientInitTypeAdvance
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.REPORT_CLIENT_PERMEATE_CLIENT_INIT.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_REPORT_CLIENT_PERMEATE_CLIENT_INIT.getTypeByte() == msg.getType();
}
}

View File

@ -9,7 +9,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
/**
* 上报客户端渗透客户端通信通道关闭
*@see MessageTypeEnums#REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE
*@see MessageTypeEnums#TCP_REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE
*/
public abstract class AbstractHandleUdpReportClientPermeateClientTransferCloseTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {
@ -22,6 +22,6 @@ public abstract class AbstractHandleUdpReportClientPermeateClientTransferCloseTy
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_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 close 信息
* REPORT_CLIENT_PERMEATE_SERVER_CLOSE
* TCP_REPORT_CLIENT_PERMEATE_SERVER_CLOSE
*/
public abstract class AbstractHandleUdpReportClientPermeateServerCloseTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {
@ -22,6 +22,6 @@ public abstract class AbstractHandleUdpReportClientPermeateServerCloseTypeAdvanc
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.REPORT_CLIENT_PERMEATE_SERVER_CLOSE.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_REPORT_CLIENT_PERMEATE_SERVER_CLOSE.getTypeByte() == msg.getType();
}
}

View File

@ -9,7 +9,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
/**
* 上报 客户端渗透服务端init信息
* REPORT_CLIENT_PERMEATE_SERVER_INIT
* TCP_REPORT_CLIENT_PERMEATE_SERVER_INIT
*/
public abstract class AbstractHandleUdpReportClientPermeateServerInitTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {
@ -22,6 +22,6 @@ public abstract class AbstractHandleUdpReportClientPermeateServerInitTypeAdvance
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.REPORT_CLIENT_PERMEATE_SERVER_INIT.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_REPORT_CLIENT_PERMEATE_SERVER_INIT.getTypeByte() == msg.getType();
}
}

View File

@ -9,7 +9,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
/**
* 上报 客户端渗透服务端通信通道关闭
* REPORT_CLIENT_PERMEATE_SERVER_TRANSFER_CLOSE
* TCP_TCP_REPORT_CLIENT_PERMEATE_SERVER_TRANSFER_CLOSE
*/
public abstract class AbstractHandleUdpReportClientPermeateServerTransferCloseTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {
@ -22,6 +22,6 @@ public abstract class AbstractHandleUdpReportClientPermeateServerTransferCloseTy
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.REPORT_CLIENT_PERMEATE_SERVER_TRANSFER_CLOSE.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_TCP_REPORT_CLIENT_PERMEATE_SERVER_TRANSFER_CLOSE.getTypeByte() == msg.getType();
}
}

View File

@ -9,7 +9,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
/**
* 上报 客户端渗透服务端通信
* REPORT_CLIENT_PERMEATE_SERVER_TRANSFER
* TCP_REPORT_CLIENT_PERMEATE_SERVER_TRANSFER
*/
public abstract class AbstractHandleUdpReportClientPermeateServerTransferTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {
@ -22,6 +22,6 @@ public abstract class AbstractHandleUdpReportClientPermeateServerTransferTypeAdv
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.REPORT_CLIENT_PERMEATE_SERVER_TRANSFER.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_REPORT_CLIENT_PERMEATE_SERVER_TRANSFER.getTypeByte() == msg.getType();
}
}

View File

@ -9,7 +9,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
/**
* 上报 客户端渗透客户端数据传输通道连接成功
* REPORT_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL
* TCP_REPORT_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL
*/
public abstract class AbstractHandleUdpReportClientTransferClientPermeateChannelConnectionSuccessfulTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {
@ -22,6 +22,6 @@ public abstract class AbstractHandleUdpReportClientTransferClientPermeateChannel
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.REPORT_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_REPORT_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL.getTypeByte() == msg.getType();
}
}

View File

@ -9,7 +9,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
/**
* 上报 客户端渗透客户端数据传输通道init
* REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CHANNEL_INIT_SUCCESSFUL
* TCP_REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CHANNEL_INIT_SUCCESSFUL
*/
public abstract class AbstractHandleUdpReportClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {
@ -22,6 +22,6 @@ public abstract class AbstractHandleUdpReportClientTransferClientPermeateChannel
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.REPORT_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_INIT_SUCCESSFUL.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_REPORT_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_INIT_SUCCESSFUL.getTypeByte() == msg.getType();
}
}

View File

@ -9,7 +9,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
/**
* 上报客户端渗透客户端数据传输结果
* REPORT_CLIENT_TRANSFER_CLIENT_RESPONSE
* TCP_REPORT_CLIENT_TRANSFER_CLIENT_RESPONSE
*/
public abstract class AbstractHandleUdpReportClientTransferClientResponseTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {
@ -22,6 +22,6 @@ public abstract class AbstractHandleUdpReportClientTransferClientResponseTypeAdv
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.REPORT_CLIENT_TRANSFER_CLIENT_RESPONSE.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_REPORT_CLIENT_TRANSFER_CLIENT_RESPONSE.getTypeByte() == msg.getType();
}
}

View File

@ -9,7 +9,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
/**
* 上报客户端渗透客户端数据传输
* REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_REQUEST
* TCP_REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_REQUEST
*/
public abstract class AbstractHandleUdpReportClientTransferClientTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {
@ -22,6 +22,6 @@ public abstract class AbstractHandleUdpReportClientTransferClientTypeAdvanced<MS
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.REPORT_CLIENT_TRANSFER_CLIENT_REQUEST.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_REPORT_CLIENT_TRANSFER_CLIENT_REQUEST.getTypeByte() == msg.getType();
}
}

View File

@ -9,7 +9,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
/**
* 上报 客户端渗透服务端数据传输通道连接成功
* REPORT_CLIENT_TRANSFER_SERVER_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL
* TCP_REPORT_CLIENT_TRANSFER_SERVER_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL
*/
public abstract class AbstractHandleUdpReportClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {
@ -22,6 +22,6 @@ public abstract class AbstractHandleUdpReportClientTransferServerPermeateChannel
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.REPORT_CLIENT_TRANSFER_SERVER_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_REPORT_CLIENT_TRANSFER_SERVER_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL.getTypeByte() == msg.getType();
}
}

View File

@ -9,7 +9,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
/**
* 上报 集群注册
* REPORT_CLUSTER_NODE_REGISTER_MESSAGE
* TCP_REPORT_CLUSTER_NODE_REGISTER_MESSAGE
*/
public abstract class AbstractHandleUdpReportClusterNodeRegisterTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {
@ -22,6 +22,6 @@ public abstract class AbstractHandleUdpReportClusterNodeRegisterTypeAdvanced<MSG
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.REPORT_CLUSTER_NODE_REGISTER_MESSAGE.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_REPORT_CLUSTER_NODE_REGISTER_MESSAGE.getTypeByte() == msg.getType();
}
}

View File

@ -22,6 +22,6 @@ public abstract class AbstractHandleUdpReportDisconnectTypeAdvanced<MSG> extends
@Override
public boolean doSupport(NettyProxyMsg msg) {
// 下发 客户端断开连接通知
return MessageTypeEnums.REPORT_CLIENT_DISCONNECTION.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_REPORT_CLIENT_DISCONNECTION.getTypeByte() == msg.getType();
}
}

View File

@ -9,7 +9,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
/**
* 服务端通道 is active
* SERVER_CHANNEL_ACTIVE
* TCP_SERVER_CHANNEL_ACTIVE
*/
public abstract class AbstractHandleUdpReportServerChannelActiveTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {
@ -22,6 +22,6 @@ public abstract class AbstractHandleUdpReportServerChannelActiveTypeAdvanced<MSG
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.SERVER_CHANNEL_ACTIVE.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_SERVER_CHANNEL_ACTIVE.getTypeByte() == msg.getType();
}
}

View File

@ -9,7 +9,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
/**
* 服务端处理客户端 关闭一个访客
* REPORT_SERVICE_PERMEATE_CLIENT_CLIENT_CLOSE_VISITOR
* TCP_REPORT_SERVICE_PERMEATE_CLIENT_CLIENT_CLOSE_VISITOR
*/
public abstract class AbstractHandleUdpReportServicePermeateClientCloseVisitorTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {

View File

@ -9,7 +9,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
/**
* 服务端处理客户端绑定真实服务成功
* REPORT_SINGLE_CLIENT_REAL_CONNECT
* TCP_REPORT_SINGLE_CLIENT_REAL_CONNECT
*/
public abstract class AbstractHandleUdpReportServicePermeateClientRealConnectTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {
@ -22,6 +22,6 @@ public abstract class AbstractHandleUdpReportServicePermeateClientRealConnectTyp
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.REPORT_SINGLE_CLIENT_REAL_CONNECT.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_REPORT_SINGLE_CLIENT_REAL_CONNECT.getTypeByte() == msg.getType();
}
}

View File

@ -9,7 +9,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
/**
* 服务端处理客户端上报数据
* REPORT_CLIENT_STAGING_CLOSED
* TCP_REPORT_CLIENT_STAGING_CLOSED
*/
public abstract class AbstractHandleUdpReportServicePermeateClientTransferTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {
@ -22,6 +22,6 @@ public abstract class AbstractHandleUdpReportServicePermeateClientTransferTypeAd
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.REPORT_CLIENT_TRANSFER.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_REPORT_CLIENT_TRANSFER.getTypeByte() == msg.getType();
}
}

View File

@ -9,7 +9,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
/**
* 服务端处理客户端 关闭一个访客
* REPORT_SERVICE_PERMEATE_CLIENT_CLIENT_CLOSE_VISITOR
* TCP_REPORT_SERVICE_PERMEATE_CLIENT_CLIENT_CLOSE_VISITOR
*/
public abstract class AbstractHandleUdpReportSingleClientMessage2OtherClientTypeAdvanced<MSG> extends AbstractHandleChannelTypeAdvanced<NettyProxyMsg> implements HandleChannelTypeAdvanced {
@ -22,6 +22,6 @@ public abstract class AbstractHandleUdpReportSingleClientMessage2OtherClientType
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.REPORT_SINGLE_CLIENT_MESSAGE.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_REPORT_SINGLE_CLIENT_MESSAGE.getTypeByte() == msg.getType();
}
}

View File

@ -24,6 +24,6 @@ public abstract class AbstractHandleUdpReportStagingClosedTypeAdvanced<MSG> exte
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.REPORT_CLIENT_STAGING_CLOSED.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_REPORT_CLIENT_STAGING_CLOSED.getTypeByte() == msg.getType();
}
}

View File

@ -20,6 +20,6 @@ public abstract class AbstractHandleUdpReportStagingOpenedTypeAdvanced<MSG> exte
*/
@Override
public boolean doSupport(NettyProxyMsg msg) {
return MessageTypeEnums.REPORT_CLIENT_STAGING_OPENED.getTypeByte() == msg.getType();
return MessageTypeEnums.TCP_REPORT_CLIENT_STAGING_OPENED.getTypeByte() == msg.getType();
}
}

View File

@ -8,6 +8,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
/**
* @see NettyProxyMsg
* NettyProxyMsg 编码
* NettyProxyMsg 编码成 ByteBuf
*/
public class NettyProxyMsgEncoder extends MessageToByteEncoder<NettyProxyMsg> {
/**

View File

@ -16,111 +16,111 @@ public enum MessageTypeEnums {
/**
* @see AbstractTcpHandleChannelHeartbeatTypeAdvanced
*/
TYPE_HEARTBEAT(MessageType.TYPE_HEARTBEAT, "心跳"),
TCP_TYPE_HEARTBEAT(MessageType.TCP_TYPE_HEARTBEAT, "心跳"),
/**
* @see AbstractHandleTcpClientConnectSuccessTypeAdvanced
*/
REPORT_CLIENT_CONNECT_SUCCESS(MessageType.REPORT_CLIENT_CONNECT_SUCCESS, "上报 客户端连接成功"),
TCP_REPORT_CLIENT_CONNECT_SUCCESS(MessageType.TCP_REPORT_CLIENT_CONNECT_SUCCESS, "上报 客户端连接成功"),
/**
* @see AbstractHandleTcpReportDisconnectTypeAdvanced
*/
REPORT_CLIENT_DISCONNECTION(MessageType.REPORT_CLIENT_DISCONNECTION, "上报 客户端断开连接"),
TCP_REPORT_CLIENT_DISCONNECTION(MessageType.TCP_REPORT_CLIENT_DISCONNECTION, "上报 客户端断开连接"),
/**
* @see AbstractHandleTcpReportStagingOpenedTypeAdvanced
*/
REPORT_CLIENT_STAGING_OPENED(MessageType.REPORT_CLIENT_STAGING_OPENED, "上报 客户端暂存开启"),
TCP_REPORT_CLIENT_STAGING_OPENED(MessageType.TCP_REPORT_CLIENT_STAGING_OPENED, "上报 客户端暂存开启"),
/**
* @see AbstractHandleTcpReportStagingClosedTypeAdvanced
*/
REPORT_CLIENT_STAGING_CLOSED(MessageType.REPORT_CLIENT_STAGING_CLOSED, "上报 客户端暂存关闭"),
TCP_REPORT_CLIENT_STAGING_CLOSED(MessageType.TCP_REPORT_CLIENT_STAGING_CLOSED, "上报 客户端暂存关闭"),
/**
* @see AbstractHandleTcpReportServicePermeateClientTransferTypeAdvanced
*/
REPORT_CLIENT_TRANSFER(MessageType.REPORT_CLIENT_TRANSFER, "上报 客户端数据传输(内网穿透数据回传)"),
TCP_REPORT_CLIENT_TRANSFER(MessageType.TCP_REPORT_CLIENT_TRANSFER, "上报 客户端数据传输(内网穿透数据回传)"),
/**
* @see AbstractHandleTcpReportServicePermeateClientRealConnectTypeAdvanced
*/
REPORT_SINGLE_CLIENT_REAL_CONNECT(MessageType.REPORT_SINGLE_CLIENT_REAL_CONNECT, "上报 客户端创建需要代理的真实端口成功"),
TCP_REPORT_SINGLE_CLIENT_REAL_CONNECT(MessageType.TCP_REPORT_SINGLE_CLIENT_REAL_CONNECT, "上报 客户端创建需要代理的真实端口成功"),
/**
* @see AbstractHandleTcpReportServicePermeateClientCloseVisitorTypeAdvanced
*/
REPORT_SINGLE_CLIENT_CLOSE_VISITOR(MessageType.REPORT_SERVICE_PERMEATE_CLIENT_CLIENT_CLOSE_VISITOR, "上报 客户端关闭一个访客通道"),
REPORT_SINGLE_CLIENT_CLOSE_VISITOR(MessageType.TCP_REPORT_SERVICE_PERMEATE_CLIENT_CLIENT_CLOSE_VISITOR, "上报 客户端关闭一个访客通道"),
/**
* @see AbstractHandleTcpReportSingleClientMessage2OtherClientTypeAdvanced
*/
REPORT_SINGLE_CLIENT_MESSAGE(MessageType.REPORT_SINGLE_CLIENT_MESSAGE, "上报 客户端消息到另一个客户端"),
TCP_REPORT_SINGLE_CLIENT_MESSAGE(MessageType.TCP_REPORT_SINGLE_CLIENT_MESSAGE, "上报 客户端消息到另一个客户端"),
/**
* @see AbstractHandleTcpReportServerChannelActiveTypeAdvanced
*/
SERVER_CHANNEL_ACTIVE(MessageType.SERVER_CHANNEL_ACTIVE, "服务端通道 is active"),
TCP_SERVER_CHANNEL_ACTIVE(MessageType.TCP_SERVER_CHANNEL_ACTIVE, "服务端通道 is active"),
/**
* @see AbstractHandleTcpReportClusterNodeRegisterTypeAdvanced
*/
REPORT_CLUSTER_NODE_REGISTER_MESSAGE(MessageType.REPORT_CLUSTER_NODE_REGISTER_MESSAGE, "上报 集群注册"),
TCP_REPORT_CLUSTER_NODE_REGISTER_MESSAGE(MessageType.TCP_REPORT_CLUSTER_NODE_REGISTER_MESSAGE, "上报 集群注册"),
/**
* @see AbstractHandleTcpReportClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced
*/
REPORT_CLIENT_TRANSFER_SERVER_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL(MessageType.REPORT_CLIENT_TRANSFER_SERVER_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL, "上报 客户端渗透服务端数据传输通道连接成功"),
TCP_REPORT_CLIENT_TRANSFER_SERVER_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL(MessageType.TCP_REPORT_CLIENT_TRANSFER_SERVER_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL, "上报 客户端渗透服务端数据传输通道连接成功"),
/**
* @see AbstractHandleTcpReportClientPermeateServerInitTypeAdvanced
*/
REPORT_CLIENT_PERMEATE_SERVER_INIT(MessageType.REPORT_CLIENT_PERMEATE_SERVER_INIT, "上报 客户端渗透服务端init信息"),
TCP_REPORT_CLIENT_PERMEATE_SERVER_INIT(MessageType.TCP_REPORT_CLIENT_PERMEATE_SERVER_INIT, "上报 客户端渗透服务端init信息"),
/**
* 上报 客户端渗透服务端init close 信息
* @see AbstractHandleTcpReportClientPermeateServerCloseTypeAdvanced
*/
REPORT_CLIENT_PERMEATE_SERVER_CLOSE(MessageType.REPORT_CLIENT_PERMEATE_SERVER_CLOSE, "上报 客户端渗透服务端init close 信息"),
TCP_REPORT_CLIENT_PERMEATE_SERVER_CLOSE(MessageType.TCP_REPORT_CLIENT_PERMEATE_SERVER_CLOSE, "上报 客户端渗透服务端init close 信息"),
/**
* 上报 客户端渗透服务端通信通道关闭
* @see AbstractHandleTcpReportClientPermeateServerTransferCloseTypeAdvanced
*/
REPORT_CLIENT_PERMEATE_SERVER_TRANSFER_CLOSE(MessageType.REPORT_CLIENT_PERMEATE_SERVER_TRANSFER_CLOSE, "上报 客户端渗透服务端通信通道关闭"),
TCP_TCP_REPORT_CLIENT_PERMEATE_SERVER_TRANSFER_CLOSE(MessageType.TCP_TCP_REPORT_CLIENT_PERMEATE_SERVER_TRANSFER_CLOSE, "上报 客户端渗透服务端通信通道关闭"),
/**
* 上报 客户端渗透服务端通信传输
* @see AbstractHandleTcpReportClientPermeateServerTransferTypeAdvanced
*/
REPORT_CLIENT_PERMEATE_SERVER_TRANSFER(MessageType.REPORT_CLIENT_PERMEATE_SERVER_TRANSFER, "上报 客户端渗透服务端通信传输"),
TCP_REPORT_CLIENT_PERMEATE_SERVER_TRANSFER(MessageType.TCP_REPORT_CLIENT_PERMEATE_SERVER_TRANSFER, "上报 客户端渗透服务端通信传输"),
/**
* @see AbstractHandleTcpReportClientPermeateClientInitTypeAdvanced
*/
REPORT_CLIENT_PERMEATE_CLIENT_INIT(MessageType.REPORT_CLIENT_PERMEATE_CLIENT_INIT, "上报 客户端渗透客户端init信息"),
TCP_REPORT_CLIENT_PERMEATE_CLIENT_INIT(MessageType.TCP_REPORT_CLIENT_PERMEATE_CLIENT_INIT, "上报 客户端渗透客户端init信息"),
/**
* 上报 客户端渗透客户端init close 信息
* @see AbstractHandleTcpReportClientPermeateClientCloseTypeAdvanced
*/
REPORT_CLIENT_PERMEATE_CLIENT_CLOSE(MessageType.REPORT_CLIENT_PERMEATE_CLIENT_CLOSE, "上报 客户端渗透客户端init close 信息"),
TCP_REPORT_CLIENT_PERMEATE_CLIENT_CLOSE(MessageType.TCP_REPORT_CLIENT_PERMEATE_CLIENT_CLOSE, "上报 客户端渗透客户端init close 信息"),
/**
* 上报 客户端渗透客户端数据传输通道连接成功
* @see AbstractHandleTcpReportClientTransferClientPermeateChannelConnectionSuccessfulTypeAdvanced
*/
REPORT_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL(MessageType.REPORT_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL, "上报 客户端渗透客户端数据传输通道连接成功"),
TCP_REPORT_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL(MessageType.TCP_REPORT_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL, "上报 客户端渗透客户端数据传输通道连接成功"),
/**
* 上报 客户端渗透客户端数据传输通道init 成功
* @see AbstractHandleTcpReportClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced
*/
REPORT_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_INIT_SUCCESSFUL(MessageType.REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CHANNEL_INIT_SUCCESSFUL, "上报 客户端渗透客户端数据传输通道init成功"),
TCP_REPORT_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_INIT_SUCCESSFUL(MessageType.TCP_REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CHANNEL_INIT_SUCCESSFUL, "上报 客户端渗透客户端数据传输通道init成功"),
/**
* 上报 上报客户端渗透客户端数据传输
* @see AbstractHandleTcpReportClientTransferClientTypeAdvanced
*/
REPORT_CLIENT_TRANSFER_CLIENT_REQUEST(MessageType.REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_REQUEST, "上报客户端渗透客户端数据传输"),
TCP_REPORT_CLIENT_TRANSFER_CLIENT_REQUEST(MessageType.TCP_REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_REQUEST, "上报客户端渗透客户端数据传输"),
/**
* 上报客户端渗透客户端数据传输结果
* @see AbstractHandleTcpReportClientTransferClientResponseTypeAdvanced
*/
REPORT_CLIENT_TRANSFER_CLIENT_RESPONSE(MessageType.REPORT_CLIENT_TRANSFER_CLIENT_RESPONSE, "上报客户端渗透客户端数据传输结果"),
TCP_REPORT_CLIENT_TRANSFER_CLIENT_RESPONSE(MessageType.TCP_REPORT_CLIENT_TRANSFER_CLIENT_RESPONSE, "上报客户端渗透客户端数据传输结果"),
/**
* 上报客户端渗透客户端通信通道关闭
*
* @see AbstractHandleTcpReportClientPermeateClientTransferCloseTypeAdvanced
*/
REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE(MessageType.REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE, "上报客户端渗透客户端通信通道关闭"),
TCP_REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE(MessageType.TCP_REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE, "上报客户端渗透客户端通信通道关闭"),
/**
* @see AbstractHandleTcpDistributeConnectSuccessNotificationTypeAdvancedHandle
*/

View File

@ -88,7 +88,7 @@ public class ClusterNodeChangeEventImpl implements ClientChangeEvent {
if (serverEndpointChannelChannel != null && serverEndpointChannelChannel.isActive()) {
// 客户端本地获取所有 已经连接的服务端的channel 通知他们 扫描数据库node信息重新初始化
NettyProxyMsg nettyMsg = new NettyProxyMsg();
nettyMsg.setType(MessageType.REPORT_CLUSTER_NODE_REGISTER_MESSAGE);
nettyMsg.setType(MessageType.TCP_REPORT_CLUSTER_NODE_REGISTER_MESSAGE);
nettyMsg.setClientId(clientId);
nettyMsg.setData((clientId).getBytes());
serverEndpointChannelChannel.writeAndFlush(nettyMsg);

View File

@ -1,102 +0,0 @@
package org.framework.lazy.cloud.network.heartbeat.server.config;
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelFlowAdapter;
import org.framework.lazy.cloud.network.heartbeat.server.netty.tcp.advanced.*;
import org.framework.lazy.cloud.network.heartbeat.server.properties.ServerNodeProperties;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.*;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Role;
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public class HeartbeatServerConfiguration {
/**
* 服务端 处理客户端心跳
*
* @return ServerHandleTcpChannelHeartbeatTypeAdvanced
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Bean
public ServerHandleTcpChannelHeartbeatTypeAdvanced serverChannelHeartbeatTypeAdvanced() {
return new ServerHandleTcpChannelHeartbeatTypeAdvanced();
}
/**
* 处理 服务端处理客户端数据传输
*
* @return ServerHandleTcpReportServicePermeateClientTransferTypeAdvanced
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Bean
public ServerHandleTcpReportServicePermeateClientTransferTypeAdvanced serverReportChannelTransferTypeAdvanced(ChannelFlowAdapter channelFlowAdapter) {
return new ServerHandleTcpReportServicePermeateClientTransferTypeAdvanced(channelFlowAdapter);
}
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Bean
public ServerHandleTcpClientConnectSuccessTypeAdvanced serverReportConnectSuccessTypeAdvanced(
LazyClientStatsChangeApplication lazyClientStatsChangeApplication,
LazyNettyClientBlacklistApplication lazyNettyClientBlacklistApplication,
LazyInternalNetworkServerPermeateClientMappingApplication lazyInternalNetworkServerPermeateClientMappingApplication,
LazyInternalNetworkClientPermeateServerMappingApplication lazyInternalNetworkClientPermeateServerMappingApplication,
LazyInternalNetworkClientPermeateClientMappingApplication lazyInternalNetworkClientPermeateClientMappingApplication,
LazyNettyClientTokenBucketApplication lazyNettyClientTokenBucketApplication,
ServerNodeProperties serverNodeProperties
) {
return new ServerHandleTcpClientConnectSuccessTypeAdvanced(lazyClientStatsChangeApplication,
lazyNettyClientBlacklistApplication,
lazyInternalNetworkServerPermeateClientMappingApplication,
lazyInternalNetworkClientPermeateServerMappingApplication,
lazyInternalNetworkClientPermeateClientMappingApplication,
lazyNettyClientTokenBucketApplication,
serverNodeProperties
);
}
/**
* 服务端处理集群注册信息
*
* @param lazyNettyClusterNodeApplication 集群信息获取
* @return ServerHandleTcpReportClusterNodeRegisterTypeAdvanced
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Bean
public ServerHandleTcpReportClusterNodeRegisterTypeAdvanced serverHandleReportClusterNodeRegisterTypeAdvanced() {
return new ServerHandleTcpReportClusterNodeRegisterTypeAdvanced();
}
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Bean
public ServerHandleTcpReportDisconnectTypeAdvanced serverReportDisconnectTypeAdvanced(LazyClientStatsChangeApplication lazyClientStatsChangeApplication) {
return new ServerHandleTcpReportDisconnectTypeAdvanced(lazyClientStatsChangeApplication);
}
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Bean
public ServerHandleTcpReportServicePermeateClientCloseVisitorTypeAdvanced serverReportSingleClientCloseVisitorTypeAdvanced() {
return new ServerHandleTcpReportServicePermeateClientCloseVisitorTypeAdvanced();
}
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Bean
public ServerHandleTcpReportServicePermeateClientRealConnectTypeAdvanced serverReportSingleClientRealConnectTypeAdvanced() {
return new ServerHandleTcpReportServicePermeateClientRealConnectTypeAdvanced();
}
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Bean
public ServerHandleTcpReportStagingClosedTypeAdvanced serverReportStagingClosedTypeAdvanced(LazyClientStatsChangeApplication lazyClientStatsChangeApplication) {
return new ServerHandleTcpReportStagingClosedTypeAdvanced(lazyClientStatsChangeApplication);
}
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Bean
public ServerHandleTcpReportStagingOpenedTypeAdvanced serverReportStagingOpenedTypeAdvanced(LazyClientStatsChangeApplication lazyClientStatsChangeApplication) {
return new ServerHandleTcpReportStagingOpenedTypeAdvanced(lazyClientStatsChangeApplication);
}
}

View File

@ -0,0 +1,196 @@
package org.framework.lazy.cloud.network.heartbeat.server.config;
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelFlowAdapter;
import org.framework.lazy.cloud.network.heartbeat.server.netty.tcp.advanced.*;
import org.framework.lazy.cloud.network.heartbeat.server.netty.udp.advanced.*;
import org.framework.lazy.cloud.network.heartbeat.server.properties.ServerNodeProperties;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.*;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Role;
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public class ServerAutoConfiguration {
@Configuration( )
static class ServerTcpConfiguration{
/**
* 服务端 处理客户端心跳
*
* @return ServerHandleTcpChannelHeartbeatTypeAdvanced
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Bean
public ServerHandleTcpChannelHeartbeatTypeAdvanced serverChannelHeartbeatTypeAdvanced() {
return new ServerHandleTcpChannelHeartbeatTypeAdvanced();
}
/**
* 处理 服务端处理客户端数据传输
*
* @return ServerHandleTcpReportServicePermeateClientTransferTypeAdvanced
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Bean
static ServerHandleTcpReportServicePermeateClientTransferTypeAdvanced serverReportChannelTransferTypeAdvanced(ChannelFlowAdapter channelFlowAdapter) {
return new ServerHandleTcpReportServicePermeateClientTransferTypeAdvanced(channelFlowAdapter);
}
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Bean
static ServerHandleTcpClientConnectSuccessTypeAdvanced serverReportConnectSuccessTypeAdvanced(
LazyClientStatsChangeApplication lazyClientStatsChangeApplication,
LazyNettyClientBlacklistApplication lazyNettyClientBlacklistApplication,
LazyInternalNetworkServerPermeateClientMappingApplication lazyInternalNetworkServerPermeateClientMappingApplication,
LazyInternalNetworkClientPermeateServerMappingApplication lazyInternalNetworkClientPermeateServerMappingApplication,
LazyInternalNetworkClientPermeateClientMappingApplication lazyInternalNetworkClientPermeateClientMappingApplication,
LazyNettyClientTokenBucketApplication lazyNettyClientTokenBucketApplication,
ServerNodeProperties serverNodeProperties
) {
return new ServerHandleTcpClientConnectSuccessTypeAdvanced(lazyClientStatsChangeApplication,
lazyNettyClientBlacklistApplication,
lazyInternalNetworkServerPermeateClientMappingApplication,
lazyInternalNetworkClientPermeateServerMappingApplication,
lazyInternalNetworkClientPermeateClientMappingApplication,
lazyNettyClientTokenBucketApplication,
serverNodeProperties
);
}
/**
* 服务端处理集群注册信息
*
* @param lazyNettyClusterNodeApplication 集群信息获取
* @return ServerHandleTcpReportClusterNodeRegisterTypeAdvanced
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Bean
static ServerHandleTcpReportClusterNodeRegisterTypeAdvanced serverHandleReportClusterNodeRegisterTypeAdvanced() {
return new ServerHandleTcpReportClusterNodeRegisterTypeAdvanced();
}
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Bean
static ServerHandleTcpReportDisconnectTypeAdvanced serverReportDisconnectTypeAdvanced(LazyClientStatsChangeApplication lazyClientStatsChangeApplication) {
return new ServerHandleTcpReportDisconnectTypeAdvanced(lazyClientStatsChangeApplication);
}
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Bean
static ServerHandleTcpReportServicePermeateClientCloseVisitorTypeAdvanced serverReportSingleClientCloseVisitorTypeAdvanced() {
return new ServerHandleTcpReportServicePermeateClientCloseVisitorTypeAdvanced();
}
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Bean
static ServerHandleTcpReportServicePermeateClientRealConnectTypeAdvanced serverReportSingleClientRealConnectTypeAdvanced() {
return new ServerHandleTcpReportServicePermeateClientRealConnectTypeAdvanced();
}
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Bean
static ServerHandleTcpReportStagingClosedTypeAdvanced serverReportStagingClosedTypeAdvanced(LazyClientStatsChangeApplication lazyClientStatsChangeApplication) {
return new ServerHandleTcpReportStagingClosedTypeAdvanced(lazyClientStatsChangeApplication);
}
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Bean
static ServerHandleTcpReportStagingOpenedTypeAdvanced serverReportStagingOpenedTypeAdvanced(LazyClientStatsChangeApplication lazyClientStatsChangeApplication) {
return new ServerHandleTcpReportStagingOpenedTypeAdvanced(lazyClientStatsChangeApplication);
}
}
@Configuration( )
static class ServerUdpConfiguration{
/**
* 服务端 处理客户端心跳
*
* @return ServerHandleUdpChannelHeartbeatTypeAdvanced
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Bean
public ServerHandleUdpChannelHeartbeatTypeAdvanced serverChannelHeartbeatTypeAdvanced() {
return new ServerHandleUdpChannelHeartbeatTypeAdvanced();
}
/**
* 处理 服务端处理客户端数据传输
*
* @return ServerHandleUdpReportServicePermeateClientTransferTypeAdvanced
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Bean
static ServerHandleUdpReportServicePermeateClientTransferTypeAdvanced serverReportChannelTransferTypeAdvanced(ChannelFlowAdapter channelFlowAdapter) {
return new ServerHandleUdpReportServicePermeateClientTransferTypeAdvanced(channelFlowAdapter);
}
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Bean
static ServerHandleUdpClientConnectSuccessTypeAdvanced serverReportConnectSuccessTypeAdvanced(
LazyClientStatsChangeApplication lazyClientStatsChangeApplication,
LazyNettyClientBlacklistApplication lazyNettyClientBlacklistApplication,
LazyInternalNetworkServerPermeateClientMappingApplication lazyInternalNetworkServerPermeateClientMappingApplication,
LazyInternalNetworkClientPermeateServerMappingApplication lazyInternalNetworkClientPermeateServerMappingApplication,
LazyInternalNetworkClientPermeateClientMappingApplication lazyInternalNetworkClientPermeateClientMappingApplication,
LazyNettyClientTokenBucketApplication lazyNettyClientTokenBucketApplication,
ServerNodeProperties serverNodeProperties
) {
return new ServerHandleUdpClientConnectSuccessTypeAdvanced(lazyClientStatsChangeApplication,
lazyNettyClientBlacklistApplication,
lazyInternalNetworkServerPermeateClientMappingApplication,
lazyInternalNetworkClientPermeateServerMappingApplication,
lazyInternalNetworkClientPermeateClientMappingApplication,
lazyNettyClientTokenBucketApplication,
serverNodeProperties
);
}
/**
* 服务端处理集群注册信息
*
* @param lazyNettyClusterNodeApplication 集群信息获取
* @return ServerHandleUdpReportClusterNodeRegisterTypeAdvanced
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Bean
static ServerHandleUdpReportClusterNodeRegisterTypeAdvanced serverHandleReportClusterNodeRegisterTypeAdvanced() {
return new ServerHandleUdpReportClusterNodeRegisterTypeAdvanced();
}
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Bean
static ServerHandleUdpReportDisconnectTypeAdvanced serverReportDisconnectTypeAdvanced(LazyClientStatsChangeApplication lazyClientStatsChangeApplication) {
return new ServerHandleUdpReportDisconnectTypeAdvanced(lazyClientStatsChangeApplication);
}
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Bean
static ServerHandleUdpReportServicePermeateClientCloseVisitorTypeAdvanced serverReportSingleClientCloseVisitorTypeAdvanced() {
return new ServerHandleUdpReportServicePermeateClientCloseVisitorTypeAdvanced();
}
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Bean
static ServerHandleUdpReportServicePermeateClientRealConnectTypeAdvanced serverReportSingleClientRealConnectTypeAdvanced() {
return new ServerHandleUdpReportServicePermeateClientRealConnectTypeAdvanced();
}
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Bean
static ServerHandleUdpReportStagingClosedTypeAdvanced serverReportStagingClosedTypeAdvanced(LazyClientStatsChangeApplication lazyClientStatsChangeApplication) {
return new ServerHandleUdpReportStagingClosedTypeAdvanced(lazyClientStatsChangeApplication);
}
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Bean
static ServerHandleUdpReportStagingOpenedTypeAdvanced serverReportStagingOpenedTypeAdvanced(LazyClientStatsChangeApplication lazyClientStatsChangeApplication) {
return new ServerHandleUdpReportStagingOpenedTypeAdvanced(lazyClientStatsChangeApplication);
}
}
}

View File

@ -10,6 +10,7 @@ import io.netty.util.internal.SystemPropertyUtil;
import jakarta.annotation.PreDestroy;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.server.netty.tcp.filter.NettyTcpServerFilter;
import org.framework.lazy.cloud.network.heartbeat.server.netty.udp.filter.NettyUdpServerFilter;
import org.framework.lazy.cloud.network.heartbeat.server.properties.ServerNodeProperties;
import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.context.ApplicationListener;
@ -20,12 +21,12 @@ import org.springframework.stereotype.Component;
public class NettyUdpServerSocketApplicationListener implements ApplicationListener<ApplicationStartedEvent> {
private final EventLoopGroup bossGroup = "linux".equalsIgnoreCase(SystemPropertyUtil.get("os.name")) ? new EpollEventLoopGroup() : new NioEventLoopGroup();
private final NettyTcpServerFilter nettyTcpServerFilter;// 通道业务处理
private final NettyUdpServerFilter nettyUdpServerFilter;// 通道业务处理
private ChannelFuture channelFuture;
private final ServerNodeProperties serverNodeProperties;
public NettyUdpServerSocketApplicationListener(NettyTcpServerFilter nettyTcpServerFilter, ServerNodeProperties serverNodeProperties) {
this.nettyTcpServerFilter = nettyTcpServerFilter;
public NettyUdpServerSocketApplicationListener(NettyUdpServerFilter nettyUdpServerFilter, ServerNodeProperties serverNodeProperties) {
this.nettyUdpServerFilter = nettyUdpServerFilter;
this.serverNodeProperties = serverNodeProperties;
}
@ -59,7 +60,7 @@ public class NettyUdpServerSocketApplicationListener implements ApplicationListe
.option(ChannelOption.SO_RCVBUF, 1024 * 1024 * 10)
//发送缓存区 10M
.option(ChannelOption.SO_SNDBUF, 1024 * 1024 * 10)
.handler(nettyTcpServerFilter);
.handler(nettyUdpServerFilter);
channelFuture = b.bind(udpPort).sync();
channelFuture.addListener((ChannelFutureListener) channelFuture -> {

View File

@ -12,7 +12,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
/**
* 服务端 处理客户端心跳
* TYPE_HEARTBEAT
* TCP_TYPE_HEARTBEAT
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Component
@ -27,7 +27,7 @@ public class ServerHandleTcpChannelHeartbeatTypeAdvanced extends AbstractTcpHand
@Override
public void doHandler(Channel channel, NettyProxyMsg msg) {
NettyProxyMsg hb = new NettyProxyMsg();
hb.setType(MessageType.TYPE_HEARTBEAT);
hb.setType(MessageType.TCP_TYPE_HEARTBEAT);
channel.writeAndFlush(hb);
}

View File

@ -28,7 +28,7 @@ import java.util.List;
/**
* 服务端连接成功处理
* REPORT_CLIENT_CONNECT_SUCCESS
* TCP_REPORT_CLIENT_CONNECT_SUCCESS
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j

View File

@ -16,7 +16,7 @@ import org.springframework.stereotype.Component;
/**
* 上报 客户端渗透服务端通信
* REPORT_CLIENT_PERMEATE_SERVER_TRANSFER
* TCP_REPORT_CLIENT_PERMEATE_SERVER_TRANSFER
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j

View File

@ -19,7 +19,7 @@ import org.springframework.stereotype.Component;
/**
* 服务端处理客户端数据传输
* REPORT_CLIENT_TRANSFER
* TCP_REPORT_CLIENT_TRANSFER
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j

View File

@ -73,7 +73,7 @@ public class NettyTcpServerHandler extends SimpleChannelInboundHandler<NettyProx
// 给所有客户端发送 这个客户端离线了
NettyProxyMsg nettyMsg = new NettyProxyMsg();
nettyMsg.setClientId(clientId);
nettyMsg.setType(MessageType.REPORT_CLIENT_DISCONNECTION);
nettyMsg.setType(MessageType.TCP_REPORT_CLIENT_DISCONNECTION);
channelTypeAdapter.handler(channel, nettyMsg);
channel.close();
} else {
@ -132,7 +132,7 @@ public class NettyTcpServerHandler extends SimpleChannelInboundHandler<NettyProx
// 断开客户端的连接:{}
log.warn("Disconnect client:{}", clientId);
NettyProxyMsg nettyMsg = new NettyProxyMsg();
nettyMsg.setType(MessageType.REPORT_CLIENT_DISCONNECTION);
nettyMsg.setType(MessageType.TCP_REPORT_CLIENT_DISCONNECTION);
nettyMsg.setClientId(clientId);
channelTypeAdapter.handler(channel, nettyMsg);
super.channelInactive(ctx);

View File

@ -0,0 +1,35 @@
package org.framework.lazy.cloud.network.heartbeat.server.netty.udp.advanced;
import io.netty.channel.Channel;
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.udp.AbstractUdpHandleChannelHeartbeatTypeAdvanced;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
import org.springframework.stereotype.Component;
/**
* 服务端 处理客户端心跳
* TCP_TYPE_HEARTBEAT
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Component
public class ServerHandleUdpChannelHeartbeatTypeAdvanced extends AbstractUdpHandleChannelHeartbeatTypeAdvanced<NettyProxyMsg> {
/**
* 处理当前数据
*
* @param channel 当前通道
* @param msg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg msg) {
NettyProxyMsg hb = new NettyProxyMsg();
hb.setType(MessageType.TCP_TYPE_HEARTBEAT);
channel.writeAndFlush(hb);
}
}

View File

@ -0,0 +1,182 @@
package org.framework.lazy.cloud.network.heartbeat.server.netty.udp.advanced;
import com.alibaba.fastjson.JSON;
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.advanced.udp.server.AbstractHandleUdpClientConnectSuccessTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.framework.lazy.cloud.network.heartbeat.server.properties.ServerNodeProperties;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.*;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.command.lazy.netty.client.permeate.client.mapping.LazyInternalNetworkClientPermeateClientMappingQueryListCommand;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.command.lazy.netty.client.permeate.server.mapping.LazyInternalNetworkClientPermeateServerMappingQueryListCommand;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.command.lazy.netty.client.state.LazyNettyClientLoginCommand;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.dto.LazyInternalNetworkClientPermeateClientMappingDTO;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.dto.LazyInternalNetworkClientPermeateServerMappingDTO;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.domain.model.lazy.netty.client.blacklist.LazyNettyClientBlacklist;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
import org.springframework.stereotype.Component;
import org.wu.framework.web.response.Result;
import java.nio.charset.StandardCharsets;
import java.util.List;
/**
* 服务端连接成功处理
* TCP_REPORT_CLIENT_CONNECT_SUCCESS
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
@Component
public class ServerHandleUdpClientConnectSuccessTypeAdvanced extends AbstractHandleUdpClientConnectSuccessTypeAdvanced<NettyProxyMsg> {
private final LazyClientStatsChangeApplication lazyClientStatsChangeApplication;
private final LazyNettyClientBlacklistApplication lazyNettyClientBlacklistApplication;
private final LazyInternalNetworkServerPermeateClientMappingApplication lazyInternalNetworkServerPermeateClientMappingApplication;
private final LazyInternalNetworkClientPermeateServerMappingApplication lazyInternalNetworkClientPermeateServerMappingApplication;
private final LazyInternalNetworkClientPermeateClientMappingApplication lazyInternalNetworkClientPermeateClientMappingApplication;
private final LazyNettyClientTokenBucketApplication lazyNettyClientTokenBucketApplication;
private final ServerNodeProperties serverNodeProperties;
public ServerHandleUdpClientConnectSuccessTypeAdvanced(LazyClientStatsChangeApplication lazyClientStatsChangeApplication, LazyNettyClientBlacklistApplication lazyNettyClientBlacklistApplication, LazyInternalNetworkServerPermeateClientMappingApplication lazyInternalNetworkServerPermeateClientMappingApplication, LazyInternalNetworkClientPermeateServerMappingApplication lazyInternalNetworkClientPermeateServerMappingApplication, LazyInternalNetworkClientPermeateClientMappingApplication lazyInternalNetworkClientPermeateClientMappingApplication, LazyNettyClientTokenBucketApplication lazyNettyClientTokenBucketApplication, ServerNodeProperties serverNodeProperties) {
this.lazyClientStatsChangeApplication = lazyClientStatsChangeApplication;
this.lazyNettyClientBlacklistApplication = lazyNettyClientBlacklistApplication;
this.lazyInternalNetworkServerPermeateClientMappingApplication = lazyInternalNetworkServerPermeateClientMappingApplication;
this.lazyInternalNetworkClientPermeateServerMappingApplication = lazyInternalNetworkClientPermeateServerMappingApplication;
this.lazyInternalNetworkClientPermeateClientMappingApplication = lazyInternalNetworkClientPermeateClientMappingApplication;
this.lazyNettyClientTokenBucketApplication = lazyNettyClientTokenBucketApplication;
this.serverNodeProperties = serverNodeProperties;
}
/**
* 处理当前数据
*
* @param newChannel 当前通道
* @param msg 通道数据
*/
@Override
public void doHandler(Channel newChannel, NettyProxyMsg msg) {
String clientId = msg.getClientIdString();
String appKey = msg.getAppKeyString();
String appSecret = msg.getAppSecretString();
String originalIp = msg.getOriginalIpString();
ChannelContext.push(newChannel, clientId);
ChannelAttributeKeyUtils.buildClientId(newChannel, clientId);
ChannelAttributeKeyUtils.buildAppKey(newChannel, appKey);
ChannelAttributeKeyUtils.buildAppSecret(newChannel, appSecret);
ChannelAttributeKeyUtils.buildOriginalIp(newChannel, originalIp);
// 客户端:{}IP:{}连接成功
log.info("Client: {}, IP: {} Connection successful", new String(msg.getClientId()), newChannel.remoteAddress().toString());
// 验证客户端是否时黑名单
LazyNettyClientBlacklist lazyNettyClientBlacklist = new LazyNettyClientBlacklist();
lazyNettyClientBlacklist.setClientId(clientId);
lazyNettyClientBlacklist.setIsDeleted(false);
lazyNettyClientBlacklistApplication.exists(lazyNettyClientBlacklist).accept(exists -> {
if (!exists) {
// 认证验证
Result<Boolean> existsTokenResult = lazyNettyClientTokenBucketApplication.certificationToken(clientId, appKey, appSecret);
Boolean existsToken= existsTokenResult.getData();
Boolean enableTokenVerification = serverNodeProperties.getEnableTokenVerification();
existsToken = enableTokenVerification ? existsToken : true;
if(existsToken){
// 服务状态在线
LazyNettyClientLoginCommand lazyNettyClientLoginCommand = new LazyNettyClientLoginCommand();
lazyNettyClientLoginCommand.setClientId(clientId);
lazyNettyClientLoginCommand.setAppKey(appKey);
lazyNettyClientLoginCommand.setAppSecret(appSecret);
lazyNettyClientLoginCommand.setOriginalIp(originalIp);
lazyClientStatsChangeApplication.clientOnLine(lazyNettyClientLoginCommand);
// 当前在线客户端数量:{}
log.info("Current number of online clients: {}", ChannelContext.getClientIds().size());
// 所有的客户端ID
List<String> clientIdList = ChannelContext.getClientIds();
// TODO 多副本本地channel 无法共享问题
// 通知所有客户端有人上线了
ChannelContext.getChannels().forEach((existClientId, channels) -> {
NettyProxyMsg nettyMsg = new NettyProxyMsg();
nettyMsg.setType(MessageType.DISTRIBUTE_CLIENT_CONNECTION_SUCCESS_NOTIFICATION);
nettyMsg.setData((JSON.toJSONString(clientIdList)
.getBytes(StandardCharsets.UTF_8)));
// 发送所有客户端ID
for (Channel channel : channels) {
channel.writeAndFlush(nettyMsg);
}
});
// 开始开启客户端{},端口映射
log.info("Start opening client: [{}], port mapping", clientId);
// 创建访问者内网穿透连接创建
lazyInternalNetworkServerPermeateClientMappingApplication.createVisitor(clientId);
// 结束开启客户端{},端口映射
log.info("End opening client: [{}], port mapping", clientId);
}else {
// 关闭通道
log.warn("无法认证客户端:【{}】",clientId);
newChannel.close();
}
} else {
// 黑名单客户端
}
});
// 查询客户端渗透服务端信息
LazyInternalNetworkClientPermeateServerMappingQueryListCommand lazyInternalNetworkClientPermeateServerMappingQueryListCommand = new LazyInternalNetworkClientPermeateServerMappingQueryListCommand();
lazyInternalNetworkClientPermeateServerMappingQueryListCommand.setClientId(clientId);
lazyInternalNetworkClientPermeateServerMappingQueryListCommand.setIsDeleted(false);
lazyInternalNetworkClientPermeateServerMappingApplication.findList(lazyInternalNetworkClientPermeateServerMappingQueryListCommand)
.accept(lazyInternalNetworkClientPermeateServerMappingDTOS -> {
for (LazyInternalNetworkClientPermeateServerMappingDTO lazyInternalNetworkClientPermeateServerMappingDTO : lazyInternalNetworkClientPermeateServerMappingDTOS) {
String permeateTargetIp = lazyInternalNetworkClientPermeateServerMappingDTO.getPermeateTargetIp();
Integer permeateTargetPort = lazyInternalNetworkClientPermeateServerMappingDTO.getPermeateTargetPort();
Integer visitorPort = lazyInternalNetworkClientPermeateServerMappingDTO.getVisitorPort();
NettyProxyMsg nettyMsg = new NettyProxyMsg();
nettyMsg.setType(MessageType.DISTRIBUTE_CLIENT_PERMEATE_SERVER_INIT);
nettyMsg.setClientTargetIp(permeateTargetIp);
nettyMsg.setClientTargetPort(permeateTargetPort);
nettyMsg.setVisitorPort(visitorPort);
newChannel.writeAndFlush(nettyMsg);
}
});
// 查询客户端渗透客户端信息
LazyInternalNetworkClientPermeateClientMappingQueryListCommand lazyInternalNetworkClientPermeateClientMappingQueryListCommand = new LazyInternalNetworkClientPermeateClientMappingQueryListCommand();
lazyInternalNetworkClientPermeateClientMappingQueryListCommand.setFromClientId(clientId);
lazyInternalNetworkClientPermeateClientMappingQueryListCommand.setIsDeleted(false);
lazyInternalNetworkClientPermeateClientMappingApplication.findList(lazyInternalNetworkClientPermeateClientMappingQueryListCommand)
.accept(lazyInternalNetworkClientPermeateServerMappingDTOS -> {
for (LazyInternalNetworkClientPermeateClientMappingDTO lazyInternalNetworkClientPermeateClientMappingDTO : lazyInternalNetworkClientPermeateServerMappingDTOS) {
String permeateTargetIp = lazyInternalNetworkClientPermeateClientMappingDTO.getPermeateTargetIp();
Integer permeateTargetPort = lazyInternalNetworkClientPermeateClientMappingDTO.getPermeateTargetPort();
Integer visitorPort = lazyInternalNetworkClientPermeateClientMappingDTO.getVisitorPort();
String toClientId = lazyInternalNetworkClientPermeateClientMappingDTO.getToClientId();
NettyProxyMsg nettyMsg = new NettyProxyMsg();
nettyMsg.setType(MessageType.DISTRIBUTE_CLIENT_PERMEATE_CLIENT_INIT);
nettyMsg.setClientTargetIp(permeateTargetIp);
nettyMsg.setClientTargetPort(permeateTargetPort);
nettyMsg.setVisitorPort(visitorPort);
nettyMsg.setClientId(clientId);
nettyMsg.setData(toClientId.getBytes(StandardCharsets.UTF_8));
newChannel.writeAndFlush(nettyMsg);
}
});
}
}

View File

@ -0,0 +1,37 @@
package org.framework.lazy.cloud.network.heartbeat.server.netty.udp.advanced;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.udp.server.AbstractHandleUdpReportClientPermeateClientCloseTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
import org.springframework.stereotype.Component;
/**
* 上报 客户端渗透客户端init close 信息
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
@Component
public class ServerHandleUdpReportClientPermeateClientCloseTypeAdvanced extends AbstractHandleUdpReportClientPermeateClientCloseTypeAdvanced<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);
channel.close();
nextChannel.close();
transferNextChannel.close();
}
}

View File

@ -0,0 +1,44 @@
package org.framework.lazy.cloud.network.heartbeat.server.netty.udp.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.udp.server.AbstractHandleUdpReportClientPermeateClientTransferCloseTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
import org.springframework.stereotype.Component;
/**
* 上报客户端渗透客户端通信通道关闭
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
@Component
public class ServerHandleUdpReportClientPermeateClientTransferCloseTypeAdvanced extends AbstractHandleUdpReportClientPermeateClientTransferCloseTypeAdvanced<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

@ -0,0 +1,32 @@
package org.framework.lazy.cloud.network.heartbeat.server.netty.udp.advanced;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.udp.server.AbstractHandleUdpReportClientPermeateServerTransferCloseTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
import org.springframework.stereotype.Component;
/**
* 上报 客户端渗透服务端通信通道关闭
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
@Component
public class ServerHandleUdpReportClientPermeateServerTransferCloseTypeAdvanced extends AbstractHandleUdpReportClientPermeateServerTransferCloseTypeAdvanced<NettyProxyMsg> {
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
// 关闭传输通信通道
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
nextChannel.close();
channel.close();
}
}

View File

@ -0,0 +1,65 @@
package org.framework.lazy.cloud.network.heartbeat.server.netty.udp.advanced;
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelFlowAdapter;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.udp.server.AbstractHandleUdpReportClientPermeateServerTransferTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelFlowEnum;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.framework.lazy.cloud.network.heartbeat.server.netty.flow.ServerChannelFlow;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
import org.springframework.stereotype.Component;
/**
* 上报 客户端渗透服务端通信
* TCP_REPORT_CLIENT_PERMEATE_SERVER_TRANSFER
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
@Component
public class ServerHandleUdpReportClientPermeateServerTransferTypeAdvanced extends AbstractHandleUdpReportClientPermeateServerTransferTypeAdvanced<NettyProxyMsg> {
private final ChannelFlowAdapter channelFlowAdapter;
public ServerHandleUdpReportClientPermeateServerTransferTypeAdvanced(ChannelFlowAdapter channelFlowAdapter) {
this.channelFlowAdapter = channelFlowAdapter;
}
/**
* 处理当前数据
*
* @param channel 当前通道
* @param msg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg msg) {
String clientId = new String(msg.getClientId());
Integer visitorPort = Integer.valueOf(new String(msg.getVisitorPort()));
byte[] visitorId = msg.getVisitorId();
log.debug("【客户端渗透服务端】访客ID:【{}】 访客端口:[{}] 接收到客户端:[{}] 接收服务端数据大小:[{}]", new String(visitorId), visitorPort, clientId, msg.getData().length);
log.debug("【客户端渗透服务端】访客ID:【{}】接收到客户端:[{}] 接收服务端数据大小:[{}] 接收服务端数据:[{}]", new String(visitorId), clientId, msg.getData().length, new String(msg.getData()));
// 将数据转发访客通道
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
if (nextChannel != null) {
ByteBuf buf = nextChannel.config().getAllocator().buffer(msg.getData().length);
buf.writeBytes(msg.getData());
ChannelFuture channelFuture = nextChannel.writeAndFlush(buf);
boolean success = channelFuture.isSuccess();
log.debug("visitor writerAndFlush status: {}", success);
// 记录进口数据
ServerChannelFlow serverChannelFlow = ServerChannelFlow
.builder()
.channelFlowEnum(ChannelFlowEnum.IN_FLOW)
.port(visitorPort)
.clientId(clientId)
.flow(msg.getData().length)
.build();
channelFlowAdapter.asyncHandler(channel, serverChannelFlow);
}
log.debug("客户端渗透服务端】访客ID:【{}】接收到客户端:[{}] 传输真实数据成功", new String(visitorId), clientId);
}
}

View File

@ -0,0 +1,60 @@
package org.framework.lazy.cloud.network.heartbeat.server.netty.udp.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.udp.server.AbstractHandleUdpReportClientTransferClientPermeateChannelConnectionSuccessfulTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
import org.springframework.stereotype.Component;
/**
* 上报 客户端渗透客户端数据传输通道连接成功
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
@Component
public class ServerHandleUdpReportClientTransferClientPermeateChannelConnectionSuccessfulTypeAdvanced extends AbstractHandleUdpReportClientTransferClientPermeateChannelConnectionSuccessfulTypeAdvanced<NettyProxyMsg> {
/**
* 处理当前数据
*
* @param transferChannel 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
protected void doHandler(Channel transferChannel, NettyProxyMsg nettyProxyMsg) {
// 创建目标地址连接
byte[] msgVisitorId = nettyProxyMsg.getVisitorId();
byte[] msgVisitorPort = nettyProxyMsg.getVisitorPort();
byte[] msgClientTargetIp = nettyProxyMsg.getClientTargetIp();
byte[] msgClientTargetPort = nettyProxyMsg.getClientTargetPort();
byte[] clientId = nettyProxyMsg.getClientId();// 目标客户端ID
ChannelAttributeKeyUtils.buildClientId(transferChannel, clientId);
ChannelAttributeKeyUtils.buildVisitorPort(transferChannel, Integer.parseInt(new String(msgVisitorPort)));
ChannelAttributeKeyUtils.buildVisitorId(transferChannel, msgVisitorId);
// 绑定访客通道
NettyTransferChannelContext.pushVisitor(transferChannel,msgVisitorId);
Channel clientChannel = ChannelContext.getLoadBalance(clientId);
NettyProxyMsg clientConnectTagetNettyProxyMsg = new NettyProxyMsg();
clientConnectTagetNettyProxyMsg.setVisitorId(msgVisitorId);
clientConnectTagetNettyProxyMsg.setVisitorPort(msgVisitorPort);
clientConnectTagetNettyProxyMsg.setClientTargetIp(msgClientTargetIp);
clientConnectTagetNettyProxyMsg.setClientTargetPort(msgClientTargetPort);
clientConnectTagetNettyProxyMsg.setClientId(clientId);
clientConnectTagetNettyProxyMsg.setType(MessageType.DISTRIBUTE_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL);
if (clientChannel != null) {
clientChannel.writeAndFlush(clientConnectTagetNettyProxyMsg);
}else {
log.error("can not find the client:【】 channel",clientId);
}
}
}

View File

@ -0,0 +1,62 @@
package org.framework.lazy.cloud.network.heartbeat.server.netty.udp.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.NettyTransferChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.udp.server.AbstractHandleUdpReportClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
import org.springframework.stereotype.Component;
/**
* 上报 客户端渗透客户端数据传输通道init
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
@Component
public class ServerHandleUdpReportClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced extends AbstractHandleUdpReportClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced<NettyProxyMsg> {
/**
* 处理当前数据
*
* @param transferChannel 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
protected void doHandler(Channel transferChannel, NettyProxyMsg nettyProxyMsg) {
// 创建目标地址连接
byte[] msgVisitorId = nettyProxyMsg.getVisitorId();
byte[] msgVisitorPort = nettyProxyMsg.getVisitorPort();
byte[] msgClientTargetIp = nettyProxyMsg.getClientTargetIp();
byte[] msgClientTargetPort = nettyProxyMsg.getClientTargetPort();
byte[] clientId = nettyProxyMsg.getClientId();
ChannelAttributeKeyUtils.buildVisitorPort(transferChannel, Integer.parseInt(new String(msgVisitorPort)));
// next translation
Channel nextTransferChannel = NettyTransferChannelContext.getVisitor(msgVisitorId);
ChannelAttributeKeyUtils.buildTransferNextChannel(nextTransferChannel,transferChannel);
ChannelAttributeKeyUtils.buildTransferNextChannel(transferChannel,nextTransferChannel);
ChannelAttributeKeyUtils.buildClientId(transferChannel,clientId);
ChannelAttributeKeyUtils.buildVisitorId(transferChannel,msgVisitorId);
Channel nextChannel = ChannelAttributeKeyUtils.getTransferNextChannel(transferChannel);
NettyProxyMsg clientConnectTagetNettyProxyMsg = new NettyProxyMsg();
clientConnectTagetNettyProxyMsg.setVisitorId(msgVisitorId);
clientConnectTagetNettyProxyMsg.setVisitorPort(msgVisitorPort);
clientConnectTagetNettyProxyMsg.setClientTargetIp(msgClientTargetIp);
clientConnectTagetNettyProxyMsg.setClientTargetPort(msgClientTargetPort);
clientConnectTagetNettyProxyMsg.setClientId(clientId);
clientConnectTagetNettyProxyMsg.setType(MessageType.DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_CHANNEL_INIT_SUCCESSFUL);
if (nextChannel != null) {
nextChannel.writeAndFlush(clientConnectTagetNettyProxyMsg);
}else {
log.error("can not find the client:【】 channel",clientId);
}
}
}

View File

@ -0,0 +1,71 @@
package org.framework.lazy.cloud.network.heartbeat.server.netty.udp.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.adapter.ChannelFlowAdapter;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.udp.server.AbstractHandleUdpReportClientTransferClientResponseTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelFlowEnum;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.framework.lazy.cloud.network.heartbeat.server.netty.flow.ServerChannelFlow;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
import org.springframework.stereotype.Component;
import org.wu.framework.spring.utils.SpringContextHolder;
/**
* 上报客户端渗透客户端数据传输结果
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
@Component
public class ServerHandleUdpReportClientTransferClientResponseTypeAdvanced extends AbstractHandleUdpReportClientTransferClientResponseTypeAdvanced<NettyProxyMsg> {
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
// 创建目标地址连接
byte[] msgVisitorId = nettyProxyMsg.getVisitorId();
byte[] msgVisitorPort = nettyProxyMsg.getVisitorPort();
byte[] msgClientTargetIp = nettyProxyMsg.getClientTargetIp();
byte[] msgClientTargetPort = nettyProxyMsg.getClientTargetPort();
String clientId = nettyProxyMsg.getClientIdString();
// 下发客户端初始化成功
Channel nextChannel = ChannelAttributeKeyUtils.getTransferNextChannel(channel);
NettyProxyMsg clientConnectTagetNettyProxyMsg = new NettyProxyMsg();
clientConnectTagetNettyProxyMsg.setVisitorId(msgVisitorId);
clientConnectTagetNettyProxyMsg.setVisitorPort(msgVisitorPort);
clientConnectTagetNettyProxyMsg.setClientTargetIp(msgClientTargetIp);
clientConnectTagetNettyProxyMsg.setClientTargetPort(msgClientTargetPort);
clientConnectTagetNettyProxyMsg.setClientId(clientId);
clientConnectTagetNettyProxyMsg.setData(nettyProxyMsg.getData());
clientConnectTagetNettyProxyMsg.setType(MessageType.DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_RESPONSE);
if (nextChannel != null) {
nextChannel.writeAndFlush(clientConnectTagetNettyProxyMsg);
//记录出口流量
ChannelFlowAdapter channelFlowAdapter = SpringContextHolder.getBean(ChannelFlowAdapter.class);
ServerChannelFlow serverChannelFlow = ServerChannelFlow
.builder()
.channelFlowEnum(ChannelFlowEnum.OUT_FLOW)
.port(Integer.parseInt(new String(msgVisitorPort)))
.clientId(clientId)
.flow(clientConnectTagetNettyProxyMsg.getData().length)
.build();
channelFlowAdapter.asyncHandler(channel, serverChannelFlow);
}else {
log.error("can not find the client:【{}】 channel",clientId);
}
}
}

View File

@ -0,0 +1,67 @@
package org.framework.lazy.cloud.network.heartbeat.server.netty.udp.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.adapter.ChannelFlowAdapter;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.udp.server.AbstractHandleUdpReportClientTransferClientTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelFlowEnum;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.framework.lazy.cloud.network.heartbeat.server.netty.flow.ServerChannelFlow;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
import org.springframework.stereotype.Component;
import org.wu.framework.spring.utils.SpringContextHolder;
/**
* 上报客户端渗透客户端数据传输
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
@Component
public class ServerHandleUdpReportClientTransferClientTypeAdvanced extends AbstractHandleUdpReportClientTransferClientTypeAdvanced<NettyProxyMsg> {
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
// 创建目标地址连接
byte[] msgVisitorId = nettyProxyMsg.getVisitorId();
byte[] msgVisitorPort = nettyProxyMsg.getVisitorPort();
byte[] msgClientTargetIp = nettyProxyMsg.getClientTargetIp();
byte[] msgClientTargetPort = nettyProxyMsg.getClientTargetPort();
String clientId = nettyProxyMsg.getClientIdString();
// 下发客户端初始化成功
Channel nextChannel = ChannelAttributeKeyUtils.getTransferNextChannel(channel);
Integer visitorPort = ChannelAttributeKeyUtils.getVisitorPort(channel);
NettyProxyMsg clientConnectTagetNettyProxyMsg = new NettyProxyMsg();
clientConnectTagetNettyProxyMsg.setVisitorId(msgVisitorId);
clientConnectTagetNettyProxyMsg.setVisitorPort(msgVisitorPort);
clientConnectTagetNettyProxyMsg.setClientTargetIp(msgClientTargetIp);
clientConnectTagetNettyProxyMsg.setClientTargetPort(msgClientTargetPort);
clientConnectTagetNettyProxyMsg.setClientId(clientId);
clientConnectTagetNettyProxyMsg.setData(nettyProxyMsg.getData());
clientConnectTagetNettyProxyMsg.setType(MessageType.DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_REQUEST);
if (nextChannel != null) {
nextChannel.writeAndFlush(clientConnectTagetNettyProxyMsg);
// 记录进口数据
ChannelFlowAdapter channelFlowAdapter = SpringContextHolder.getBean(ChannelFlowAdapter.class);
ServerChannelFlow serverChannelFlow = ServerChannelFlow
.builder()
.channelFlowEnum(ChannelFlowEnum.IN_FLOW)
.port(visitorPort)
.clientId(clientId)
.flow(clientConnectTagetNettyProxyMsg.getData().length)
.build();
channelFlowAdapter.asyncHandler(channel, serverChannelFlow);
}else {
log.error("can not find the client:【{}】 channel",clientId);
}
}
}

View File

@ -0,0 +1,45 @@
package org.framework.lazy.cloud.network.heartbeat.server.netty.udp.advanced;
import io.netty.channel.Channel;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.udp.server.AbstractHandleUdpReportClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.framework.lazy.cloud.network.heartbeat.server.netty.udp.socket.NettyUdpClientPermeateServerConnectRealSocket;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
import org.springframework.stereotype.Component;
/**
* 上报客户端通信通道连接成功
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Component
public class ServerHandleUdpReportClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced extends AbstractHandleUdpReportClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced<NettyProxyMsg> {
/**
* 处理当前数据
*
* @param transferChannel 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
protected void doHandler(Channel transferChannel, NettyProxyMsg nettyProxyMsg) {
// 创建目标地址连接
byte[] msgVisitorId = nettyProxyMsg.getVisitorId();
byte[] msgVisitorPort = nettyProxyMsg.getVisitorPort();
byte[] msgClientTargetIp = nettyProxyMsg.getClientTargetIp();
byte[] msgClientTargetPort = nettyProxyMsg.getClientTargetPort();
byte[] msgClientId = nettyProxyMsg.getClientId();
String clientId = new String(msgClientId);
// 绑定客户端ID
ChannelAttributeKeyUtils.buildClientId(transferChannel,clientId);
ChannelAttributeKeyUtils.buildVisitorId(transferChannel,msgVisitorId);
NettyUdpClientPermeateServerConnectRealSocket.buildNewRealServer(new String(msgVisitorId),
Integer.parseInt(new String(msgVisitorPort)),
new String(msgClientTargetIp),
Integer.parseInt(new String(msgClientTargetPort)),
transferChannel
);
}
}

View File

@ -0,0 +1,43 @@
package org.framework.lazy.cloud.network.heartbeat.server.netty.udp.advanced;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.udp.server.AbstractHandleUdpReportClusterNodeRegisterTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.server.cluster.application.LazyNettyClusterNodeApplication;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
import org.springframework.stereotype.Component;
import org.wu.framework.bean.factory.BeanContext;
/**
* 集群节点注册 服务端本地处理
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
@Component
public class ServerHandleUdpReportClusterNodeRegisterTypeAdvanced extends
AbstractHandleUdpReportClusterNodeRegisterTypeAdvanced<NettyProxyMsg> {
public ServerHandleUdpReportClusterNodeRegisterTypeAdvanced() {
}
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
log.info("node register and me start scan node config");
// 本地扫描节点配置重新注册
LazyNettyClusterNodeApplication lazyNettyClusterNodeApplication = BeanContext.getBean(LazyNettyClusterNodeApplication.class);
// 循环依赖问题
lazyNettyClusterNodeApplication.starterClusterNodes();
}
}

View File

@ -0,0 +1,96 @@
package org.framework.lazy.cloud.network.heartbeat.server.netty.udp.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.NettyClientVisitorContext;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.udp.server.AbstractHandleUdpReportDisconnectTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.framework.lazy.cloud.network.heartbeat.server.netty.udp.socket.NettyUdpServerPermeateClientVisitorSocket;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.LazyClientStatsChangeApplication;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.command.lazy.netty.client.state.LazyNettyClientLoginCommand;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
import org.springframework.stereotype.Component;
import org.wu.framework.core.utils.ObjectUtils;
import java.nio.charset.StandardCharsets;
import java.util.List;
/**
* 服务端处理客户端断开连接处理
* TYPE_DISCONNECT
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
@Component
public class ServerHandleUdpReportDisconnectTypeAdvanced extends AbstractHandleUdpReportDisconnectTypeAdvanced<NettyProxyMsg> {
private final LazyClientStatsChangeApplication lazyClientStatsChangeApplication;
public ServerHandleUdpReportDisconnectTypeAdvanced(LazyClientStatsChangeApplication lazyClientStatsChangeApplication) {
this.lazyClientStatsChangeApplication = lazyClientStatsChangeApplication;
}
/**
* 处理当前数据
*
* @param deathChannel 关闭的通道
* @param msg 通道数据
*/
@Override
public void doHandler(Channel deathChannel, NettyProxyMsg msg) {
// 关闭连接通知
String clientId = msg.getClientIdString();
log.warn("close client :{} channel", clientId);
Channel deathClientChannelDTO = ChannelContext.getLoadBalance(clientId);
String appKey = ChannelAttributeKeyUtils.getAppKey(deathChannel);
String appSecret = ChannelAttributeKeyUtils.getAppSecret(deathChannel);
String originalIp = ChannelAttributeKeyUtils.getOriginalIp(deathChannel);
if (deathClientChannelDTO != null) {
// 服务状态离线
LazyNettyClientLoginCommand lazyNettyClientLoginCommand = new LazyNettyClientLoginCommand();
lazyNettyClientLoginCommand.setClientId(clientId);
lazyNettyClientLoginCommand.setAppKey(appKey);
lazyNettyClientLoginCommand.setAppSecret(appSecret);
lazyNettyClientLoginCommand.setOriginalIp(originalIp);
lazyClientStatsChangeApplication.clientOffLine(lazyNettyClientLoginCommand);
ChannelContext.remove(clientId);
// 通知其他客户端 channelId 关闭了
ChannelContext.getChannels().forEach((existClientId, channels) -> {
for (Channel channel : channels) {
// 离线通知
NettyProxyMsg nettyMsg = new NettyProxyMsg();
nettyMsg.setType(MessageType.DISTRIBUTE_CLIENT_DISCONNECTION_NOTIFICATION);
nettyMsg.setClientId(clientId);
nettyMsg.setData(clientId.getBytes(StandardCharsets.UTF_8));
channel.writeAndFlush(nettyMsg);
// 暂存通知
NettyProxyMsg stagingNettyProxyMsg = new NettyProxyMsg();
stagingNettyProxyMsg.setType(MessageType.DISTRIBUTE_CLIENT_STAGING_OPENED_NOTIFICATION);
stagingNettyProxyMsg.setData(clientId.getBytes(StandardCharsets.UTF_8));
stagingNettyProxyMsg.setClientId(clientId);
channel.writeAndFlush(stagingNettyProxyMsg);
}
});
// 关闭绑定的访客端口
List<NettyUdpServerPermeateClientVisitorSocket> visitorSockets = NettyClientVisitorContext.getVisitorSockets(new String(clientId));
if (!ObjectUtils.isEmpty(visitorSockets)) {
for (NettyUdpServerPermeateClientVisitorSocket visitorSocket : visitorSockets) {
int visitorPort = visitorSocket.getVisitorPort();
visitorSocket.close();
log.warn("client :[{}] visitorPort:[{}] close", new String(clientId), visitorPort);
}
}
}
}
}

View File

@ -0,0 +1,35 @@
package org.framework.lazy.cloud.network.heartbeat.server.netty.udp.advanced;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyCommunicationIdContext;
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.advanced.udp.server.AbstractHandleUdpReportServicePermeateClientCloseVisitorTypeAdvanced;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
import org.springframework.stereotype.Component;
/**
* 服务端处理客户端 关闭一个访客
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
@Component
public class ServerHandleUdpReportServicePermeateClientCloseVisitorTypeAdvanced extends AbstractHandleUdpReportServicePermeateClientCloseVisitorTypeAdvanced<NettyProxyMsg> {
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
// 关闭访客通道
byte[] visitorId = nettyProxyMsg.getVisitorId();
NettyCommunicationIdContext.clear(visitorId);
NettyRealIdContext.clear(visitorId);
}
}

View File

@ -0,0 +1,56 @@
package org.framework.lazy.cloud.network.heartbeat.server.netty.udp.advanced;
import io.netty.channel.Channel;
import io.netty.channel.ChannelOption;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyCommunicationIdContext;
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.advanced.udp.server.AbstractHandleUdpReportServicePermeateClientRealConnectTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
import org.springframework.stereotype.Component;
/**
* 服务端渗透客户端通信通道
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
@Component
public class ServerHandleUdpReportServicePermeateClientRealConnectTypeAdvanced extends AbstractHandleUdpReportServicePermeateClientRealConnectTypeAdvanced<NettyProxyMsg> {
/**
* 处理当前数据
*
* @param transferChannel 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
protected void doHandler(Channel transferChannel, NettyProxyMsg nettyProxyMsg) {
// 客户端绑定端口成功
byte[] clientId = nettyProxyMsg.getClientId();
byte[] clientTargetIp = nettyProxyMsg.getClientTargetIp();
byte[] clientTargetPort = nettyProxyMsg.getClientTargetPort();
byte[] visitorPort = nettyProxyMsg.getVisitorPort();
byte[] visitorId = nettyProxyMsg.getVisitorId();
log.info("客户端:{},绑定真实服务ip:{},port:{},成功", new String(clientId), new String(clientTargetIp), new String(clientTargetPort));
// 绑定服务端访客通信通道
NettyCommunicationIdContext.pushVisitor(transferChannel, new String(visitorId));
ChannelAttributeKeyUtils.buildVisitorId(transferChannel, visitorId);
ChannelAttributeKeyUtils.buildClientId(transferChannel, clientId);
ChannelAttributeKeyUtils.buildVisitorPort(transferChannel, Integer.valueOf(new String(visitorPort)));
// 访客通道开启自动读取
Channel visitorRealChannel = NettyRealIdContext.getReal(visitorId);
visitorRealChannel.config().setOption(ChannelOption.AUTO_READ, true);
ChannelAttributeKeyUtils.buildNextChannel(transferChannel, visitorRealChannel);
ChannelAttributeKeyUtils.buildNextChannel(visitorRealChannel, transferChannel);
// 或许此处还应该通知服务端 这个访客绑定的客户端真实通道打开
// 下发客户端 真实通道自动读写开启
}
}

View File

@ -0,0 +1,70 @@
package org.framework.lazy.cloud.network.heartbeat.server.netty.udp.advanced;
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import lombok.extern.slf4j.Slf4j;
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.adapter.ChannelFlowAdapter;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.udp.server.AbstractHandleUdpReportServicePermeateClientTransferTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelFlowEnum;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.framework.lazy.cloud.network.heartbeat.server.netty.flow.ServerChannelFlow;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
import org.springframework.stereotype.Component;
/**
* 服务端处理客户端数据传输
* TCP_REPORT_CLIENT_TRANSFER
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
@Component
public class ServerHandleUdpReportServicePermeateClientTransferTypeAdvanced extends AbstractHandleUdpReportServicePermeateClientTransferTypeAdvanced<NettyProxyMsg> {
private final ChannelFlowAdapter channelFlowAdapter;
public ServerHandleUdpReportServicePermeateClientTransferTypeAdvanced(ChannelFlowAdapter channelFlowAdapter) {
this.channelFlowAdapter = channelFlowAdapter;
}
/**
* 处理当前数据
*
* @param channel 当前通道
* @param msg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg msg) {
String clientId = new String(msg.getClientId());
Integer visitorPort = Integer.valueOf(new String(msg.getVisitorPort()));
byte[] visitorId = msg.getVisitorId();
// log.info("访客ID:【{}】 访客端口:[{}] 接收到客户端:[{}]", new String(visitorId), visitorPort, clientId);
// log.debug("访客ID:【{}】接收到客户端:[{}] 返回数据大小:[{}] 内网穿透返回的数据:[{}]", new String(visitorId), clientId, msg.getData().length, new String(msg.getData()));
// 将数据转发访客通道
Channel visitor = NettyRealIdContext.getReal(visitorId);
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
if (nextChannel != null) {
ByteBuf buf = nextChannel.config().getAllocator().buffer(msg.getData().length);
buf.writeBytes(msg.getData());
ChannelFuture channelFuture = nextChannel.writeAndFlush(buf);
boolean success = channelFuture.isSuccess();
log.debug("visitor writerAndFlush status: {}", success);
// 记录出口数据
ServerChannelFlow serverChannelFlow = ServerChannelFlow
.builder()
.channelFlowEnum(ChannelFlowEnum.OUT_FLOW)
.port(visitorPort)
.clientId(clientId)
.flow(msg.getData().length)
.build();
channelFlowAdapter.asyncHandler(channel, serverChannelFlow);
}
log.debug("访客ID:【{}】接收到客户端:[{}] 发送真实数据成功", new String(visitorId), clientId);
}
}

View File

@ -0,0 +1,72 @@
package org.framework.lazy.cloud.network.heartbeat.server.netty.udp.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.advanced.udp.server.AbstractHandleUdpReportStagingClosedTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.LazyClientStatsChangeApplication;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.command.lazy.netty.client.state.LazyNettyClientLoginCommand;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
import org.springframework.stereotype.Component;
import java.nio.charset.StandardCharsets;
import java.util.List;
/**
* 服务端处理上报的暂存关闭
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
@Component
public class ServerHandleUdpReportStagingClosedTypeAdvanced extends AbstractHandleUdpReportStagingClosedTypeAdvanced<NettyProxyMsg> {
private final LazyClientStatsChangeApplication lazyClientStatsChangeApplication;
public ServerHandleUdpReportStagingClosedTypeAdvanced(LazyClientStatsChangeApplication lazyClientStatsChangeApplication) {
this.lazyClientStatsChangeApplication = lazyClientStatsChangeApplication;
}
/**
* 处理当前数据
*
* @param stagingClosedChannel 关闭暂存的通道
* @param msg 通道数据
*/
@Override
protected void doHandler(Channel stagingClosedChannel, NettyProxyMsg msg) {
String appKey = ChannelAttributeKeyUtils.getAppKey(stagingClosedChannel);
String appSecret = ChannelAttributeKeyUtils.getAppSecret(stagingClosedChannel);
String originalIp = ChannelAttributeKeyUtils.getOriginalIp(stagingClosedChannel);
byte[] clientIdBytes = msg.getClientId();
// 获取所有通道
List<Channel> stagingOpenedClientChannel = ChannelContext.get(clientIdBytes);
if (stagingOpenedClientChannel != null) {
String clientId = new String(clientIdBytes);
// 存储当前客户端暂存关闭
LazyNettyClientLoginCommand lazyNettyClientLoginCommand = new LazyNettyClientLoginCommand();
lazyNettyClientLoginCommand.setClientId(clientId);
lazyNettyClientLoginCommand.setAppKey(appKey);
lazyNettyClientLoginCommand.setAppSecret(appSecret);
lazyNettyClientLoginCommand.setOriginalIp(originalIp);
lazyClientStatsChangeApplication.stagingClosed(lazyNettyClientLoginCommand);
ChannelContext.getChannels().forEach((existClientId, channels) -> {
for (Channel channel : channels) {
// 告诉他们 当前参数这个通道 暂存关闭了
NettyProxyMsg nettyMsg = new NettyProxyMsg();
nettyMsg.setType(MessageType.DISTRIBUTE_CLIENT_STAGING_CLOSED_NOTIFICATION);
nettyMsg.setData((clientId
.getBytes(StandardCharsets.UTF_8)));
nettyMsg.setClientId((clientId
.getBytes(StandardCharsets.UTF_8)));
channel.writeAndFlush(nettyMsg);
}
});
}
}
}

View File

@ -0,0 +1,77 @@
package org.framework.lazy.cloud.network.heartbeat.server.netty.udp.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.advanced.udp.server.AbstractHandleUdpReportStagingOpenedTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.enums.NettyClientStatus;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.LazyClientStatsChangeApplication;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.command.lazy.netty.client.state.LazyNettyClientLoginCommand;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
import org.springframework.stereotype.Component;
import java.nio.charset.StandardCharsets;
import java.util.List;
/**
* 服务端处理上报的暂存开启
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
@Component
public class ServerHandleUdpReportStagingOpenedTypeAdvanced extends AbstractHandleUdpReportStagingOpenedTypeAdvanced<NettyProxyMsg> {
private final LazyClientStatsChangeApplication lazyClientStatsChangeApplication;
public ServerHandleUdpReportStagingOpenedTypeAdvanced(LazyClientStatsChangeApplication lazyClientStatsChangeApplication) {
this.lazyClientStatsChangeApplication = lazyClientStatsChangeApplication;
}
/**
* 处理当前数据
*
* @param stagingOpenedChannel 开启暂存的通道
* @param msg 通道数据
*/
@Override
protected void doHandler(Channel stagingOpenedChannel, NettyProxyMsg msg) {
// 获取所有通道
byte[] clientIdBytes = msg.getClientId();
String appKey = ChannelAttributeKeyUtils.getAppKey(stagingOpenedChannel);
String appSecret = ChannelAttributeKeyUtils.getAppSecret(stagingOpenedChannel);
String originalIp = ChannelAttributeKeyUtils.getOriginalIp(stagingOpenedChannel);
List<Channel> stagingOpenedClientChannel = ChannelContext.get(clientIdBytes);
// 存储当前客户端暂存关闭
String clientId = new String(clientIdBytes);
LazyNettyClientLoginCommand lazyNettyClientLoginCommand = new LazyNettyClientLoginCommand();
lazyNettyClientLoginCommand.setClientId(clientId);
lazyNettyClientLoginCommand.setAppKey(appKey);
lazyNettyClientLoginCommand.setAppSecret(appSecret);
lazyNettyClientLoginCommand.setOriginalIp(originalIp);
lazyNettyClientLoginCommand.setOnLineState(NettyClientStatus.OFF_LINE);
lazyClientStatsChangeApplication.stagingOpened(lazyNettyClientLoginCommand);
if (stagingOpenedClientChannel != null) {
ChannelContext.getChannels().forEach((existClientId, channels) -> {
for (Channel channel : channels) {
// 告诉他们 当前参数这个通道 暂存开启了
NettyProxyMsg nettyMsg = new NettyProxyMsg();
nettyMsg.setType(MessageType.DISTRIBUTE_CLIENT_STAGING_OPENED_NOTIFICATION);
nettyMsg.setData((clientId
.getBytes(StandardCharsets.UTF_8)));
nettyMsg.setClientId((clientId
.getBytes(StandardCharsets.UTF_8)));
channel.writeAndFlush(nettyMsg);
}
});
}
}
}

View File

@ -0,0 +1,29 @@
package org.framework.lazy.cloud.network.heartbeat.server.netty.udp.filter;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import org.framework.lazy.cloud.network.heartbeat.common.decoder.TransferDecoder;
import org.framework.lazy.cloud.network.heartbeat.common.encoder.TransferEncoder;
import org.framework.lazy.cloud.network.heartbeat.common.filter.DebugChannelInitializer;
import org.framework.lazy.cloud.network.heartbeat.server.netty.udp.handler.NettyUdpClientPermeateServerRealHandler;
/**
* 客户端渗透服务端
*/
public class NettyUdpClientPermeateServerRealFilter extends DebugChannelInitializer<SocketChannel> {
/**
* This method will be called once the {@link Channel} was registered. After the method returns this instance
* will be removed from the {@link ChannelPipeline} of the {@link Channel}.
*
* @param ch the {@link Channel} which was registered.
*/
@Override
protected void initChannel0(SocketChannel ch) {
ChannelPipeline pipeline = ch.pipeline();
// 解码编码
pipeline.addLast(new TransferDecoder(Integer.MAX_VALUE, 1024 * 1024*10));
pipeline.addLast(new TransferEncoder());
pipeline.addLast(new NettyUdpClientPermeateServerRealHandler());
}
}

View File

@ -0,0 +1,55 @@
package org.framework.lazy.cloud.network.heartbeat.server.netty.udp.filter;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.string.StringDecoder;
import io.netty.handler.codec.string.StringEncoder;
import io.netty.handler.timeout.IdleStateHandler;
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.decoder.NettyProxyMsgDecoder;
import org.framework.lazy.cloud.network.heartbeat.common.encoder.NettyProxyMsgEncoder;
import org.framework.lazy.cloud.network.heartbeat.common.filter.DebugChannelInitializer;
import org.framework.lazy.cloud.network.heartbeat.server.netty.udp.handler.NettyUdpServerHandler;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
* description
*
* @author 吴佳伟
* @date 2023/09/13 10:26
*/
@Component
public class NettyUdpServerFilter extends DebugChannelInitializer<SocketChannel> {
private final List<HandleChannelTypeAdvanced> handleChannelTypeAdvancedList;
public NettyUdpServerFilter(List<HandleChannelTypeAdvanced> handleChannelTypeAdvancedList) {
this.handleChannelTypeAdvancedList = handleChannelTypeAdvancedList;
}
@Override
protected void initChannel0(SocketChannel ch) throws Exception {
ChannelPipeline pipeline = ch.pipeline();
// ("\n")为结尾分割的 解码器
// 解码编码
pipeline.addLast(new NettyProxyMsgDecoder(Integer.MAX_VALUE, 0, 4, -4, 0));
pipeline.addLast(new NettyProxyMsgEncoder());
// ph.addLast("framer", new DelimiterBasedFrameDecoder(8192, Delimiters.lineDelimiter()));
// 解码和编码应和客户端一致
//入参说明: 读超时时间写超时时间所有类型的超时时间时间格式
pipeline.addLast(new IdleStateHandler(5, 0, 0, TimeUnit.SECONDS));
pipeline.addLast("decoder", new StringDecoder());
pipeline.addLast("encoder", new StringEncoder());
// 类型处理器适配器
ChannelTypeAdapter channelTypeAdapter = new ChannelTypeAdapter(handleChannelTypeAdvancedList);
pipeline.addLast("doHandler", new NettyUdpServerHandler(channelTypeAdapter));// 服务端业务逻辑
}
}

View File

@ -0,0 +1,37 @@
package org.framework.lazy.cloud.network.heartbeat.server.netty.udp.filter;
import io.netty.channel.Channel;
import io.netty.channel.ChannelDuplexHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import org.framework.lazy.cloud.network.heartbeat.common.InternalNetworkPenetrationRealClient;
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelFlowAdapter;
import org.framework.lazy.cloud.network.heartbeat.common.filter.DebugChannelInitializer;
import org.framework.lazy.cloud.network.heartbeat.server.netty.udp.handler.NettyUdpServerPermeateClientVisitorHandler;
public class NettyUdpServerPermeateClientVisitorFilter extends DebugChannelInitializer<SocketChannel> {
private final InternalNetworkPenetrationRealClient internalNetworkPenetrationRealClient;
private final ChannelFlowAdapter channelFlowAdapter;
public NettyUdpServerPermeateClientVisitorFilter(InternalNetworkPenetrationRealClient internalNetworkPenetrationRealClient, ChannelFlowAdapter channelFlowAdapter) {
this.internalNetworkPenetrationRealClient = internalNetworkPenetrationRealClient;
this.channelFlowAdapter = channelFlowAdapter;
}
/**
* This method will be called once the {@link Channel} was registered. After the method returns this instance
* will be removed from the {@link ChannelPipeline} of the {@link Channel}.
*
* @param ch the {@link Channel} which was registered.
* @throws Exception is thrown if an error occurs. In that case it will be handled by
* {@link #exceptionCaught(ChannelHandlerContext, Throwable)} which will by default connectionClose
* the {@link Channel}.
*/
@Override
protected void initChannel0(SocketChannel ch) throws Exception {
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast(new ChannelDuplexHandler());
pipeline.addLast(new NettyUdpServerPermeateClientVisitorHandler(internalNetworkPenetrationRealClient, channelFlowAdapter));
}
}

View File

@ -0,0 +1,54 @@
package org.framework.lazy.cloud.network.heartbeat.server.netty.udp.filter;
import io.netty.channel.Channel;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.ssl.SslContext;
import io.netty.handler.ssl.SslContextBuilder;
import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.InternalNetworkServerPermeateServerRealServer;
import org.framework.lazy.cloud.network.heartbeat.common.decoder.TransferDecoder;
import org.framework.lazy.cloud.network.heartbeat.common.encoder.TransferEncoder;
import org.framework.lazy.cloud.network.heartbeat.common.filter.DebugChannelInitializer;
import org.framework.lazy.cloud.network.heartbeat.server.netty.udp.handler.NettyUdpServerPermeateServerRealHandler;
@Slf4j
public class NettyUdpServerPermeateServerRealFilter extends DebugChannelInitializer<SocketChannel> {
private final InternalNetworkServerPermeateServerRealServer internalNetworkServerPermeateServerRealServer;
public NettyUdpServerPermeateServerRealFilter(InternalNetworkServerPermeateServerRealServer internalNetworkServerPermeateServerRealServer) {
this.internalNetworkServerPermeateServerRealServer = internalNetworkServerPermeateServerRealServer;
}
/**
* This method will be called once the {@link Channel} was registered. After the method returns this instance
* will be removed from the {@link ChannelPipeline} of the {@link Channel}.
*
* @param ch the {@link Channel} which was registered.
*/
@Override
protected void initChannel0(SocketChannel ch) {
ChannelPipeline pipeline = ch.pipeline();
Boolean isSsl = internalNetworkServerPermeateServerRealServer.getIsSsl();
if(isSsl!=null && isSsl) {
log.info("init channel0 ssl");
String targetIp = internalNetworkServerPermeateServerRealServer.getClientTargetIp();
Integer targetPort = internalNetworkServerPermeateServerRealServer.getClientTargetPort();
// 适配https
try {
SslContext sslContext = SslContextBuilder.forClient()
.trustManager(InsecureTrustManagerFactory.INSTANCE).build();
pipeline.addLast(sslContext.newHandler(ch.alloc()));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
// 解码编码
pipeline.addLast(new TransferDecoder(Integer.MAX_VALUE, 1024 * 1024*10));
pipeline.addLast(new TransferEncoder());
pipeline.addLast(new NettyUdpServerPermeateServerRealHandler());
}
}

View File

@ -0,0 +1,37 @@
package org.framework.lazy.cloud.network.heartbeat.server.netty.udp.filter;
import io.netty.channel.Channel;
import io.netty.channel.ChannelDuplexHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import org.framework.lazy.cloud.network.heartbeat.common.InternalNetworkServerPermeateServerRealServer;
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelFlowAdapter;
import org.framework.lazy.cloud.network.heartbeat.common.filter.DebugChannelInitializer;
import org.framework.lazy.cloud.network.heartbeat.server.netty.udp.handler.NettyUdpServerPermeateServerVisitorHandler;
public class NettyUdpServerPermeateServerVisitorFilter extends DebugChannelInitializer<SocketChannel> {
private final InternalNetworkServerPermeateServerRealServer internalNetworkServerPermeateServerRealServer;
private final ChannelFlowAdapter channelFlowAdapter;
public NettyUdpServerPermeateServerVisitorFilter(InternalNetworkServerPermeateServerRealServer internalNetworkServerPermeateServerRealServer, ChannelFlowAdapter channelFlowAdapter) {
this.internalNetworkServerPermeateServerRealServer = internalNetworkServerPermeateServerRealServer;
this.channelFlowAdapter = channelFlowAdapter;
}
/**
* This method will be called once the {@link Channel} was registered. After the method returns this instance
* will be removed from the {@link ChannelPipeline} of the {@link Channel}.
*
* @param ch the {@link Channel} which was registered.
* @throws Exception is thrown if an error occurs. In that case it will be handled by
* {@link #exceptionCaught(ChannelHandlerContext, Throwable)} which will by default connectionClose
* the {@link Channel}.
*/
@Override
protected void initChannel0(SocketChannel ch) throws Exception {
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast(new ChannelDuplexHandler());
pipeline.addLast(new NettyUdpServerPermeateServerVisitorHandler(internalNetworkServerPermeateServerRealServer, channelFlowAdapter));
}
}

View File

@ -0,0 +1,537 @@
/*
* Copyright 2012 The Netty Project
*
* The Netty Project licenses this file to you under the Apache License,
* version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at:
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package org.framework.lazy.cloud.network.heartbeat.server.netty.udp.handler;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.*;
import io.netty.handler.timeout.*;
import io.netty.util.concurrent.Future;
import io.netty.util.internal.ObjectUtil;
import java.util.concurrent.TimeUnit;
/**
* Raises a {@link ReadTimeoutException} when no data was read within a certain
* period of time.
*
* <pre>
* // The connection is closed when there is no inbound traffic
* // for 30 seconds.
*
* public class MyChannelInitializer extends {@link ChannelInitializer}&lt;{@link Channel}&gt; {
* public void initChannel({@link Channel} channel) {
* channel.pipeline().addLast("readTimeoutHandler", new {@link LazyUdpServerIdleStateHandler}(30));
* channel.pipeline().addLast("myHandler", new MyHandler());
* }
* }
*
* // Handler should handle the {@link ReadTimeoutException}.
* public class MyHandler extends {@link ChannelDuplexHandler} {
* {@code @Override}
* public void exceptionCaught({@link ChannelHandlerContext} ctx, {@link Throwable} cause)
* throws {@link Exception} {
* if (cause instanceof {@link ReadTimeoutException}) {
* // do something
* } else {
* super.exceptionCaught(ctx, cause);
* }
* }
* }
*
* {@link ServerBootstrap} bootstrap = ...;
* ...
* bootstrap.childHandler(new MyChannelInitializer());
* ...
* </pre>
*
* @see WriteTimeoutHandler
* @see IdleStateHandler
*/
public class LazyUdpServerIdleStateHandler extends ChannelDuplexHandler {
private static final long MIN_TIMEOUT_NANOS = TimeUnit.MILLISECONDS.toNanos(1);
private final boolean observeOutput;
private final long readerIdleTimeNanos;
private final long writerIdleTimeNanos;
private final long allIdleTimeNanos;
private Future<?> readerIdleTimeout;
private long lastReadTime;
private boolean firstReaderIdleEvent = true;
private Future<?> writerIdleTimeout;
private long lastWriteTime;
private boolean firstWriterIdleEvent = true;
private Future<?> allIdleTimeout;
private boolean firstAllIdleEvent = true;
// Not create a new ChannelFutureListener per write operation to reduce GC pressure.
private final ChannelFutureListener writeListener = new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) throws Exception {
lastWriteTime = ticksInNanos();
firstWriterIdleEvent = firstAllIdleEvent = true;
}
};
private byte state; // 0 - none, 1 - initialized, 2 - destroyed
private boolean reading;
private long lastChangeCheckTimeStamp;
private int lastMessageHashCode;
private long lastPendingWriteBytes;
private long lastFlushProgress;
/**
* Creates a new instance firing {@link IdleStateEvent}s.
*
* @param readerIdleTimeSeconds an {@link IdleStateEvent} whose state is {@link IdleState#READER_IDLE}
* will be triggered when no read was performed for the specified
* period of time. Specify {@code 0} to disable.
* @param writerIdleTimeSeconds an {@link IdleStateEvent} whose state is {@link IdleState#WRITER_IDLE}
* will be triggered when no write was performed for the specified
* period of time. Specify {@code 0} to disable.
* @param allIdleTimeSeconds an {@link IdleStateEvent} whose state is {@link IdleState#ALL_IDLE}
* will be triggered when neither read nor write was performed for
* the specified period of time. Specify {@code 0} to disable.
*/
public LazyUdpServerIdleStateHandler(
int readerIdleTimeSeconds,
int writerIdleTimeSeconds,
int allIdleTimeSeconds) {
this(readerIdleTimeSeconds, writerIdleTimeSeconds, allIdleTimeSeconds,
TimeUnit.SECONDS);
}
/**
* @see #LazyUdpServerIdleStateHandler(boolean, long, long, long, TimeUnit)
*/
public LazyUdpServerIdleStateHandler(
long readerIdleTime, long writerIdleTime, long allIdleTime,
TimeUnit unit) {
this(false, readerIdleTime, writerIdleTime, allIdleTime, unit);
}
/**
* Creates a new instance firing {@link IdleStateEvent}s.
*
* @param observeOutput whether or not the consumption of {@code bytes} should be taken into
* consideration when assessing write idleness. The default is {@code false}.
* @param readerIdleTime an {@link IdleStateEvent} whose state is {@link IdleState#READER_IDLE}
* will be triggered when no read was performed for the specified
* period of time. Specify {@code 0} to disable.
* @param writerIdleTime an {@link IdleStateEvent} whose state is {@link IdleState#WRITER_IDLE}
* will be triggered when no write was performed for the specified
* period of time. Specify {@code 0} to disable.
* @param allIdleTime an {@link IdleStateEvent} whose state is {@link IdleState#ALL_IDLE}
* will be triggered when neither read nor write was performed for
* the specified period of time. Specify {@code 0} to disable.
* @param unit the {@link TimeUnit} of {@code readerIdleTime},
* {@code writeIdleTime}, and {@code allIdleTime}
*/
public LazyUdpServerIdleStateHandler(boolean observeOutput,
long readerIdleTime, long writerIdleTime, long allIdleTime,
TimeUnit unit) {
ObjectUtil.checkNotNull(unit, "unit");
this.observeOutput = observeOutput;
if (readerIdleTime <= 0) {
readerIdleTimeNanos = 0;
} else {
readerIdleTimeNanos = Math.max(unit.toNanos(readerIdleTime), MIN_TIMEOUT_NANOS);
}
if (writerIdleTime <= 0) {
writerIdleTimeNanos = 0;
} else {
writerIdleTimeNanos = Math.max(unit.toNanos(writerIdleTime), MIN_TIMEOUT_NANOS);
}
if (allIdleTime <= 0) {
allIdleTimeNanos = 0;
} else {
allIdleTimeNanos = Math.max(unit.toNanos(allIdleTime), MIN_TIMEOUT_NANOS);
}
}
/**
* Return the readerIdleTime that was given when instance this class in milliseconds.
*/
public long getReaderIdleTimeInMillis() {
return TimeUnit.NANOSECONDS.toMillis(readerIdleTimeNanos);
}
/**
* Return the writerIdleTime that was given when instance this class in milliseconds.
*/
public long getWriterIdleTimeInMillis() {
return TimeUnit.NANOSECONDS.toMillis(writerIdleTimeNanos);
}
/**
* Return the allIdleTime that was given when instance this class in milliseconds.
*/
public long getAllIdleTimeInMillis() {
return TimeUnit.NANOSECONDS.toMillis(allIdleTimeNanos);
}
@Override
public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
if (ctx.channel().isActive() && ctx.channel().isRegistered()) {
// channelActive() event has been fired already, which means this.channelActive() will
// not be invoked. We have to initialize here instead.
initialize(ctx);
} else {
// channelActive() event has not been fired yet. this.channelActive() will be invoked
// and initialization will occur there.
}
}
@Override
public void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
destroy();
}
@Override
public void channelRegistered(ChannelHandlerContext ctx) throws Exception {
// Initialize early if channel is active already.
if (ctx.channel().isActive()) {
initialize(ctx);
}
super.channelRegistered(ctx);
}
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
// This method will be invoked only if this doHandler was added
// before channelActive() event is fired. If a user adds this doHandler
// after the channelActive() event, initialize() will be called by beforeAdd().
initialize(ctx);
super.channelActive(ctx);
}
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
destroy();
super.channelInactive(ctx);
}
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
if (readerIdleTimeNanos > 0 || allIdleTimeNanos > 0) {
reading = true;
firstReaderIdleEvent = firstAllIdleEvent = true;
}
ctx.fireChannelRead(msg);
System.out.println("channelRead");
}
@Override
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
if ((readerIdleTimeNanos > 0 || allIdleTimeNanos > 0) && reading) {
lastReadTime = ticksInNanos();
reading = false;
}
ctx.fireChannelReadComplete();
System.out.println("channelReadComplete");
}
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
// Allow writing with void promise if doHandler is only configured for read timeout events.
if (writerIdleTimeNanos > 0 || allIdleTimeNanos > 0) {
ctx.write(msg, promise.unvoid()).addListener(writeListener);
} else {
ctx.write(msg, promise);
}
System.out.println("write");
}
private void initialize(ChannelHandlerContext ctx) {
// Avoid the case where destroy() is called before scheduling timeouts.
// See: https://github.com/netty/netty/issues/143
switch (state) {
case 1:
case 2:
return;
default:
break;
}
state = 1;
initOutputChanged(ctx);
lastReadTime = lastWriteTime = ticksInNanos();
if (readerIdleTimeNanos > 0) {
readerIdleTimeout = schedule(ctx, new ReaderIdleTimeoutTask(ctx),
readerIdleTimeNanos, TimeUnit.NANOSECONDS);
}
if (writerIdleTimeNanos > 0) {
writerIdleTimeout = schedule(ctx, new WriterIdleTimeoutTask(ctx),
writerIdleTimeNanos, TimeUnit.NANOSECONDS);
}
if (allIdleTimeNanos > 0) {
allIdleTimeout = schedule(ctx, new AllIdleTimeoutTask(ctx),
allIdleTimeNanos, TimeUnit.NANOSECONDS);
}
}
/**
* This method is visible for testing!
*/
long ticksInNanos() {
return System.nanoTime();
}
/**
* This method is visible for testing!
*/
Future<?> schedule(ChannelHandlerContext ctx, Runnable task, long delay, TimeUnit unit) {
return ctx.executor().schedule(task, delay, unit);
}
private void destroy() {
state = 2;
if (readerIdleTimeout != null) {
readerIdleTimeout.cancel(false);
readerIdleTimeout = null;
}
if (writerIdleTimeout != null) {
writerIdleTimeout.cancel(false);
writerIdleTimeout = null;
}
if (allIdleTimeout != null) {
allIdleTimeout.cancel(false);
allIdleTimeout = null;
}
}
/**
* Is called when an {@link IdleStateEvent} should be fired. This implementation calls
* {@link ChannelHandlerContext#fireUserEventTriggered(Object)}.
*/
protected void channelIdle(ChannelHandlerContext ctx, IdleStateEvent evt) throws Exception {
ctx.fireUserEventTriggered(evt);
}
/**
* Returns a {@link IdleStateEvent}.
*/
protected IdleStateEvent newIdleStateEvent(IdleState state, boolean first) {
switch (state) {
case ALL_IDLE:
return first ? IdleStateEvent.FIRST_ALL_IDLE_STATE_EVENT : IdleStateEvent.ALL_IDLE_STATE_EVENT;
case READER_IDLE:
return first ? IdleStateEvent.FIRST_READER_IDLE_STATE_EVENT : IdleStateEvent.READER_IDLE_STATE_EVENT;
case WRITER_IDLE:
return first ? IdleStateEvent.FIRST_WRITER_IDLE_STATE_EVENT : IdleStateEvent.WRITER_IDLE_STATE_EVENT;
default:
throw new IllegalArgumentException("Unhandled: state=" + state + ", first=" + first);
}
}
/**
* @see #hasOutputChanged(ChannelHandlerContext, boolean)
*/
private void initOutputChanged(ChannelHandlerContext ctx) {
if (observeOutput) {
Channel channel = ctx.channel();
Channel.Unsafe unsafe = channel.unsafe();
ChannelOutboundBuffer buf = unsafe.outboundBuffer();
if (buf != null) {
lastMessageHashCode = System.identityHashCode(buf.current());
lastPendingWriteBytes = buf.totalPendingWriteBytes();
lastFlushProgress = buf.currentProgress();
}
}
}
/**
* Returns {@code true} if and only if the {@link IdleStateHandler} was constructed
* with {@link #observeOutput} enabled and there has been an observed change in the
* {@link ChannelOutboundBuffer} between two consecutive calls of this method.
* <p>
* https://github.com/netty/netty/issues/6150
*/
private boolean hasOutputChanged(ChannelHandlerContext ctx, boolean first) {
if (observeOutput) {
// We can take this shortcut if the ChannelPromises that got passed into write()
// appear to complete. It indicates "change" on message level and we simply assume
// that there's change happening on byte level. If the user doesn't observe channel
// writability events then they'll eventually OOME and there's clearly a different
// problem and idleness is least of their concerns.
if (lastChangeCheckTimeStamp != lastWriteTime) {
lastChangeCheckTimeStamp = lastWriteTime;
// But this applies only if it's the non-first call.
if (!first) {
return true;
}
}
Channel channel = ctx.channel();
Channel.Unsafe unsafe = channel.unsafe();
ChannelOutboundBuffer buf = unsafe.outboundBuffer();
if (buf != null) {
int messageHashCode = System.identityHashCode(buf.current());
long pendingWriteBytes = buf.totalPendingWriteBytes();
if (messageHashCode != lastMessageHashCode || pendingWriteBytes != lastPendingWriteBytes) {
lastMessageHashCode = messageHashCode;
lastPendingWriteBytes = pendingWriteBytes;
if (!first) {
return true;
}
}
long flushProgress = buf.currentProgress();
if (flushProgress != lastFlushProgress) {
lastFlushProgress = flushProgress;
return !first;
}
}
}
return false;
}
private abstract static class AbstractIdleTask implements Runnable {
private final ChannelHandlerContext ctx;
AbstractIdleTask(ChannelHandlerContext ctx) {
this.ctx = ctx;
}
@Override
public void run() {
if (!ctx.channel().isOpen()) {
return;
}
run(ctx);
}
protected abstract void run(ChannelHandlerContext ctx);
}
private final class ReaderIdleTimeoutTask extends AbstractIdleTask {
ReaderIdleTimeoutTask(ChannelHandlerContext ctx) {
super(ctx);
}
@Override
protected void run(ChannelHandlerContext ctx) {
long nextDelay = readerIdleTimeNanos;
if (!reading) {
nextDelay -= ticksInNanos() - lastReadTime;
}
if (nextDelay <= 0) {
// Reader is idle - set a new timeout and notify the callback.
readerIdleTimeout = schedule(ctx, this, readerIdleTimeNanos, TimeUnit.NANOSECONDS);
boolean first = firstReaderIdleEvent;
firstReaderIdleEvent = false;
try {
IdleStateEvent event = newIdleStateEvent(IdleState.READER_IDLE, first);
channelIdle(ctx, event);
} catch (Throwable t) {
ctx.fireExceptionCaught(t);
}
} else {
// Read occurred before the timeout - set a new timeout with shorter delay.
readerIdleTimeout = schedule(ctx, this, nextDelay, TimeUnit.NANOSECONDS);
}
}
}
private final class WriterIdleTimeoutTask extends AbstractIdleTask {
WriterIdleTimeoutTask(ChannelHandlerContext ctx) {
super(ctx);
}
@Override
protected void run(ChannelHandlerContext ctx) {
long lastWriteTime = LazyUdpServerIdleStateHandler.this.lastWriteTime;
long nextDelay = writerIdleTimeNanos - (ticksInNanos() - lastWriteTime);
if (nextDelay <= 0) {
// Writer is idle - set a new timeout and notify the callback.
writerIdleTimeout = schedule(ctx, this, writerIdleTimeNanos, TimeUnit.NANOSECONDS);
boolean first = firstWriterIdleEvent;
firstWriterIdleEvent = false;
try {
if (hasOutputChanged(ctx, first)) {
return;
}
IdleStateEvent event = newIdleStateEvent(IdleState.WRITER_IDLE, first);
channelIdle(ctx, event);
} catch (Throwable t) {
ctx.fireExceptionCaught(t);
}
} else {
// Write occurred before the timeout - set a new timeout with shorter delay.
writerIdleTimeout = schedule(ctx, this, nextDelay, TimeUnit.NANOSECONDS);
}
}
}
private final class AllIdleTimeoutTask extends AbstractIdleTask {
AllIdleTimeoutTask(ChannelHandlerContext ctx) {
super(ctx);
}
@Override
protected void run(ChannelHandlerContext ctx) {
long nextDelay = allIdleTimeNanos;
if (!reading) {
nextDelay -= ticksInNanos() - Math.max(lastReadTime, lastWriteTime);
}
if (nextDelay <= 0) {
// Both reader and writer are idle - set a new timeout and
// notify the callback.
allIdleTimeout = schedule(ctx, this, allIdleTimeNanos, TimeUnit.NANOSECONDS);
boolean first = firstAllIdleEvent;
firstAllIdleEvent = false;
try {
if (hasOutputChanged(ctx, first)) {
return;
}
IdleStateEvent event = newIdleStateEvent(IdleState.ALL_IDLE, first);
channelIdle(ctx, event);
} catch (Throwable t) {
ctx.fireExceptionCaught(t);
}
} else {
// Either read or write occurred before the timeout - set a new
// timeout with shorter delay.
allIdleTimeout = schedule(ctx, this, nextDelay, TimeUnit.NANOSECONDS);
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More