mirror of
https://gitee.com/wujiawei1207537021/wu-lazy-cloud-network.git
synced 2025-06-06 21:37:56 +08:00
[fix] 优化tcp、udp架构
This commit is contained in:
parent
daeba59a43
commit
2b3c7cb7c2
@ -6,7 +6,7 @@ import org.framework.lazy.cloud.network.heartbeat.client.application.assembler.L
|
|||||||
import org.framework.lazy.cloud.network.heartbeat.client.application.dto.LazyNettyServerPropertiesDTO;
|
import org.framework.lazy.cloud.network.heartbeat.client.application.dto.LazyNettyServerPropertiesDTO;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.domain.model.lazy.netty.server.properties.LazyNettyServerProperties;
|
import org.framework.lazy.cloud.network.heartbeat.client.domain.model.lazy.netty.server.properties.LazyNettyServerProperties;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.domain.model.lazy.netty.server.properties.LazyNettyServerPropertiesRepository;
|
import org.framework.lazy.cloud.network.heartbeat.client.domain.model.lazy.netty.server.properties.LazyNettyServerPropertiesRepository;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.socket.NettyClientSocket;
|
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.socket.NettyTcpClientSocket;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.application.LazyNettyServerPropertiesApplication;
|
import org.framework.lazy.cloud.network.heartbeat.client.application.LazyNettyServerPropertiesApplication;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.application.command.lazy.netty.server.properties.*;
|
import org.framework.lazy.cloud.network.heartbeat.client.application.command.lazy.netty.server.properties.*;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
|
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
|
||||||
@ -52,7 +52,7 @@ public class LazyNettyServerPropertiesApplicationImpl implements LazyNettyServer
|
|||||||
|
|
||||||
|
|
||||||
// 缓存连接socket
|
// 缓存连接socket
|
||||||
private final ConcurrentHashMap<LazyNettyServerProperties, NettyClientSocket> cacheNettyClientSocketMap = new ConcurrentHashMap<>();
|
private final ConcurrentHashMap<LazyNettyServerProperties, NettyTcpClientSocket> cacheNettyClientSocketMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public static final ThreadPoolExecutor NETTY_CLIENT_EXECUTOR =
|
public static final ThreadPoolExecutor NETTY_CLIENT_EXECUTOR =
|
||||||
new ThreadPoolExecutor(20, 50, 200, TimeUnit.MILLISECONDS,
|
new ThreadPoolExecutor(20, 50, 200, TimeUnit.MILLISECONDS,
|
||||||
@ -189,18 +189,18 @@ public class LazyNettyServerPropertiesApplicationImpl implements LazyNettyServer
|
|||||||
String appKey = lazyNettyServerProperties.getAppKey();
|
String appKey = lazyNettyServerProperties.getAppKey();
|
||||||
String appSecret = lazyNettyServerProperties.getAppSecret();
|
String appSecret = lazyNettyServerProperties.getAppSecret();
|
||||||
|
|
||||||
NettyClientSocket nettyClientSocket = new
|
NettyTcpClientSocket nettyTcpClientSocket = new
|
||||||
NettyClientSocket(inetHost, inetPort, clientId,
|
NettyTcpClientSocket(inetHost, inetPort, clientId,
|
||||||
NormalUsedString.DEFAULT,appKey,appSecret,
|
NormalUsedString.DEFAULT,appKey,appSecret,
|
||||||
clientChangeEvent, handleChannelTypeAdvancedList);
|
clientChangeEvent, handleChannelTypeAdvancedList);
|
||||||
cacheNettyClientSocketMap.put(lazyNettyServerProperties, nettyClientSocket);
|
cacheNettyClientSocketMap.put(lazyNettyServerProperties, nettyTcpClientSocket);
|
||||||
|
|
||||||
// 更新状态为运行中
|
// 更新状态为运行中
|
||||||
lazyNettyServerProperties.setConnectStatus(NettyClientStatus.RUNNING);
|
lazyNettyServerProperties.setConnectStatus(NettyClientStatus.RUNNING);
|
||||||
lazyNettyServerPropertiesRepository.story(lazyNettyServerProperties);
|
lazyNettyServerPropertiesRepository.story(lazyNettyServerProperties);
|
||||||
Thread thread = new Thread(() -> {
|
Thread thread = new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
nettyClientSocket.newConnect2Server();
|
nettyTcpClientSocket.newConnect2Server();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
@ -237,7 +237,7 @@ public class LazyNettyServerPropertiesApplicationImpl implements LazyNettyServer
|
|||||||
@Override
|
@Override
|
||||||
public void destroyOneClientSocket(LazyNettyServerProperties needCloseLazyNettyServerProperties) {
|
public void destroyOneClientSocket(LazyNettyServerProperties needCloseLazyNettyServerProperties) {
|
||||||
// 关闭指定socket
|
// 关闭指定socket
|
||||||
cacheNettyClientSocketMap.forEach(((nettyServerProperties, nettyClientSocket) -> {
|
cacheNettyClientSocketMap.forEach(((nettyServerProperties, nettyTcpClientSocket) -> {
|
||||||
String clientId = nettyServerProperties.getClientId();
|
String clientId = nettyServerProperties.getClientId();
|
||||||
String inetHost = nettyServerProperties.getInetHost();
|
String inetHost = nettyServerProperties.getInetHost();
|
||||||
Integer inetPort = nettyServerProperties.getInetPort();
|
Integer inetPort = nettyServerProperties.getInetPort();
|
||||||
@ -247,7 +247,7 @@ public class LazyNettyServerPropertiesApplicationImpl implements LazyNettyServer
|
|||||||
if (Objects.equals(clientId, needCloseClientId)
|
if (Objects.equals(clientId, needCloseClientId)
|
||||||
&& Objects.equals(inetPort, needCloseInetPort)
|
&& Objects.equals(inetPort, needCloseInetPort)
|
||||||
&& Objects.equals(inetHost, needCloseInetHost)) {
|
&& Objects.equals(inetHost, needCloseInetHost)) {
|
||||||
nettyClientSocket.shutdown();
|
nettyTcpClientSocket.shutdown();
|
||||||
// 关闭客户端:{}与服务端连接:{}:{}
|
// 关闭客户端:{}与服务端连接:{}:{}
|
||||||
log.warn("Close client: {} Connect to server: {}: {}", clientId, inetHost, inetPort);
|
log.warn("Close client: {} Connect to server: {}: {}", clientId, inetHost, inetPort);
|
||||||
}
|
}
|
||||||
@ -260,8 +260,8 @@ public class LazyNettyServerPropertiesApplicationImpl implements LazyNettyServer
|
|||||||
@Override
|
@Override
|
||||||
public void destroyClientSocket() {
|
public void destroyClientSocket() {
|
||||||
// 关闭socket
|
// 关闭socket
|
||||||
cacheNettyClientSocketMap.forEach(((nettyServerProperties, nettyClientSocket) -> {
|
cacheNettyClientSocketMap.forEach(((nettyServerProperties, nettyTcpClientSocket) -> {
|
||||||
nettyClientSocket.shutdown();
|
nettyTcpClientSocket.shutdown();
|
||||||
String clientId = nettyServerProperties.getClientId();
|
String clientId = nettyServerProperties.getClientId();
|
||||||
String inetHost = nettyServerProperties.getInetHost();
|
String inetHost = nettyServerProperties.getInetHost();
|
||||||
Integer inetPort = nettyServerProperties.getInetPort();
|
Integer inetPort = nettyServerProperties.getInetPort();
|
||||||
|
@ -22,11 +22,11 @@ public class ClientAutoConfiguration {
|
|||||||
/**
|
/**
|
||||||
* 服务端 处理客户端心跳
|
* 服务端 处理客户端心跳
|
||||||
*
|
*
|
||||||
* @return ClientTcpHandleChannelHeartbeatTypeAdvanced
|
* @return ClientHandleTcpChannelHeartbeatTypeAdvanced
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public ClientTcpHandleChannelHeartbeatTypeAdvanced clientTcpHandleChannelHeartbeatTypeAdvanced() {
|
public ClientHandleTcpChannelHeartbeatTypeAdvanced clientHandleTcpChannelHeartbeatTypeAdvanced() {
|
||||||
return new ClientTcpHandleChannelHeartbeatTypeAdvanced();
|
return new ClientHandleTcpChannelHeartbeatTypeAdvanced();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -90,8 +90,8 @@ public class ClientAutoConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public ClientHandleChannelTransferTypeAdvancedHandleDistributeTcpDistribute clientHandleChannelTransferTypeAdvancedHandleDistributeTcpDistribute(NettyClientProperties nettyClientProperties) {
|
public ClientHandleTcpChannelTransferTypeAdvancedHandleDistributeTcpDistribute clientHandleTcpChannelTransferTypeAdvancedHandleDistributeTcpDistribute(NettyClientProperties nettyClientProperties) {
|
||||||
return new ClientHandleChannelTransferTypeAdvancedHandleDistributeTcpDistribute(nettyClientProperties);
|
return new ClientHandleTcpChannelTransferTypeAdvancedHandleDistributeTcpDistribute(nettyClientProperties);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ -168,8 +168,164 @@ public class ClientAutoConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public ClientHandleHandleTcpDistributeClientPermeateServerTransferCloseTypeAdvanced clientHandleHandleTcpDistributeClientPermeateServerTransferCloseTypeAdvanced() {
|
public ClientHandleTcpDistributeClientPermeateServerTransferCloseTypeAdvanced clientHandleTcpDistributeClientPermeateServerTransferCloseTypeAdvanced() {
|
||||||
return new ClientHandleHandleTcpDistributeClientPermeateServerTransferCloseTypeAdvanced();
|
return new ClientHandleTcpDistributeClientPermeateServerTransferCloseTypeAdvanced();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Configuration()
|
||||||
|
static class ClientUdpConfiguration {
|
||||||
|
/**
|
||||||
|
* 服务端 处理客户端心跳
|
||||||
|
*
|
||||||
|
* @return ClientUdpHandleChannelHeartbeatTypeAdvanced
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public ClientUdpHandleChannelHeartbeatTypeAdvanced clientUdpHandleChannelHeartbeatTypeAdvanced() {
|
||||||
|
return new ClientUdpHandleChannelHeartbeatTypeAdvanced();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理 客户端代理的真实端口自动读写
|
||||||
|
*
|
||||||
|
* @return ClientHandleUdpDistributeSingleClientRealAutoReadConnectTypeAdvanced
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public ClientHandleUdpDistributeSingleClientRealAutoReadConnectTypeAdvanced clientHandleUdpDistributeSingleClientRealAutoReadConnectTypeAdvanced() {
|
||||||
|
return new ClientHandleUdpDistributeSingleClientRealAutoReadConnectTypeAdvanced();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理 接收服务端发送过来的聊天信息
|
||||||
|
*
|
||||||
|
* @return ClientHandleUdpDistributeSingleClientMessageTypeAdvanced
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public ClientHandleUdpDistributeSingleClientMessageTypeAdvanced clientHandleUdpDistributeSingleClientMessageTypeAdvanced() {
|
||||||
|
return new ClientHandleUdpDistributeSingleClientMessageTypeAdvanced();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理 客户端渗透服务端数据传输通道连接成功
|
||||||
|
*
|
||||||
|
* @return ClientHandleUdpDistributeClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public ClientHandleUdpDistributeClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced clientHandleUdpDistributeClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced() {
|
||||||
|
return new ClientHandleUdpDistributeClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理 客户端渗透客户端数据传输通道连接成功
|
||||||
|
*
|
||||||
|
* @return ClientHandleUdpDistributeClientTransferClientPermeateChannelConnectionSuccessfulTypeAdvanced
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public ClientHandleUdpDistributeClientTransferClientPermeateChannelConnectionSuccessfulTypeAdvanced clientHandleUdpDistributeClientTransferClientPermeateChannelConnectionSuccessfulTypeAdvanced() {
|
||||||
|
return new ClientHandleUdpDistributeClientTransferClientPermeateChannelConnectionSuccessfulTypeAdvanced();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ClientHandleUdpDistributeClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced clientHandleUdpDistributeClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced() {
|
||||||
|
return new ClientHandleUdpDistributeClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ClientHandleUdpDistributeClientTransferClientRequestTypeAdvanced clientHandleUdpDistributeClientTransferClientRequestTypeAdvanced() {
|
||||||
|
return new ClientHandleUdpDistributeClientTransferClientRequestTypeAdvanced();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ClientHandleUdpDistributeServicePermeateClientTransferClientResponseTypeAdvanced clientHandleUdpDistributeServicePermeateClientTransferClientResponseTypeAdvanced() {
|
||||||
|
return new ClientHandleUdpDistributeServicePermeateClientTransferClientResponseTypeAdvanced();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ClientHandleUdpDistributeSingleClientRealCloseVisitorTypeAdvanced clientHandleUdpDistributeSingleClientRealCloseVisitorTypeAdvanced() {
|
||||||
|
return new ClientHandleUdpDistributeSingleClientRealCloseVisitorTypeAdvanced();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ClientHandleChannelTransferTypeAdvancedHandleDistributeUdpDistribute clientHandleChannelTransferTypeAdvancedHandleDistributeUdpDistribute(NettyClientProperties nettyClientProperties) {
|
||||||
|
return new ClientHandleChannelTransferTypeAdvancedHandleDistributeUdpDistribute(nettyClientProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ClientHandleUdpDistributeConnectSuccessNotificationTypeAdvancedHandle clientHandleUdpDistributeConnectSuccessNotificationTypeAdvancedHandle(ClientChangeEvent clientChangeEvent) {
|
||||||
|
return new ClientHandleUdpDistributeConnectSuccessNotificationTypeAdvancedHandle(clientChangeEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ClientHandleUdpClientChannelActiveAdvanced clientHandleUdpClientChannelActiveAdvanced(NettyClientProperties nettyClientProperties) {
|
||||||
|
return new ClientHandleUdpClientChannelActiveAdvanced(nettyClientProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ClientHandleUdpDistributeDisconnectTypeAdvancedHandle clientHandleUdpDistributeDisconnectTypeAdvancedHandle(ClientChangeEvent clientChangeEvent) {
|
||||||
|
return new ClientHandleUdpDistributeDisconnectTypeAdvancedHandle(clientChangeEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ClientHandleUdpDistributeStagingClosedTypeAdvanced clientHandleUdpDistributeStagingClosedTypeAdvanced() {
|
||||||
|
return new ClientHandleUdpDistributeStagingClosedTypeAdvanced();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ClientHandleUdpDistributeStagingOpenedTypeAdvanced clientHandleUdpDistributeStagingOpenedTypeAdvanced() {
|
||||||
|
return new ClientHandleUdpDistributeStagingOpenedTypeAdvanced();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理 客户端渗透服务端init信息
|
||||||
|
*
|
||||||
|
* @return ClientHandleUdpDistributeClientPermeateServerInitTypeAdvanced
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public ClientHandleUdpDistributeClientPermeateServerInitTypeAdvanced clientHandleUdpDistributeClientPermeateServerInitTypeAdvanced(NettyClientProperties nettyClientProperties) {
|
||||||
|
return new ClientHandleUdpDistributeClientPermeateServerInitTypeAdvanced(nettyClientProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理 客户端渗透服务端init close 信息
|
||||||
|
*
|
||||||
|
* @return ClientHandleUdpDistributeClientPermeateServerCloseTypeAdvanced
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public ClientHandleUdpDistributeClientPermeateServerCloseTypeAdvanced clientHandleUdpDistributeClientPermeateServerCloseTypeAdvanced() {
|
||||||
|
return new ClientHandleUdpDistributeClientPermeateServerCloseTypeAdvanced();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ClientHandleUdpDistributeClientPermeateServerTransferTypeAdvanced clientHandleUdpDistributeClientPermeateServerTransferTypeAdvanced() {
|
||||||
|
return new ClientHandleUdpDistributeClientPermeateServerTransferTypeAdvanced();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ClientHandleUdpDistributeClientPermeateClientCloseTypeAdvanced clientHandleUdpDistributeClientPermeateClientCloseTypeAdvanced() {
|
||||||
|
return new ClientHandleUdpDistributeClientPermeateClientCloseTypeAdvanced();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ClientHandleUdpDistributeClientPermeateClientInitTypeAdvanced clientHandleUdpDistributeClientPermeateClientInitTypeAdvanced() {
|
||||||
|
return new ClientHandleUdpDistributeClientPermeateClientInitTypeAdvanced();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ClientHandleUdpDistributeClientPermeateClientTransferCloseTypeAdvanced clientHandleUdpDistributeClientPermeateClientTransferCloseTypeAdvanced() {
|
||||||
|
return new ClientHandleUdpDistributeClientPermeateClientTransferCloseTypeAdvanced();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ClientHandleUdpDistributeServicePermeateClientRealConnectTypeAdvanced clientHandleUdpDistributeServicePermeateClientRealConnectTypeAdvanced(
|
||||||
|
NettyClientProperties nettyClientProperties,
|
||||||
|
List<HandleChannelTypeAdvanced> handleChannelTypeAdvancedList) {
|
||||||
|
return new ClientHandleUdpDistributeServicePermeateClientRealConnectTypeAdvanced(nettyClientProperties, handleChannelTypeAdvancedList);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ClientHandleHandleUdpDistributeClientPermeateServerTransferCloseTypeAdvanced clientHandleHandleUdpDistributeClientPermeateServerTransferCloseTypeAdvanced() {
|
||||||
|
return new ClientHandleHandleUdpDistributeClientPermeateServerTransferCloseTypeAdvanced();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.advanced.tcp.AbstractTc
|
|||||||
* 服务端 处理客户端心跳
|
* 服务端 处理客户端心跳
|
||||||
* TCP_TYPE_HEARTBEAT
|
* TCP_TYPE_HEARTBEAT
|
||||||
*/
|
*/
|
||||||
public class ClientTcpHandleChannelHeartbeatTypeAdvanced extends AbstractTcpHandleChannelHeartbeatTypeAdvanced<NettyProxyMsg> {
|
public class ClientHandleTcpChannelHeartbeatTypeAdvanced extends AbstractTcpHandleChannelHeartbeatTypeAdvanced<NettyProxyMsg> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理当前数据
|
* 处理当前数据
|
@ -17,11 +17,11 @@ import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeK
|
|||||||
* @see MessageTypeEnums#TCP_DISTRIBUTE_CLIENT_TRANSFER
|
* @see MessageTypeEnums#TCP_DISTRIBUTE_CLIENT_TRANSFER
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class ClientHandleChannelTransferTypeAdvancedHandleDistributeTcpDistribute extends AbstractHandleTcpDistributeServicePermeateClientTransferTypeAdvanced<NettyProxyMsg> {
|
public class ClientHandleTcpChannelTransferTypeAdvancedHandleDistributeTcpDistribute extends AbstractHandleTcpDistributeServicePermeateClientTransferTypeAdvanced<NettyProxyMsg> {
|
||||||
|
|
||||||
private final NettyClientProperties nettyClientProperties;
|
private final NettyClientProperties nettyClientProperties;
|
||||||
|
|
||||||
public ClientHandleChannelTransferTypeAdvancedHandleDistributeTcpDistribute(NettyClientProperties nettyClientProperties) {
|
public ClientHandleTcpChannelTransferTypeAdvancedHandleDistributeTcpDistribute(NettyClientProperties nettyClientProperties) {
|
||||||
this.nettyClientProperties = nettyClientProperties;
|
this.nettyClientProperties = nettyClientProperties;
|
||||||
}
|
}
|
||||||
|
|
@ -4,7 +4,7 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.advanced;
|
|||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
|
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.socket.NettyClientPermeateClientVisitorSocket;
|
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.socket.NettyTcpClientPermeateClientVisitorSocket;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
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.HandleChannelTypeAdvanced;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.advanced.tcp.client.AbstractHandleTcpDistributeClientPermeateClientInitTypeAdvanced;
|
import org.framework.lazy.cloud.network.heartbeat.common.advanced.tcp.client.AbstractHandleTcpDistributeClientPermeateClientInitTypeAdvanced;
|
||||||
@ -49,8 +49,8 @@ public class ClientHandleTcpDistributeClientPermeateClientInitTypeAdvanced exten
|
|||||||
NettyClientProperties nettyClientProperties = SpringContextHolder.getBean(NettyClientProperties.class);
|
NettyClientProperties nettyClientProperties = SpringContextHolder.getBean(NettyClientProperties.class);
|
||||||
log.info("client permeate client from client_id:【{}】 to_client_id【{}】with visitor_port【{}】, clientTargetIp:【{}】clientTargetPort:【{}】",
|
log.info("client permeate client from client_id:【{}】 to_client_id【{}】with visitor_port【{}】, clientTargetIp:【{}】clientTargetPort:【{}】",
|
||||||
fromClientId, toClientId, visitorPort, clientTargetIp, clientTargetPort);
|
fromClientId, toClientId, visitorPort, clientTargetIp, clientTargetPort);
|
||||||
NettyClientPermeateClientVisitorSocket nettyClientPermeateClientVisitorSocket =
|
NettyTcpClientPermeateClientVisitorSocket nettyTcpClientPermeateClientVisitorSocket =
|
||||||
NettyClientPermeateClientVisitorSocket.NettyClientPermeateClientVisitorSocketBuilder.builder()
|
NettyTcpClientPermeateClientVisitorSocket.NettyClientPermeateClientVisitorSocketBuilder.builder()
|
||||||
.builderClientId(fromClientId)
|
.builderClientId(fromClientId)
|
||||||
.builderClientTargetIp(clientTargetIp)
|
.builderClientTargetIp(clientTargetIp)
|
||||||
.builderClientTargetPort(clientTargetPort)
|
.builderClientTargetPort(clientTargetPort)
|
||||||
@ -62,7 +62,7 @@ public class ClientHandleTcpDistributeClientPermeateClientInitTypeAdvanced exten
|
|||||||
|
|
||||||
.build();
|
.build();
|
||||||
try {
|
try {
|
||||||
nettyClientPermeateClientVisitorSocket.start();
|
nettyTcpClientPermeateClientVisitorSocket.start();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.advanced;
|
|||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
|
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.socket.NettyClientPermeateServerVisitorSocket;
|
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.socket.NettyTcpClientPermeateServerVisitorSocket;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
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.HandleChannelTypeAdvanced;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.advanced.tcp.client.AbstractHandleTcpDistributeClientPermeateServerInitTypeAdvanced;
|
import org.framework.lazy.cloud.network.heartbeat.common.advanced.tcp.client.AbstractHandleTcpDistributeClientPermeateServerInitTypeAdvanced;
|
||||||
@ -44,7 +44,7 @@ public class ClientHandleTcpDistributeClientPermeateServerInitTypeAdvanced exten
|
|||||||
byte[] clientTargetPort = nettyProxyMsg.getClientTargetPort();
|
byte[] clientTargetPort = nettyProxyMsg.getClientTargetPort();
|
||||||
|
|
||||||
List<HandleChannelTypeAdvanced> handleChannelTypeAdvancedList = new ArrayList<>(SpringContextHolder.getApplicationContext().getBeansOfType(HandleChannelTypeAdvanced.class).values());
|
List<HandleChannelTypeAdvanced> handleChannelTypeAdvancedList = new ArrayList<>(SpringContextHolder.getApplicationContext().getBeansOfType(HandleChannelTypeAdvanced.class).values());
|
||||||
NettyClientPermeateServerVisitorSocket nettyClientPermeateServerVisitorSocket = NettyClientPermeateServerVisitorSocket.NettyVisitorSocketBuilder.builder()
|
NettyTcpClientPermeateServerVisitorSocket nettyTcpClientPermeateServerVisitorSocket = NettyTcpClientPermeateServerVisitorSocket.NettyVisitorSocketBuilder.builder()
|
||||||
.builderClientId(new String(clientIdBytes))
|
.builderClientId(new String(clientIdBytes))
|
||||||
.builderClientTargetIp(new String(clientTargetIp))
|
.builderClientTargetIp(new String(clientTargetIp))
|
||||||
.builderClientTargetPort(Integer.parseInt(new String(clientTargetPort)))
|
.builderClientTargetPort(Integer.parseInt(new String(clientTargetPort)))
|
||||||
@ -53,7 +53,7 @@ public class ClientHandleTcpDistributeClientPermeateServerInitTypeAdvanced exten
|
|||||||
.builderHandleChannelTypeAdvancedList(handleChannelTypeAdvancedList)
|
.builderHandleChannelTypeAdvancedList(handleChannelTypeAdvancedList)
|
||||||
.build();
|
.build();
|
||||||
try {
|
try {
|
||||||
nettyClientPermeateServerVisitorSocket.start();
|
nettyTcpClientPermeateServerVisitorSocket.start();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -15,7 +15,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeK
|
|||||||
* @see MessageTypeEnums#TCP_DISTRIBUTE_CLIENT_PERMEATE_SERVER_TRANSFER_CLOSE
|
* @see MessageTypeEnums#TCP_DISTRIBUTE_CLIENT_PERMEATE_SERVER_TRANSFER_CLOSE
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class ClientHandleHandleTcpDistributeClientPermeateServerTransferCloseTypeAdvanced extends AbstractHandleTcpDistributeClientPermeateServerTransferCloseTypeAdvanced<NettyProxyMsg> {
|
public class ClientHandleTcpDistributeClientPermeateServerTransferCloseTypeAdvanced extends AbstractHandleTcpDistributeClientPermeateServerTransferCloseTypeAdvanced<NettyProxyMsg> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理当前数据
|
* 处理当前数据
|
@ -4,7 +4,7 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.advanced;
|
|||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
|
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.socket.NettyClientPermeateClientRealSocket;
|
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.socket.NettyTcpClientPermeateClientRealSocket;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
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.HandleChannelTypeAdvanced;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.advanced.tcp.client.AbstractHandleTcpDistributeClientTransferClientPermeateChannelConnectionSuccessfulTypeAdvanced;
|
import org.framework.lazy.cloud.network.heartbeat.common.advanced.tcp.client.AbstractHandleTcpDistributeClientTransferClientPermeateChannelConnectionSuccessfulTypeAdvanced;
|
||||||
@ -46,7 +46,7 @@ public class ClientHandleTcpDistributeClientTransferClientPermeateChannelConnect
|
|||||||
Integer visitorPort=Integer.parseInt(new String(msgVisitorPort));
|
Integer visitorPort=Integer.parseInt(new String(msgVisitorPort));
|
||||||
NettyClientProperties nettyClientProperties = SpringContextHolder.getBean(NettyClientProperties.class);
|
NettyClientProperties nettyClientProperties = SpringContextHolder.getBean(NettyClientProperties.class);
|
||||||
List<HandleChannelTypeAdvanced> handleChannelTypeAdvancedList = new ArrayList<>(SpringContextHolder.getApplicationContext().getBeansOfType(HandleChannelTypeAdvanced.class).values());
|
List<HandleChannelTypeAdvanced> handleChannelTypeAdvancedList = new ArrayList<>(SpringContextHolder.getApplicationContext().getBeansOfType(HandleChannelTypeAdvanced.class).values());
|
||||||
NettyClientPermeateClientRealSocket.buildRealServer(
|
NettyTcpClientPermeateClientRealSocket.buildRealServer(
|
||||||
clientId,
|
clientId,
|
||||||
clientTargetIp,
|
clientTargetIp,
|
||||||
clientTargetPort,
|
clientTargetPort,
|
||||||
|
@ -4,8 +4,8 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.advanced;
|
|||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import io.netty.channel.ChannelOption;
|
import io.netty.channel.ChannelOption;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.handler.NettyClientPermeateServerVisitorHandler;
|
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.handler.NettyTcpClientPermeateServerVisitorHandler;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.socket.NettyClientPermeateServerVisitorTransferSocket;
|
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.socket.NettyTcpClientPermeateServerVisitorTransferSocket;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.advanced.tcp.client.AbstractHandleTcpDistributeClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced;
|
import org.framework.lazy.cloud.network.heartbeat.common.advanced.tcp.client.AbstractHandleTcpDistributeClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
|
import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
|
||||||
@ -14,8 +14,8 @@ import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeK
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 客户端渗透服务端数据传输通道连接成功
|
* 客户端渗透服务端数据传输通道连接成功
|
||||||
* @see NettyClientPermeateServerVisitorTransferSocket
|
* @see NettyTcpClientPermeateServerVisitorTransferSocket
|
||||||
* @see NettyClientPermeateServerVisitorHandler
|
* @see NettyTcpClientPermeateServerVisitorHandler
|
||||||
*
|
*
|
||||||
* @see MessageTypeEnums#TCP_DISTRIBUTE_CLIENT_TRANSFER_SERVER_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL
|
* @see MessageTypeEnums#TCP_DISTRIBUTE_CLIENT_TRANSFER_SERVER_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL
|
||||||
*/
|
*/
|
||||||
|
@ -3,7 +3,7 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.advanced;
|
|||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
|
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.socket.NettyServerPermeateClientRealSocket;
|
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.socket.NettyTcpServerPermeateClientRealSocket;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.InternalNetworkPenetrationRealClient;
|
import org.framework.lazy.cloud.network.heartbeat.common.InternalNetworkPenetrationRealClient;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
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.HandleChannelTypeAdvanced;
|
||||||
@ -50,7 +50,7 @@ public class ClientHandleTcpDistributeServicePermeateClientRealConnectTypeAdvanc
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
// 绑定真实服务端口
|
// 绑定真实服务端口
|
||||||
NettyServerPermeateClientRealSocket.buildRealServer(internalNetworkPenetrationRealClient, nettyClientProperties, handleChannelTypeAdvancedList);
|
NettyTcpServerPermeateClientRealSocket.buildRealServer(internalNetworkPenetrationRealClient, nettyClientProperties, handleChannelTypeAdvancedList);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,22 +5,22 @@ import io.netty.channel.socket.SocketChannel;
|
|||||||
import io.netty.handler.codec.string.StringDecoder;
|
import io.netty.handler.codec.string.StringDecoder;
|
||||||
import io.netty.handler.codec.string.StringEncoder;
|
import io.netty.handler.codec.string.StringEncoder;
|
||||||
import io.netty.handler.timeout.IdleStateHandler;
|
import io.netty.handler.timeout.IdleStateHandler;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.handler.NettyClientHandler;
|
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.handler.NettyTcpClientHandler;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.socket.NettyClientSocket;
|
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.socket.NettyTcpClientSocket;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
|
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.decoder.NettyProxyMsgDecoder;
|
import org.framework.lazy.cloud.network.heartbeat.common.decoder.NettyProxyMsgDecoder;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.encoder.NettyProxyMsgEncoder;
|
import org.framework.lazy.cloud.network.heartbeat.common.encoder.NettyProxyMsgEncoder;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.filter.DebugChannelInitializer;
|
import org.framework.lazy.cloud.network.heartbeat.common.filter.DebugChannelInitializer;
|
||||||
|
|
||||||
public class NettyClientFilter extends DebugChannelInitializer<SocketChannel> {
|
public class NettyTcpClientFilter extends DebugChannelInitializer<SocketChannel> {
|
||||||
|
|
||||||
|
|
||||||
private final ChannelTypeAdapter channelTypeAdapter;
|
private final ChannelTypeAdapter channelTypeAdapter;
|
||||||
private final NettyClientSocket nettyClientSocket;
|
private final NettyTcpClientSocket nettyTcpClientSocket;
|
||||||
|
|
||||||
public NettyClientFilter(ChannelTypeAdapter channelTypeAdapter, NettyClientSocket nettyClientSocket) {
|
public NettyTcpClientFilter(ChannelTypeAdapter channelTypeAdapter, NettyTcpClientSocket nettyTcpClientSocket) {
|
||||||
this.channelTypeAdapter = channelTypeAdapter;
|
this.channelTypeAdapter = channelTypeAdapter;
|
||||||
this.nettyClientSocket = nettyClientSocket;
|
this.nettyTcpClientSocket = nettyTcpClientSocket;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -40,6 +40,6 @@ public class NettyClientFilter extends DebugChannelInitializer<SocketChannel> {
|
|||||||
pipeline.addLast(new IdleStateHandler(0, 4, 0));
|
pipeline.addLast(new IdleStateHandler(0, 4, 0));
|
||||||
pipeline.addLast("decoder", new StringDecoder());
|
pipeline.addLast("decoder", new StringDecoder());
|
||||||
pipeline.addLast("encoder", new StringEncoder());
|
pipeline.addLast("encoder", new StringEncoder());
|
||||||
pipeline.addLast("doHandler", new NettyClientHandler(channelTypeAdapter, nettyClientSocket)); //客户端的逻辑
|
pipeline.addLast("doHandler", new NettyTcpClientHandler(channelTypeAdapter, nettyTcpClientSocket)); //客户端的逻辑
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,12 +3,12 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.filter;
|
|||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import io.netty.channel.ChannelPipeline;
|
import io.netty.channel.ChannelPipeline;
|
||||||
import io.netty.channel.socket.SocketChannel;
|
import io.netty.channel.socket.SocketChannel;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.handler.NettyClientPermeateClientRealHandler;
|
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.handler.NettyTcpClientPermeateClientRealHandler;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.decoder.TransferDecoder;
|
import org.framework.lazy.cloud.network.heartbeat.common.decoder.TransferDecoder;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.encoder.TransferEncoder;
|
import org.framework.lazy.cloud.network.heartbeat.common.encoder.TransferEncoder;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.filter.DebugChannelInitializer;
|
import org.framework.lazy.cloud.network.heartbeat.common.filter.DebugChannelInitializer;
|
||||||
|
|
||||||
public class NettyClientPermeateClientRealFilter extends DebugChannelInitializer<SocketChannel> {
|
public class NettyTcpClientPermeateClientRealFilter extends DebugChannelInitializer<SocketChannel> {
|
||||||
/**
|
/**
|
||||||
* This method will be called once the {@link Channel} was registered. After the method returns this instance
|
* This method will be called once the {@link Channel} was registered. After the method returns this instance
|
||||||
* will be removed from the {@link ChannelPipeline} of the {@link Channel}.
|
* will be removed from the {@link ChannelPipeline} of the {@link Channel}.
|
||||||
@ -21,7 +21,7 @@ public class NettyClientPermeateClientRealFilter extends DebugChannelInitializer
|
|||||||
// 解码、编码
|
// 解码、编码
|
||||||
pipeline.addLast(new TransferDecoder(Integer.MAX_VALUE, 1024 * 1024*10));
|
pipeline.addLast(new TransferDecoder(Integer.MAX_VALUE, 1024 * 1024*10));
|
||||||
pipeline.addLast(new TransferEncoder());
|
pipeline.addLast(new TransferEncoder());
|
||||||
pipeline.addLast(new NettyClientPermeateClientRealHandler());
|
pipeline.addLast(new NettyTcpClientPermeateClientRealHandler());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,7 +5,7 @@ import io.netty.channel.ChannelHandlerContext;
|
|||||||
import io.netty.channel.ChannelPipeline;
|
import io.netty.channel.ChannelPipeline;
|
||||||
import io.netty.channel.socket.SocketChannel;
|
import io.netty.channel.socket.SocketChannel;
|
||||||
import io.netty.handler.timeout.IdleStateHandler;
|
import io.netty.handler.timeout.IdleStateHandler;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.handler.NettyClientPermeateClientTransferHandler;
|
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.handler.NettyTcpClientPermeateClientTransferHandler;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
|
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.decoder.NettyProxyMsgDecoder;
|
import org.framework.lazy.cloud.network.heartbeat.common.decoder.NettyProxyMsgDecoder;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.encoder.NettyProxyMsgEncoder;
|
import org.framework.lazy.cloud.network.heartbeat.common.encoder.NettyProxyMsgEncoder;
|
||||||
@ -14,10 +14,10 @@ import org.framework.lazy.cloud.network.heartbeat.common.filter.DebugChannelInit
|
|||||||
/**
|
/**
|
||||||
* netty 客户端渗透通信通道
|
* netty 客户端渗透通信通道
|
||||||
*/
|
*/
|
||||||
public class NettyClientPermeateClientTransferFilter extends DebugChannelInitializer<SocketChannel> {
|
public class NettyTcpClientPermeateClientTransferFilter extends DebugChannelInitializer<SocketChannel> {
|
||||||
private final ChannelTypeAdapter channelTypeAdapter;
|
private final ChannelTypeAdapter channelTypeAdapter;
|
||||||
|
|
||||||
public NettyClientPermeateClientTransferFilter(ChannelTypeAdapter channelTypeAdapter) {
|
public NettyTcpClientPermeateClientTransferFilter(ChannelTypeAdapter channelTypeAdapter) {
|
||||||
this.channelTypeAdapter = channelTypeAdapter;
|
this.channelTypeAdapter = channelTypeAdapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,6 +41,6 @@ public class NettyClientPermeateClientTransferFilter extends DebugChannelInitial
|
|||||||
|
|
||||||
pipeline.addLast(new NettyProxyMsgDecoder(Integer.MAX_VALUE, 0, 4, -4, 0));
|
pipeline.addLast(new NettyProxyMsgDecoder(Integer.MAX_VALUE, 0, 4, -4, 0));
|
||||||
pipeline.addLast(new NettyProxyMsgEncoder());
|
pipeline.addLast(new NettyProxyMsgEncoder());
|
||||||
pipeline.addLast(new NettyClientPermeateClientTransferHandler(channelTypeAdapter));
|
pipeline.addLast(new NettyTcpClientPermeateClientTransferHandler(channelTypeAdapter));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,7 +5,7 @@ import io.netty.channel.ChannelHandlerContext;
|
|||||||
import io.netty.channel.ChannelPipeline;
|
import io.netty.channel.ChannelPipeline;
|
||||||
import io.netty.channel.socket.SocketChannel;
|
import io.netty.channel.socket.SocketChannel;
|
||||||
import io.netty.handler.timeout.IdleStateHandler;
|
import io.netty.handler.timeout.IdleStateHandler;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.handler.NettyClientPermeateClientTransferRealHandler;
|
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.handler.NettyTcpClientPermeateClientTransferRealHandler;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
|
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.decoder.NettyProxyMsgDecoder;
|
import org.framework.lazy.cloud.network.heartbeat.common.decoder.NettyProxyMsgDecoder;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.encoder.NettyProxyMsgEncoder;
|
import org.framework.lazy.cloud.network.heartbeat.common.encoder.NettyProxyMsgEncoder;
|
||||||
@ -14,10 +14,10 @@ import org.framework.lazy.cloud.network.heartbeat.common.filter.DebugChannelInit
|
|||||||
/**
|
/**
|
||||||
* netty 客户端连接真实服服务端访客拦截器
|
* netty 客户端连接真实服服务端访客拦截器
|
||||||
*/
|
*/
|
||||||
public class NettyClientPermeateClientTransferRealFilter extends DebugChannelInitializer<SocketChannel> {
|
public class NettyTcpClientPermeateClientTransferRealFilter extends DebugChannelInitializer<SocketChannel> {
|
||||||
private final ChannelTypeAdapter channelTypeAdapter;
|
private final ChannelTypeAdapter channelTypeAdapter;
|
||||||
|
|
||||||
public NettyClientPermeateClientTransferRealFilter(ChannelTypeAdapter channelTypeAdapter) {
|
public NettyTcpClientPermeateClientTransferRealFilter(ChannelTypeAdapter channelTypeAdapter) {
|
||||||
this.channelTypeAdapter = channelTypeAdapter;
|
this.channelTypeAdapter = channelTypeAdapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,6 +41,6 @@ public class NettyClientPermeateClientTransferRealFilter extends DebugChannelIni
|
|||||||
|
|
||||||
pipeline.addLast(new NettyProxyMsgDecoder(Integer.MAX_VALUE, 0, 4, -4, 0));
|
pipeline.addLast(new NettyProxyMsgDecoder(Integer.MAX_VALUE, 0, 4, -4, 0));
|
||||||
pipeline.addLast(new NettyProxyMsgEncoder());
|
pipeline.addLast(new NettyProxyMsgEncoder());
|
||||||
pipeline.addLast(new NettyClientPermeateClientTransferRealHandler(channelTypeAdapter));
|
pipeline.addLast(new NettyTcpClientPermeateClientTransferRealHandler(channelTypeAdapter));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -6,14 +6,14 @@ import io.netty.channel.ChannelHandlerContext;
|
|||||||
import io.netty.channel.ChannelPipeline;
|
import io.netty.channel.ChannelPipeline;
|
||||||
import io.netty.channel.socket.SocketChannel;
|
import io.netty.channel.socket.SocketChannel;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.InternalNetworkClientPermeateClientVisitor;
|
import org.framework.lazy.cloud.network.heartbeat.client.netty.InternalNetworkClientPermeateClientVisitor;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.handler.NettyClientPermeateClientVisitorHandler;
|
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.handler.NettyTcpClientPermeateClientVisitorHandler;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.filter.DebugChannelInitializer;
|
import org.framework.lazy.cloud.network.heartbeat.common.filter.DebugChannelInitializer;
|
||||||
|
|
||||||
public class NettyClientPermeateClientVisitorFilter extends DebugChannelInitializer<SocketChannel> {
|
public class NettyTcpClientPermeateClientVisitorFilter extends DebugChannelInitializer<SocketChannel> {
|
||||||
|
|
||||||
private final InternalNetworkClientPermeateClientVisitor internalNetworkClientPermeateClientVisitor;
|
private final InternalNetworkClientPermeateClientVisitor internalNetworkClientPermeateClientVisitor;
|
||||||
|
|
||||||
public NettyClientPermeateClientVisitorFilter(InternalNetworkClientPermeateClientVisitor internalNetworkClientPermeateClientVisitor) {
|
public NettyTcpClientPermeateClientVisitorFilter(InternalNetworkClientPermeateClientVisitor internalNetworkClientPermeateClientVisitor) {
|
||||||
this.internalNetworkClientPermeateClientVisitor = internalNetworkClientPermeateClientVisitor;
|
this.internalNetworkClientPermeateClientVisitor = internalNetworkClientPermeateClientVisitor;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -31,6 +31,6 @@ public class NettyClientPermeateClientVisitorFilter extends DebugChannelInitiali
|
|||||||
protected void initChannel0(SocketChannel ch) throws Exception {
|
protected void initChannel0(SocketChannel ch) throws Exception {
|
||||||
ChannelPipeline pipeline = ch.pipeline();
|
ChannelPipeline pipeline = ch.pipeline();
|
||||||
pipeline.addLast(new ChannelDuplexHandler());
|
pipeline.addLast(new ChannelDuplexHandler());
|
||||||
pipeline.addLast(new NettyClientPermeateClientVisitorHandler(internalNetworkClientPermeateClientVisitor));
|
pipeline.addLast(new NettyTcpClientPermeateClientVisitorHandler(internalNetworkClientPermeateClientVisitor));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,7 +5,7 @@ import io.netty.channel.ChannelHandlerContext;
|
|||||||
import io.netty.channel.ChannelPipeline;
|
import io.netty.channel.ChannelPipeline;
|
||||||
import io.netty.channel.socket.SocketChannel;
|
import io.netty.channel.socket.SocketChannel;
|
||||||
import io.netty.handler.timeout.IdleStateHandler;
|
import io.netty.handler.timeout.IdleStateHandler;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.handler.NettyClientPermeateServerTransferHandler;
|
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.handler.NettyTcpClientPermeateServerTransferHandler;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
|
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.decoder.NettyProxyMsgDecoder;
|
import org.framework.lazy.cloud.network.heartbeat.common.decoder.NettyProxyMsgDecoder;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.encoder.NettyProxyMsgEncoder;
|
import org.framework.lazy.cloud.network.heartbeat.common.encoder.NettyProxyMsgEncoder;
|
||||||
@ -14,10 +14,10 @@ import org.framework.lazy.cloud.network.heartbeat.common.filter.DebugChannelInit
|
|||||||
/**
|
/**
|
||||||
* netty 客户端渗透通信通道
|
* netty 客户端渗透通信通道
|
||||||
*/
|
*/
|
||||||
public class NettyClientPermeateServerTransferFilter extends DebugChannelInitializer<SocketChannel> {
|
public class NettyTcpClientPermeateServerTransferFilter extends DebugChannelInitializer<SocketChannel> {
|
||||||
private final ChannelTypeAdapter channelTypeAdapter;
|
private final ChannelTypeAdapter channelTypeAdapter;
|
||||||
|
|
||||||
public NettyClientPermeateServerTransferFilter(ChannelTypeAdapter channelTypeAdapter) {
|
public NettyTcpClientPermeateServerTransferFilter(ChannelTypeAdapter channelTypeAdapter) {
|
||||||
this.channelTypeAdapter = channelTypeAdapter;
|
this.channelTypeAdapter = channelTypeAdapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,6 +40,6 @@ public class NettyClientPermeateServerTransferFilter extends DebugChannelInitial
|
|||||||
pipeline.addLast(new NettyProxyMsgDecoder(Integer.MAX_VALUE, 0, 4, -4, 0));
|
pipeline.addLast(new NettyProxyMsgDecoder(Integer.MAX_VALUE, 0, 4, -4, 0));
|
||||||
pipeline.addLast(new IdleStateHandler(0, 4, 0));
|
pipeline.addLast(new IdleStateHandler(0, 4, 0));
|
||||||
pipeline.addLast(new NettyProxyMsgEncoder());
|
pipeline.addLast(new NettyProxyMsgEncoder());
|
||||||
pipeline.addLast(new NettyClientPermeateServerTransferHandler(channelTypeAdapter));
|
pipeline.addLast(new NettyTcpClientPermeateServerTransferHandler(channelTypeAdapter));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -6,14 +6,14 @@ import io.netty.channel.ChannelHandlerContext;
|
|||||||
import io.netty.channel.ChannelPipeline;
|
import io.netty.channel.ChannelPipeline;
|
||||||
import io.netty.channel.socket.SocketChannel;
|
import io.netty.channel.socket.SocketChannel;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.InternalNetworkClientPermeateServerVisitor;
|
import org.framework.lazy.cloud.network.heartbeat.client.netty.InternalNetworkClientPermeateServerVisitor;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.handler.NettyClientPermeateServerVisitorHandler;
|
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.handler.NettyTcpClientPermeateServerVisitorHandler;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.filter.DebugChannelInitializer;
|
import org.framework.lazy.cloud.network.heartbeat.common.filter.DebugChannelInitializer;
|
||||||
|
|
||||||
public class NettyClientPermeateServerVisitorFilter extends DebugChannelInitializer<SocketChannel> {
|
public class NettyTcpClientPermeateServerVisitorFilter extends DebugChannelInitializer<SocketChannel> {
|
||||||
|
|
||||||
private final InternalNetworkClientPermeateServerVisitor internalNetworkClientPermeateServerVisitor;
|
private final InternalNetworkClientPermeateServerVisitor internalNetworkClientPermeateServerVisitor;
|
||||||
|
|
||||||
public NettyClientPermeateServerVisitorFilter(InternalNetworkClientPermeateServerVisitor internalNetworkClientPermeateServerVisitor) {
|
public NettyTcpClientPermeateServerVisitorFilter(InternalNetworkClientPermeateServerVisitor internalNetworkClientPermeateServerVisitor) {
|
||||||
this.internalNetworkClientPermeateServerVisitor = internalNetworkClientPermeateServerVisitor;
|
this.internalNetworkClientPermeateServerVisitor = internalNetworkClientPermeateServerVisitor;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -31,6 +31,6 @@ public class NettyClientPermeateServerVisitorFilter extends DebugChannelInitiali
|
|||||||
protected void initChannel0(SocketChannel ch) throws Exception {
|
protected void initChannel0(SocketChannel ch) throws Exception {
|
||||||
ChannelPipeline pipeline = ch.pipeline();
|
ChannelPipeline pipeline = ch.pipeline();
|
||||||
pipeline.addLast(new ChannelDuplexHandler());
|
pipeline.addLast(new ChannelDuplexHandler());
|
||||||
pipeline.addLast(new NettyClientPermeateServerVisitorHandler(internalNetworkClientPermeateServerVisitor));
|
pipeline.addLast(new NettyTcpClientPermeateServerVisitorHandler(internalNetworkClientPermeateServerVisitor));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,12 +3,12 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.filter;
|
|||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import io.netty.channel.ChannelPipeline;
|
import io.netty.channel.ChannelPipeline;
|
||||||
import io.netty.channel.socket.SocketChannel;
|
import io.netty.channel.socket.SocketChannel;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.handler.NettyServerPermeateClientRealHandler;
|
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.handler.NettyTcpServerPermeateClientRealHandler;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.decoder.TransferDecoder;
|
import org.framework.lazy.cloud.network.heartbeat.common.decoder.TransferDecoder;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.encoder.TransferEncoder;
|
import org.framework.lazy.cloud.network.heartbeat.common.encoder.TransferEncoder;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.filter.DebugChannelInitializer;
|
import org.framework.lazy.cloud.network.heartbeat.common.filter.DebugChannelInitializer;
|
||||||
|
|
||||||
public class NettyServerPermeateClientRealFilter extends DebugChannelInitializer<SocketChannel> {
|
public class NettyTcpServerPermeateClientRealFilter extends DebugChannelInitializer<SocketChannel> {
|
||||||
/**
|
/**
|
||||||
* This method will be called once the {@link Channel} was registered. After the method returns this instance
|
* This method will be called once the {@link Channel} was registered. After the method returns this instance
|
||||||
* will be removed from the {@link ChannelPipeline} of the {@link Channel}.
|
* will be removed from the {@link ChannelPipeline} of the {@link Channel}.
|
||||||
@ -21,7 +21,7 @@ public class NettyServerPermeateClientRealFilter extends DebugChannelInitializer
|
|||||||
// 解码、编码
|
// 解码、编码
|
||||||
pipeline.addLast(new TransferDecoder(Integer.MAX_VALUE, 1024 * 1024*10));
|
pipeline.addLast(new TransferDecoder(Integer.MAX_VALUE, 1024 * 1024*10));
|
||||||
pipeline.addLast(new TransferEncoder());
|
pipeline.addLast(new TransferEncoder());
|
||||||
pipeline.addLast(new NettyServerPermeateClientRealHandler());
|
pipeline.addLast(new NettyTcpServerPermeateClientRealHandler());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,7 +4,7 @@ import io.netty.channel.Channel;
|
|||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.channel.ChannelPipeline;
|
import io.netty.channel.ChannelPipeline;
|
||||||
import io.netty.channel.socket.SocketChannel;
|
import io.netty.channel.socket.SocketChannel;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.handler.NettyServerPermeateClientTransferHandler;
|
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.handler.NettyTcpServerPermeateClientTransferHandler;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
|
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.decoder.NettyProxyMsgDecoder;
|
import org.framework.lazy.cloud.network.heartbeat.common.decoder.NettyProxyMsgDecoder;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.encoder.NettyProxyMsgEncoder;
|
import org.framework.lazy.cloud.network.heartbeat.common.encoder.NettyProxyMsgEncoder;
|
||||||
@ -13,10 +13,10 @@ import org.framework.lazy.cloud.network.heartbeat.common.filter.DebugChannelInit
|
|||||||
/**
|
/**
|
||||||
* netty 客户端连接真实服服务端访客拦截器
|
* netty 客户端连接真实服服务端访客拦截器
|
||||||
*/
|
*/
|
||||||
public class NettyServerPermeateClientTransferFilter extends DebugChannelInitializer<SocketChannel> {
|
public class NettyTcpServerPermeateClientTransferFilter extends DebugChannelInitializer<SocketChannel> {
|
||||||
private final ChannelTypeAdapter channelTypeAdapter;
|
private final ChannelTypeAdapter channelTypeAdapter;
|
||||||
|
|
||||||
public NettyServerPermeateClientTransferFilter(ChannelTypeAdapter channelTypeAdapter) {
|
public NettyTcpServerPermeateClientTransferFilter(ChannelTypeAdapter channelTypeAdapter) {
|
||||||
this.channelTypeAdapter = channelTypeAdapter;
|
this.channelTypeAdapter = channelTypeAdapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,6 +37,6 @@ public class NettyServerPermeateClientTransferFilter extends DebugChannelInitial
|
|||||||
// pipeline.addLast(new NettMsgEncoder());
|
// pipeline.addLast(new NettMsgEncoder());
|
||||||
pipeline.addLast(new NettyProxyMsgDecoder(Integer.MAX_VALUE, 0, 4, -4, 0));
|
pipeline.addLast(new NettyProxyMsgDecoder(Integer.MAX_VALUE, 0, 4, -4, 0));
|
||||||
pipeline.addLast(new NettyProxyMsgEncoder());
|
pipeline.addLast(new NettyProxyMsgEncoder());
|
||||||
pipeline.addLast(new NettyServerPermeateClientTransferHandler(channelTypeAdapter));
|
pipeline.addLast(new NettyTcpServerPermeateClientTransferHandler(channelTypeAdapter));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -7,7 +7,7 @@ import io.netty.channel.SimpleChannelInboundHandler;
|
|||||||
import io.netty.handler.timeout.IdleState;
|
import io.netty.handler.timeout.IdleState;
|
||||||
import io.netty.handler.timeout.IdleStateEvent;
|
import io.netty.handler.timeout.IdleStateEvent;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.socket.NettyClientSocket;
|
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.socket.NettyTcpClientSocket;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.MessageType;
|
import org.framework.lazy.cloud.network.heartbeat.common.MessageType;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
|
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
|
||||||
@ -23,15 +23,15 @@ import java.util.concurrent.TimeUnit;
|
|||||||
* @date 2023/09/13 10:29
|
* @date 2023/09/13 10:29
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class NettyClientHandler extends SimpleChannelInboundHandler<NettyProxyMsg> {
|
public class NettyTcpClientHandler extends SimpleChannelInboundHandler<NettyProxyMsg> {
|
||||||
|
|
||||||
private final ChannelTypeAdapter channelTypeAdapter;
|
private final ChannelTypeAdapter channelTypeAdapter;
|
||||||
private final NettyClientSocket nettyClientSocket;
|
private final NettyTcpClientSocket nettyTcpClientSocket;
|
||||||
|
|
||||||
|
|
||||||
public NettyClientHandler(ChannelTypeAdapter channelTypeAdapter, NettyClientSocket nettyClientSocket) {
|
public NettyTcpClientHandler(ChannelTypeAdapter channelTypeAdapter, NettyTcpClientSocket nettyTcpClientSocket) {
|
||||||
this.channelTypeAdapter = channelTypeAdapter;
|
this.channelTypeAdapter = channelTypeAdapter;
|
||||||
this.nettyClientSocket = nettyClientSocket;
|
this.nettyTcpClientSocket = nettyTcpClientSocket;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -58,7 +58,7 @@ public class NettyClientHandler extends SimpleChannelInboundHandler<NettyProxyMs
|
|||||||
// 建立连接时
|
// 建立连接时
|
||||||
log.info("When establishing a connection:{}" , new Date());
|
log.info("When establishing a connection:{}" , new Date());
|
||||||
ctx.fireChannelActive();
|
ctx.fireChannelActive();
|
||||||
String clientId = nettyClientSocket.getClientId();
|
String clientId = nettyTcpClientSocket.getClientId();
|
||||||
// 处理客户端连接成功
|
// 处理客户端连接成功
|
||||||
Channel channel = ctx.channel();
|
Channel channel = ctx.channel();
|
||||||
NettyProxyMsg nettyMsg = new NettyProxyMsg();
|
NettyProxyMsg nettyMsg = new NettyProxyMsg();
|
||||||
@ -79,7 +79,7 @@ public class NettyClientHandler extends SimpleChannelInboundHandler<NettyProxyMs
|
|||||||
final EventLoop eventLoop = ctx.channel().eventLoop();
|
final EventLoop eventLoop = ctx.channel().eventLoop();
|
||||||
eventLoop.schedule(() -> {
|
eventLoop.schedule(() -> {
|
||||||
try {
|
try {
|
||||||
nettyClientSocket.newConnect2Server();
|
nettyTcpClientSocket.newConnect2Server();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
@ -95,7 +95,7 @@ public class NettyClientHandler extends SimpleChannelInboundHandler<NettyProxyMs
|
|||||||
public void userEventTriggered(ChannelHandlerContext ctx, Object obj) throws Exception {
|
public void userEventTriggered(ChannelHandlerContext ctx, Object obj) throws Exception {
|
||||||
if (obj instanceof IdleStateEvent event) {
|
if (obj instanceof IdleStateEvent event) {
|
||||||
if (IdleState.WRITER_IDLE.equals(event.state())) { //如果写通道处于空闲状态,就发送心跳命令
|
if (IdleState.WRITER_IDLE.equals(event.state())) { //如果写通道处于空闲状态,就发送心跳命令
|
||||||
String clientId = nettyClientSocket.getClientId();
|
String clientId = nettyTcpClientSocket.getClientId();
|
||||||
NettyProxyMsg nettyMsg = new NettyProxyMsg();
|
NettyProxyMsg nettyMsg = new NettyProxyMsg();
|
||||||
nettyMsg.setType(MessageType.TCP_TYPE_HEARTBEAT);
|
nettyMsg.setType(MessageType.TCP_TYPE_HEARTBEAT);
|
||||||
nettyMsg.setData(clientId.getBytes(StandardCharsets.UTF_8));
|
nettyMsg.setData(clientId.getBytes(StandardCharsets.UTF_8));
|
||||||
@ -103,7 +103,7 @@ public class NettyClientHandler extends SimpleChannelInboundHandler<NettyProxyMs
|
|||||||
ctx.writeAndFlush(nettyMsg);// 发送心跳数据
|
ctx.writeAndFlush(nettyMsg);// 发送心跳数据
|
||||||
} else if (event.state() == IdleState.WRITER_IDLE) { // 如果检测到写空闲状态,关闭连接
|
} else if (event.state() == IdleState.WRITER_IDLE) { // 如果检测到写空闲状态,关闭连接
|
||||||
// 离线、暂存通知
|
// 离线、暂存通知
|
||||||
String clientId = nettyClientSocket.getClientId();
|
String clientId = nettyTcpClientSocket.getClientId();
|
||||||
Channel channel = ctx.channel();
|
Channel channel = ctx.channel();
|
||||||
NettyProxyMsg nettyMsg = new NettyProxyMsg();
|
NettyProxyMsg nettyMsg = new NettyProxyMsg();
|
||||||
nettyMsg.setType(MessageType.TCP_DISTRIBUTE_CLIENT_DISCONNECTION_NOTIFICATION);
|
nettyMsg.setType(MessageType.TCP_DISTRIBUTE_CLIENT_DISCONNECTION_NOTIFICATION);
|
@ -3,21 +3,18 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.handler;
|
|||||||
|
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.channel.ChannelOption;
|
|
||||||
import io.netty.channel.SimpleChannelInboundHandler;
|
import io.netty.channel.SimpleChannelInboundHandler;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.MessageType;
|
import org.framework.lazy.cloud.network.heartbeat.common.MessageType;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyByteBuf;
|
import org.framework.lazy.cloud.network.heartbeat.common.NettyByteBuf;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyCommunicationIdContext;
|
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
|
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
|
||||||
import org.wu.framework.core.utils.ObjectUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 来自客户端 真实服务器返回的数据请求
|
* 来自客户端 真实服务器返回的数据请求
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class NettyClientPermeateClientRealHandler extends SimpleChannelInboundHandler<NettyByteBuf> {
|
public class NettyTcpClientPermeateClientRealHandler extends SimpleChannelInboundHandler<NettyByteBuf> {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
@ -3,25 +3,21 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.handler;
|
|||||||
|
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.channel.ChannelOption;
|
|
||||||
import io.netty.channel.SimpleChannelInboundHandler;
|
import io.netty.channel.SimpleChannelInboundHandler;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.ChannelContext;
|
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.MessageType;
|
import org.framework.lazy.cloud.network.heartbeat.common.MessageType;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyRealIdContext;
|
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
|
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
|
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
|
||||||
import org.wu.framework.core.utils.ObjectUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 客户端访客通信通道 处理器
|
* 客户端访客通信通道 处理器
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class NettyClientPermeateClientTransferHandler extends SimpleChannelInboundHandler<NettyProxyMsg> {
|
public class NettyTcpClientPermeateClientTransferHandler extends SimpleChannelInboundHandler<NettyProxyMsg> {
|
||||||
private final ChannelTypeAdapter channelTypeAdapter;
|
private final ChannelTypeAdapter channelTypeAdapter;
|
||||||
|
|
||||||
public NettyClientPermeateClientTransferHandler(ChannelTypeAdapter channelTypeAdapter) {
|
public NettyTcpClientPermeateClientTransferHandler(ChannelTypeAdapter channelTypeAdapter) {
|
||||||
this.channelTypeAdapter = channelTypeAdapter;
|
this.channelTypeAdapter = channelTypeAdapter;
|
||||||
}
|
}
|
||||||
|
|
@ -3,24 +3,21 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.handler;
|
|||||||
|
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.channel.ChannelOption;
|
|
||||||
import io.netty.channel.SimpleChannelInboundHandler;
|
import io.netty.channel.SimpleChannelInboundHandler;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.MessageType;
|
import org.framework.lazy.cloud.network.heartbeat.common.MessageType;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyRealIdContext;
|
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
|
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
|
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
|
||||||
import org.wu.framework.core.utils.ObjectUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 客户端访客通信通道 处理器
|
* 客户端访客通信通道 处理器
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class NettyClientPermeateClientTransferRealHandler extends SimpleChannelInboundHandler<NettyProxyMsg> {
|
public class NettyTcpClientPermeateClientTransferRealHandler extends SimpleChannelInboundHandler<NettyProxyMsg> {
|
||||||
private final ChannelTypeAdapter channelTypeAdapter;
|
private final ChannelTypeAdapter channelTypeAdapter;
|
||||||
|
|
||||||
public NettyClientPermeateClientTransferRealHandler(ChannelTypeAdapter channelTypeAdapter) {
|
public NettyTcpClientPermeateClientTransferRealHandler(ChannelTypeAdapter channelTypeAdapter) {
|
||||||
this.channelTypeAdapter = channelTypeAdapter;
|
this.channelTypeAdapter = channelTypeAdapter;
|
||||||
}
|
}
|
||||||
|
|
@ -10,8 +10,8 @@ import io.netty.util.internal.StringUtil;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.InternalNetworkClientPermeateClientVisitor;
|
import org.framework.lazy.cloud.network.heartbeat.client.netty.InternalNetworkClientPermeateClientVisitor;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.advanced.ClientHandleTcpDistributeClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced;
|
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.advanced.ClientHandleTcpDistributeClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.socket.NettyClientPermeateClientVisitorTransferSocket;
|
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.socket.NettyTcpClientPermeateClientVisitorTransferSocket;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.socket.NettyClientPermeateServerVisitorTransferSocket;
|
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.socket.NettyTcpClientPermeateServerVisitorTransferSocket;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.MessageType;
|
import org.framework.lazy.cloud.network.heartbeat.common.MessageType;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyCommunicationIdContext;
|
import org.framework.lazy.cloud.network.heartbeat.common.NettyCommunicationIdContext;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
||||||
@ -21,18 +21,18 @@ import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeK
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class NettyClientPermeateClientVisitorHandler extends SimpleChannelInboundHandler<ByteBuf> {
|
public class NettyTcpClientPermeateClientVisitorHandler extends SimpleChannelInboundHandler<ByteBuf> {
|
||||||
private final InternalNetworkClientPermeateClientVisitor internalNetworkClientPermeateClientVisitor;
|
private final InternalNetworkClientPermeateClientVisitor internalNetworkClientPermeateClientVisitor;
|
||||||
// private final NettyChannelPool nettyChannelPool = new DefaultNettyChannelPool(10);
|
// private final NettyChannelPool nettyChannelPool = new DefaultNettyChannelPool(10);
|
||||||
|
|
||||||
public NettyClientPermeateClientVisitorHandler(InternalNetworkClientPermeateClientVisitor internalNetworkClientPermeateClientVisitor) {
|
public NettyTcpClientPermeateClientVisitorHandler(InternalNetworkClientPermeateClientVisitor internalNetworkClientPermeateClientVisitor) {
|
||||||
this.internalNetworkClientPermeateClientVisitor = internalNetworkClientPermeateClientVisitor;
|
this.internalNetworkClientPermeateClientVisitor = internalNetworkClientPermeateClientVisitor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ctx
|
* @param ctx
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
* @see NettyClientPermeateServerVisitorTransferSocket
|
* @see NettyTcpClientPermeateServerVisitorTransferSocket
|
||||||
* @see ClientHandleTcpDistributeClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced
|
* @see ClientHandleTcpDistributeClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@ -53,7 +53,7 @@ public class NettyClientPermeateClientVisitorHandler extends SimpleChannelInbou
|
|||||||
// 判断是否有可用的通道 如果没有创建新的通道
|
// 判断是否有可用的通道 如果没有创建新的通道
|
||||||
// Channel transferChannel = nettyChannelPool.availableChannel(visitorId);
|
// Channel transferChannel = nettyChannelPool.availableChannel(visitorId);
|
||||||
// 创建访客连接客户端通道
|
// 创建访客连接客户端通道
|
||||||
NettyClientPermeateClientVisitorTransferSocket.buildTransferServer(internalNetworkClientPermeateClientVisitor,visitorChannel);
|
NettyTcpClientPermeateClientVisitorTransferSocket.buildTransferServer(internalNetworkClientPermeateClientVisitor,visitorChannel);
|
||||||
log.info("客户端渗透客户端访客:【{}】端口连接成功了",visitorId);
|
log.info("客户端渗透客户端访客:【{}】端口连接成功了",visitorId);
|
||||||
super.channelActive(ctx);
|
super.channelActive(ctx);
|
||||||
}
|
}
|
@ -12,16 +12,14 @@ import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
|||||||
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
|
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
|
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 客户端访客通信通道 处理器
|
* 客户端访客通信通道 处理器
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class NettyClientPermeateServerTransferHandler extends SimpleChannelInboundHandler<NettyProxyMsg> {
|
public class NettyTcpClientPermeateServerTransferHandler extends SimpleChannelInboundHandler<NettyProxyMsg> {
|
||||||
private final ChannelTypeAdapter channelTypeAdapter;
|
private final ChannelTypeAdapter channelTypeAdapter;
|
||||||
|
|
||||||
public NettyClientPermeateServerTransferHandler(ChannelTypeAdapter channelTypeAdapter) {
|
public NettyTcpClientPermeateServerTransferHandler(ChannelTypeAdapter channelTypeAdapter) {
|
||||||
this.channelTypeAdapter = channelTypeAdapter;
|
this.channelTypeAdapter = channelTypeAdapter;
|
||||||
}
|
}
|
||||||
|
|
@ -10,7 +10,7 @@ import io.netty.util.internal.StringUtil;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.InternalNetworkClientPermeateServerVisitor;
|
import org.framework.lazy.cloud.network.heartbeat.client.netty.InternalNetworkClientPermeateServerVisitor;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.advanced.ClientHandleTcpDistributeClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced;
|
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.advanced.ClientHandleTcpDistributeClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.socket.NettyClientPermeateServerVisitorTransferSocket;
|
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.socket.NettyTcpClientPermeateServerVisitorTransferSocket;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.MessageType;
|
import org.framework.lazy.cloud.network.heartbeat.common.MessageType;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
|
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
|
||||||
@ -18,18 +18,18 @@ import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeK
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class NettyClientPermeateServerVisitorHandler extends SimpleChannelInboundHandler<ByteBuf> {
|
public class NettyTcpClientPermeateServerVisitorHandler extends SimpleChannelInboundHandler<ByteBuf> {
|
||||||
private final InternalNetworkClientPermeateServerVisitor internalNetworkClientPermeateServerVisitor;
|
private final InternalNetworkClientPermeateServerVisitor internalNetworkClientPermeateServerVisitor;
|
||||||
// private final NettyChannelPool nettyChannelPool = new DefaultNettyChannelPool(10);
|
// private final NettyChannelPool nettyChannelPool = new DefaultNettyChannelPool(10);
|
||||||
|
|
||||||
public NettyClientPermeateServerVisitorHandler(InternalNetworkClientPermeateServerVisitor internalNetworkClientPermeateServerVisitor) {
|
public NettyTcpClientPermeateServerVisitorHandler(InternalNetworkClientPermeateServerVisitor internalNetworkClientPermeateServerVisitor) {
|
||||||
this.internalNetworkClientPermeateServerVisitor = internalNetworkClientPermeateServerVisitor;
|
this.internalNetworkClientPermeateServerVisitor = internalNetworkClientPermeateServerVisitor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ctx
|
* @param ctx
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
* @see NettyClientPermeateServerVisitorTransferSocket
|
* @see NettyTcpClientPermeateServerVisitorTransferSocket
|
||||||
* @see ClientHandleTcpDistributeClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced
|
* @see ClientHandleTcpDistributeClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@ -48,7 +48,7 @@ public class NettyClientPermeateServerVisitorHandler extends SimpleChannelInboun
|
|||||||
// 判断是否有可用的通道 如果没有创建新的通道
|
// 判断是否有可用的通道 如果没有创建新的通道
|
||||||
// Channel transferChannel = nettyChannelPool.availableChannel(visitorId);
|
// Channel transferChannel = nettyChannelPool.availableChannel(visitorId);
|
||||||
// 创建访客连接服务端通道
|
// 创建访客连接服务端通道
|
||||||
NettyClientPermeateServerVisitorTransferSocket.buildTransferServer(internalNetworkClientPermeateServerVisitor,visitorChannel);
|
NettyTcpClientPermeateServerVisitorTransferSocket.buildTransferServer(internalNetworkClientPermeateServerVisitor,visitorChannel);
|
||||||
log.debug("客户端渗透服务端访客端口连接成功了,访客ID:{}", visitorId);
|
log.debug("客户端渗透服务端访客端口连接成功了,访客ID:{}", visitorId);
|
||||||
super.channelActive(ctx);
|
super.channelActive(ctx);
|
||||||
}
|
}
|
@ -16,7 +16,7 @@ import org.wu.framework.core.utils.ObjectUtils;
|
|||||||
* 来自客户端 真实服务器返回的数据请求
|
* 来自客户端 真实服务器返回的数据请求
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class NettyServerPermeateClientRealHandler extends SimpleChannelInboundHandler<NettyByteBuf> {
|
public class NettyTcpServerPermeateClientRealHandler extends SimpleChannelInboundHandler<NettyByteBuf> {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
@ -15,10 +15,10 @@ import org.wu.framework.core.utils.ObjectUtils;
|
|||||||
* 客户端访客通信通道 处理器
|
* 客户端访客通信通道 处理器
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class NettyServerPermeateClientTransferHandler extends SimpleChannelInboundHandler<NettyProxyMsg> {
|
public class NettyTcpServerPermeateClientTransferHandler extends SimpleChannelInboundHandler<NettyProxyMsg> {
|
||||||
private final ChannelTypeAdapter channelTypeAdapter;
|
private final ChannelTypeAdapter channelTypeAdapter;
|
||||||
|
|
||||||
public NettyServerPermeateClientTransferHandler(ChannelTypeAdapter channelTypeAdapter) {
|
public NettyTcpServerPermeateClientTransferHandler(ChannelTypeAdapter channelTypeAdapter) {
|
||||||
this.channelTypeAdapter = channelTypeAdapter;
|
this.channelTypeAdapter = channelTypeAdapter;
|
||||||
}
|
}
|
||||||
|
|
@ -7,7 +7,7 @@ import io.netty.handler.timeout.IdleStateEvent;
|
|||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
public class HeartBeatClientHandler extends ChannelInboundHandlerAdapter {
|
public class TcpHeartBeatClientHandler extends ChannelInboundHandlerAdapter {
|
||||||
private final int lossConnectCount = 0;
|
private final int lossConnectCount = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
@ -7,8 +7,8 @@ import io.netty.channel.nio.NioEventLoopGroup;
|
|||||||
import io.netty.channel.socket.nio.NioSocketChannel;
|
import io.netty.channel.socket.nio.NioSocketChannel;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
|
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.filter.NettyClientPermeateClientRealFilter;
|
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.filter.NettyTcpClientPermeateClientRealFilter;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.filter.NettyClientPermeateClientTransferRealFilter;
|
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.filter.NettyTcpClientPermeateClientTransferRealFilter;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.*;
|
import org.framework.lazy.cloud.network.heartbeat.common.*;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
|
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
|
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
|
||||||
@ -21,7 +21,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
* 客户端连接真实服务
|
* 客户端连接真实服务
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class NettyClientPermeateClientRealSocket {
|
public class NettyTcpClientPermeateClientRealSocket {
|
||||||
static EventLoopGroup eventLoopGroup = new NioEventLoopGroup();
|
static EventLoopGroup eventLoopGroup = new NioEventLoopGroup();
|
||||||
|
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ public class NettyClientPermeateClientRealSocket {
|
|||||||
// .option(ChannelOption.SO_BACKLOG, 128)//务端接受连接的队列长度 默认128
|
// .option(ChannelOption.SO_BACKLOG, 128)//务端接受连接的队列长度 默认128
|
||||||
// .option(ChannelOption.RCVBUF_ALLOCATOR, new NettyRecvByteBufAllocator(1024 * 1024))//用于Channel分配接受Buffer的分配器 默认AdaptiveRecvByteBufAllocator.DEFAULT
|
// .option(ChannelOption.RCVBUF_ALLOCATOR, new NettyRecvByteBufAllocator(1024 * 1024))//用于Channel分配接受Buffer的分配器 默认AdaptiveRecvByteBufAllocator.DEFAULT
|
||||||
.option(ChannelOption.WRITE_BUFFER_WATER_MARK, new WriteBufferWaterMark(1024 * 1024, 1024 * 1024 * 2))
|
.option(ChannelOption.WRITE_BUFFER_WATER_MARK, new WriteBufferWaterMark(1024 * 1024, 1024 * 1024 * 2))
|
||||||
.handler(new NettyClientPermeateClientRealFilter())
|
.handler(new NettyTcpClientPermeateClientRealFilter())
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -113,7 +113,7 @@ public class NettyClientPermeateClientRealSocket {
|
|||||||
|
|
||||||
.option(ChannelOption.WRITE_BUFFER_WATER_MARK, new WriteBufferWaterMark(1024 * 1024, 1024 * 1024 * 2))
|
.option(ChannelOption.WRITE_BUFFER_WATER_MARK, new WriteBufferWaterMark(1024 * 1024, 1024 * 1024 * 2))
|
||||||
|
|
||||||
.handler(new NettyClientPermeateClientTransferRealFilter(new ChannelTypeAdapter(handleChannelTypeAdvancedList)))
|
.handler(new NettyTcpClientPermeateClientTransferRealFilter(new ChannelTypeAdapter(handleChannelTypeAdvancedList)))
|
||||||
;
|
;
|
||||||
|
|
||||||
String inetHost = nettyClientProperties.getInetHost();
|
String inetHost = nettyClientProperties.getInetHost();
|
@ -8,7 +8,7 @@ import lombok.Getter;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
|
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.InternalNetworkClientPermeateClientVisitor;
|
import org.framework.lazy.cloud.network.heartbeat.client.netty.InternalNetworkClientPermeateClientVisitor;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.filter.NettyClientPermeateClientVisitorFilter;
|
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.filter.NettyTcpClientPermeateClientVisitorFilter;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyClientVisitorContext;
|
import org.framework.lazy.cloud.network.heartbeat.common.NettyClientVisitorContext;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyVisitorPortContext;
|
import org.framework.lazy.cloud.network.heartbeat.common.NettyVisitorPortContext;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelFlowAdapter;
|
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelFlowAdapter;
|
||||||
@ -25,17 +25,17 @@ import java.util.List;
|
|||||||
* @see NettyClientVisitorContext
|
* @see NettyClientVisitorContext
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class NettyClientPermeateClientVisitorSocket implements PermeateVisitorSocket {
|
public class NettyTcpClientPermeateClientVisitorSocket implements PermeateVisitorSocket {
|
||||||
private final EventLoopGroup bossGroup = new NioEventLoopGroup();
|
private final EventLoopGroup bossGroup = new NioEventLoopGroup();
|
||||||
private final EventLoopGroup workerGroup = new NioEventLoopGroup();
|
private final EventLoopGroup workerGroup = new NioEventLoopGroup();
|
||||||
private final NettyClientPermeateClientVisitorFilter nettyClientPermeateClientVisitorFilter;
|
private final NettyTcpClientPermeateClientVisitorFilter nettyTcpClientPermeateClientVisitorFilter;
|
||||||
@Getter
|
@Getter
|
||||||
private final String clientId;
|
private final String clientId;
|
||||||
@Getter
|
@Getter
|
||||||
private final int visitorPort;
|
private final int visitorPort;
|
||||||
|
|
||||||
public NettyClientPermeateClientVisitorSocket(NettyClientPermeateClientVisitorFilter nettyClientPermeateClientVisitorFilter, String clientId, int visitorPort) {
|
public NettyTcpClientPermeateClientVisitorSocket(NettyTcpClientPermeateClientVisitorFilter nettyTcpClientPermeateClientVisitorFilter, String clientId, int visitorPort) {
|
||||||
this.nettyClientPermeateClientVisitorFilter = nettyClientPermeateClientVisitorFilter;
|
this.nettyTcpClientPermeateClientVisitorFilter = nettyTcpClientPermeateClientVisitorFilter;
|
||||||
this.clientId = clientId;
|
this.clientId = clientId;
|
||||||
this.visitorPort = visitorPort;
|
this.visitorPort = visitorPort;
|
||||||
}
|
}
|
||||||
@ -68,7 +68,7 @@ public class NettyClientPermeateClientVisitorSocket implements PermeateVisitorSo
|
|||||||
.childOption(ChannelOption.WRITE_BUFFER_WATER_MARK, new WriteBufferWaterMark(1024 * 1024, 1024 * 1024 * 2))
|
.childOption(ChannelOption.WRITE_BUFFER_WATER_MARK, new WriteBufferWaterMark(1024 * 1024, 1024 * 1024 * 2))
|
||||||
|
|
||||||
|
|
||||||
.childHandler(nettyClientPermeateClientVisitorFilter);
|
.childHandler(nettyTcpClientPermeateClientVisitorFilter);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
bootstrap.bind(visitorPort).sync().addListener((ChannelFutureListener) future -> {
|
bootstrap.bind(visitorPort).sync().addListener((ChannelFutureListener) future -> {
|
||||||
@ -260,7 +260,7 @@ public class NettyClientPermeateClientVisitorSocket implements PermeateVisitorSo
|
|||||||
this.toClientId = toClientId;
|
this.toClientId = toClientId;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public NettyClientPermeateClientVisitorSocket build() {
|
public NettyTcpClientPermeateClientVisitorSocket build() {
|
||||||
if (clientTargetIp == null) {
|
if (clientTargetIp == null) {
|
||||||
throw new IllegalArgumentException("clientTargetIp must not null");
|
throw new IllegalArgumentException("clientTargetIp must not null");
|
||||||
}
|
}
|
||||||
@ -282,8 +282,8 @@ public class NettyClientPermeateClientVisitorSocket implements PermeateVisitorSo
|
|||||||
internalNetworkClientPermeateClientVisitor.setHandleChannelTypeAdvancedList(handleChannelTypeAdvancedList);
|
internalNetworkClientPermeateClientVisitor.setHandleChannelTypeAdvancedList(handleChannelTypeAdvancedList);
|
||||||
|
|
||||||
|
|
||||||
NettyClientPermeateClientVisitorFilter visitorFilter = new NettyClientPermeateClientVisitorFilter(internalNetworkClientPermeateClientVisitor);
|
NettyTcpClientPermeateClientVisitorFilter visitorFilter = new NettyTcpClientPermeateClientVisitorFilter(internalNetworkClientPermeateClientVisitor);
|
||||||
return new NettyClientPermeateClientVisitorSocket(visitorFilter, clientId, visitorPort);
|
return new NettyTcpClientPermeateClientVisitorSocket(visitorFilter, clientId, visitorPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -8,7 +8,7 @@ import io.netty.channel.socket.nio.NioSocketChannel;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
|
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.InternalNetworkClientPermeateClientVisitor;
|
import org.framework.lazy.cloud.network.heartbeat.client.netty.InternalNetworkClientPermeateClientVisitor;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.filter.NettyClientPermeateClientTransferFilter;
|
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.filter.NettyTcpClientPermeateClientTransferFilter;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.MessageType;
|
import org.framework.lazy.cloud.network.heartbeat.common.MessageType;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
|
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
|
||||||
@ -20,7 +20,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
* 客户端渗透服务端传输通道
|
* 客户端渗透服务端传输通道
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class NettyClientPermeateClientVisitorTransferSocket {
|
public class NettyTcpClientPermeateClientVisitorTransferSocket {
|
||||||
static EventLoopGroup eventLoopGroup = new NioEventLoopGroup();
|
static EventLoopGroup eventLoopGroup = new NioEventLoopGroup();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -43,7 +43,7 @@ public class NettyClientPermeateClientVisitorTransferSocket {
|
|||||||
// .option(ChannelOption.RCVBUF_ALLOCATOR, new NettyRecvByteBufAllocator(1024 * 1024))//用于Channel分配接受Buffer的分配器 默认AdaptiveRecvByteBufAllocator.DEFAULT
|
// .option(ChannelOption.RCVBUF_ALLOCATOR, new NettyRecvByteBufAllocator(1024 * 1024))//用于Channel分配接受Buffer的分配器 默认AdaptiveRecvByteBufAllocator.DEFAULT
|
||||||
|
|
||||||
.option(ChannelOption.WRITE_BUFFER_WATER_MARK, new WriteBufferWaterMark(1024 * 1024, 1024 * 1024 * 2))
|
.option(ChannelOption.WRITE_BUFFER_WATER_MARK, new WriteBufferWaterMark(1024 * 1024, 1024 * 1024 * 2))
|
||||||
.handler(new NettyClientPermeateClientTransferFilter(new ChannelTypeAdapter(internalNetworkClientPermeateClientVisitor.getHandleChannelTypeAdvancedList())))
|
.handler(new NettyTcpClientPermeateClientTransferFilter(new ChannelTypeAdapter(internalNetworkClientPermeateClientVisitor.getHandleChannelTypeAdvancedList())))
|
||||||
;
|
;
|
||||||
NettyClientProperties nettyClientProperties = internalNetworkClientPermeateClientVisitor.getNettyClientProperties();
|
NettyClientProperties nettyClientProperties = internalNetworkClientPermeateClientVisitor.getNettyClientProperties();
|
||||||
String inetHost = nettyClientProperties.getInetHost();
|
String inetHost = nettyClientProperties.getInetHost();
|
@ -8,7 +8,7 @@ import lombok.Getter;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
|
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.InternalNetworkClientPermeateServerVisitor;
|
import org.framework.lazy.cloud.network.heartbeat.client.netty.InternalNetworkClientPermeateServerVisitor;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.filter.NettyClientPermeateServerVisitorFilter;
|
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.filter.NettyTcpClientPermeateServerVisitorFilter;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyClientVisitorContext;
|
import org.framework.lazy.cloud.network.heartbeat.common.NettyClientVisitorContext;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyVisitorPortContext;
|
import org.framework.lazy.cloud.network.heartbeat.common.NettyVisitorPortContext;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
|
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
|
||||||
@ -24,17 +24,17 @@ import java.util.List;
|
|||||||
* @see NettyClientVisitorContext
|
* @see NettyClientVisitorContext
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class NettyClientPermeateServerVisitorSocket implements PermeateVisitorSocket {
|
public class NettyTcpClientPermeateServerVisitorSocket implements PermeateVisitorSocket {
|
||||||
private final EventLoopGroup bossGroup = new NioEventLoopGroup();
|
private final EventLoopGroup bossGroup = new NioEventLoopGroup();
|
||||||
private final EventLoopGroup workerGroup = new NioEventLoopGroup();
|
private final EventLoopGroup workerGroup = new NioEventLoopGroup();
|
||||||
private final NettyClientPermeateServerVisitorFilter nettyClientPermeateServerVisitorFilter;
|
private final NettyTcpClientPermeateServerVisitorFilter nettyTcpClientPermeateServerVisitorFilter;
|
||||||
@Getter
|
@Getter
|
||||||
private final String clientId;
|
private final String clientId;
|
||||||
@Getter
|
@Getter
|
||||||
private final int visitorPort;
|
private final int visitorPort;
|
||||||
|
|
||||||
public NettyClientPermeateServerVisitorSocket(NettyClientPermeateServerVisitorFilter nettyClientPermeateServerVisitorFilter, String clientId, int visitorPort) {
|
public NettyTcpClientPermeateServerVisitorSocket(NettyTcpClientPermeateServerVisitorFilter nettyTcpClientPermeateServerVisitorFilter, String clientId, int visitorPort) {
|
||||||
this.nettyClientPermeateServerVisitorFilter = nettyClientPermeateServerVisitorFilter;
|
this.nettyTcpClientPermeateServerVisitorFilter = nettyTcpClientPermeateServerVisitorFilter;
|
||||||
this.clientId = clientId;
|
this.clientId = clientId;
|
||||||
this.visitorPort = visitorPort;
|
this.visitorPort = visitorPort;
|
||||||
}
|
}
|
||||||
@ -67,7 +67,7 @@ public class NettyClientPermeateServerVisitorSocket implements PermeateVisitorSo
|
|||||||
.childOption(ChannelOption.WRITE_BUFFER_WATER_MARK, new WriteBufferWaterMark(1024 * 1024, 1024 * 1024 * 2))
|
.childOption(ChannelOption.WRITE_BUFFER_WATER_MARK, new WriteBufferWaterMark(1024 * 1024, 1024 * 1024 * 2))
|
||||||
|
|
||||||
|
|
||||||
.childHandler(nettyClientPermeateServerVisitorFilter);
|
.childHandler(nettyTcpClientPermeateServerVisitorFilter);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
bootstrap.bind(visitorPort).sync().addListener((ChannelFutureListener) future -> {
|
bootstrap.bind(visitorPort).sync().addListener((ChannelFutureListener) future -> {
|
||||||
@ -208,7 +208,7 @@ public class NettyClientPermeateServerVisitorSocket implements PermeateVisitorSo
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public NettyClientPermeateServerVisitorSocket build() {
|
public NettyTcpClientPermeateServerVisitorSocket build() {
|
||||||
if (clientTargetIp == null) {
|
if (clientTargetIp == null) {
|
||||||
throw new IllegalArgumentException("clientTargetIp must not null");
|
throw new IllegalArgumentException("clientTargetIp must not null");
|
||||||
}
|
}
|
||||||
@ -227,8 +227,8 @@ public class NettyClientPermeateServerVisitorSocket implements PermeateVisitorSo
|
|||||||
internalNetworkClientPermeateServerVisitor.setHandleChannelTypeAdvancedList(handleChannelTypeAdvancedList);
|
internalNetworkClientPermeateServerVisitor.setHandleChannelTypeAdvancedList(handleChannelTypeAdvancedList);
|
||||||
|
|
||||||
|
|
||||||
NettyClientPermeateServerVisitorFilter nettyClientPermeateServerVisitorFilter = new NettyClientPermeateServerVisitorFilter(internalNetworkClientPermeateServerVisitor);
|
NettyTcpClientPermeateServerVisitorFilter nettyTcpClientPermeateServerVisitorFilter = new NettyTcpClientPermeateServerVisitorFilter(internalNetworkClientPermeateServerVisitor);
|
||||||
return new NettyClientPermeateServerVisitorSocket(nettyClientPermeateServerVisitorFilter, clientId, visitorPort);
|
return new NettyTcpClientPermeateServerVisitorSocket(nettyTcpClientPermeateServerVisitorFilter, clientId, visitorPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -8,7 +8,7 @@ import io.netty.channel.socket.nio.NioSocketChannel;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
|
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.InternalNetworkClientPermeateServerVisitor;
|
import org.framework.lazy.cloud.network.heartbeat.client.netty.InternalNetworkClientPermeateServerVisitor;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.filter.NettyClientPermeateServerTransferFilter;
|
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.filter.NettyTcpClientPermeateServerTransferFilter;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.MessageType;
|
import org.framework.lazy.cloud.network.heartbeat.common.MessageType;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
|
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
|
||||||
@ -20,7 +20,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
* 客户端渗透服务端传输通道
|
* 客户端渗透服务端传输通道
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class NettyClientPermeateServerVisitorTransferSocket {
|
public class NettyTcpClientPermeateServerVisitorTransferSocket {
|
||||||
static EventLoopGroup eventLoopGroup = new NioEventLoopGroup();
|
static EventLoopGroup eventLoopGroup = new NioEventLoopGroup();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,7 +45,7 @@ public class NettyClientPermeateServerVisitorTransferSocket {
|
|||||||
|
|
||||||
.option(ChannelOption.WRITE_BUFFER_WATER_MARK, new WriteBufferWaterMark(1024 * 1024, 1024 * 1024 * 2))
|
.option(ChannelOption.WRITE_BUFFER_WATER_MARK, new WriteBufferWaterMark(1024 * 1024, 1024 * 1024 * 2))
|
||||||
|
|
||||||
.handler(new NettyClientPermeateServerTransferFilter(new ChannelTypeAdapter(internalNetworkClientPermeateServerVisitor.getHandleChannelTypeAdvancedList())))
|
.handler(new NettyTcpClientPermeateServerTransferFilter(new ChannelTypeAdapter(internalNetworkClientPermeateServerVisitor.getHandleChannelTypeAdvancedList())))
|
||||||
;
|
;
|
||||||
NettyClientProperties nettyClientProperties = internalNetworkClientPermeateServerVisitor.getNettyClientProperties();
|
NettyClientProperties nettyClientProperties = internalNetworkClientPermeateServerVisitor.getNettyClientProperties();
|
||||||
String inetHost = nettyClientProperties.getInetHost();
|
String inetHost = nettyClientProperties.getInetHost();
|
@ -8,7 +8,7 @@ import io.netty.channel.socket.nio.NioSocketChannel;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.event.ClientChangeEvent;
|
import org.framework.lazy.cloud.network.heartbeat.client.netty.event.ClientChangeEvent;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.filter.NettyClientFilter;
|
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.filter.NettyTcpClientFilter;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.MessageType;
|
import org.framework.lazy.cloud.network.heartbeat.common.MessageType;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyServerContext;
|
import org.framework.lazy.cloud.network.heartbeat.common.NettyServerContext;
|
||||||
@ -24,7 +24,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
* 客户端连接服务端
|
* 客户端连接服务端
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class NettyClientSocket {
|
public class NettyTcpClientSocket {
|
||||||
private final EventLoopGroup eventLoopGroup = new NioEventLoopGroup();
|
private final EventLoopGroup eventLoopGroup = new NioEventLoopGroup();
|
||||||
/**
|
/**
|
||||||
* 服务端host
|
* 服务端host
|
||||||
@ -53,7 +53,7 @@ public class NettyClientSocket {
|
|||||||
private final ClientChangeEvent clientChangeEvent;
|
private final ClientChangeEvent clientChangeEvent;
|
||||||
private final List<HandleChannelTypeAdvanced> handleChannelTypeAdvancedList; // 处理服务端发送过来的数据类型
|
private final List<HandleChannelTypeAdvanced> handleChannelTypeAdvancedList; // 处理服务端发送过来的数据类型
|
||||||
|
|
||||||
public NettyClientSocket(String inetHost,
|
public NettyTcpClientSocket(String inetHost,
|
||||||
int inetPort,
|
int inetPort,
|
||||||
String clientId,
|
String clientId,
|
||||||
String serverId,
|
String serverId,
|
||||||
@ -88,7 +88,7 @@ public class NettyClientSocket {
|
|||||||
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 1000 * 60)//连接超时时间设置为 60 秒
|
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 1000 * 60)//连接超时时间设置为 60 秒
|
||||||
// .childOption(ChannelOption.RCVBUF_ALLOCATOR, new NettyRecvByteBufAllocator(1024 * 1024))//用于Channel分配接受Buffer的分配器 默认AdaptiveRecvByteBufAllocator.DEFAULT
|
// .childOption(ChannelOption.RCVBUF_ALLOCATOR, new NettyRecvByteBufAllocator(1024 * 1024))//用于Channel分配接受Buffer的分配器 默认AdaptiveRecvByteBufAllocator.DEFAULT
|
||||||
.option(ChannelOption.WRITE_BUFFER_WATER_MARK, new WriteBufferWaterMark(1024 * 1024, 1024 * 1024 * 2))
|
.option(ChannelOption.WRITE_BUFFER_WATER_MARK, new WriteBufferWaterMark(1024 * 1024, 1024 * 1024 * 2))
|
||||||
.handler(new NettyClientFilter(new ChannelTypeAdapter(handleChannelTypeAdvancedList), this))
|
.handler(new NettyTcpClientFilter(new ChannelTypeAdapter(handleChannelTypeAdvancedList), this))
|
||||||
;
|
;
|
||||||
log.info("use clientId:{} connect to server IP:{},server port :{}", clientId, inetHost, inetPort);
|
log.info("use clientId:{} connect to server IP:{},server port :{}", clientId, inetHost, inetPort);
|
||||||
ChannelFuture future = bootstrap.connect(inetHost, inetPort);
|
ChannelFuture future = bootstrap.connect(inetHost, inetPort);
|
@ -7,8 +7,8 @@ import io.netty.channel.nio.NioEventLoopGroup;
|
|||||||
import io.netty.channel.socket.nio.NioSocketChannel;
|
import io.netty.channel.socket.nio.NioSocketChannel;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
|
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.filter.NettyServerPermeateClientRealFilter;
|
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.filter.NettyTcpServerPermeateClientRealFilter;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.filter.NettyServerPermeateClientTransferFilter;
|
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.filter.NettyTcpServerPermeateClientTransferFilter;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.*;
|
import org.framework.lazy.cloud.network.heartbeat.common.*;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
|
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
|
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
|
||||||
@ -21,7 +21,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
* 客户端连接真实服务
|
* 客户端连接真实服务
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class NettyServerPermeateClientRealSocket {
|
public class NettyTcpServerPermeateClientRealSocket {
|
||||||
static EventLoopGroup eventLoopGroup = new NioEventLoopGroup();
|
static EventLoopGroup eventLoopGroup = new NioEventLoopGroup();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -62,7 +62,7 @@ public class NettyServerPermeateClientRealSocket {
|
|||||||
// .option(ChannelOption.SO_BACKLOG, 128)//务端接受连接的队列长度 默认128
|
// .option(ChannelOption.SO_BACKLOG, 128)//务端接受连接的队列长度 默认128
|
||||||
// .option(ChannelOption.RCVBUF_ALLOCATOR, new NettyRecvByteBufAllocator(1024 * 1024))//用于Channel分配接受Buffer的分配器 默认AdaptiveRecvByteBufAllocator.DEFAULT
|
// .option(ChannelOption.RCVBUF_ALLOCATOR, new NettyRecvByteBufAllocator(1024 * 1024))//用于Channel分配接受Buffer的分配器 默认AdaptiveRecvByteBufAllocator.DEFAULT
|
||||||
.option(ChannelOption.WRITE_BUFFER_WATER_MARK, new WriteBufferWaterMark(1024 * 1024, 1024 * 1024 * 2))
|
.option(ChannelOption.WRITE_BUFFER_WATER_MARK, new WriteBufferWaterMark(1024 * 1024, 1024 * 1024 * 2))
|
||||||
.handler(new NettyServerPermeateClientRealFilter())
|
.handler(new NettyTcpServerPermeateClientRealFilter())
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -149,7 +149,7 @@ public class NettyServerPermeateClientRealSocket {
|
|||||||
|
|
||||||
.option(ChannelOption.WRITE_BUFFER_WATER_MARK, new WriteBufferWaterMark(1024 * 1024, 1024 * 1024 * 2))
|
.option(ChannelOption.WRITE_BUFFER_WATER_MARK, new WriteBufferWaterMark(1024 * 1024, 1024 * 1024 * 2))
|
||||||
|
|
||||||
.handler(new NettyServerPermeateClientTransferFilter(new ChannelTypeAdapter(handleChannelTypeAdvancedList)))
|
.handler(new NettyTcpServerPermeateClientTransferFilter(new ChannelTypeAdapter(handleChannelTypeAdvancedList)))
|
||||||
;
|
;
|
||||||
|
|
||||||
String inetHost = nettyClientProperties.getInetHost();
|
String inetHost = nettyClientProperties.getInetHost();
|
@ -1,4 +0,0 @@
|
|||||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.tcp;
|
|
||||||
|
|
||||||
public class xx {
|
|
||||||
}
|
|
@ -2,7 +2,7 @@ package org.framework.lazy.cloud.network.heartbeat.server.cluster.application.im
|
|||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.event.ClientChangeEvent;
|
import org.framework.lazy.cloud.network.heartbeat.client.netty.event.ClientChangeEvent;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.socket.NettyClientSocket;
|
import org.framework.lazy.cloud.network.heartbeat.client.netty.tcp.socket.NettyTcpClientSocket;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
|
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.server.cluster.application.dto.LazyNettyClusterNodeDTO;
|
import org.framework.lazy.cloud.network.heartbeat.server.cluster.application.dto.LazyNettyClusterNodeDTO;
|
||||||
import org.framework.lazy.cloud.network.heartbeat.server.cluster.domain.model.cluster.node.LazyNettyClusterNode;
|
import org.framework.lazy.cloud.network.heartbeat.server.cluster.domain.model.cluster.node.LazyNettyClusterNode;
|
||||||
@ -55,7 +55,7 @@ public class LazyNettyClusterNodeApplicationImpl implements LazyNettyClusterNode
|
|||||||
ServerNodeProperties serverNodeProperties;
|
ServerNodeProperties serverNodeProperties;
|
||||||
|
|
||||||
// 缓存连接集群 socket
|
// 缓存连接集群 socket
|
||||||
private final ConcurrentHashMap<LazyNettyClusterNode, NettyClientSocket> cacheClusterNettyClientSocketMap = new ConcurrentHashMap<>();
|
private final ConcurrentHashMap<LazyNettyClusterNode, NettyTcpClientSocket> cacheClusterNettyClientSocketMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public static final ThreadPoolExecutor NETTY_CLUSTER_CLIENT_EXECUTOR =
|
public static final ThreadPoolExecutor NETTY_CLUSTER_CLIENT_EXECUTOR =
|
||||||
new ThreadPoolExecutor(20, 50, 200, TimeUnit.MILLISECONDS,
|
new ThreadPoolExecutor(20, 50, 200, TimeUnit.MILLISECONDS,
|
||||||
@ -180,8 +180,8 @@ public class LazyNettyClusterNodeApplicationImpl implements LazyNettyClusterNode
|
|||||||
// 当前节点ID
|
// 当前节点ID
|
||||||
String clusterNodeClientId = serverNodeProperties.getNodeId();
|
String clusterNodeClientId = serverNodeProperties.getNodeId();
|
||||||
|
|
||||||
NettyClientSocket nettyClientSocket = new
|
NettyTcpClientSocket nettyTcpClientSocket = new
|
||||||
NettyClientSocket(inetHost, inetPort, clusterNodeClientId,
|
NettyTcpClientSocket(inetHost, inetPort, clusterNodeClientId,
|
||||||
clusterNodeId,null,null,
|
clusterNodeId,null,null,
|
||||||
clientChangeEvent, handleChannelTypeAdvancedList);
|
clientChangeEvent, handleChannelTypeAdvancedList);
|
||||||
// 过滤已经存在的
|
// 过滤已经存在的
|
||||||
@ -192,11 +192,11 @@ public class LazyNettyClusterNodeApplicationImpl implements LazyNettyClusterNode
|
|||||||
log.warn("当前节点注册:{} 已经存在", lazyNettyClusterNode);
|
log.warn("当前节点注册:{} 已经存在", lazyNettyClusterNode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cacheClusterNettyClientSocketMap.put(lazyNettyClusterNode, nettyClientSocket);
|
cacheClusterNettyClientSocketMap.put(lazyNettyClusterNode, nettyTcpClientSocket);
|
||||||
|
|
||||||
Thread thread = new Thread(() -> {
|
Thread thread = new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
nettyClientSocket.newConnect2Server();
|
nettyTcpClientSocket.newConnect2Server();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
@ -237,7 +237,7 @@ public class LazyNettyClusterNodeApplicationImpl implements LazyNettyClusterNode
|
|||||||
// 当前节点ID
|
// 当前节点ID
|
||||||
String clusterNodeId = serverNodeProperties.getNodeId();
|
String clusterNodeId = serverNodeProperties.getNodeId();
|
||||||
// 关闭指定socket
|
// 关闭指定socket
|
||||||
cacheClusterNettyClientSocketMap.forEach(((lazyNettyClusterNode, nettyClientSocket) -> {
|
cacheClusterNettyClientSocketMap.forEach(((lazyNettyClusterNode, nettyTcpClientSocket) -> {
|
||||||
String inetHost = lazyNettyClusterNode.getClusterNodeHost();
|
String inetHost = lazyNettyClusterNode.getClusterNodeHost();
|
||||||
Integer inetPort = lazyNettyClusterNode.getClusterNodePort();
|
Integer inetPort = lazyNettyClusterNode.getClusterNodePort();
|
||||||
String needCloseInetHost = needCloseLazyNettyClusterNode.getClusterNodeHost();
|
String needCloseInetHost = needCloseLazyNettyClusterNode.getClusterNodeHost();
|
||||||
@ -246,7 +246,7 @@ public class LazyNettyClusterNodeApplicationImpl implements LazyNettyClusterNode
|
|||||||
if (Objects.equals(clusterNodeId, needCloseClientId)
|
if (Objects.equals(clusterNodeId, needCloseClientId)
|
||||||
&& Objects.equals(inetPort, needCloseInetPort)
|
&& Objects.equals(inetPort, needCloseInetPort)
|
||||||
&& Objects.equals(inetHost, needCloseInetHost)) {
|
&& Objects.equals(inetHost, needCloseInetHost)) {
|
||||||
nettyClientSocket.shutdown();
|
nettyTcpClientSocket.shutdown();
|
||||||
// 关闭客户端:{}与服务端连接:{}:{}
|
// 关闭客户端:{}与服务端连接:{}:{}
|
||||||
log.warn("Close client: {} Connect to server: {}: {}", clusterNodeId, inetHost, inetPort);
|
log.warn("Close client: {} Connect to server: {}: {}", clusterNodeId, inetHost, inetPort);
|
||||||
}
|
}
|
||||||
@ -259,8 +259,8 @@ public class LazyNettyClusterNodeApplicationImpl implements LazyNettyClusterNode
|
|||||||
@Override
|
@Override
|
||||||
public void destroyClusterNodes() {
|
public void destroyClusterNodes() {
|
||||||
// 关闭socket
|
// 关闭socket
|
||||||
cacheClusterNettyClientSocketMap.forEach(((lazyNettyClusterNode, nettyClientSocket) -> {
|
cacheClusterNettyClientSocketMap.forEach(((lazyNettyClusterNode, nettyTcpClientSocket) -> {
|
||||||
nettyClientSocket.shutdown();
|
nettyTcpClientSocket.shutdown();
|
||||||
String clientId = lazyNettyClusterNode.getClusterNodeId();
|
String clientId = lazyNettyClusterNode.getClusterNodeId();
|
||||||
String inetHost = lazyNettyClusterNode.getClusterNodeHost();
|
String inetHost = lazyNettyClusterNode.getClusterNodeHost();
|
||||||
Integer inetPort = lazyNettyClusterNode.getClusterNodePort();
|
Integer inetPort = lazyNettyClusterNode.getClusterNodePort();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user