mirror of
https://gitee.com/wujiawei1207537021/wu-lazy-cloud-network.git
synced 2025-06-16 18:35:05 +08:00
【fix】客户端渗透客户端编码
This commit is contained in:
@ -1,12 +1,8 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.server.netty.advanced;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
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.*;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.advanced.server.AbstractHandleReportClientTransferClientPermeateChannelConnectionSuccessfulTypeAdvanced;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.advanced.server.AbstractHandleReportClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced;
|
||||
import org.framework.lazy.cloud.network.heartbeat.server.netty.socket.NettyClientPermeateServerConnectRealSocket;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
@ -27,8 +23,9 @@ public class ServerHandleReportClientTransferClientPermeateChannelConnectionSucc
|
||||
byte[] msgVisitorPort = nettyProxyMsg.getVisitorPort();
|
||||
byte[] msgClientTargetIp = nettyProxyMsg.getClientTargetIp();
|
||||
byte[] msgClientTargetPort = nettyProxyMsg.getClientTargetPort();
|
||||
byte[] clientId = nettyProxyMsg.getClientId();
|
||||
//
|
||||
byte[] clientId = nettyProxyMsg.getClientId();// 目标客户端ID
|
||||
// 绑定访客通道
|
||||
NettyTransferChannelContext.pushVisitor(channel,msgVisitorId);
|
||||
ChannelContext.ClientChannel clientChannel = ChannelContext.get(clientId);
|
||||
|
||||
NettyProxyMsg clientConnectTagetNettyProxyMsg = new NettyProxyMsg();
|
||||
|
@ -0,0 +1,59 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.server.netty.advanced;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.ChannelContext;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.MessageType;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyTransferChannelContext;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.advanced.server.AbstractHandleReportClientTransferClientPermeateChannelConnectionSuccessfulTypeAdvanced;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.advanced.server.AbstractHandleReportClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 上报 客户端渗透客户端数据传输通道init
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ServerHandleReportClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced extends AbstractHandleReportClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced<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();
|
||||
byte[] clientId = nettyProxyMsg.getClientId();
|
||||
|
||||
|
||||
// next translation
|
||||
Channel nextTransferChannel = NettyTransferChannelContext.getVisitor(msgVisitorId);
|
||||
ChannelAttributeKeyUtils.buildTransferNextChannel(nextTransferChannel,channel);
|
||||
ChannelAttributeKeyUtils.buildTransferNextChannel(channel,nextTransferChannel);
|
||||
|
||||
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.setType(MessageType.DISTRIBUTE_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_INIT_SUCCESSFUL);
|
||||
if (nextChannel != null) {
|
||||
nextChannel.writeAndFlush(clientConnectTagetNettyProxyMsg);
|
||||
}else {
|
||||
log.error("error");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.server.netty.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.server.AbstractHandleReportClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.advanced.server.AbstractHandleReportClientTransferClientResponseTypeAdvanced;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 上报客户端渗透客户端数据传输结果
|
||||
*/
|
||||
@Component
|
||||
public class ServerHandleReportClientTransferClientResponseTypeAdvanced extends AbstractHandleReportClientTransferClientResponseTypeAdvanced<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();
|
||||
byte[] clientId = nettyProxyMsg.getClientId();
|
||||
// 下发客户端初始化成功
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
|
||||
|
||||
|
||||
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_RESPONSE);
|
||||
if (nextChannel != null) {
|
||||
nextChannel.writeAndFlush(clientConnectTagetNettyProxyMsg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.server.netty.advanced;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.MessageType;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.advanced.server.AbstractHandleReportClientTransferClientTypeAdvanced;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 上报客户端渗透客户端数据传输
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ServerHandleReportClientTransferClientTypeAdvanced extends AbstractHandleReportClientTransferClientTypeAdvanced<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();
|
||||
byte[] clientId = nettyProxyMsg.getClientId();
|
||||
// 下发客户端初始化成功
|
||||
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.setType(MessageType.DISTRIBUTE_CLIENT_TRANSFER_CLIENT_REQUEST);
|
||||
if (nextChannel != null) {
|
||||
nextChannel.writeAndFlush(clientConnectTagetNettyProxyMsg);
|
||||
}else {
|
||||
log.error("eeeee");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user