【fix】

This commit is contained in:
wujiawei
2025-04-30 15:19:56 +08:00
parent 98587b442c
commit f2a22c177e
144 changed files with 958 additions and 669 deletions

View File

@ -1,7 +1,7 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import org.framework.lazy.cloud.network.heartbeat.common.constant.TcpMessageType;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.AbstractTcpHandleChannelHeartbeatTypeAdvanced;
@ -16,14 +16,14 @@ public class ClientHandleTcpChannelHeartbeatTypeAdvanced extends AbstractTcpHand
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param msg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg msg) {
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg msg) {
NettyProxyMsg hb = new NettyProxyMsg();
hb.setType(TcpMessageType.TCP_TYPE_HEARTBEAT);
// channel.writeAndFlush(hb);
// channelHandlerContext.writeAndFlush(hb);
}
}

View File

@ -3,6 +3,7 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.adv
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
@ -28,11 +29,12 @@ public class ClientHandleTcpChannelTransferTypeAdvancedHandleDistributeTcpDistri
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
Channel channel = channelHandlerContext.channel();
log.debug("接收到服务端需要内网穿透的数据:{}" , nettyProxyMsg);
String clientId = nettyClientProperties.getClientId();
byte[] visitorPort = nettyProxyMsg.getVisitorPort();

View File

@ -1,6 +1,7 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
import org.framework.lazy.cloud.network.heartbeat.common.ChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
@ -20,11 +21,12 @@ public class ClientHandleTcpClientChannelActiveAdvanced extends AbstractHandleTc
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
Channel channel = channelHandlerContext.channel();
// 缓存当前通道
byte[] clientIdByte = nettyProxyMsg.getClientId();
String clientId = new String(clientIdByte);

View File

@ -1,7 +1,7 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.NettyVisitorPortContext;
@ -22,11 +22,11 @@ public class ClientHandleTcpDistributeClientPermeateClientCloseTypeAdvanced exte
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
// 初始化 客户端渗透服务端socket
byte[] msgVisitorPort = nettyProxyMsg.getVisitorPort();
Integer visitorPort = Integer.parseInt(new String(msgVisitorPort));

View File

@ -1,7 +1,7 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.socket.NettyTcpClientPermeateClientVisitorSocket;
@ -26,11 +26,11 @@ public class ClientHandleTcpDistributeClientPermeateClientInitTypeAdvanced exten
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
// 初始化 客户端渗透服务端socket
byte[] fromClientIdBytes = nettyProxyMsg.getClientId();
byte[] visitorPortBytes = nettyProxyMsg.getVisitorPort();

View File

@ -2,6 +2,7 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.adv
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.client.AbstractHandleTcpDistributeClientPermeateClientTransferCloseTypeAdvanced;
@ -20,11 +21,12 @@ public class ClientHandleTcpDistributeClientPermeateClientTransferCloseTypeAdvan
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
Channel channel = channelHandlerContext.channel();
// 关闭客户端真实通道、访客通道
Channel realChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
realChannel.close();// 真实通道关闭

View File

@ -1,7 +1,7 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.NettyVisitorPortContext;
@ -22,11 +22,11 @@ public class ClientHandleTcpDistributeClientPermeateServerCloseTypeAdvanced exte
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
// 初始化 客户端渗透服务端socket
byte[] msgVisitorPort = nettyProxyMsg.getVisitorPort();
Integer visitorPort = Integer.parseInt(new String(msgVisitorPort));

View File

@ -1,7 +1,7 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.socket.NettyTcpClientPermeateServerVisitorSocket;
@ -32,11 +32,11 @@ public class ClientHandleTcpDistributeClientPermeateServerInitTypeAdvanced exten
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
// 初始化 客户端渗透服务端socket
byte[] clientIdBytes = nettyProxyMsg.getClientId();
byte[] visitorPort = nettyProxyMsg.getVisitorPort();

View File

@ -2,6 +2,7 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.adv
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.client.AbstractHandleTcpDistributeClientPermeateServerTransferCloseTypeAdvanced;
@ -20,11 +21,12 @@ public class ClientHandleTcpDistributeClientPermeateServerTransferCloseTypeAdvan
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
Channel channel = channelHandlerContext.channel();
// 关闭本地通信通道
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
channel.close();

View File

@ -3,6 +3,7 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.adv
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.client.AbstractHandleTcpDistributeClientPermeateServerTransferTypeAdvanced;
@ -22,11 +23,12 @@ public class ClientHandleTcpDistributeClientPermeateServerTransferTypeAdvanced e
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
Channel channel = channelHandlerContext.channel();
log.debug("客户端渗透服务端返回数据:{}" , new String(nettyProxyMsg.getData()));
byte[] visitorPort = nettyProxyMsg.getVisitorPort();
byte[] clientTargetIp = nettyProxyMsg.getClientTargetIp();

View File

@ -1,7 +1,7 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.socket.NettyTcpClientPermeateClientRealSocket;
@ -27,11 +27,11 @@ public class ClientHandleTcpDistributeClientTransferClientPermeateChannelConnect
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
// 创建connect 然后发送创建成功
byte[] msgClientId = nettyProxyMsg.getClientId();
byte[] msgClientTargetIp = nettyProxyMsg.getClientTargetIp();

