mirror of
https://gitee.com/wujiawei1207537021/wu-lazy-cloud-network.git
synced 2025-06-16 10:25:07 +08:00
【fix】
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.server.netty.permeate.tcp.advanced;
|
||||
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.AbstractTcpHandleChannelHeartbeatTypeAdvanced;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.Role;
|
||||
@ -21,14 +21,14 @@ public class ServerHandleTcpChannelHeartbeatTypeAdvanced 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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,6 +3,7 @@ package org.framework.lazy.cloud.network.heartbeat.server.netty.permeate.tcp.adv
|
||||
|
||||
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.ChannelContext;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.constant.ProxyMessageType;
|
||||
@ -71,13 +72,13 @@ public class ServerHandleTcpClientConnectSuccessTypeAdvanced extends AbstractHan
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param newChannel 当前通道
|
||||
* @param channelHandlerContext 当前通道
|
||||
* @param msg 通道数据
|
||||
*/
|
||||
@Override
|
||||
public void doHandler(Channel newChannel, NettyProxyMsg msg) {
|
||||
|
||||
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg msg) {
|
||||
|
||||
Channel newChannel = channelHandlerContext.channel();
|
||||
String clientId = msg.getClientIdString();
|
||||
String appKey = msg.getAppKeyString();
|
||||
String appSecret = msg.getAppSecretString();
|
||||
@ -136,7 +137,7 @@ public class ServerHandleTcpClientConnectSuccessTypeAdvanced extends AbstractHan
|
||||
}else {
|
||||
// 关闭通道
|
||||
log.warn("无法认证客户端:【{}】",clientId);
|
||||
newChannel.close();
|
||||
channelHandlerContext.close();
|
||||
}
|
||||
|
||||
|
||||
@ -161,7 +162,7 @@ public class ServerHandleTcpClientConnectSuccessTypeAdvanced extends AbstractHan
|
||||
nettyMsg.setClientTargetIp(permeateTargetIp);
|
||||
nettyMsg.setClientTargetPort(permeateTargetPort);
|
||||
nettyMsg.setVisitorPort(visitorPort);
|
||||
newChannel.writeAndFlush(nettyMsg);
|
||||
channelHandlerContext.writeAndFlush(nettyMsg);
|
||||
}
|
||||
});
|
||||
|
||||
@ -185,7 +186,7 @@ public class ServerHandleTcpClientConnectSuccessTypeAdvanced extends AbstractHan
|
||||
nettyMsg.setVisitorPort(visitorPort);
|
||||
nettyMsg.setClientId(clientId);
|
||||
nettyMsg.setData(toClientId.getBytes(StandardCharsets.UTF_8));
|
||||
newChannel.writeAndFlush(nettyMsg);
|
||||
channelHandlerContext.writeAndFlush(nettyMsg);
|
||||
}
|
||||
});
|
||||
// 下发服务端路由
|
||||
@ -205,7 +206,7 @@ public class ServerHandleTcpClientConnectSuccessTypeAdvanced extends AbstractHan
|
||||
nettyMsg.setType(ProxyMessageType.HTTP_DISTRIBUTE_CLIENT_PROXY_SERVER_SERVER_ROUTE_);
|
||||
nettyMsg.setData((JSON.toJSONString(serverProxyRoute)
|
||||
.getBytes(StandardCharsets.UTF_8)));
|
||||
newChannel.writeAndFlush(nettyMsg);
|
||||
channelHandlerContext.writeAndFlush(nettyMsg);
|
||||
}
|
||||
});
|
||||
|
||||
@ -228,7 +229,7 @@ public class ServerHandleTcpClientConnectSuccessTypeAdvanced extends AbstractHan
|
||||
nettyMsg.setType(ProxyMessageType.HTTP_DISTRIBUTE_CLIENT_PROXY_SERVER_CLIENT_ROUTE_);
|
||||
nettyMsg.setData((JSON.toJSONString(clientProxyRoute)
|
||||
.getBytes(StandardCharsets.UTF_8)));
|
||||
newChannel.writeAndFlush(nettyMsg);
|
||||
channelHandlerContext.writeAndFlush(nettyMsg);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.server.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.server.AbstractHandleTcpReportClientPermeateClientCloseTypeAdvanced;
|
||||
@ -21,12 +22,13 @@ public class ServerHandleTcpReportClientPermeateClientCloseTypeAdvanced extends
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param channel 当前通道
|
||||
* @param channelHandlerContext 当前通道
|
||||
* @param nettyProxyMsg 通道数据
|
||||
*/
|
||||
@Override
|
||||
protected void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
|
||||
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
|
||||
// 关闭 next、next transfer 通道
|
||||
Channel channel = channelHandlerContext.channel();
|
||||
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
|
||||
Channel transferNextChannel = ChannelAttributeKeyUtils.getTransferNextChannel(channel);
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.server.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.constant.TcpMessageType;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
||||
@ -22,13 +23,13 @@ public class ServerHandleTcpReportClientPermeateClientTransferCloseTypeAdvanced
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param channel 当前通道
|
||||
* @param channelHandlerContext 当前通道
|
||||
* @param nettyProxyMsg 通道数据
|
||||
*/
|
||||
@Override
|
||||
protected void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
|
||||
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
|
||||
// 关闭 next、next transfer 通道
|
||||
|
||||
Channel channel = channelHandlerContext.channel();
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
|
||||
Channel transferNextChannel = ChannelAttributeKeyUtils.getTransferNextChannel(channel);
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.server.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.server.AbstractHandleTcpReportClientPermeateServerTransferCloseTypeAdvanced;
|
||||
@ -19,11 +20,12 @@ public class ServerHandleTcpReportClientPermeateServerTransferCloseTypeAdvanced
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @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();
|
||||
// 关闭传输通信通道
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
|
||||
nextChannel.close();
|
||||
|
@ -3,6 +3,7 @@ package org.framework.lazy.cloud.network.heartbeat.server.netty.permeate.tcp.adv
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
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.adapter.ChannelFlowAdapter;
|
||||
@ -31,11 +32,12 @@ public class ServerHandleTcpReportClientPermeateServerTransferTypeAdvanced exten
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param channel 当前通道
|
||||
* @param channelHandlerContext 当前通道
|
||||
* @param msg 通道数据
|
||||
*/
|
||||
@Override
|
||||
protected void doHandler(Channel channel, NettyProxyMsg msg) {
|
||||
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg msg) {
|
||||
Channel channel = channelHandlerContext.channel();
|
||||
String clientId = new String(msg.getClientId());
|
||||
Integer visitorPort = Integer.valueOf(new String(msg.getVisitorPort()));
|
||||
byte[] visitorId = msg.getVisitorId();
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.server.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.*;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.server.AbstractHandleTcpReportClientTransferClientPermeateChannelConnectionSuccessfulTypeAdvanced;
|
||||
@ -20,11 +21,12 @@ public class ServerHandleTcpReportClientTransferClientPermeateChannelConnectionS
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param transferChannel 当前通道
|
||||
* @param channelHandlerContext 当前通道
|
||||
* @param nettyProxyMsg 通道数据
|
||||
*/
|
||||
@Override
|
||||
protected void doHandler(Channel transferChannel, NettyProxyMsg nettyProxyMsg) {
|
||||
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
|
||||
Channel transferChannel = channelHandlerContext.channel();
|
||||
// 创建目标地址连接
|
||||
byte[] msgVisitorId = nettyProxyMsg.getVisitorId();
|
||||
byte[] msgVisitorPort = nettyProxyMsg.getVisitorPort();
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.server.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.constant.TcpMessageType;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
||||
@ -21,11 +22,12 @@ public class ServerHandleTcpReportClientTransferClientPermeateChannelInitSuccess
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param transferChannel 当前通道
|
||||
* @param channelHandlerContext 当前通道
|
||||
* @param nettyProxyMsg 通道数据
|
||||
*/
|
||||
@Override
|
||||
protected void doHandler(Channel transferChannel, NettyProxyMsg nettyProxyMsg) {
|
||||
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
|
||||
Channel transferChannel = channelHandlerContext.channel();
|
||||
// 创建目标地址连接
|
||||
byte[] msgVisitorId = nettyProxyMsg.getVisitorId();
|
||||
byte[] msgVisitorPort = nettyProxyMsg.getVisitorPort();
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.server.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.constant.TcpMessageType;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
||||
@ -24,11 +25,12 @@ public class ServerHandleTcpReportClientTransferClientResponseTypeAdvanced exten
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @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[] msgVisitorId = nettyProxyMsg.getVisitorId();
|
||||
byte[] msgVisitorPort = nettyProxyMsg.getVisitorPort();
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.server.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.constant.TcpMessageType;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
||||
@ -24,11 +25,12 @@ public class ServerHandleTcpReportClientTransferClientTypeAdvanced extends Abstr
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @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[] msgVisitorId = nettyProxyMsg.getVisitorId();
|
||||
byte[] msgVisitorPort = nettyProxyMsg.getVisitorPort();
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.server.netty.permeate.tcp.advanced;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.server.AbstractHandleTcpReportClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
|
||||
@ -18,11 +19,12 @@ public class ServerHandleTcpReportClientTransferServerPermeateChannelConnectionS
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param transferChannel 当前通道
|
||||
* @param channelHandlerContext 当前通道
|
||||
* @param nettyProxyMsg 通道数据
|
||||
*/
|
||||
@Override
|
||||
protected void doHandler(Channel transferChannel, NettyProxyMsg nettyProxyMsg) {
|
||||
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
|
||||
Channel transferChannel = channelHandlerContext.channel();
|
||||
// 创建目标地址连接
|
||||
byte[] msgVisitorId = nettyProxyMsg.getVisitorId();
|
||||
byte[] msgVisitorPort = nettyProxyMsg.getVisitorPort();
|
||||
|
@ -1,6 +1,6 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.server.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.server.AbstractHandleTcpReportClusterNodeRegisterTypeAdvanced;
|
||||
@ -26,11 +26,11 @@ public class ServerHandleTcpReportClusterNodeRegisterTypeAdvanced extends
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param channel 当前通道
|
||||
* @param channelHandlerContext 当前通道
|
||||
* @param nettyProxyMsg 通道数据
|
||||
*/
|
||||
@Override
|
||||
protected void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
|
||||
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
|
||||
|
||||
log.info("node register and me start scan node config");
|
||||
// 本地扫描节点配置重新注册
|
||||
|
@ -2,6 +2,7 @@ package org.framework.lazy.cloud.network.heartbeat.server.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.ChannelContext;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.constant.TcpMessageType;
|
||||
@ -38,11 +39,12 @@ public class ServerHandleTcpReportDisconnectTypeAdvanced extends AbstractHandleT
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param deathChannel 关闭的通道
|
||||
* @param channelHandlerContext 关闭的通道
|
||||
* @param msg 通道数据
|
||||
*/
|
||||
@Override
|
||||
public void doHandler(Channel deathChannel, NettyProxyMsg msg) {
|
||||
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg msg) {
|
||||
Channel deathChannel = channelHandlerContext.channel();
|
||||
// 关闭连接通知
|
||||
String clientId = msg.getClientIdString();
|
||||
log.warn("close client :{} channel", clientId);
|
||||
|
@ -1,6 +1,6 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.server.netty.permeate.tcp.advanced;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.Role;
|
||||
@ -22,11 +22,11 @@ public class ServerHandleTcpReportServicePermeateClientCloseVisitorTypeAdvanced
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @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();
|
||||
NettyCommunicationIdContext.clear(visitorId);
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.server.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.springframework.beans.factory.config.BeanDefinition;
|
||||
@ -23,11 +24,12 @@ public class ServerHandleTcpReportServicePermeateClientRealConnectTypeAdvanced e
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param transferChannel 当前通道
|
||||
* @param channelHandlerContext 当前通道
|
||||
* @param nettyProxyMsg 通道数据
|
||||
*/
|
||||
@Override
|
||||
protected void doHandler(Channel transferChannel, NettyProxyMsg nettyProxyMsg) {
|
||||
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
|
||||
Channel transferChannel = channelHandlerContext.channel();
|
||||
// 客户端绑定端口成功
|
||||
byte[] clientId = nettyProxyMsg.getClientId();
|
||||
byte[] clientTargetIp = nettyProxyMsg.getClientTargetIp();
|
||||
|
@ -4,6 +4,7 @@ package org.framework.lazy.cloud.network.heartbeat.server.netty.permeate.tcp.adv
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
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.NettyRealIdContext;
|
||||
@ -35,11 +36,12 @@ public class ServerHandleTcpReportServicePermeateClientTransferTypeAdvanced exte
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param channel 当前通道
|
||||
* @param channelHandlerContext 当前通道
|
||||
* @param msg 通道数据
|
||||
*/
|
||||
@Override
|
||||
public void doHandler(Channel channel, NettyProxyMsg msg) {
|
||||
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg msg) {
|
||||
Channel channel = channelHandlerContext.channel();
|
||||
String clientId = new String(msg.getClientId());
|
||||
Integer visitorPort = Integer.valueOf(new String(msg.getVisitorPort()));
|
||||
byte[] visitorId = msg.getVisitorId();
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.server.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.utils.ChannelAttributeKeyUtils;
|
||||
import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.LazyClientStatsChangeApplication;
|
||||
@ -32,12 +33,12 @@ public class ServerHandleTcpReportStagingClosedTypeAdvanced extends AbstractHand
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param stagingClosedChannel 关闭暂存的通道
|
||||
* @param channelHandlerContext 关闭暂存的通道
|
||||
* @param msg 通道数据
|
||||
*/
|
||||
@Override
|
||||
protected void doHandler(Channel stagingClosedChannel, NettyProxyMsg msg) {
|
||||
|
||||
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg msg) {
|
||||
Channel stagingClosedChannel = channelHandlerContext.channel();
|
||||
String appKey = ChannelAttributeKeyUtils.getAppKey(stagingClosedChannel);
|
||||
String appSecret = ChannelAttributeKeyUtils.getAppSecret(stagingClosedChannel);
|
||||
String originalIp = ChannelAttributeKeyUtils.getOriginalIp(stagingClosedChannel);
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.server.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.ChannelContext;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.constant.TcpMessageType;
|
||||
@ -34,11 +35,12 @@ public class ServerHandleTcpReportStagingOpenedTypeAdvanced extends AbstractHand
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param stagingOpenedChannel 开启暂存的通道
|
||||
* @param channelHandlerContext 开启暂存的通道
|
||||
* @param msg 通道数据
|
||||
*/
|
||||
@Override
|
||||
protected void doHandler(Channel stagingOpenedChannel, NettyProxyMsg msg) {
|
||||
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg msg) {
|
||||
Channel stagingOpenedChannel = channelHandlerContext.channel();
|
||||
// 获取所有通道
|
||||
byte[] clientIdBytes = msg.getClientId();
|
||||
String appKey = ChannelAttributeKeyUtils.getAppKey(stagingOpenedChannel);
|
||||
|
@ -50,7 +50,7 @@ public class NettyTcpServerHandler extends SimpleChannelInboundHandler<NettyProx
|
||||
byte type = nettyMsg.getType();
|
||||
// byte[] data = nettyMsg.getData();
|
||||
// log.info("客户端发送数据类型:{},发送数据:{}", type, new String(data));
|
||||
channelTypeAdapter.handler(channel, nettyMsg);
|
||||
channelTypeAdapter.handler(ctx, nettyMsg);
|
||||
|
||||
}
|
||||
|
||||
@ -74,7 +74,7 @@ public class NettyTcpServerHandler extends SimpleChannelInboundHandler<NettyProx
|
||||
NettyProxyMsg nettyMsg = new NettyProxyMsg();
|
||||
nettyMsg.setClientId(clientId);
|
||||
nettyMsg.setType(TcpMessageType.TCP_REPORT_CLIENT_DISCONNECTION);
|
||||
channelTypeAdapter.handler(channel, nettyMsg);
|
||||
channelTypeAdapter.handler(ctx, nettyMsg);
|
||||
channel.close();
|
||||
} else {
|
||||
// 访客通道数据 5*100秒后关闭
|
||||
@ -134,7 +134,7 @@ public class NettyTcpServerHandler extends SimpleChannelInboundHandler<NettyProx
|
||||
NettyProxyMsg nettyMsg = new NettyProxyMsg();
|
||||
nettyMsg.setType(TcpMessageType.TCP_REPORT_CLIENT_DISCONNECTION);
|
||||
nettyMsg.setClientId(clientId);
|
||||
channelTypeAdapter.handler(channel, nettyMsg);
|
||||
channelTypeAdapter.handler(ctx, nettyMsg);
|
||||
super.channelInactive(ctx);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.server.netty.permeate.udp.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.udp.AbstractUdpHandleChannelHeartbeatTypeAdvanced;
|
||||
@ -21,14 +21,14 @@ public class ServerHandleUdpChannelHeartbeatTypeAdvanced 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(TcpMessageType.TCP_TYPE_HEARTBEAT);
|
||||
channel.writeAndFlush(hb);
|
||||
channelHandlerContext.writeAndFlush(hb);
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,6 +3,7 @@ package org.framework.lazy.cloud.network.heartbeat.server.netty.permeate.udp.adv
|
||||
|
||||
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.ChannelContext;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.constant.TcpMessageType;
|
||||
@ -59,26 +60,26 @@ public class ServerHandleUdpClientConnectSuccessTypeAdvanced extends AbstractHan
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param newChannel 当前通道
|
||||
* @param channelHandlerContext 当前通道
|
||||
* @param msg 通道数据
|
||||
*/
|
||||
@Override
|
||||
public void doHandler(Channel newChannel, NettyProxyMsg msg) {
|
||||
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg msg) {
|
||||
|
||||
|
||||
String clientId = msg.getClientIdString();
|
||||
String appKey = msg.getAppKeyString();
|
||||
String appSecret = msg.getAppSecretString();
|
||||
String originalIp = msg.getOriginalIpString();
|
||||
ChannelContext.push(newChannel, clientId);
|
||||
ChannelContext.push(channelHandlerContext, clientId);
|
||||
|
||||
ChannelAttributeKeyUtils.buildClientId(newChannel, clientId);
|
||||
ChannelAttributeKeyUtils.buildAppKey(newChannel, appKey);
|
||||
ChannelAttributeKeyUtils.buildAppSecret(newChannel, appSecret);
|
||||
ChannelAttributeKeyUtils.buildOriginalIp(newChannel, originalIp);
|
||||
ChannelAttributeKeyUtils.buildClientId(channelHandlerContext, clientId);
|
||||
ChannelAttributeKeyUtils.buildAppKey(channelHandlerContext, appKey);
|
||||
ChannelAttributeKeyUtils.buildAppSecret(channelHandlerContext, appSecret);
|
||||
ChannelAttributeKeyUtils.buildOriginalIp(channelHandlerContext, originalIp);
|
||||
|
||||
// 客户端:{},IP:{}连接成功
|
||||
log.info("Client: {}, IP: {} Connection successful", new String(msg.getClientId()), newChannel.remoteAddress().toString());
|
||||
log.info("Client: {}, IP: {} Connection successful", new String(msg.getClientId()), channelHandlerContext.remoteAddress().toString());
|
||||
// 验证客户端是否时黑名单
|
||||
LazyNettyClientBlacklist lazyNettyClientBlacklist = new LazyNettyClientBlacklist();
|
||||
lazyNettyClientBlacklist.setClientId(clientId);
|
||||
@ -124,7 +125,7 @@ public class ServerHandleUdpClientConnectSuccessTypeAdvanced extends AbstractHan
|
||||
}else {
|
||||
// 关闭通道
|
||||
log.warn("无法认证客户端:【{}】",clientId);
|
||||
newChannel.close();
|
||||
channelHandlerContext.close();
|
||||
}
|
||||
|
||||
|
||||
@ -149,7 +150,7 @@ public class ServerHandleUdpClientConnectSuccessTypeAdvanced extends AbstractHan
|
||||
nettyMsg.setClientTargetIp(permeateTargetIp);
|
||||
nettyMsg.setClientTargetPort(permeateTargetPort);
|
||||
nettyMsg.setVisitorPort(visitorPort);
|
||||
newChannel.writeAndFlush(nettyMsg);
|
||||
channelHandlerContext.writeAndFlush(nettyMsg);
|
||||
}
|
||||
});
|
||||
|
||||
@ -173,7 +174,7 @@ public class ServerHandleUdpClientConnectSuccessTypeAdvanced extends AbstractHan
|
||||
nettyMsg.setVisitorPort(visitorPort);
|
||||
nettyMsg.setClientId(clientId);
|
||||
nettyMsg.setData(toClientId.getBytes(StandardCharsets.UTF_8));
|
||||
newChannel.writeAndFlush(nettyMsg);
|
||||
channelHandlerContext.writeAndFlush(nettyMsg);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.server.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.server.AbstractHandleUdpReportClientPermeateClientCloseTypeAdvanced;
|
||||
@ -21,16 +22,16 @@ public class ServerHandleUdpReportClientPermeateClientCloseTypeAdvanced extends
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param channel 当前通道
|
||||
* @param channelHandlerContext 当前通道
|
||||
* @param nettyProxyMsg 通道数据
|
||||
*/
|
||||
@Override
|
||||
protected void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
|
||||
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
|
||||
// 关闭 next、next transfer 通道
|
||||
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
|
||||
Channel transferNextChannel = ChannelAttributeKeyUtils.getTransferNextChannel(channel);
|
||||
channel.close();
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channelHandlerContext);
|
||||
Channel transferNextChannel = ChannelAttributeKeyUtils.getTransferNextChannel(channelHandlerContext);
|
||||
channelHandlerContext.close();
|
||||
nextChannel.close();
|
||||
transferNextChannel.close();
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.server.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.constant.TcpMessageType;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
||||
@ -22,22 +23,22 @@ public class ServerHandleUdpReportClientPermeateClientTransferCloseTypeAdvanced
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param channel 当前通道
|
||||
* @param channelHandlerContext 当前通道
|
||||
* @param nettyProxyMsg 通道数据
|
||||
*/
|
||||
@Override
|
||||
protected void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
|
||||
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
|
||||
// 关闭 next、next transfer 通道
|
||||
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
|
||||
Channel transferNextChannel = ChannelAttributeKeyUtils.getTransferNextChannel(channel);
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channelHandlerContext);
|
||||
Channel transferNextChannel = ChannelAttributeKeyUtils.getTransferNextChannel(channelHandlerContext);
|
||||
|
||||
// 下发关闭客户端真实通道
|
||||
NettyProxyMsg closeTransferNettyProxyMsg = new NettyProxyMsg();
|
||||
closeTransferNettyProxyMsg.setType(TcpMessageType.TCP_DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE);
|
||||
transferNextChannel.writeAndFlush(closeTransferNettyProxyMsg);
|
||||
|
||||
channel.close();
|
||||
channelHandlerContext.close();
|
||||
nextChannel.close();
|
||||
transferNextChannel.close();
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.server.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.server.AbstractHandleUdpReportClientPermeateServerTransferCloseTypeAdvanced;
|
||||
@ -19,14 +20,14 @@ public class ServerHandleUdpReportClientPermeateServerTransferCloseTypeAdvanced
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @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);
|
||||
nextChannel.close();
|
||||
channel.close();
|
||||
channelHandlerContext.close();
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package org.framework.lazy.cloud.network.heartbeat.server.netty.permeate.udp.adv
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
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.adapter.ChannelFlowAdapter;
|
||||
@ -31,11 +32,11 @@ public class ServerHandleUdpReportClientPermeateServerTransferTypeAdvanced exten
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @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());
|
||||
Integer visitorPort = Integer.valueOf(new String(msg.getVisitorPort()));
|
||||
byte[] visitorId = msg.getVisitorId();
|
||||
@ -43,7 +44,7 @@ public class ServerHandleUdpReportClientPermeateServerTransferTypeAdvanced exten
|
||||
log.debug("【客户端渗透服务端】访客ID:【{}】接收到客户端:[{}] 接收服务端数据大小:[{}] 接收服务端数据:[{}]", new String(visitorId), clientId, msg.getData().length, new String(msg.getData()));
|
||||
// 将数据转发访客通道
|
||||
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channelHandlerContext);
|
||||
if (nextChannel != null) {
|
||||
ByteBuf buf = nextChannel.config().getAllocator().buffer(msg.getData().length);
|
||||
buf.writeBytes(msg.getData());
|
||||
@ -58,7 +59,7 @@ public class ServerHandleUdpReportClientPermeateServerTransferTypeAdvanced exten
|
||||
.clientId(clientId)
|
||||
.flow(msg.getData().length)
|
||||
.build();
|
||||
channelFlowAdapter.asyncHandler(channel, serverChannelFlow);
|
||||
channelFlowAdapter.asyncHandler(channelHandlerContext, serverChannelFlow);
|
||||
}
|
||||
log.debug("客户端渗透服务端】访客ID:【{}】接收到客户端:[{}] 传输真实数据成功", new String(visitorId), clientId);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.server.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.ChannelContext;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.constant.TcpMessageType;
|
||||
@ -22,11 +23,11 @@ public class ServerHandleUdpReportClientTransferClientPermeateChannelConnectionS
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param transferChannel 当前通道
|
||||
* @param channelHandlerContext 当前通道
|
||||
* @param nettyProxyMsg 通道数据
|
||||
*/
|
||||
@Override
|
||||
protected void doHandler(Channel transferChannel, NettyProxyMsg nettyProxyMsg) {
|
||||
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
|
||||
// 创建目标地址连接
|
||||
byte[] msgVisitorId = nettyProxyMsg.getVisitorId();
|
||||
byte[] msgVisitorPort = nettyProxyMsg.getVisitorPort();
|
||||
@ -34,11 +35,11 @@ public class ServerHandleUdpReportClientTransferClientPermeateChannelConnectionS
|
||||
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);
|
||||
ChannelAttributeKeyUtils.buildClientId(channelHandlerContext, clientId);
|
||||
ChannelAttributeKeyUtils.buildVisitorPort(channelHandlerContext, Integer.parseInt(new String(msgVisitorPort)));
|
||||
ChannelAttributeKeyUtils.buildVisitorId(channelHandlerContext, msgVisitorId);
|
||||
// 绑定访客通道
|
||||
NettyTransferChannelContext.pushVisitor(transferChannel,msgVisitorId);
|
||||
NettyTransferChannelContext.pushVisitor(channelHandlerContext,msgVisitorId);
|
||||
Channel clientChannel = ChannelContext.getLoadBalance(clientId);
|
||||
|
||||
NettyProxyMsg clientConnectTagetNettyProxyMsg = new NettyProxyMsg();
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.server.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.constant.TcpMessageType;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
||||
@ -21,11 +22,11 @@ public class ServerHandleUdpReportClientTransferClientPermeateChannelInitSuccess
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param transferChannel 当前通道
|
||||
* @param channelHandlerContext 当前通道
|
||||
* @param nettyProxyMsg 通道数据
|
||||
*/
|
||||
@Override
|
||||
protected void doHandler(Channel transferChannel, NettyProxyMsg nettyProxyMsg) {
|
||||
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
|
||||
// 创建目标地址连接
|
||||
byte[] msgVisitorId = nettyProxyMsg.getVisitorId();
|
||||
byte[] msgVisitorPort = nettyProxyMsg.getVisitorPort();
|
||||
@ -33,15 +34,15 @@ public class ServerHandleUdpReportClientTransferClientPermeateChannelInitSuccess
|
||||
byte[] msgClientTargetPort = nettyProxyMsg.getClientTargetPort();
|
||||
byte[] clientId = nettyProxyMsg.getClientId();
|
||||
|
||||
ChannelAttributeKeyUtils.buildVisitorPort(transferChannel, Integer.parseInt(new String(msgVisitorPort)));
|
||||
ChannelAttributeKeyUtils.buildVisitorPort(channelHandlerContext, 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);
|
||||
ChannelAttributeKeyUtils.buildTransferNextChannel(nextTransferChannel, channelHandlerContext);
|
||||
ChannelAttributeKeyUtils.buildTransferNextChannel(channelHandlerContext,nextTransferChannel);
|
||||
ChannelAttributeKeyUtils.buildClientId(channelHandlerContext,clientId);
|
||||
ChannelAttributeKeyUtils.buildVisitorId(channelHandlerContext,msgVisitorId);
|
||||
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getTransferNextChannel(transferChannel);
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getTransferNextChannel(channelHandlerContext);
|
||||
|
||||
NettyProxyMsg clientConnectTagetNettyProxyMsg = new NettyProxyMsg();
|
||||
clientConnectTagetNettyProxyMsg.setVisitorId(msgVisitorId);
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.server.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.constant.TcpMessageType;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
||||
@ -24,11 +25,11 @@ public class ServerHandleUdpReportClientTransferClientResponseTypeAdvanced exten
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param channel 当前通道
|
||||
* @param channelHandlerContext 当前通道
|
||||
* @param nettyProxyMsg 通道数据
|
||||
*/
|
||||
@Override
|
||||
protected void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
|
||||
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
|
||||
// 创建目标地址连接
|
||||
byte[] msgVisitorId = nettyProxyMsg.getVisitorId();
|
||||
byte[] msgVisitorPort = nettyProxyMsg.getVisitorPort();
|
||||
@ -36,7 +37,7 @@ public class ServerHandleUdpReportClientTransferClientResponseTypeAdvanced exten
|
||||
byte[] msgClientTargetPort = nettyProxyMsg.getClientTargetPort();
|
||||
String clientId = nettyProxyMsg.getClientIdString();
|
||||
// 下发客户端初始化成功
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getTransferNextChannel(channel);
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getTransferNextChannel(channelHandlerContext);
|
||||
|
||||
|
||||
NettyProxyMsg clientConnectTagetNettyProxyMsg = new NettyProxyMsg();
|
||||
@ -60,9 +61,9 @@ public class ServerHandleUdpReportClientTransferClientResponseTypeAdvanced exten
|
||||
.flow(clientConnectTagetNettyProxyMsg.getData().length)
|
||||
.build();
|
||||
|
||||
channelFlowAdapter.asyncHandler(channel, serverChannelFlow);
|
||||
channelFlowAdapter.asyncHandler(channelHandlerContext, serverChannelFlow);
|
||||
}else {
|
||||
log.error("can not find the client:【{}】 channel",clientId);
|
||||
log.error("can not find the client:【{}】 channelHandlerContext",clientId);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.server.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.constant.TcpMessageType;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
||||
@ -24,11 +25,11 @@ public class ServerHandleUdpReportClientTransferClientTypeAdvanced extends Abstr
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param channel 当前通道
|
||||
* @param channelHandlerContext 当前通道
|
||||
* @param nettyProxyMsg 通道数据
|
||||
*/
|
||||
@Override
|
||||
protected void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
|
||||
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
|
||||
// 创建目标地址连接
|
||||
byte[] msgVisitorId = nettyProxyMsg.getVisitorId();
|
||||
byte[] msgVisitorPort = nettyProxyMsg.getVisitorPort();
|
||||
@ -36,8 +37,8 @@ public class ServerHandleUdpReportClientTransferClientTypeAdvanced extends Abstr
|
||||
byte[] msgClientTargetPort = nettyProxyMsg.getClientTargetPort();
|
||||
String clientId = nettyProxyMsg.getClientIdString();
|
||||
// 下发客户端初始化成功
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getTransferNextChannel(channel);
|
||||
Integer visitorPort = ChannelAttributeKeyUtils.getVisitorPort(channel);
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getTransferNextChannel(channelHandlerContext);
|
||||
Integer visitorPort = ChannelAttributeKeyUtils.getVisitorPort(channelHandlerContext);
|
||||
|
||||
|
||||
NettyProxyMsg clientConnectTagetNettyProxyMsg = new NettyProxyMsg();
|
||||
@ -59,9 +60,9 @@ public class ServerHandleUdpReportClientTransferClientTypeAdvanced extends Abstr
|
||||
.clientId(clientId)
|
||||
.flow(clientConnectTagetNettyProxyMsg.getData().length)
|
||||
.build();
|
||||
channelFlowAdapter.asyncHandler(channel, serverChannelFlow);
|
||||
channelFlowAdapter.asyncHandler(channelHandlerContext, serverChannelFlow);
|
||||
}else {
|
||||
log.error("can not find the client:【{}】 channel",clientId);
|
||||
log.error("can not find the client:【{}】 channelHandlerContext",clientId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.server.netty.permeate.udp.advanced;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.udp.server.AbstractHandleUdpReportClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
|
||||
@ -18,11 +18,11 @@ public class ServerHandleUdpReportClientTransferServerPermeateChannelConnectionS
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param transferChannel 当前通道
|
||||
* @param channelHandlerContext 当前通道
|
||||
* @param nettyProxyMsg 通道数据
|
||||
*/
|
||||
@Override
|
||||
protected void doHandler(Channel transferChannel, NettyProxyMsg nettyProxyMsg) {
|
||||
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
|
||||
// 创建目标地址连接
|
||||
byte[] msgVisitorId = nettyProxyMsg.getVisitorId();
|
||||
byte[] msgVisitorPort = nettyProxyMsg.getVisitorPort();
|
||||
@ -31,13 +31,13 @@ public class ServerHandleUdpReportClientTransferServerPermeateChannelConnectionS
|
||||
byte[] msgClientId = nettyProxyMsg.getClientId();
|
||||
String clientId = new String(msgClientId);
|
||||
// 绑定客户端ID
|
||||
ChannelAttributeKeyUtils.buildClientId(transferChannel,clientId);
|
||||
ChannelAttributeKeyUtils.buildVisitorId(transferChannel,msgVisitorId);
|
||||
ChannelAttributeKeyUtils.buildClientId(channelHandlerContext,clientId);
|
||||
ChannelAttributeKeyUtils.buildVisitorId(channelHandlerContext,msgVisitorId);
|
||||
NettyUdpClientPermeateServerConnectRealSocket.buildNewRealServer(new String(msgVisitorId),
|
||||
Integer.parseInt(new String(msgVisitorPort)),
|
||||
new String(msgClientTargetIp),
|
||||
Integer.parseInt(new String(msgClientTargetPort)),
|
||||
transferChannel
|
||||
channelHandlerContext
|
||||
);
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.server.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.server.AbstractHandleUdpReportClusterNodeRegisterTypeAdvanced;
|
||||
@ -26,11 +26,11 @@ public class ServerHandleUdpReportClusterNodeRegisterTypeAdvanced extends
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param channel 当前通道
|
||||
* @param channelHandlerContext 当前通道
|
||||
* @param nettyProxyMsg 通道数据
|
||||
*/
|
||||
@Override
|
||||
protected void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
|
||||
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
|
||||
|
||||
log.info("node register and me start scan node config");
|
||||
// 本地扫描节点配置重新注册
|
||||
|
@ -2,6 +2,7 @@ package org.framework.lazy.cloud.network.heartbeat.server.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.ChannelContext;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.constant.TcpMessageType;
|
||||
@ -38,18 +39,18 @@ public class ServerHandleUdpReportDisconnectTypeAdvanced extends AbstractHandleU
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param deathChannel 关闭的通道
|
||||
* @param channelHandlerContext 关闭的通道
|
||||
* @param msg 通道数据
|
||||
*/
|
||||
@Override
|
||||
public void doHandler(Channel deathChannel, NettyProxyMsg msg) {
|
||||
public void doHandler(ChannelHandlerContext channelHandlerContext, 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);
|
||||
String appKey = ChannelAttributeKeyUtils.getAppKey(channelHandlerContext);
|
||||
String appSecret = ChannelAttributeKeyUtils.getAppSecret(channelHandlerContext);
|
||||
String originalIp = ChannelAttributeKeyUtils.getOriginalIp(channelHandlerContext);
|
||||
if (deathClientChannelDTO != null) {
|
||||
// 服务状态离线
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.server.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;
|
||||
@ -22,11 +22,11 @@ public class ServerHandleUdpReportServicePermeateClientCloseVisitorTypeAdvanced
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @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();
|
||||
NettyCommunicationIdContext.clear(visitorId);
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.server.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.NettyCommunicationIdContext;
|
||||
@ -23,11 +24,11 @@ public class ServerHandleUdpReportServicePermeateClientRealConnectTypeAdvanced e
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param transferChannel 当前通道
|
||||
* @param channelHandlerContext 当前通道
|
||||
* @param nettyProxyMsg 通道数据
|
||||
*/
|
||||
@Override
|
||||
protected void doHandler(Channel transferChannel, NettyProxyMsg nettyProxyMsg) {
|
||||
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
|
||||
// 客户端绑定端口成功
|
||||
byte[] clientId = nettyProxyMsg.getClientId();
|
||||
byte[] clientTargetIp = nettyProxyMsg.getClientTargetIp();
|
||||
@ -36,16 +37,16 @@ public class ServerHandleUdpReportServicePermeateClientRealConnectTypeAdvanced e
|
||||
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)));
|
||||
NettyCommunicationIdContext.pushVisitor(channelHandlerContext, new String(visitorId));
|
||||
ChannelAttributeKeyUtils.buildVisitorId(channelHandlerContext, visitorId);
|
||||
ChannelAttributeKeyUtils.buildClientId(channelHandlerContext, clientId);
|
||||
ChannelAttributeKeyUtils.buildVisitorPort(channelHandlerContext, 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);
|
||||
ChannelAttributeKeyUtils.buildNextChannel(channelHandlerContext, visitorRealChannel);
|
||||
ChannelAttributeKeyUtils.buildNextChannel(visitorRealChannel, channelHandlerContext);
|
||||
|
||||
// 或许此处还应该通知服务端 这个访客绑定的客户端真实通道打开
|
||||
|
||||
|
@ -4,6 +4,7 @@ package org.framework.lazy.cloud.network.heartbeat.server.netty.permeate.udp.adv
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
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.NettyRealIdContext;
|
||||
@ -35,11 +36,11 @@ public class ServerHandleUdpReportServicePermeateClientTransferTypeAdvanced exte
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param channel 当前通道
|
||||
* @param channelHandlerContext 当前通道
|
||||
* @param msg 通道数据
|
||||
*/
|
||||
@Override
|
||||
public void doHandler(Channel channel, NettyProxyMsg msg) {
|
||||
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg msg) {
|
||||
String clientId = new String(msg.getClientId());
|
||||
Integer visitorPort = Integer.valueOf(new String(msg.getVisitorPort()));
|
||||
byte[] visitorId = msg.getVisitorId();
|
||||
@ -47,7 +48,7 @@ public class ServerHandleUdpReportServicePermeateClientTransferTypeAdvanced exte
|
||||
// log.debug("访客ID:【{}】接收到客户端:[{}] 返回数据大小:[{}] 内网穿透返回的数据:[{}]", new String(visitorId), clientId, msg.getData().length, new String(msg.getData()));
|
||||
// 将数据转发访客通道
|
||||
Channel visitor = NettyRealIdContext.getReal(visitorId);
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channelHandlerContext);
|
||||
if (nextChannel != null) {
|
||||
ByteBuf buf = nextChannel.config().getAllocator().buffer(msg.getData().length);
|
||||
buf.writeBytes(msg.getData());
|
||||
@ -62,7 +63,7 @@ public class ServerHandleUdpReportServicePermeateClientTransferTypeAdvanced exte
|
||||
.clientId(clientId)
|
||||
.flow(msg.getData().length)
|
||||
.build();
|
||||
channelFlowAdapter.asyncHandler(channel, serverChannelFlow);
|
||||
channelFlowAdapter.asyncHandler(channelHandlerContext, serverChannelFlow);
|
||||
}
|
||||
log.debug("访客ID:【{}】接收到客户端:[{}] 发送真实数据成功", new String(visitorId), clientId);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.server.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.ChannelContext;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.constant.TcpMessageType;
|
||||
@ -32,15 +33,15 @@ public class ServerHandleUdpReportStagingClosedTypeAdvanced extends AbstractHand
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param stagingClosedChannel 关闭暂存的通道
|
||||
* @param channelHandlerContext 关闭暂存的通道
|
||||
* @param msg 通道数据
|
||||
*/
|
||||
@Override
|
||||
protected void doHandler(Channel stagingClosedChannel, NettyProxyMsg msg) {
|
||||
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg msg) {
|
||||
|
||||
String appKey = ChannelAttributeKeyUtils.getAppKey(stagingClosedChannel);
|
||||
String appSecret = ChannelAttributeKeyUtils.getAppSecret(stagingClosedChannel);
|
||||
String originalIp = ChannelAttributeKeyUtils.getOriginalIp(stagingClosedChannel);
|
||||
String appKey = ChannelAttributeKeyUtils.getAppKey(channelHandlerContext);
|
||||
String appSecret = ChannelAttributeKeyUtils.getAppSecret(channelHandlerContext);
|
||||
String originalIp = ChannelAttributeKeyUtils.getOriginalIp(channelHandlerContext);
|
||||
|
||||
byte[] clientIdBytes = msg.getClientId();
|
||||
// 获取所有通道
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.server.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.ChannelContext;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.constant.TcpMessageType;
|
||||
@ -34,16 +35,16 @@ public class ServerHandleUdpReportStagingOpenedTypeAdvanced extends AbstractHand
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param stagingOpenedChannel 开启暂存的通道
|
||||
* @param channelHandlerContext 开启暂存的通道
|
||||
* @param msg 通道数据
|
||||
*/
|
||||
@Override
|
||||
protected void doHandler(Channel stagingOpenedChannel, NettyProxyMsg msg) {
|
||||
protected void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg msg) {
|
||||
// 获取所有通道
|
||||
byte[] clientIdBytes = msg.getClientId();
|
||||
String appKey = ChannelAttributeKeyUtils.getAppKey(stagingOpenedChannel);
|
||||
String appSecret = ChannelAttributeKeyUtils.getAppSecret(stagingOpenedChannel);
|
||||
String originalIp = ChannelAttributeKeyUtils.getOriginalIp(stagingOpenedChannel);
|
||||
String appKey = ChannelAttributeKeyUtils.getAppKey(channelHandlerContext);
|
||||
String appSecret = ChannelAttributeKeyUtils.getAppSecret(channelHandlerContext);
|
||||
String originalIp = ChannelAttributeKeyUtils.getOriginalIp(channelHandlerContext);
|
||||
|
||||
List<Channel> stagingOpenedClientChannel = ChannelContext.get(clientIdBytes);
|
||||
|
||||
|
@ -50,7 +50,7 @@ public class NettyUdpServerHandler extends SimpleChannelInboundHandler<NettyProx
|
||||
byte type = nettyMsg.getType();
|
||||
// byte[] data = nettyMsg.getData();
|
||||
// log.info("客户端发送数据类型:{},发送数据:{}", type, new String(data));
|
||||
channelTypeAdapter.handler(channel, nettyMsg);
|
||||
channelTypeAdapter.handler(ctx, nettyMsg);
|
||||
|
||||
}
|
||||
|
||||
@ -74,7 +74,7 @@ public class NettyUdpServerHandler extends SimpleChannelInboundHandler<NettyProx
|
||||
NettyProxyMsg nettyMsg = new NettyProxyMsg();
|
||||
nettyMsg.setClientId(clientId);
|
||||
nettyMsg.setType(TcpMessageType.TCP_REPORT_CLIENT_DISCONNECTION);
|
||||
channelTypeAdapter.handler(channel, nettyMsg);
|
||||
channelTypeAdapter.handler(ctx, nettyMsg);
|
||||
channel.close();
|
||||
} else {
|
||||
// 访客通道数据 5*100秒后关闭
|
||||
@ -134,7 +134,7 @@ public class NettyUdpServerHandler extends SimpleChannelInboundHandler<NettyProx
|
||||
NettyProxyMsg nettyMsg = new NettyProxyMsg();
|
||||
nettyMsg.setType(TcpMessageType.TCP_REPORT_CLIENT_DISCONNECTION);
|
||||
nettyMsg.setClientId(clientId);
|
||||
channelTypeAdapter.handler(channel, nettyMsg);
|
||||
channelTypeAdapter.handler(ctx, nettyMsg);
|
||||
super.channelInactive(ctx);
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package org.framework.lazy.cloud.network.heartbeat.server.netty.proxy.http.advan
|
||||
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.ChannelContext;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyByteBuf;
|
||||
@ -9,7 +10,6 @@ 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.proxy.http.server.AbstractHandleHttpReportClientProxyClientConnectionTransferTypeAdvanced;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.constant.ProxyMessageType;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.constant.TcpMessageType;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.Role;
|
||||
@ -30,11 +30,11 @@ public class ServerHandleHttpReportClientProxyClientConnectTransferTypeAdvanced
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param transferChannel 当前通道
|
||||
* @param channelHandlerContext 当前通道
|
||||
* @param nettyProxyMsg 通道数据
|
||||
*/
|
||||
@Override
|
||||
public void doHandler(Channel transferChannel, NettyProxyMsg nettyProxyMsg) {
|
||||
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
|
||||
// 创建链接、发送数据
|
||||
String targetPortString = nettyProxyMsg.getTargetPortString();
|
||||
String targetIpString = nettyProxyMsg.getTargetIpString();
|
||||
@ -42,13 +42,13 @@ public class ServerHandleHttpReportClientProxyClientConnectTransferTypeAdvanced
|
||||
byte[] visitorId = nettyProxyMsg.getVisitorId();
|
||||
byte[] clientId = nettyProxyMsg.getClientId();
|
||||
String msgVisitorId = new String(visitorId);
|
||||
ChannelAttributeKeyUtils.buildClientId(transferChannel, clientId);
|
||||
ChannelAttributeKeyUtils.buildVisitorId(transferChannel, msgVisitorId);
|
||||
ChannelAttributeKeyUtils.buildClientId(channelHandlerContext, clientId);
|
||||
ChannelAttributeKeyUtils.buildVisitorId(channelHandlerContext, msgVisitorId);
|
||||
|
||||
NettyTransferChannelContext.pushVisitor(transferChannel, msgVisitorId);
|
||||
NettyTransferChannelContext.pushVisitor(channelHandlerContext, msgVisitorId);
|
||||
NettyByteBuf nettyByteBuf = new NettyByteBuf();
|
||||
nettyByteBuf.setData(data);
|
||||
ChannelAttributeKeyUtils.buildNettyByteBufData(transferChannel, nettyByteBuf);
|
||||
ChannelAttributeKeyUtils.buildNettyByteBufData(channelHandlerContext, nettyByteBuf);
|
||||
// 获取客户端心跳通道
|
||||
Channel loadBalance = ChannelContext.getLoadBalance(clientId);
|
||||
|
||||
|
@ -2,13 +2,13 @@ package org.framework.lazy.cloud.network.heartbeat.server.netty.proxy.http.advan
|
||||
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyByteBuf;
|
||||
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.proxy.http.server.AbstractHandleHttpReportClientProxyClientTransferChannelInitSuccessfulTypeAdvanced;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.constant.ProxyMessageType;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.constant.TcpMessageType;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.Role;
|
||||
@ -29,11 +29,11 @@ public class ServerHandleHttpReportClientProxyClientTransferChannelInitSuccessfu
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @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();
|
||||
|
||||
@ -44,10 +44,10 @@ public class ServerHandleHttpReportClientProxyClientTransferChannelInitSuccessfu
|
||||
|
||||
// next translation
|
||||
Channel nextTransferChannel = NettyTransferChannelContext.getVisitor(msgVisitorId);
|
||||
ChannelAttributeKeyUtils.buildTransferNextChannel(nextTransferChannel, transferChannel);
|
||||
ChannelAttributeKeyUtils.buildTransferNextChannel(transferChannel, nextTransferChannel);
|
||||
ChannelAttributeKeyUtils.buildClientId(transferChannel, clientId);
|
||||
ChannelAttributeKeyUtils.buildVisitorId(transferChannel, msgVisitorId);
|
||||
ChannelAttributeKeyUtils.buildTransferNextChannel(nextTransferChannel, channelHandlerContext);
|
||||
ChannelAttributeKeyUtils.buildTransferNextChannel(channelHandlerContext, nextTransferChannel);
|
||||
ChannelAttributeKeyUtils.buildClientId(channelHandlerContext, clientId);
|
||||
ChannelAttributeKeyUtils.buildVisitorId(channelHandlerContext, msgVisitorId);
|
||||
NettyByteBuf nettyByteBufData = ChannelAttributeKeyUtils.getNettyByteBufData(nextTransferChannel);
|
||||
|
||||
|
||||
@ -62,7 +62,7 @@ public class ServerHandleHttpReportClientProxyClientTransferChannelInitSuccessfu
|
||||
|
||||
clientConnectTagetNettyProxyMsg.setType(ProxyMessageType.HTTP_DISTRIBUTE_CLIENT_PROXY_CLIENT_TRANSFER_REQUEST_);
|
||||
|
||||
transferChannel.writeAndFlush(clientConnectTagetNettyProxyMsg);
|
||||
channelHandlerContext.writeAndFlush(clientConnectTagetNettyProxyMsg);
|
||||
|
||||
|
||||
}
|
||||
|
@ -2,13 +2,11 @@ package org.framework.lazy.cloud.network.heartbeat.server.netty.proxy.http.advan
|
||||
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyByteBuf;
|
||||
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.proxy.http.server.AbstractHandleHttpReportClientProxyClientTransferCloseTypeAdvanced;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.constant.ProxyMessageType;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.constant.TcpMessageType;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.Role;
|
||||
@ -29,25 +27,25 @@ public class ServerHandleHttpReportClientProxyClientTransferCloseTypeAdvanced
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param channel 当前通道
|
||||
* @param channelHandlerContext 当前通道
|
||||
* @param nettyProxyMsg 通道数据
|
||||
*/
|
||||
@Override
|
||||
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
|
||||
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
|
||||
|
||||
// 关闭通道
|
||||
|
||||
// 关闭 next、next transfer 通道
|
||||
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
|
||||
Channel transferNextChannel = ChannelAttributeKeyUtils.getTransferNextChannel(channel);
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channelHandlerContext);
|
||||
Channel transferNextChannel = ChannelAttributeKeyUtils.getTransferNextChannel(channelHandlerContext);
|
||||
|
||||
// 下发关闭客户端真实通道
|
||||
NettyProxyMsg closeTransferNettyProxyMsg = new NettyProxyMsg();
|
||||
closeTransferNettyProxyMsg.setType(ProxyMessageType.HTTP_DISTRIBUTE_CLIENT_PROXY_CLIENT_TRANSFER_CLOSE_);
|
||||
transferNextChannel.writeAndFlush(closeTransferNettyProxyMsg);
|
||||
|
||||
channel.close();
|
||||
channelHandlerContext.close();
|
||||
nextChannel.close();
|
||||
transferNextChannel.close();
|
||||
}
|
||||
|
@ -2,11 +2,11 @@ package org.framework.lazy.cloud.network.heartbeat.server.netty.proxy.http.advan
|
||||
|
||||
|
||||
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.server.AbstractHandleHttpReportClientProxyClientTransferResponseTypeAdvanced;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.constant.ProxyMessageType;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.constant.TcpMessageType;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.Role;
|
||||
@ -28,13 +28,13 @@ public class ServerHandleHttpReportClientProxyClientTransferResponseTypeAdvanced
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param transferChannel 当前通道
|
||||
* @param channelHandlerContext 当前通道
|
||||
* @param nettyProxyMsg 通道数据
|
||||
*/
|
||||
@Override
|
||||
public void doHandler(Channel transferChannel, NettyProxyMsg nettyProxyMsg) {
|
||||
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
|
||||
// 将返回数据下发客户端
|
||||
Channel transferNextChannel = ChannelAttributeKeyUtils.getTransferNextChannel(transferChannel);
|
||||
Channel transferNextChannel = ChannelAttributeKeyUtils.getTransferNextChannel(channelHandlerContext);
|
||||
|
||||
if(ObjectUtils.isNotEmpty(transferNextChannel)) {
|
||||
log.info("目标客户端返回数据通过服务端下发到原始通道");
|
||||
|
@ -1,7 +1,7 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.server.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.common.NettyProxyMsg;
|
||||
@ -32,11 +32,11 @@ public class ServerHandleHttpReportClientProxyServerProxyTransferTypeAdvanced
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param channel 当前通道
|
||||
* @param channelHandlerContext 当前通道
|
||||
* @param nettyProxyMsg 通道数据
|
||||
*/
|
||||
@Override
|
||||
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
|
||||
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
|
||||
// 创建链接、发送数据
|
||||
String targetPortString = nettyProxyMsg.getTargetPortString();
|
||||
String targetIpString = nettyProxyMsg.getTargetIpString();
|
||||
@ -56,7 +56,7 @@ public class ServerHandleHttpReportClientProxyServerProxyTransferTypeAdvanced
|
||||
nettyHttpClientProxyServerTransfer.setData(data);
|
||||
|
||||
NettyHttpClientProxyServerRealSocket
|
||||
.buildRealServer(nettyHttpClientProxyServerTransfer,channel,new String(visitorId));
|
||||
.buildRealServer(nettyHttpClientProxyServerTransfer, channelHandlerContext,new String(visitorId));
|
||||
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package org.framework.lazy.cloud.network.heartbeat.server.netty.proxy.http.advan
|
||||
|
||||
|
||||
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.server.AbstractHandleHttpReportClientProxyServerTransferCloseTypeAdvanced;
|
||||
@ -25,15 +26,15 @@ public class ServerHandleHttpReportClientProxyServerTransferCloseTypeAdvanced ex
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @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 nextChannel = ChannelAttributeKeyUtils.getNextChannel(channelHandlerContext);
|
||||
nextChannel.close();
|
||||
channel.close();
|
||||
channelHandlerContext.close();
|
||||
|
||||
}
|
||||
|
||||
|
@ -2,13 +2,13 @@ package org.framework.lazy.cloud.network.heartbeat.server.netty.proxy.http.advan
|
||||
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyByteBuf;
|
||||
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.proxy.http.server.AbstractHandleHttpReportServerProxyClientTransferChannelInitSuccessfulTypeAdvanced;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.constant.ProxyMessageType;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.constant.TcpMessageType;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.Role;
|
||||
@ -25,11 +25,11 @@ public class ServerHandleHttpReportServerProxyClientTransferChannelInitSuccessfu
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @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();
|
||||
@ -41,11 +41,11 @@ public class ServerHandleHttpReportServerProxyClientTransferChannelInitSuccessfu
|
||||
|
||||
// next
|
||||
Channel nextChannel = NettyTransferChannelContext.getVisitor(msgVisitorId);
|
||||
ChannelAttributeKeyUtils.buildNextChannel(nextChannel, transferChannel);
|
||||
ChannelAttributeKeyUtils.buildNextChannel(transferChannel, nextChannel);
|
||||
ChannelAttributeKeyUtils.buildNextChannel(nextChannel, channelHandlerContext);
|
||||
ChannelAttributeKeyUtils.buildNextChannel(channelHandlerContext, nextChannel);
|
||||
|
||||
ChannelAttributeKeyUtils.buildClientId(transferChannel, clientId);
|
||||
ChannelAttributeKeyUtils.buildVisitorId(transferChannel, msgVisitorId);
|
||||
ChannelAttributeKeyUtils.buildClientId(channelHandlerContext, clientId);
|
||||
ChannelAttributeKeyUtils.buildVisitorId(channelHandlerContext, msgVisitorId);
|
||||
NettyByteBuf nettyByteBufData = ChannelAttributeKeyUtils.getNettyByteBufData(nextChannel);
|
||||
|
||||
|
||||
@ -60,7 +60,7 @@ public class ServerHandleHttpReportServerProxyClientTransferChannelInitSuccessfu
|
||||
|
||||
clientConnectTagetNettyProxyMsg.setType(ProxyMessageType.HTTP_DISTRIBUTE_SERVER_PROXY_CLIENT_TRANSFER_REQUEST_);
|
||||
|
||||
transferChannel.writeAndFlush(clientConnectTagetNettyProxyMsg);
|
||||
channelHandlerContext.writeAndFlush(clientConnectTagetNettyProxyMsg);
|
||||
|
||||
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package org.framework.lazy.cloud.network.heartbeat.server.netty.proxy.http.advan
|
||||
|
||||
|
||||
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.server.AbstractHandleHttpReportServerProxyClientTransferCloseTypeAdvanced;
|
||||
@ -21,15 +22,15 @@ public class ServerHandleHttpReportServerProxyClientTransferCloseTypeAdvanced ex
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @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 nextChannel = ChannelAttributeKeyUtils.getNextChannel(channelHandlerContext);
|
||||
nextChannel.close();
|
||||
channel.close();
|
||||
channelHandlerContext.close();
|
||||
|
||||
}
|
||||
|
||||
|
@ -3,11 +3,10 @@ package org.framework.lazy.cloud.network.heartbeat.server.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.server.AbstractHandleHttpReportClientProxyClientTransferResponseTypeAdvanced;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.advanced.proxy.http.server.AbstractHandleHttpReportServerProxyClientTransferResponseTypeAdvanced;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.constant.TcpMessageType;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.Role;
|
||||
@ -26,17 +25,17 @@ public class ServerHandleHttpReportServerProxyClientTransferResponseTypeAdvanced
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param transferChannel 当前通道
|
||||
* @param channelHandlerContext 当前通道
|
||||
* @param nettyProxyMsg 通道数据
|
||||
*/
|
||||
@Override
|
||||
public void doHandler(Channel transferChannel, NettyProxyMsg nettyProxyMsg) {
|
||||
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
|
||||
// 将返回数据
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(transferChannel);
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channelHandlerContext);
|
||||
|
||||
if(ObjectUtils.isNotEmpty(nextChannel)) {
|
||||
log.info("目标客户端返回数据通过服务端下发到原始通道");
|
||||
ByteBuf buf = transferChannel.config().getAllocator().buffer(nettyProxyMsg.getData().length);
|
||||
ByteBuf buf = channelHandlerContext.config().getAllocator().buffer(nettyProxyMsg.getData().length);
|
||||
buf.writeBytes(nettyProxyMsg.getData());
|
||||
nextChannel.writeAndFlush(buf);
|
||||
}else {
|
||||
|
@ -2,6 +2,7 @@ package org.framework.lazy.cloud.network.heartbeat.server.netty.proxy.http.advan
|
||||
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.ChannelContext;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyByteBuf;
|
||||
@ -9,7 +10,6 @@ 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.proxy.http.server.AbstractHttpServerProxyClientTypeAdvanced;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.constant.ProxyMessageType;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.constant.TcpMessageType;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.Role;
|
||||
@ -26,11 +26,11 @@ public class ServerHandleHttpReportServerProxyClientTransferTypeAdvanced
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param channel 当前通道
|
||||
* @param channelHandlerContext 当前通道
|
||||
* @param nettyProxyMsg 通道数据
|
||||
*/
|
||||
@Override
|
||||
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
|
||||
public void doHandler(ChannelHandlerContext channelHandlerContext, NettyProxyMsg nettyProxyMsg) {
|
||||
|
||||
// 创建链接、发送数据
|
||||
String targetPortString = nettyProxyMsg.getTargetPortString();
|
||||
@ -39,13 +39,13 @@ public class ServerHandleHttpReportServerProxyClientTransferTypeAdvanced
|
||||
byte[] visitorId = nettyProxyMsg.getVisitorId();
|
||||
byte[] clientId = nettyProxyMsg.getClientId();
|
||||
String msgVisitorId = new String(visitorId);
|
||||
ChannelAttributeKeyUtils.buildClientId(channel, clientId);
|
||||
ChannelAttributeKeyUtils.buildVisitorId(channel, msgVisitorId);
|
||||
ChannelAttributeKeyUtils.buildClientId(channelHandlerContext, clientId);
|
||||
ChannelAttributeKeyUtils.buildVisitorId(channelHandlerContext, msgVisitorId);
|
||||
|
||||
NettyTransferChannelContext.pushVisitor(channel, msgVisitorId);
|
||||
NettyTransferChannelContext.pushVisitor(channelHandlerContext, msgVisitorId);
|
||||
NettyByteBuf nettyByteBuf = new NettyByteBuf();
|
||||
nettyByteBuf.setData(data);
|
||||
ChannelAttributeKeyUtils.buildNettyByteBufData(channel, nettyByteBuf);
|
||||
ChannelAttributeKeyUtils.buildNettyByteBufData(channelHandlerContext, nettyByteBuf);
|
||||
// 获取客户端心跳通道
|
||||
Channel loadBalance = ChannelContext.getLoadBalance(clientId);
|
||||
|
||||
@ -59,7 +59,7 @@ public class ServerHandleHttpReportServerProxyClientTransferTypeAdvanced
|
||||
// 让客户端主动创建一个数据传输通道
|
||||
loadBalance.writeAndFlush(clientConnectTagetNettyProxyMsg);
|
||||
}else {
|
||||
log.error("can not find target client:【】 channel",clientId);
|
||||
log.error("can not find target client:【】 channelHandlerContext",clientId);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user