View File

@ -2,6 +2,7 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.adv
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOption;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
@ -24,11 +25,12 @@ public class ClientHandleTcpDistributeClientTransferClientPermeateChannelInitSuc
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
Channel channel = channelHandlerContext.channel();
// 连接成功 开启自动读取写
byte[] msgClientId = nettyProxyMsg.getClientId();
byte[] msgClientTargetIp = nettyProxyMsg.getClientTargetIp();

View File

@ -3,6 +3,7 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.adv
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.client.AbstractHandleTcpDistributeClientTransferClientRequestTypeAdvanced;
@ -24,11 +25,12 @@ public class ClientHandleTcpDistributeClientTransferClientRequestTypeAdvanced ex
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
Channel channel = channelHandlerContext.channel();
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
// 把数据转到真实服务
ByteBuf buf = channel.config().getAllocator().buffer(nettyProxyMsg.getData().length);

View File

@ -2,6 +2,7 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.adv
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOption;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.handler.NettyTcpClientPermeateServerVisitorHandler;
@ -27,15 +28,16 @@ public class ClientHandleTcpDistributeClientTransferServerPermeateChannelConnect
/**
* 处理当前数据
*
* @param transferChannel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel transferChannel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
Channel channel = channelHandlerContext.channel();
// 连接成功 开启自动读取写
byte[] msgVisitorId = nettyProxyMsg.getVisitorId();
String visitorId = new String(msgVisitorId);
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(transferChannel);
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
nextChannel.config().setOption(ChannelOption.AUTO_READ, true);
}

View File

@ -1,7 +1,7 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
import com.alibaba.fastjson.JSONObject;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.event.ClientChangeEvent;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
@ -25,11 +25,11 @@ public class ClientHandleTcpDistributeConnectSuccessNotificationTypeAdvancedHand
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param msg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg msg) {
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg msg) {
// 客户端ID{},客户端:{}连接成功
log.warn("Client ID: {}, Client Data : {} Connection successful", new String(msg.getClientId()), new String(msg.getData()));

View File

@ -1,7 +1,7 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.event.ClientChangeEvent;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
@ -25,11 +25,11 @@ public class ClientHandleTcpDistributeDisconnectTypeAdvancedHandle extends Abstr
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param msg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg msg) {
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg msg) {
// 服务下线
byte[] data = msg.getData();
byte[] clientId = msg.getClientId();

View File

@ -1,6 +1,6 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.socket.NettyTcpServerPermeateClientRealSocket;
@ -30,11 +30,11 @@ public class ClientHandleTcpDistributeServicePermeateClientRealConnectTypeAdvanc
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param msg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg msg) {
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg msg) {
// 创建真实端口监听
byte[] clientIdBytes = msg.getClientId();
byte[] visitorPort = msg.getVisitorPort();

View File

@ -3,6 +3,7 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.adv
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.client.AbstractHandleTcpDistributeServicePermeateClientTransferClientResponseTypeAdvanced;
@ -24,11 +25,12 @@ public class ClientHandleTcpDistributeServicePermeateClientTransferClientRespons
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
Channel channel = channelHandlerContext.channel();
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
// 把数据转到真实服务
ByteBuf buf = channel.config().getAllocator().buffer(nettyProxyMsg.getData().length);

View File

@ -1,6 +1,6 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.client.AbstractHandleTcpDistributeSingleClientMessageTypeAdvanced;
@ -13,11 +13,11 @@ public class ClientHandleTcpDistributeSingleClientMessageTypeAdvanced extends Ab
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
byte[] clientId = nettyProxyMsg.getClientId();
byte[] data = nettyProxyMsg.getData();
log.info("接收客户端:{},发送过来的聊天信息:{}", new String(clientId), new String(data));

View File

@ -1,6 +1,7 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOption;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
@ -13,11 +14,12 @@ public class ClientHandleTcpDistributeSingleClientRealAutoReadConnectTypeAdvance
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
Channel channel = channelHandlerContext.channel();
// 获取访客ID
byte[] visitorId = nettyProxyMsg.getVisitorId();
// 获取访客对应的真实代理通道

View File

@ -1,6 +1,6 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyCommunicationIdContext;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
@ -12,11 +12,11 @@ public class ClientHandleTcpDistributeSingleClientRealCloseVisitorTypeAdvanced e
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
// 关闭代理的真实通道
byte[] visitorId = nettyProxyMsg.getVisitorId();
NettyRealIdContext.clear(visitorId);

View File

@ -1,6 +1,6 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.client.AbstractHandleTcpDistributeStagingClosedTypeAdvanced;
@ -15,11 +15,11 @@ public class ClientHandleTcpDistributeStagingClosedTypeAdvanced extends Abstract
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param msg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg msg) {
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg msg) {
String clientId = new String(msg.getClientId());
log.info("客户端:{}离线暂存关闭", clientId);
// 修改redis 客户端暂存状态

View File

@ -1,6 +1,6 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.client.AbstractHandleTcpDistributeStagingOpenedTypeAdvanced;
@ -19,11 +19,11 @@ public class ClientHandleTcpDistributeStagingOpenedTypeAdvanced extends Abstract
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param msg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg msg) {
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg msg) {
String clientId = new String(msg.getClientId());
//客户端:{}离线暂存开启
log.warn("Client: {} Offline temporary storage enabled", new String(msg.getClientId()));

View File

@ -47,7 +47,7 @@ public class NettyTcpClientHandler extends SimpleChannelInboundHandler<NettyProx
// 接收服务端、或者是代理端的信息
Channel channel = ctx.channel();
// log.info("type:{},clientId:{},data:{}",msg.getMysqlType(),new String(msg.getClientId()),new String(msg.getData()));
channelTypeAdapter.handler(channel, msg);
channelTypeAdapter.handler(ctx, msg);
}
/**
@ -64,7 +64,7 @@ public class NettyTcpClientHandler extends SimpleChannelInboundHandler<NettyProx
NettyProxyMsg nettyMsg = new NettyProxyMsg();
nettyMsg.setType(TcpMessageType.TCP_CLIENT_CHANNEL_ACTIVE);
nettyMsg.setClientId(clientId);
channelTypeAdapter.handler(channel, nettyMsg);
channelTypeAdapter.handler(ctx, nettyMsg);
}
@ -108,7 +108,7 @@ public class NettyTcpClientHandler extends SimpleChannelInboundHandler<NettyProx
NettyProxyMsg nettyMsg = new NettyProxyMsg();
nettyMsg.setType(TcpMessageType.TCP_DISTRIBUTE_CLIENT_DISCONNECTION_NOTIFICATION);
nettyMsg.setClientId(clientId.getBytes(StandardCharsets.UTF_8));
channelTypeAdapter.handler(channel, nettyMsg);
channelTypeAdapter.handler(ctx, nettyMsg);
ctx.close();
}

View File

@ -29,7 +29,7 @@ public class NettyTcpClientPermeateClientTransferHandler extends SimpleChannelIn
@Override
public void channelRead0(ChannelHandlerContext ctx, NettyProxyMsg nettyProxyMsg) throws Exception {
Channel channel = ctx.channel();
channelTypeAdapter.handler(channel, nettyProxyMsg);
channelTypeAdapter.handler(ctx, nettyProxyMsg);
}

View File

@ -29,7 +29,7 @@ public class NettyTcpClientPermeateClientTransferRealHandler extends SimpleChann
@Override
public void channelRead0(ChannelHandlerContext ctx, NettyProxyMsg nettyProxyMsg) throws Exception {
Channel channel = ctx.channel();
channelTypeAdapter.handler(channel, nettyProxyMsg);
channelTypeAdapter.handler(ctx, nettyProxyMsg);
}

View File

@ -31,7 +31,7 @@ public class NettyTcpClientPermeateServerTransferHandler extends SimpleChannelIn
@Override
public void channelRead0(ChannelHandlerContext ctx, NettyProxyMsg nettyProxyMsg) throws Exception {
Channel channel = ctx.channel();
channelTypeAdapter.handler(channel, nettyProxyMsg);
channelTypeAdapter.handler(ctx, nettyProxyMsg);
}

View File

@ -31,7 +31,7 @@ public class NettyTcpServerPermeateClientTransferHandler extends SimpleChannelIn
@Override
public void channelRead0(ChannelHandlerContext ctx, NettyProxyMsg nettyProxyMsg) throws Exception {
Channel channel = ctx.channel();
channelTypeAdapter.handler(channel, nettyProxyMsg);
channelTypeAdapter.handler(ctx, nettyProxyMsg);
}

View File

@ -1,7 +1,7 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.advanced;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import org.framework.lazy.cloud.network.heartbeat.common.constant.UdpMessageType;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.udp.AbstractUdpHandleChannelHeartbeatTypeAdvanced;
@ -16,14 +16,14 @@ public class ClientHandleUdpChannelHeartbeatTypeAdvanced extends AbstractUdpHand
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param msg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg msg) {
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg msg) {
NettyProxyMsg hb = new NettyProxyMsg();
hb.setType(UdpMessageType.UDP_TYPE_HEARTBEAT);
// channel.writeAndFlush(hb);
// channelHandlerContext.writeAndFlush(hb);
}
}

View File

@ -3,6 +3,7 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.adv
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
@ -28,11 +29,11 @@ public class ClientHandleUdpChannelTransferTypeAdvancedHandleDistribute extends
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
log.debug("接收到服务端需要内网穿透的数据:{}" , nettyProxyMsg);
String clientId = nettyClientProperties.getClientId();
byte[] visitorPort = nettyProxyMsg.getVisitorPort();
@ -41,7 +42,7 @@ public class ClientHandleUdpChannelTransferTypeAdvancedHandleDistribute extends
byte[] visitorId = nettyProxyMsg.getVisitorId();
// 真实服务通道
// Channel realChannel = NettyRealIdContext.getReal(new String(visitorId));
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channelHandlerContext);
if (nextChannel == null) {
log.error("无法获取访客:{} 真实服务", new String(visitorId));
return;
@ -49,7 +50,7 @@ public class ClientHandleUdpChannelTransferTypeAdvancedHandleDistribute extends
// 把数据转到真实服务
ByteBuf buf = channel.config().getAllocator().buffer(nettyProxyMsg.getData().length);
ByteBuf buf = channelHandlerContext.config().getAllocator().buffer(nettyProxyMsg.getData().length);
buf.writeBytes(nettyProxyMsg.getData());
nextChannel.writeAndFlush(buf);

View File

@ -1,6 +1,6 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.advanced;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
import org.framework.lazy.cloud.network.heartbeat.common.ChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
@ -20,15 +20,15 @@ public class ClientHandleUdpClientChannelActiveAdvanced extends AbstractHandleUd
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
// 缓存当前通道
byte[] clientIdByte = nettyProxyMsg.getClientId();
String clientId = new String(clientIdByte);
ChannelContext.push(channel, clientId);
ChannelAttributeKeyUtils.buildClientId(channel, clientId);
ChannelContext.push(channelHandlerContext, clientId);
ChannelAttributeKeyUtils.buildClientId(channelHandlerContext, clientId);
}
}

View File

@ -1,7 +1,7 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.advanced;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.NettyVisitorPortContext;
@ -22,11 +22,11 @@ public class ClientHandleUdpDistributeClientPermeateClientCloseTypeAdvanced exte
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
// 初始化 客户端渗透服务端socket
byte[] msgVisitorPort = nettyProxyMsg.getVisitorPort();
Integer visitorPort = Integer.parseInt(new String(msgVisitorPort));

View File

@ -1,7 +1,7 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.advanced;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.socket.NettyUdpClientPermeateClientVisitorSocket;
@ -26,11 +26,11 @@ public class ClientHandleUdpDistributeClientPermeateClientInitTypeAdvanced exten
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
// 初始化 客户端渗透服务端socket
byte[] fromClientIdBytes = nettyProxyMsg.getClientId();
byte[] visitorPortBytes = nettyProxyMsg.getVisitorPort();

View File

@ -2,6 +2,7 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.adv
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.udp.client.AbstractHandleUdpDistributeClientPermeateClientTransferCloseTypeAdvanced;
@ -20,15 +21,15 @@ public class ClientHandleUdpDistributeClientPermeateClientTransferCloseTypeAdvan
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
// 关闭客户端真实通道、访客通道
Channel realChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
Channel realChannel = ChannelAttributeKeyUtils.getNextChannel(channelHandlerContext);
realChannel.close();// 真实通道关闭
channel.close(); // 数据传输通道关闭
channelHandlerContext.close(); // 数据传输通道关闭
}

View File

@ -1,7 +1,7 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.advanced;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.NettyVisitorPortContext;
@ -22,11 +22,11 @@ public class ClientHandleUdpDistributeClientPermeateServerCloseTypeAdvanced exte
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
// 初始化 客户端渗透服务端socket
byte[] msgVisitorPort = nettyProxyMsg.getVisitorPort();
Integer visitorPort = Integer.parseInt(new String(msgVisitorPort));

View File

@ -1,7 +1,7 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.advanced;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.socket.NettyUdpClientPermeateServerVisitorSocket;
@ -32,11 +32,11 @@ public class ClientHandleUdpDistributeClientPermeateServerInitTypeAdvanced exten
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
// 初始化 客户端渗透服务端socket
byte[] clientIdBytes = nettyProxyMsg.getClientId();
byte[] visitorPort = nettyProxyMsg.getVisitorPort();

View File

@ -2,6 +2,7 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.adv
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.udp.client.AbstractHandleUdpDistributeClientPermeateServerTransferCloseTypeAdvanced;
@ -20,14 +21,14 @@ public class ClientHandleUdpDistributeClientPermeateServerTransferCloseTypeAdvan
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
// 关闭本地通信通道
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
channel.close();
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channelHandlerContext);
channelHandlerContext.close();
nextChannel.close();
}

View File

@ -3,6 +3,7 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.adv
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.udp.client.AbstractHandleUdpDistributeClientPermeateServerTransferTypeAdvanced;
@ -22,11 +23,12 @@ public class ClientHandleUdpDistributeClientPermeateServerTransferTypeAdvanced e
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
Channel channel = channelHandlerContext.channel();
log.debug("客户端渗透服务端返回数据:{}" , new String(nettyProxyMsg.getData()));
byte[] visitorPort = nettyProxyMsg.getVisitorPort();
byte[] clientTargetIp = nettyProxyMsg.getClientTargetIp();

View File

@ -1,7 +1,7 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.advanced;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.socket.NettyUdpClientPermeateClientRealSocket;
@ -26,11 +26,11 @@ public class ClientHandleUdpDistributeClientTransferClientPermeateChannelConnect
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
// 创建connect 然后发送创建成功
byte[] msgClientId = nettyProxyMsg.getClientId();
byte[] msgClientTargetIp = nettyProxyMsg.getClientTargetIp();

View File

@ -2,6 +2,7 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.adv
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOption;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
@ -24,11 +25,11 @@ public class ClientHandleUdpDistributeClientTransferClientPermeateChannelInitSuc
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
// 连接成功 开启自动读取写
byte[] msgClientId = nettyProxyMsg.getClientId();
byte[] msgClientTargetIp = nettyProxyMsg.getClientTargetIp();
@ -36,7 +37,7 @@ public class ClientHandleUdpDistributeClientTransferClientPermeateChannelInitSuc
byte[] msgVisitorId = nettyProxyMsg.getVisitorId();
byte[] msgVisitorPort = nettyProxyMsg.getVisitorPort();
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channelHandlerContext);
nextChannel.config().setOption(ChannelOption.AUTO_READ, true);
}

View File

@ -3,6 +3,7 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.adv
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.udp.client.AbstractHandleUdpDistributeClientTransferClientRequestTypeAdvanced;
@ -24,11 +25,12 @@ public class ClientHandleUdpDistributeClientTransferClientRequestTypeAdvanced ex
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
Channel channel = channelHandlerContext.channel();
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
// 把数据转到真实服务
ByteBuf buf = channel.config().getAllocator().buffer(nettyProxyMsg.getData().length);

View File

@ -2,6 +2,7 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.adv
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOption;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.handler.NettyUdpClientPermeateServerVisitorHandler;
@ -27,15 +28,15 @@ public class ClientHandleUdpDistributeClientTransferServerPermeateChannelConnect
/**
* 处理当前数据
*
* @param transferChannel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel transferChannel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
// 连接成功 开启自动读取写
byte[] msgVisitorId = nettyProxyMsg.getVisitorId();
String visitorId = new String(msgVisitorId);
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(transferChannel);
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channelHandlerContext);
nextChannel.config().setOption(ChannelOption.AUTO_READ, true);
}

View File

@ -1,7 +1,7 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.advanced;
import com.alibaba.fastjson.JSONObject;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.event.ClientChangeEvent;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
@ -25,11 +25,11 @@ public class ClientHandleUdpDistributeConnectSuccessNotificationTypeAdvancedHand
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param msg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg msg) {
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg msg) {
// 客户端ID{},客户端:{}连接成功
log.warn("Client ID: {}, Client Data : {} Connection successful", new String(msg.getClientId()), new String(msg.getData()));

View File

@ -1,7 +1,7 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.advanced;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.event.ClientChangeEvent;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
@ -25,11 +25,11 @@ public class ClientHandleUdpDistributeDisconnectTypeAdvancedHandle extends Abstr
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param msg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg msg) {
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg msg) {
// 服务下线
byte[] data = msg.getData();
byte[] clientId = msg.getClientId();

View File

@ -1,6 +1,6 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.advanced;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.socket.NettyUdpServerPermeateClientRealSocket;
@ -29,11 +29,11 @@ public class ClientHandleUdpDistributeServicePermeateClientRealConnectTypeAdvanc
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param msg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg msg) {
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg msg) {
// 创建真实端口监听
byte[] clientIdBytes = msg.getClientId();
byte[] visitorPort = msg.getVisitorPort();

View File

@ -3,6 +3,7 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.adv
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.udp.client.AbstractHandleUdpDistributeServicePermeateClientTransferClientResponseTypeAdvanced;
@ -24,14 +25,14 @@ public class ClientHandleUdpDistributeServicePermeateClientTransferClientRespons
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channelHandlerContext);
// 把数据转到真实服务
ByteBuf buf = channel.config().getAllocator().buffer(nettyProxyMsg.getData().length);
ByteBuf buf = channelHandlerContext.config().getAllocator().buffer(nettyProxyMsg.getData().length);
buf.writeBytes(nettyProxyMsg.getData());
nextChannel.writeAndFlush(buf);

View File

@ -1,6 +1,6 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.advanced;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.udp.client.AbstractHandleUdpDistributeSingleClientMessageTypeAdvanced;
@ -13,11 +13,11 @@ public class ClientHandleUdpDistributeSingleClientMessageTypeAdvanced extends Ab
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
byte[] clientId = nettyProxyMsg.getClientId();
byte[] data = nettyProxyMsg.getData();
log.info("接收客户端:{},发送过来的聊天信息:{}", new String(clientId), new String(data));

View File

@ -1,6 +1,7 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.advanced;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOption;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
@ -13,16 +14,16 @@ public class ClientHandleUdpDistributeSingleClientRealAutoReadConnectTypeAdvance
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
// 获取访客ID
byte[] visitorId = nettyProxyMsg.getVisitorId();
// 获取访客对应的真实代理通道
Channel realChannel = NettyRealIdContext.getReal(visitorId);
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channelHandlerContext);
if (nextChannel != null) {
nextChannel.config().setOption(ChannelOption.AUTO_READ, true);
}

View File

@ -1,6 +1,6 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.advanced;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyCommunicationIdContext;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
@ -12,11 +12,11 @@ public class ClientHandleUdpDistributeSingleClientRealCloseVisitorTypeAdvanced e
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
// 关闭代理的真实通道
byte[] visitorId = nettyProxyMsg.getVisitorId();
NettyRealIdContext.clear(visitorId);

View File

@ -1,6 +1,6 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.advanced;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.udp.client.AbstractHandleUdpDistributeStagingClosedTypeAdvanced;
@ -15,11 +15,11 @@ public class ClientHandleUdpDistributeStagingClosedTypeAdvanced extends Abstract
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param msg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg msg) {
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg msg) {
String clientId = new String(msg.getClientId());
log.info("客户端:{}离线暂存关闭", clientId);
// 修改redis 客户端暂存状态

View File

@ -1,6 +1,6 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.advanced;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.udp.client.AbstractHandleUdpDistributeStagingOpenedTypeAdvanced;
@ -19,11 +19,11 @@ public class ClientHandleUdpDistributeStagingOpenedTypeAdvanced extends Abstract
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param msg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg msg) {
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg msg) {
String clientId = new String(msg.getClientId());
//客户端:{}离线暂存开启
log.warn("Client: {} Offline temporary storage enabled", new String(msg.getClientId()));

View File

@ -47,7 +47,7 @@ public class NettyUdpClientHandler extends SimpleChannelInboundHandler<NettyProx
// 接收服务端、或者是代理端的信息
Channel channel = ctx.channel();
// log.info("type:{},clientId:{},data:{}",msg.getMysqlType(),new String(msg.getClientId()),new String(msg.getData()));
channelTypeAdapter.handler(channel, msg);
channelTypeAdapter.handler(ctx, msg);
}
/**
@ -64,7 +64,7 @@ public class NettyUdpClientHandler extends SimpleChannelInboundHandler<NettyProx
NettyProxyMsg nettyMsg = new NettyProxyMsg();
nettyMsg.setType(UdpMessageType.UDP_CLIENT_CHANNEL_ACTIVE);
nettyMsg.setClientId(clientId);
channelTypeAdapter.handler(channel, nettyMsg);
channelTypeAdapter.handler(ctx, nettyMsg);
}
@ -108,7 +108,7 @@ public class NettyUdpClientHandler extends SimpleChannelInboundHandler<NettyProx
NettyProxyMsg nettyMsg = new NettyProxyMsg();
nettyMsg.setType(UdpMessageType.UDP_DISTRIBUTE_CLIENT_DISCONNECTION_NOTIFICATION);
nettyMsg.setClientId(clientId.getBytes(StandardCharsets.UTF_8));
channelTypeAdapter.handler(channel, nettyMsg);
channelTypeAdapter.handler(ctx, nettyMsg);
ctx.close();
}

View File

@ -29,7 +29,7 @@ public class NettyUdpClientPermeateClientTransferHandler extends SimpleChannelIn
@Override
public void channelRead0(ChannelHandlerContext ctx, NettyProxyMsg nettyProxyMsg) throws Exception {
Channel channel = ctx.channel();
channelTypeAdapter.handler(channel, nettyProxyMsg);
channelTypeAdapter.handler(ctx, nettyProxyMsg);
}

View File

@ -29,7 +29,7 @@ public class NettyUdpClientPermeateClientTransferRealHandler extends SimpleChann
@Override
public void channelRead0(ChannelHandlerContext ctx, NettyProxyMsg nettyProxyMsg) throws Exception {
Channel channel = ctx.channel();
channelTypeAdapter.handler(channel, nettyProxyMsg);
channelTypeAdapter.handler(ctx, nettyProxyMsg);
}

View File

@ -31,7 +31,7 @@ public class NettyUdpClientPermeateServerTransferHandler extends SimpleChannelIn
@Override
public void channelRead0(ChannelHandlerContext ctx, NettyProxyMsg nettyProxyMsg) throws Exception {
Channel channel = ctx.channel();
channelTypeAdapter.handler(channel, nettyProxyMsg);
channelTypeAdapter.handler(ctx, nettyProxyMsg);
}

View File

@ -31,7 +31,7 @@ public class NettyUdpServerPermeateClientTransferHandler extends SimpleChannelIn
@Override
public void channelRead0(ChannelHandlerContext ctx, NettyProxyMsg nettyProxyMsg) throws Exception {
Channel channel = ctx.channel();
channelTypeAdapter.handler(channel, nettyProxyMsg);
channelTypeAdapter.handler(ctx, nettyProxyMsg);
}

View File

@ -1,6 +1,6 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.proxy.http.advanced;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
import org.framework.lazy.cloud.network.heartbeat.client.netty.proxy.http.socket.NettyHttpClientProxyClientRealSocket;
@ -24,11 +24,11 @@ public class ClientHandleDistributeHttpClientProxyClientConnectionTransferSucces
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
// 客户端主动连接服务端创建一个传输通道

View File

@ -2,19 +2,12 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.proxy.http.advan
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
import org.framework.lazy.cloud.network.heartbeat.client.netty.proxy.http.socket.NettyHttpClientProxyClientRealSocket;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.proxy.http.client.AbstractHandleHttpDistributeClientProxyClientConnectionTransferSuccessfulTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.proxy.http.client.AbstractHandleHttpDistributeClientProxyClientTransferRequestTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.wu.framework.core.utils.ObjectUtils;
import org.wu.framework.spring.utils.SpringContextHolder;
import java.util.ArrayList;
import java.util.List;
/**
* http 远程代理
@ -28,16 +21,16 @@ public class ClientHandleDistributeHttpClientProxyClientTransferRequestAdvanced
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
// 数据发送
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channelHandlerContext);
if(ObjectUtils.isNotEmpty(nextChannel)){
ByteBuf buf = channel.config().getAllocator().buffer(nettyProxyMsg.getData().length);
ByteBuf buf = channelHandlerContext.config().getAllocator().buffer(nettyProxyMsg.getData().length);
buf.writeBytes(nettyProxyMsg.getData());
nextChannel.writeAndFlush(buf);
}else {

View File

@ -1,7 +1,7 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.proxy.http.advanced;
import com.alibaba.fastjson.JSON;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.proxy.http.client.AbstractHandleHttpDistributeClientProxyServerClientRouteTypeAdvanced;
@ -20,11 +20,11 @@ public class ClientHandleDistributeHttpClientProxyServerClientRouteTypeAdvanced
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
byte[] data = nettyProxyMsg.getData();
ClientProxyRoute clientProxyRoute = JSON.parseObject(data, ClientProxyRoute.class);

View File

@ -1,15 +1,11 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.proxy.http.advanced;
import com.alibaba.fastjson.JSON;
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.proxy.http.client.AbstractHandleHttpDistributeClientProxyServerServerRouteTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.proxy.http.client.AbstractHandleHttpDistributeClientProxyServerTransferTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.framework.lazy.cloud.network.heartbeat.protocol.route.RouteContext;
import org.framework.lazy.cloud.network.heartbeat.protocol.route.RouteType;
import org.framework.lazy.cloud.network.heartbeat.protocol.route.ServerProxyRoute;
/**
@ -24,11 +20,11 @@ public class ClientHandleDistributeHttpClientProxyServerServerRouteTypeAdvanced
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
byte[] data = nettyProxyMsg.getData();
ServerProxyRoute serverProxyRoute = JSON.parseObject(data, ServerProxyRoute.class);

View File

@ -2,6 +2,7 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.proxy.http.advan
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.proxy.http.client.AbstractHandleHttpDistributeClientProxyServerTransferTypeAdvanced;
@ -19,21 +20,21 @@ public class ClientHandleDistributeHttpClientProxyServerTransferTypeAdvanced ext
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
String visitorId = ChannelAttributeKeyUtils.getVisitorId(channel);
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
String visitorId = ChannelAttributeKeyUtils.getVisitorId(channelHandlerContext);
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channelHandlerContext);
if (nextChannel == null) {
log.error("无法获取访客:{} 真实服务", visitorId);
return;
}
// 把数据转到真实服务
ByteBuf buf = channel.config().getAllocator().buffer(nettyProxyMsg.getData().length);
ByteBuf buf = channelHandlerContext.config().getAllocator().buffer(nettyProxyMsg.getData().length);
buf.writeBytes(nettyProxyMsg.getData());
nextChannel.writeAndFlush(buf);

View File

@ -1,6 +1,6 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.proxy.http.advanced;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
import org.framework.lazy.cloud.network.heartbeat.client.netty.proxy.http.socket.NettyHttpServerProxyClientRealSocket;
@ -19,11 +19,11 @@ public class ClientHandleDistributeHttpServerProxyClientConnectionSuccessfulType
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
// 创建一个传输通道

View File

@ -2,6 +2,7 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.proxy.http.advan
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.netty.proxy.http.handler.NettyHttpServerProxyClientRealHandler;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
@ -20,16 +21,16 @@ public class ClientHandleDistributeHttpServerProxyClientTransferRequestAdvanced
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
// 数据发送
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channelHandlerContext);
if (ObjectUtils.isNotEmpty(nextChannel)) {
ByteBuf buf = channel.config().getAllocator().buffer(nettyProxyMsg.getData().length);
ByteBuf buf = channelHandlerContext.config().getAllocator().buffer(nettyProxyMsg.getData().length);
buf.writeBytes(nettyProxyMsg.getData());
nextChannel.writeAndFlush(buf);
} else {

View File

@ -1,6 +1,6 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.proxy.http.advanced;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
import org.framework.lazy.cloud.network.heartbeat.client.netty.proxy.http.NettyHttpClientProxyClient;
import org.framework.lazy.cloud.network.heartbeat.client.netty.proxy.http.socket.NettyHttpClientProxyClientProxySocket;
@ -24,11 +24,11 @@ public class ClientHandleHttpClientProxyClientTypeAdvanced extends
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
String targetPortString = nettyProxyMsg.getTargetPortString();
String targetIpString = nettyProxyMsg.getTargetIpString();
byte[] data = nettyProxyMsg.getData();
@ -46,6 +46,6 @@ public class ClientHandleHttpClientProxyClientTypeAdvanced extends
nettyHttpClientProxyClient.setNettyClientProperties(nettyClientProperties);
nettyHttpClientProxyClient.setData(data);
NettyHttpClientProxyClientProxySocket.buildTransferServer(nettyHttpClientProxyClient, channel);
NettyHttpClientProxyClientProxySocket.buildTransferServer(nettyHttpClientProxyClient, channelHandlerContext);
}
}

View File

@ -1,6 +1,6 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.proxy.http.advanced;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
import org.framework.lazy.cloud.network.heartbeat.client.netty.proxy.http.NettyHttpClientProxyServer;
import org.framework.lazy.cloud.network.heartbeat.client.netty.proxy.http.socket.NettyHttpClientProxyServerProxySocket;
@ -23,11 +23,11 @@ public class ClientHandleHttpClientProxyServerTypeAdvanced extends
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
String targetPortString = nettyProxyMsg.getTargetPortString();
String targetIpString = nettyProxyMsg.getTargetIpString();
@ -45,7 +45,7 @@ public class ClientHandleHttpClientProxyServerTypeAdvanced extends
nettyHttpClientProxyServer.setNettyClientProperties(nettyClientProperties);
nettyHttpClientProxyServer.setData(data);
NettyHttpClientProxyServerProxySocket.buildTransferServer(nettyHttpClientProxyServer, channel);
NettyHttpClientProxyServerProxySocket.buildTransferServer(nettyHttpClientProxyServer, channelHandlerContext);
}
}

View File

@ -1,17 +1,11 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.proxy.http.advanced;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
import org.framework.lazy.cloud.network.heartbeat.client.netty.proxy.http.socket.NettyHttpClientProxyClientRealSocket;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.proxy.http.client.AbstractHandleHttpDistributeClientProxyClientTransferCLoseTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.wu.framework.spring.utils.SpringContextHolder;
import java.util.ArrayList;
import java.util.List;
/**
* http 远程代理
@ -25,15 +19,15 @@ public class ClientHandleHttpDistributeClientProxyClientTransferCLoseTypeAdvance
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
// 关闭传输通道
Channel realChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
Channel realChannel = ChannelAttributeKeyUtils.getNextChannel(channelHandlerContext);
realChannel.close();// 真实通道关闭
channel.close(); // 数据传输通道关闭
channelHandlerContext.close(); // 数据传输通道关闭
}
}

View File

@ -2,6 +2,7 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.proxy.http.advan
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.proxy.http.client.AbstractHandleHttpDistributeClientProxyClientTransferResponseTypeAdvanced;
@ -20,16 +21,16 @@ public class ClientHandleHttpDistributeClientProxyClientTransferResponseTypeAdva
/**
* 处理当前数据
*
* @param channel 当前通道
* @param channelHandlerContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
// 数据发送
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channelHandlerContext);
if(ObjectUtils.isNotEmpty(nextChannel)){
ByteBuf buf = channel.config().getAllocator().buffer(nettyProxyMsg.getData().length);
ByteBuf buf = channelHandlerContext.config().getAllocator().buffer(nettyProxyMsg.getData().length);
buf.writeBytes(nettyProxyMsg.getData());
nextChannel.writeAndFlush(buf);
}else {

View File

@ -30,7 +30,7 @@ public class NettyHttpClientProxyClientProxyHandler extends SimpleChannelInbound
@Override
public void channelRead0(ChannelHandlerContext ctx, NettyProxyMsg nettyProxyMsg) throws Exception {
Channel channel = ctx.channel();
channelTypeAdapter.handler(channel, nettyProxyMsg);
channelTypeAdapter.handler(ctx, nettyProxyMsg);
}

View File

@ -30,7 +30,7 @@ public class NettyHttpClientProxyClientTransferRealHandler extends SimpleChannel
@Override
public void channelRead0(ChannelHandlerContext ctx, NettyProxyMsg nettyProxyMsg) throws Exception {
Channel channel = ctx.channel();
channelTypeAdapter.handler(channel, nettyProxyMsg);
channelTypeAdapter.handler(ctx, nettyProxyMsg);
}

View File

@ -29,7 +29,7 @@ public class NettyHttpClientProxyServerProxyHandler extends SimpleChannelInbound
@Override
public void channelRead0(ChannelHandlerContext ctx, NettyProxyMsg nettyProxyMsg) throws Exception {
Channel channel = ctx.channel();
channelTypeAdapter.handler(channel, nettyProxyMsg);
channelTypeAdapter.handler(ctx, nettyProxyMsg);
}

View File

@ -30,7 +30,7 @@ public class NettyHttpServerProxyClientTransferRealHandler extends SimpleChannel
@Override
public void channelRead0(ChannelHandlerContext ctx, NettyProxyMsg nettyProxyMsg) throws Exception {
Channel channel = ctx.channel();
channelTypeAdapter.handler(channel, nettyProxyMsg);
channelTypeAdapter.handler(ctx, nettyProxyMsg);
}