41 Commits

Author SHA1 Message Date
wujiawei
6c86a41359 [fix] 使用自定义@LazyMapper 进行数据转换 2025-06-25 11:08:52 +08:00
wujiawei
3353e4bd83 【fix】 添加版本记录 2025-06-23 13:16:10 +08:00
wujiawei
2f0f4270d3 【fix】 添加版本记录 2025-06-23 13:11:23 +08:00
wujiawei
61f639c51d [fix] registry.cn-hangzhou.aliyuncs.com/wu-lazy/wu-framework-parent:jdk-24-x64 2025-06-19 20:09:21 +08:00
wujiawei
46e657535b [fix] add docker hub image version 2025-06-19 19:59:19 +08:00
wujiawei
ea296da78e [fix] 1.3.1-JDK24-SNAPSHOT 2025-06-19 19:33:31 +08:00
wujiawei
aafa684525 [fix] 使用自定义@LazyMapper 进行数据转换 2025-06-19 16:25:37 +08:00
wujiawei
e41c293c31 [fix] 使用自定义@LazyMapper 进行数据转换 2025-06-18 16:51:08 +08:00
wujiawei
c8b4238d90 [fix] 1.3.1-JDK24-SNAPSHOT 2025-06-18 13:33:43 +08:00
wujiawei
32eaace9c1 [fix] 异常打印 2025-06-17 13:51:42 +08:00
wujiawei
21136284c7 [fix] 优化绑定下一个通道问题 2025-06-17 13:50:37 +08:00
wujiawei
7c640816aa [fix] 优化页面展示 2025-06-17 10:14:55 +08:00
wujiawei
aba3e2acc9 [fix] 优化端口映射问题 2025-06-17 09:27:03 +08:00
wujiawei
25f81ca271 [fix] 代理流量使用队列 2025-06-16 17:11:38 +08:00
wujiawei
a1f764f1cc [fix] 客户端路由,客户端ID及路由IP为唯一行索引 2025-06-16 16:14:52 +08:00
wujiawei
1699130f14 [fix] 代码格式化 2025-06-16 13:48:35 +08:00
wujiawei
6b16ff7065 [fix] 修改native无法正常打包问题 2025-06-16 13:27:29 +08:00
wujiawei
87435b85d4 [add] 删除namespace规则 2025-06-16 08:45:54 +08:00
wujiawei
2fc0187f43 [add] 删除namespace规则 2025-06-16 08:44:48 +08:00
wujiawei
513c8ba095 [add] 删除namespace规则 2025-06-16 00:34:06 +08:00
wujiawei
2add2ddfa7 [add] 删除namespace规则 2025-06-15 22:06:58 +08:00
wujiawei
f791b36d24 [add] 服务端渗透客户端优化 2025-06-15 18:16:41 +08:00
wujiawei
bebb67395e [add] 服务端渗透客户端优化 2025-06-15 18:08:19 +08:00
wujiawei
ad1c5b1b36 [add] 服务端渗透客户端优化 2025-06-15 18:04:11 +08:00
wujiawei
4c76635292 [add] 服务端渗透服务端 2025-06-15 17:22:25 +08:00
wujiawei
ffdd593113 [add] 客户端渗透优化 2025-06-15 16:11:17 +08:00
wujiawei
5616abafd0 [add] 客户端下线异常问题 2025-06-15 01:49:38 +08:00
wujiawei
6d0bcd2f63 [add] 客户端下线异常问题 2025-06-15 00:50:16 +08:00
wujiawei
da7d55c266 [add] 调试namespace 2025-06-14 20:03:16 +08:00
wujiawei
30403d1da8 [add] 添加namespace管理 2025-06-14 19:28:16 +08:00
wujiawei
58026465ad [add] 添加namespace管理 2025-06-14 19:02:13 +08:00
wujiawei
3b7bf3d983 [add] 添加namespace管理 2025-06-14 19:02:07 +08:00
wujiawei
7838f7a88d [fix] 修改native无法正常打包问题 2025-06-13 16:20:05 +08:00
wujiawei
9c13074e5c [fix] 客户端存储服务器信息namespace 字段设置非空 2025-06-13 16:10:15 +08:00
wujiawei
08c0194733 [fix] 客户端存储服务器信息namespace 字段设置非空 2025-06-13 12:24:47 +08:00
wujiawei
e3deb4cdfe [fix] 客户端存储服务器信息namespace 字段设置非空 2025-06-12 12:38:35 +08:00
wujiawei
229e273b7d [fix] 添加namespace 2025-06-11 16:45:17 +08:00
wujiawei
3163987ef7 [fix] 添加namespace 2025-06-11 16:19:11 +08:00
wujiawei
51b603a6c5 [fix] 添加服务端ID 2025-06-11 10:09:28 +08:00
wujiawei
c34f1239d8 [fix] 修复native打包与mapper不兼容问题,切换至自定义bean拷贝 2025-06-10 09:26:40 +08:00
wujiawei
edaa4b84d7 Revert "[fix] 修复native打包与mapper不兼容问题,切换至自定义bean拷贝"
This reverts commit 6c6584fdb9.
2025-06-10 09:26:16 +08:00
848 changed files with 6584 additions and 8965 deletions

View File

@@ -7,19 +7,19 @@
#### 操作步骤拥有公网ip的服务器开发6001web、7001端口tcp然后执行命令启动服务端
```shell
docker run -d -it -p 6001:6001 -p 7001:7001 -e spring.profiles.active=prod -e MAIN_DB_HOST=localhost:3306 -e MAIN_DB_PASSWORD=root -e MAIN_DB_PASSWORD=root --name wu-lazy-cloud-heartbeat-server-start registry.cn-hangzhou.aliyuncs.com/wu-lazy/wu-lazy-cloud-heartbeat-server-start:1.3.1-JDK17-SNAPSHOT
docker run -d -it -p 6001:6001 -p 7001:7001 -e spring.profiles.active=prod -e MAIN_DB_HOST=localhost:3306 -e MAIN_DB_PASSWORD=root -e MAIN_DB_PASSWORD=root --name wu-lazy-cloud-heartbeat-server-start registry.cn-hangzhou.aliyuncs.com/wu-lazy/wu-lazy-cloud-heartbeat-server-start:1.3.1-JDK24-SNAPSHOT
```
#### 操作步骤:杭州本地机房所在网络服务器启动客户端、你老家所在网络中启动客户端,命令如下
```shell
docker run -d -it --privileged --name hangzhou-client --restart=always -e spring.lazy.netty.client.inet-host=公网IP -e spring.lazy.netty.client.inet-port=7001 -e spring.lazy.netty.client.client-id="hangzhou-jifang" registry.cn-hangzhou.aliyuncs.com/wu-lazy/wu-lazy-cloud-heartbeat-client-start:1.3.1-JDK17-SNAPSHOT
docker run -d -it --privileged --name hangzhou-client --restart=always -e spring.lazy.netty.client.inet-host=公网IP -e spring.lazy.netty.client.inet-port=7001 -e spring.lazy.netty.client.client-id="hangzhou-jifang" registry.cn-hangzhou.aliyuncs.com/wu-lazy/wu-lazy-cloud-heartbeat-client-start:1.3.1-JDK24-SNAPSHOT
```
```shell
docker run -d -it --privileged --name my-home-client --restart=always -e spring.lazy.netty.client.inet-host=公网IP -e spring.lazy.netty.client.inet-port=7001 -e spring.lazy.netty.client.client-id="my-home" registry.cn-hangzhou.aliyuncs.com/wu-lazy/wu-lazy-cloud-heartbeat-client-start:1.3.1-JDK17-SNAPSHOT
docker run -d -it --privileged --name my-home-client --restart=always -e spring.lazy.netty.client.inet-host=公网IP -e spring.lazy.netty.client.inet-port=7001 -e spring.lazy.netty.client.client-id="my-home" registry.cn-hangzhou.aliyuncs.com/wu-lazy/wu-lazy-cloud-heartbeat-client-start:1.3.1-JDK24-SNAPSHOT
```
#### 操作步骤:配置端口
![client_permeate_port_pool.png](client_permeate_port_pool.png)
#### 操作步骤:打开页面配置菜单看到如下界面(from客户端ID你老家网络中的电脑to客户端ID
#### 操作步骤:打开页面配置菜单看到如下界面(客户端ID你老家网络中的电脑目标客户端ID
![client_permeate_client_mapping.png](client_permeate_client_mapping.png)
#### 连接使用在你老家使用my-home这个客户端所在机器上的ip+13306 即可访问杭州机房内的数据库的服务3306

View File

@@ -14,6 +14,9 @@
<a target="_blank" href="https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html">
<img src="https://img.shields.io/badge/JDK-17-green.svg" alt="jdk-17" />
</a>
<a target="_blank" href="https://www.oracle.com/java/technologies/javase/jdk24-archive-downloads.html">
<img src="https://img.shields.io/badge/JDK-24-green.svg" alt="jdk-24" />
</a>
<br />
<img src="https://img.shields.io/badge/SpringBoot-v3.x-blue">
<br />
@@ -33,7 +36,7 @@
wu-lazy-cloud-network
是一款基于([wu-framework-parent](https://gitee.com/wujiawei1207537021/wu-framework-parent)孵化出的项目内部使用Lazy
ORM操作数据库使用环境JDK17 Spring Boot 3.0.2。的网络穿透、渗透工具支持Tcp、Http、Socks
ORM操作数据库使用环境JDK24 Spring Boot 3.5.0。的网络穿透、渗透工具支持Tcp、Http、Socks
主要功能:
- 服务端渗透客户端网络穿透对于没有公网IP的服务进行公网IP映射
- ![NetworkPermeateServerPermeateClient.png](NetworkPermeateServerPermeateClient.png)
@@ -88,21 +91,21 @@ ORM操作数据库使用环境JDK17 Spring Boot 3.0.2。的网络穿透、渗
| 模块 | 版本 | 描述 |
|------------------------------------------------------------------------------------------------------------|----------------------|------------------------------|
| [wu-lazy-cloud-heartbeat-common](wu-lazy-cloud-heartbeat-common) | 1.3.1-JDK17-SNAPSHOT | 内网穿透公共模块(声明接口、枚举、常量、适配器、解析器) |
| [wu-lazy-cloud-heartbeat-client](wu-lazy-cloud-heartbeat-client) | 1.3.1-JDK17-SNAPSHOT | 客户端(支持二次开发) |
| [wu-lazy-cloud-heartbeat-server](wu-lazy-cloud-heartbeat-server) | 1.3.1-JDK17-SNAPSHOT | 服务端(支持二次开发) |
| [wu-lazy-cloud-heartbeat-client-start](wu-lazy-cloud-heartbeat-start/wu-lazy-cloud-heartbeat-server-start) | 1.3.1-JDK17-SNAPSHOT | 客户端样例 |
| [wu-lazy-cloud-heartbeat-server-start](wu-lazy-cloud-heartbeat-start/wu-lazy-cloud-heartbeat-client-start) | 1.3.1-JDK17-SNAPSHOT | 服务端样例 |
| [wu-lazy-cloud-heartbeat-common](wu-lazy-cloud-heartbeat-common) | 1.3.1-JDK24-SNAPSHOT | 内网穿透公共模块(声明接口、枚举、常量、适配器、解析器) |
| [wu-lazy-cloud-heartbeat-client](wu-lazy-cloud-heartbeat-client) | 1.3.1-JDK24-SNAPSHOT | 客户端(支持二次开发) |
| [wu-lazy-cloud-heartbeat-server](wu-lazy-cloud-heartbeat-server) | 1.3.1-JDK24-SNAPSHOT | 服务端(支持二次开发) |
| [wu-lazy-cloud-heartbeat-client-start](wu-lazy-cloud-heartbeat-start/wu-lazy-cloud-heartbeat-server-start) | 1.3.1-JDK24-SNAPSHOT | 客户端样例 |
| [wu-lazy-cloud-heartbeat-server-start](wu-lazy-cloud-heartbeat-start/wu-lazy-cloud-heartbeat-client-start) | 1.3.1-JDK24-SNAPSHOT | 服务端样例 |
### 使用技术
| 框架 | 版本 | 描述 |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------|--------------|
| spring-boot | 3.0.7 | springboot框架 |
| [wu-framework-web](https://gitee.com/wujiawei1207537021/wu-framework-parent/tree/master/wu-framework-web) | 1.3.1-JDK17-SNAPSHOT | web容器 |
| [Lazy -ORM](https://gitee.com/wujiawei1207537021/wu-framework-parent/tree/master/wu-inner-intergration/wu-database-parent) | 1.3.1-JDK17-SNAPSHOT | ORM |
| [wu-framework-web](https://gitee.com/wujiawei1207537021/wu-framework-parent/tree/master/wu-framework-web) | 1.3.1-JDK24-SNAPSHOT | web容器 |
| [Lazy -ORM](https://gitee.com/wujiawei1207537021/wu-framework-parent/tree/master/wu-inner-intergration/wu-database-parent) | 1.3.1-JDK24-SNAPSHOT | ORM |
| mysql-connector-j | 8.0.33 | mysql驱动 |
| [wu-authorization-server-platform-starter](https://gitee.com/wujiawei1207537021/wu-framework-parent/tree/master/wu-smart-platform/wu-authorization-server-platform-starter) | 1.3.1-JDK17-SNAPSHOT | 用户授权体系 |
| [wu-authorization-server-platform-starter](https://gitee.com/wujiawei1207537021/wu-framework-parent/tree/master/wu-smart-platform/wu-authorization-server-platform-starter) | 1.3.1-JDK24-SNAPSHOT | 用户授权体系 |
### 使用环境
@@ -115,7 +118,7 @@ ORM操作数据库使用环境JDK17 Spring Boot 3.0.2。的网络穿透、渗
docker启动
docker run -d -it -p 18080:18080 --name wu-lazy-cloud-heartbeat-server registry.cn-hangzhou.aliyuncs.com/wu-lazy/wu-lazy-cloud-heartbeat-server:1.3.1-JDK17-SNAPSHOT
docker run -d -it -p 18080:18080 --name wu-lazy-cloud-heartbeat-server registry.cn-hangzhou.aliyuncs.com/wu-lazy/wu-lazy-cloud-heartbeat-server:1.3.1-JDK24-SNAPSHOT
http://127.0.0.1:18080/swagger-ui/index.html
@@ -183,4 +186,7 @@ ORM操作数据库使用环境JDK17 Spring Boot 3.0.2。的网络穿透、渗
![server_route.png](server_route.png)
- 服务端虚拟路由管理
- 创建一个虚拟的不存在的IP代理到指定的IP
![server_virtual_route.png](server_virtual_route.png)
![server_virtual_route.png](server_virtual_route.png)
-
- 代理流量管理
![client_proxy_flow_manager.png](client_proxy_flow_manager.png)

View File

@@ -28,7 +28,7 @@ spec:
containers:
- name: wu-lazy-cloud-heartbeat-local-client-start
image: >-
registry.cn-hangzhou.aliyuncs.com/wu-lazy/wu-lazy-cloud-heartbeat-client-start:1.3.1-JDK17-SNAPSHOT
registry.cn-hangzhou.aliyuncs.com/wu-lazy/wu-lazy-cloud-heartbeat-client-start:1.3.1-JDK24-SNAPSHOT
env:
- name: spring.lazy.netty.client.inet-host
value: 124.222.48.62

Binary file not shown.

After

Width:  |  Height:  |  Size: 206 KiB

View File

@@ -9,7 +9,7 @@
```shell
docker run -d -it -p 6001:6001 -p 7001:7001 -p 8001:8001 -p 9001:9001 --name wlcn-s registry.cn-hangzhou.aliyuncs.com/wu-lazy/wu-lazy-cloud-heartbeat-server:1.3.1-JDK17-SNAPSHOT
docker run -d -it -p 6001:6001 -p 7001:7001 -p 8001:8001 -p 9001:9001 --name wlcn-s registry.cn-hangzhou.aliyuncs.com/wu-lazy/wu-lazy-cloud-heartbeat-server:1.3.1-JDK24-SNAPSHOT
```
##### 启动客户端
@@ -24,5 +24,5 @@ docker run -d -it -p 6001:6001 -p 7001:7001 -p 8001:8001 -p 9001:9001 --nam
- 打开浏览器访问界面 http://127.0.0.1:6004/netty-client-local-ui/index.html
```shell
docker run -d -it --privileged -p 6004:6004 --name wlcn-c --restart=always -e spring.lazy.netty.client.inet-host=192.168.xx.xx -e spring.lazy.netty.client.inet-port=7001 -e spring.lazy.netty.client.client-id="wlcn-c" registry.cn-hangzhou.aliyuncs.com/wu-lazy/wu-lazy-cloud-heartbeat-client-start:1.3.1-JDK17-SNAPSHOT
docker run -d -it --privileged -p 6004:6004 --name wlcn-c --restart=always -e spring.lazy.netty.client.inet-host=192.168.xx.xx -e spring.lazy.netty.client.inet-port=7001 -e spring.lazy.netty.client.client-id="wlcn-c" registry.cn-hangzhou.aliyuncs.com/wu-lazy/wu-lazy-cloud-heartbeat-client-start:1.3.1-JDK24-SNAPSHOT
```

View File

@@ -8,12 +8,12 @@
<parent>
<artifactId>wu-framework-parent</artifactId>
<groupId>top.wu2020</groupId>
<version>1.3.1-JDK17-SNAPSHOT</version>
<version>1.3.1-JDK24-SNAPSHOT</version>
</parent>
<artifactId>wu-lazy-cloud-network</artifactId>
<packaging>pom</packaging>
<version>1.3.1-JDK17-SNAPSHOT</version>
<version>1.3.1-JDK24-SNAPSHOT</version>
<description>云上云下</description>
@@ -38,7 +38,6 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.32</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
@@ -72,7 +71,7 @@
<dependency>
<groupId>top.wu2020</groupId>
<artifactId>wu-framework-dependencies</artifactId>
<version>1.3.1-JDK17-SNAPSHOT</version>
<version>1.3.1-JDK24-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>

View File

@@ -36,4 +36,11 @@
[add] 新增客户端路由管理、新增服务端路由管理
[add] 支持新增虚拟IP代理到指定的IP
[add] 通过页面配置,代理支持控制端口代理控制
#### 1.3.1-JDK17
[add] 新增代理流量监控
[add] docker仓库上架dockerhub搜索https://hub.docker.com/search?q=wlcn
#### 1.3.1-JDK24-SNAPSHOT
[add] 新增代理流量监控
[add] 升级使用jdk24、springboot 3.5.0
#### 下一版本计划

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>top.wu2020</groupId>
<artifactId>wu-lazy-cloud-network</artifactId>
<version>1.3.1-JDK17-SNAPSHOT</version>
<version>1.3.1-JDK24-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -13,8 +13,8 @@
<description>云下心跳客户端</description>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>24</maven.compiler.source>
<maven.compiler.target>24</maven.compiler.target>
</properties>
<dependencies>
@@ -26,7 +26,7 @@
<dependency>
<groupId>top.wu2020</groupId>
<artifactId>wu-lazy-cloud-heartbeat-protocol-proxy</artifactId>
<version>1.3.1-JDK17-SNAPSHOT</version>
<version>1.3.1-JDK24-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>

View File

@@ -1,144 +1,92 @@
package org.framework.lazy.cloud.network.heartbeat.client.application.assembler;
import org.framework.lazy.cloud.network.heartbeat.client.application.command.lazy.netty.server.properties.*;
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.mapstruct.factory.Mappers;
import org.framework.lazy.cloud.network.heartbeat.client.application.command.lazy.netty.server.properties.LazyNettyServerPropertiesRemoveCommand;
import org.framework.lazy.cloud.network.heartbeat.client.application.command.lazy.netty.server.properties.LazyNettyServerPropertiesStoryCommand;
import org.framework.lazy.cloud.network.heartbeat.client.application.command.lazy.netty.server.properties.LazyNettyServerPropertiesUpdateCommand;
import org.framework.lazy.cloud.network.heartbeat.client.application.command.lazy.netty.server.properties.LazyNettyServerPropertiesQueryListCommand;
import org.framework.lazy.cloud.network.heartbeat.client.application.command.lazy.netty.server.properties.LazyNettyServerPropertiesQueryOneCommand;
import org.framework.lazy.cloud.network.heartbeat.client.application.dto.LazyNettyServerPropertiesDTO;
import org.wu.framework.core.mapper.LazyStructMappers;
import org.wu.framework.core.mapper.LazyStructMapper;
public class LazyNettyServerPropertiesDTOAssembler {
/**
* describe 服务端配置信息
*
* @author Jia wei Wu
* @date 2024/04/03 03:00 下午
* @see org.wu.framework.lazy.orm.core.persistence.reverse.lazy.ddd.DefaultDDDLazyAssembler
**/
@LazyStructMapper
public interface LazyNettyServerPropertiesDTOAssembler {
/**
* describe MapStruct 创建的代理对象
*
* @author Jia wei Wu
* @date 2024/01/24 05:19 下午
* @date 2024/04/03 03:00 下午
**/
public static LazyNettyServerPropertiesDTOAssembler INSTANCE = new LazyNettyServerPropertiesDTOAssembler();
LazyNettyServerPropertiesDTOAssembler INSTANCE = LazyStructMappers.getMapper(LazyNettyServerPropertiesDTOAssembler.class);
// LazyNettyServerPropertiesDTOAssembler INSTANCE = new LazyNettyServerPropertiesDTOAssemblerImpl();
/**
* describe 应用层存储入参转换成 领域对象
*
* @param lazyNettyServerPropertiesStoryCommand 保存服务端配置信息对象
* @return {@link LazyNettyServerProperties} 服务端配置信息领域对象
* @author Jia wei Wu
* @date 2024/04/03 03:00 下午
**/
LazyNettyServerProperties toLazyNettyServerProperties(LazyNettyServerPropertiesStoryCommand lazyNettyServerPropertiesStoryCommand);
public LazyNettyServerProperties toLazyNettyServerProperties(LazyNettyServerPropertiesStoryCommand lazyNettyServerPropertiesStoryCommand) {
if ( lazyNettyServerPropertiesStoryCommand == null ) {
return null;
}
/**
* describe 应用层更新入参转换成 领域对象
*
* @param lazyNettyServerPropertiesUpdateCommand 更新服务端配置信息对象
* @return {@link LazyNettyServerProperties} 服务端配置信息领域对象
* @author Jia wei Wu
* @date 2024/04/03 03:00 下午
**/
LazyNettyServerProperties toLazyNettyServerProperties(LazyNettyServerPropertiesUpdateCommand lazyNettyServerPropertiesUpdateCommand);
LazyNettyServerProperties lazyNettyServerProperties = new LazyNettyServerProperties();
/**
* describe 应用层查询入参转换成 领域对象
*
* @param lazyNettyServerPropertiesQueryOneCommand 查询单个服务端配置信息对象参数
* @return {@link LazyNettyServerProperties} 服务端配置信息领域对象
* @author Jia wei Wu
* @date 2024/04/03 03:00 下午
**/
LazyNettyServerProperties toLazyNettyServerProperties(LazyNettyServerPropertiesQueryOneCommand lazyNettyServerPropertiesQueryOneCommand);
lazyNettyServerProperties.setClientId( lazyNettyServerPropertiesStoryCommand.getClientId() );
lazyNettyServerProperties.setConnectStatus( lazyNettyServerPropertiesStoryCommand.getConnectStatus() );
lazyNettyServerProperties.setCreateTime( lazyNettyServerPropertiesStoryCommand.getCreateTime() );
lazyNettyServerProperties.setInetHost( lazyNettyServerPropertiesStoryCommand.getInetHost() );
lazyNettyServerProperties.setInetPort( lazyNettyServerPropertiesStoryCommand.getInetPort() );
lazyNettyServerProperties.setType( lazyNettyServerPropertiesStoryCommand.getType() );
lazyNettyServerProperties.setAppKey( lazyNettyServerPropertiesStoryCommand.getAppKey() );
lazyNettyServerProperties.setAppSecret( lazyNettyServerPropertiesStoryCommand.getAppSecret() );
lazyNettyServerProperties.setUpdateTime( lazyNettyServerPropertiesStoryCommand.getUpdateTime() );
/**
* describe 应用层查询入参转换成 领域对象
*
* @param lazyNettyServerPropertiesQueryListCommand 查询集合服务端配置信息对象参数
* @return {@link LazyNettyServerProperties} 服务端配置信息领域对象
* @author Jia wei Wu
* @date 2024/04/03 03:00 下午
**/
LazyNettyServerProperties toLazyNettyServerProperties(LazyNettyServerPropertiesQueryListCommand lazyNettyServerPropertiesQueryListCommand);
return lazyNettyServerProperties;
}
/**
* describe 应用层删除入参转换成 领域对象
*
* @param lazyNettyServerPropertiesRemoveCommand 删除服务端配置信息对象参数
* @return {@link LazyNettyServerProperties} 服务端配置信息领域对象
* @author Jia wei Wu
* @date 2024/04/03 03:00 下午
**/
LazyNettyServerProperties toLazyNettyServerProperties(LazyNettyServerPropertiesRemoveCommand lazyNettyServerPropertiesRemoveCommand);
public LazyNettyServerProperties toLazyNettyServerProperties(LazyNettyServerPropertiesUpdateCommand lazyNettyServerPropertiesUpdateCommand) {
if ( lazyNettyServerPropertiesUpdateCommand == null ) {
return null;
}
LazyNettyServerProperties lazyNettyServerProperties = new LazyNettyServerProperties();
lazyNettyServerProperties.setClientId( lazyNettyServerPropertiesUpdateCommand.getClientId() );
lazyNettyServerProperties.setConnectStatus( lazyNettyServerPropertiesUpdateCommand.getConnectStatus() );
lazyNettyServerProperties.setCreateTime( lazyNettyServerPropertiesUpdateCommand.getCreateTime() );
lazyNettyServerProperties.setInetHost( lazyNettyServerPropertiesUpdateCommand.getInetHost() );
lazyNettyServerProperties.setInetPort( lazyNettyServerPropertiesUpdateCommand.getInetPort() );
lazyNettyServerProperties.setType( lazyNettyServerPropertiesUpdateCommand.getType() );
lazyNettyServerProperties.setAppKey( lazyNettyServerPropertiesUpdateCommand.getAppKey() );
lazyNettyServerProperties.setAppSecret( lazyNettyServerPropertiesUpdateCommand.getAppSecret() );
lazyNettyServerProperties.setUpdateTime( lazyNettyServerPropertiesUpdateCommand.getUpdateTime() );
return lazyNettyServerProperties;
}
public LazyNettyServerProperties toLazyNettyServerProperties(LazyNettyServerPropertiesQueryOneCommand lazyNettyServerPropertiesQueryOneCommand) {
if ( lazyNettyServerPropertiesQueryOneCommand == null ) {
return null;
}
LazyNettyServerProperties lazyNettyServerProperties = new LazyNettyServerProperties();
lazyNettyServerProperties.setClientId( lazyNettyServerPropertiesQueryOneCommand.getClientId() );
lazyNettyServerProperties.setConnectStatus( lazyNettyServerPropertiesQueryOneCommand.getConnectStatus() );
lazyNettyServerProperties.setCreateTime( lazyNettyServerPropertiesQueryOneCommand.getCreateTime() );
lazyNettyServerProperties.setInetHost( lazyNettyServerPropertiesQueryOneCommand.getInetHost() );
lazyNettyServerProperties.setInetPort( lazyNettyServerPropertiesQueryOneCommand.getInetPort() );
lazyNettyServerProperties.setType( lazyNettyServerPropertiesQueryOneCommand.getType() );
lazyNettyServerProperties.setAppKey( lazyNettyServerPropertiesQueryOneCommand.getAppKey() );
lazyNettyServerProperties.setAppSecret( lazyNettyServerPropertiesQueryOneCommand.getAppSecret() );
lazyNettyServerProperties.setUpdateTime( lazyNettyServerPropertiesQueryOneCommand.getUpdateTime() );
return lazyNettyServerProperties;
}
public LazyNettyServerProperties toLazyNettyServerProperties(LazyNettyServerPropertiesQueryListCommand lazyNettyServerPropertiesQueryListCommand) {
if ( lazyNettyServerPropertiesQueryListCommand == null ) {
return null;
}
LazyNettyServerProperties lazyNettyServerProperties = new LazyNettyServerProperties();
lazyNettyServerProperties.setClientId( lazyNettyServerPropertiesQueryListCommand.getClientId() );
lazyNettyServerProperties.setConnectStatus( lazyNettyServerPropertiesQueryListCommand.getConnectStatus() );
lazyNettyServerProperties.setCreateTime( lazyNettyServerPropertiesQueryListCommand.getCreateTime() );
lazyNettyServerProperties.setInetHost( lazyNettyServerPropertiesQueryListCommand.getInetHost() );
lazyNettyServerProperties.setInetPort( lazyNettyServerPropertiesQueryListCommand.getInetPort() );
lazyNettyServerProperties.setType( lazyNettyServerPropertiesQueryListCommand.getType() );
lazyNettyServerProperties.setAppKey( lazyNettyServerPropertiesQueryListCommand.getAppKey() );
lazyNettyServerProperties.setAppSecret( lazyNettyServerPropertiesQueryListCommand.getAppSecret() );
lazyNettyServerProperties.setUpdateTime( lazyNettyServerPropertiesQueryListCommand.getUpdateTime() );
return lazyNettyServerProperties;
}
public LazyNettyServerProperties toLazyNettyServerProperties(LazyNettyServerPropertiesRemoveCommand lazyNettyServerPropertiesRemoveCommand) {
if ( lazyNettyServerPropertiesRemoveCommand == null ) {
return null;
}
LazyNettyServerProperties lazyNettyServerProperties = new LazyNettyServerProperties();
lazyNettyServerProperties.setClientId( lazyNettyServerPropertiesRemoveCommand.getClientId() );
lazyNettyServerProperties.setConnectStatus( lazyNettyServerPropertiesRemoveCommand.getConnectStatus() );
lazyNettyServerProperties.setCreateTime( lazyNettyServerPropertiesRemoveCommand.getCreateTime() );
lazyNettyServerProperties.setInetHost( lazyNettyServerPropertiesRemoveCommand.getInetHost() );
lazyNettyServerProperties.setInetPort( lazyNettyServerPropertiesRemoveCommand.getInetPort() );
lazyNettyServerProperties.setType( lazyNettyServerPropertiesRemoveCommand.getType() );
lazyNettyServerProperties.setAppKey( lazyNettyServerPropertiesRemoveCommand.getAppKey() );
lazyNettyServerProperties.setAppSecret( lazyNettyServerPropertiesRemoveCommand.getAppSecret() );
lazyNettyServerProperties.setUpdateTime( lazyNettyServerPropertiesRemoveCommand.getUpdateTime() );
return lazyNettyServerProperties;
}
public LazyNettyServerPropertiesDTO fromLazyNettyServerProperties(LazyNettyServerProperties lazyNettyServerProperties) {
if ( lazyNettyServerProperties == null ) {
return null;
}
LazyNettyServerPropertiesDTO lazyNettyServerPropertiesDTO = new LazyNettyServerPropertiesDTO();
lazyNettyServerPropertiesDTO.setClientId( lazyNettyServerProperties.getClientId() );
lazyNettyServerPropertiesDTO.setConnectStatus( lazyNettyServerProperties.getConnectStatus() );
lazyNettyServerPropertiesDTO.setCreateTime( lazyNettyServerProperties.getCreateTime() );
lazyNettyServerPropertiesDTO.setInetHost( lazyNettyServerProperties.getInetHost() );
lazyNettyServerPropertiesDTO.setInetPort( lazyNettyServerProperties.getInetPort() );
lazyNettyServerPropertiesDTO.setType( lazyNettyServerProperties.getType() );
lazyNettyServerPropertiesDTO.setAppKey( lazyNettyServerProperties.getAppKey() );
lazyNettyServerPropertiesDTO.setAppSecret( lazyNettyServerProperties.getAppSecret() );
lazyNettyServerPropertiesDTO.setUpdateTime( lazyNettyServerProperties.getUpdateTime() );
return lazyNettyServerPropertiesDTO;
}
}
/**
* describe 持久层领域对象转换成DTO对象
*
* @param lazyNettyServerProperties 服务端配置信息领域对象
* @return {@link LazyNettyServerPropertiesDTO} 服务端配置信息DTO对象
* @author Jia wei Wu
* @date 2024/04/03 03:00 下午
**/
LazyNettyServerPropertiesDTO fromLazyNettyServerProperties(LazyNettyServerProperties lazyNettyServerProperties);
}

View File

@@ -1,14 +1,12 @@
package org.framework.lazy.cloud.network.heartbeat.client.application.command.lazy.netty.server.properties;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.experimental.Accessors;
import io.swagger.v3.oas.annotations.media.Schema;
import org.framework.lazy.cloud.network.heartbeat.common.enums.NettyClientStatus;
import org.framework.lazy.cloud.network.heartbeat.client.config.PropertiesType;
import org.framework.lazy.cloud.network.heartbeat.common.enums.NettyClientStatus;
import java.lang.String;
import java.time.LocalDateTime;
import java.lang.Integer;
/**
* describe 服务端配置信息
*
@@ -21,7 +19,6 @@ import java.lang.Integer;
@Schema(title = "lazy_netty_server_properties_query_List_command",description = "服务端配置信息")
public class LazyNettyServerPropertiesQueryListCommand {
/**
*
* 客户身份ID

View File

@@ -5,6 +5,7 @@ import lombok.experimental.Accessors;
import io.swagger.v3.oas.annotations.media.Schema;
import org.framework.lazy.cloud.network.heartbeat.common.enums.NettyClientStatus;
import org.framework.lazy.cloud.network.heartbeat.client.config.PropertiesType;
import org.wu.framework.core.NormalUsedString;
import java.lang.String;
import java.time.LocalDateTime;
@@ -22,6 +23,7 @@ import java.lang.Integer;
public class LazyNettyServerPropertiesQueryOneCommand {
/**
*
* 客户身份ID

View File

@@ -5,6 +5,7 @@ import lombok.experimental.Accessors;
import io.swagger.v3.oas.annotations.media.Schema;
import org.framework.lazy.cloud.network.heartbeat.common.enums.NettyClientStatus;
import org.framework.lazy.cloud.network.heartbeat.client.config.PropertiesType;
import org.wu.framework.core.NormalUsedString;
import java.lang.String;
import java.time.LocalDateTime;
@@ -22,6 +23,7 @@ import java.lang.Integer;
public class LazyNettyServerPropertiesRemoveCommand {
/**
*
* 客户身份ID

View File

@@ -5,6 +5,7 @@ import lombok.experimental.Accessors;
import io.swagger.v3.oas.annotations.media.Schema;
import org.framework.lazy.cloud.network.heartbeat.common.enums.NettyClientStatus;
import org.framework.lazy.cloud.network.heartbeat.client.config.PropertiesType;
import org.wu.framework.core.NormalUsedString;
import java.lang.String;
import java.time.LocalDateTime;
@@ -22,6 +23,7 @@ import java.lang.Integer;
public class LazyNettyServerPropertiesStoryCommand {
/**
*
* 客户身份ID

View File

@@ -5,6 +5,7 @@ import lombok.experimental.Accessors;
import io.swagger.v3.oas.annotations.media.Schema;
import org.framework.lazy.cloud.network.heartbeat.common.enums.NettyClientStatus;
import org.framework.lazy.cloud.network.heartbeat.client.config.PropertiesType;
import org.wu.framework.core.NormalUsedString;
import java.lang.String;
import java.time.LocalDateTime;
@@ -22,6 +23,7 @@ import java.lang.Integer;
public class LazyNettyServerPropertiesUpdateCommand {
/**
*
* 客户身份ID

View File

@@ -1,14 +1,12 @@
package org.framework.lazy.cloud.network.heartbeat.client.application.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.experimental.Accessors;
import io.swagger.v3.oas.annotations.media.Schema;
import org.framework.lazy.cloud.network.heartbeat.common.enums.NettyClientStatus;
import org.framework.lazy.cloud.network.heartbeat.client.config.PropertiesType;
import org.framework.lazy.cloud.network.heartbeat.common.enums.NettyClientStatus;
import java.lang.String;
import java.time.LocalDateTime;
import java.lang.Integer;
/**
* describe 服务端配置信息
*
@@ -22,6 +20,7 @@ import java.lang.Integer;
public class LazyNettyServerPropertiesDTO {
/**
*
* 客户身份ID

View File

@@ -17,7 +17,6 @@ import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.sock
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.enums.NettyClientStatus;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ProtocolType;
import org.wu.framework.core.NormalUsedString;
import org.wu.framework.lazy.orm.database.lambda.domain.LazyPage;
import org.wu.framework.lazy.orm.web.plus.stereotype.LazyApplication;
import org.wu.framework.web.response.Result;
@@ -142,7 +141,7 @@ public class LazyNettyServerPropertiesApplicationImpl implements LazyNettyServer
@Override
public Result<List<LazyNettyServerPropertiesDTO>> findList(LazyNettyServerPropertiesQueryListCommand lazyNettyServerPropertiesQueryListCommand) {
LazyNettyServerProperties lazyNettyServerProperties = LazyNettyServerPropertiesDTOAssembler.INSTANCE.toLazyNettyServerProperties(lazyNettyServerPropertiesQueryListCommand);
return lazyNettyServerPropertiesRepository.findList(lazyNettyServerProperties).convert(lazyNettyServerPropertiess -> lazyNettyServerPropertiess.stream().map(LazyNettyServerPropertiesDTOAssembler.INSTANCE::fromLazyNettyServerProperties).collect(Collectors.toList()));
return lazyNettyServerPropertiesRepository.findList(lazyNettyServerProperties).convert(lazyNettyServerPropertiesList -> lazyNettyServerPropertiesList.stream().map(LazyNettyServerPropertiesDTOAssembler.INSTANCE::fromLazyNettyServerProperties).collect(Collectors.toList()));
}
/**
@@ -196,12 +195,12 @@ public class LazyNettyServerPropertiesApplicationImpl implements LazyNettyServer
if (ProtocolType.TCP.equals(protocolType)) {
nettyClientSocket = new
NettyTcpClientSocket(inetHost, inetPort, clientId,
NormalUsedString.DEFAULT, appKey, appSecret,
appKey, appSecret,
clientChangeEvent, handleChannelTypeAdvancedList);
} else if (ProtocolType.UDP.equals(protocolType)) {
nettyClientSocket = new
NettyUdpClientSocket(inetHost, inetPort, clientId,
NormalUsedString.DEFAULT, appKey, appSecret,
appKey, appSecret,
clientChangeEvent, handleChannelTypeAdvancedList);
} else {
nettyClientSocket = null;

View File

@@ -4,6 +4,7 @@ import lombok.Data;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ProtocolType;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.wu.framework.core.NormalUsedString;
/**
* netty 客户服务端地址配置属性
@@ -13,6 +14,7 @@ import org.springframework.context.annotation.Configuration;
@Data
public class NettyClientProperties {
public static final String PREFIX = "spring.lazy.netty.client";
/**
* 服务端地址 如127.0.0.1
*/

View File

@@ -26,7 +26,9 @@ public class NettyClientSocketApplicationListener implements ApplicationListener
private final LazyNettyServerPropertiesApplication lazyNettyServerPropertiesApplication;
public NettyClientSocketApplicationListener(NettyClientProperties nettyClientProperties, LazyLambdaStream lazyLambdaStream, LazyNettyServerPropertiesApplication lazyNettyServerPropertiesApplication) {
public NettyClientSocketApplicationListener(NettyClientProperties nettyClientProperties,
LazyLambdaStream lazyLambdaStream,
LazyNettyServerPropertiesApplication lazyNettyServerPropertiesApplication) {
this.nettyClientProperties = nettyClientProperties;
this.lazyLambdaStream = lazyLambdaStream;
this.lazyNettyServerPropertiesApplication = lazyNettyServerPropertiesApplication;
@@ -50,6 +52,7 @@ public class NettyClientSocketApplicationListener implements ApplicationListener
return;
}
LazyNettyServerPropertiesDO lazyNettyServerPropertiesDO = new LazyNettyServerPropertiesDO();
lazyNettyServerPropertiesDO.setClientId(clientId);
lazyNettyServerPropertiesDO.setInetHost(inetHost);
lazyNettyServerPropertiesDO.setInetPort(inetPort);

View File

@@ -6,6 +6,7 @@ import lombok.experimental.Accessors;
import org.framework.lazy.cloud.network.heartbeat.client.config.PropertiesType;
import org.framework.lazy.cloud.network.heartbeat.common.enums.NettyClientStatus;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ProtocolType;
import org.wu.framework.core.NormalUsedString;
import java.time.LocalDateTime;
/**
@@ -21,6 +22,7 @@ import java.time.LocalDateTime;
public class LazyNettyServerProperties {
/**
*
* 客户身份ID

View File

@@ -2,60 +2,46 @@ package org.framework.lazy.cloud.network.heartbeat.client.infrastructure.convert
import org.framework.lazy.cloud.network.heartbeat.client.domain.model.lazy.netty.server.properties.LazyNettyServerProperties;
import org.framework.lazy.cloud.network.heartbeat.client.infrastructure.entity.LazyNettyServerPropertiesDO;
import org.wu.framework.core.mapper.LazyStructMapper;
import org.wu.framework.core.mapper.LazyStructMappers;
public class LazyNettyServerPropertiesConverter {
/**
* describe 服务端配置信息
*
* @author Jia wei Wu
* @date 2024/04/03 03:00 下午
* @see org.wu.framework.lazy.orm.core.persistence.reverse.lazy.ddd.DefaultDDDLazyInfrastructureConverter
**/
@LazyStructMapper
public interface LazyNettyServerPropertiesConverter {
/**
* describe MapStruct 创建的代理对象
*
* @author Jia wei Wu
* @date 2024/01/24 05:19 下午
* @date 2024/04/03 03:00 下午
**/
public static LazyNettyServerPropertiesConverter INSTANCE = new LazyNettyServerPropertiesConverter();
LazyNettyServerPropertiesConverter INSTANCE = LazyStructMappers.getMapper(LazyNettyServerPropertiesConverter.class);
// LazyNettyServerPropertiesConverter INSTANCE = new LazyNettyServerPropertiesConverterImpl();
public LazyNettyServerProperties toLazyNettyServerProperties(LazyNettyServerPropertiesDO lazyNettyServerPropertiesDO) {
if (lazyNettyServerPropertiesDO == null) {
return null;
}
/**
* describe 实体对象 转换成领域对象
*
* @param lazyNettyServerPropertiesDO 服务端配置信息实体对象
* @return {@link LazyNettyServerProperties} 服务端配置信息领域对象
* @author Jia wei Wu
* @date 2024/04/03 03:00 下午
**/
LazyNettyServerProperties toLazyNettyServerProperties(LazyNettyServerPropertiesDO lazyNettyServerPropertiesDO);
LazyNettyServerProperties lazyNettyServerProperties = new LazyNettyServerProperties();
lazyNettyServerProperties.setClientId(lazyNettyServerPropertiesDO.getClientId());
lazyNettyServerProperties.setConnectStatus(lazyNettyServerPropertiesDO.getConnectStatus());
lazyNettyServerProperties.setCreateTime(lazyNettyServerPropertiesDO.getCreateTime());
lazyNettyServerProperties.setInetHost(lazyNettyServerPropertiesDO.getInetHost());
lazyNettyServerProperties.setInetPort(lazyNettyServerPropertiesDO.getInetPort());
lazyNettyServerProperties.setType(lazyNettyServerPropertiesDO.getType());
lazyNettyServerProperties.setProtocolType(lazyNettyServerPropertiesDO.getProtocolType());
lazyNettyServerProperties.setAppKey(lazyNettyServerPropertiesDO.getAppKey());
lazyNettyServerProperties.setAppSecret(lazyNettyServerPropertiesDO.getAppSecret());
lazyNettyServerProperties.setUpdateTime(lazyNettyServerPropertiesDO.getUpdateTime());
return lazyNettyServerProperties;
}
public LazyNettyServerPropertiesDO fromLazyNettyServerProperties(LazyNettyServerProperties lazyNettyServerProperties) {
if (lazyNettyServerProperties == null) {
return null;
}
LazyNettyServerPropertiesDO lazyNettyServerPropertiesDO = new LazyNettyServerPropertiesDO();
lazyNettyServerPropertiesDO.setClientId(lazyNettyServerProperties.getClientId());
lazyNettyServerPropertiesDO.setConnectStatus(lazyNettyServerProperties.getConnectStatus());
lazyNettyServerPropertiesDO.setCreateTime(lazyNettyServerProperties.getCreateTime());
lazyNettyServerPropertiesDO.setInetHost(lazyNettyServerProperties.getInetHost());
lazyNettyServerPropertiesDO.setInetPort(lazyNettyServerProperties.getInetPort());
lazyNettyServerPropertiesDO.setAppKey(lazyNettyServerProperties.getAppKey());
lazyNettyServerPropertiesDO.setAppSecret(lazyNettyServerProperties.getAppSecret());
lazyNettyServerPropertiesDO.setType(lazyNettyServerProperties.getType());
lazyNettyServerPropertiesDO.setProtocolType(lazyNettyServerProperties.getProtocolType());
lazyNettyServerPropertiesDO.setUpdateTime(lazyNettyServerProperties.getUpdateTime());
return lazyNettyServerPropertiesDO;
}
}
/**
* describe 领域对象 转换成实体对象
*
* @param lazyNettyServerProperties 服务端配置信息领域对象
* @return {@link LazyNettyServerPropertiesDO} 服务端配置信息实体对象
* @author Jia wei Wu
* @date 2024/04/03 03:00 下午
**/
LazyNettyServerPropertiesDO fromLazyNettyServerProperties(LazyNettyServerProperties lazyNettyServerProperties);
}

View File

@@ -6,6 +6,7 @@ import lombok.experimental.Accessors;
import org.framework.lazy.cloud.network.heartbeat.client.config.PropertiesType;
import org.framework.lazy.cloud.network.heartbeat.common.enums.NettyClientStatus;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ProtocolType;
import org.wu.framework.core.NormalUsedString;
import org.wu.framework.lazy.orm.core.stereotype.LazyTable;
import org.wu.framework.lazy.orm.core.stereotype.LazyTableField;
import org.wu.framework.lazy.orm.core.stereotype.LazyTableFieldId;
@@ -26,6 +27,7 @@ import java.time.LocalDateTime;
public class LazyNettyServerPropertiesDO {
/**
*
* 主键ID
@@ -38,7 +40,7 @@ public class LazyNettyServerPropertiesDO {
* 客户身份ID
*/
@Schema(description ="客户身份ID",name ="clientId",example = "")
@LazyTableFieldUnique(name="client_id",comment="客户身份ID",columnType="varchar(255)")
@LazyTableFieldUnique(name="client_id",comment="客户身份ID",columnType="varchar(25)")
private String clientId;
/**
@@ -63,7 +65,7 @@ public class LazyNettyServerPropertiesDO {
* 服务端host
*/
@Schema(description ="服务端host",name ="inetHost",example = "")
@LazyTableFieldUnique(name="inet_host",comment="服务端host",columnType="varchar(255)")
@LazyTableFieldUnique(name="inet_host",comment="服务端host",columnType="varchar(25)")
private String inetHost;
/**

View File

@@ -1,22 +1,19 @@
package org.framework.lazy.cloud.network.heartbeat.client.infrastructure.persistence;
import jakarta.annotation.Resource;
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.infrastructure.converter.LazyNettyServerPropertiesConverter;
import org.framework.lazy.cloud.network.heartbeat.client.infrastructure.entity.LazyNettyServerPropertiesDO;
import org.springframework.stereotype.Repository;
import java.util.stream.Collectors;
import org.wu.framework.lazy.orm.database.lambda.domain.LazyPage;
import org.wu.framework.lazy.orm.database.lambda.stream.lambda.LazyLambdaStream;
import org.wu.framework.lazy.orm.database.lambda.stream.wrapper.LazyWrappers;
import org.wu.framework.web.response.Result;
import org.wu.framework.web.response.ResultFactory;
import jakarta.annotation.Resource;
import org.wu.framework.lazy.orm.database.lambda.stream.lambda.LazyLambdaStream;
import java.util.List;
import org.wu.framework.lazy.orm.database.lambda.domain.LazyPage;
import java.util.stream.Collectors;
/**
* describe 服务端配置信息

View File

@@ -13,14 +13,15 @@ import java.util.List;
@Data
public class NettyClientPermeateClientVisitor implements InternalNetworkPermeate {
/**
* 当前客户端ID
*/
private String fromClientId;
private String originClientId;
/**
* 目标客户端ID
*/
private String toClientId;
private String targetClientId;
/**
* 目标地址
*/

View File

@@ -13,12 +13,12 @@ public interface ClientChangeEvent {
/**
* 推送客户端在线
* @param clientId 客户端
* @param inetHost 服务端ip
* @param inetPort 服务端端口
* @param serverId 服务端ID
*
* @param inetHost 服务端ip
* @param inetPort 服务端端口
* @param clientId 客户端
*/
void clientOnLine(String inetHost, int inetPort,String serverId ,String clientId);
void clientOnLine(String inetHost, int inetPort,String clientId);
/**
* 推送客户端离线
@@ -30,10 +30,9 @@ public interface ClientChangeEvent {
*
* @param inetHost 服务端ip
* @param inetPort 服务端端口
* @param serverId 服务端ID
* @param clientId 客户端
*/
void clientOffLine(String inetHost, int inetPort,String serverId,String clientId);
void clientOffLine(String inetHost, int inetPort,String clientId);
/**
* 暂存开启

View File

@@ -51,11 +51,10 @@ public class DefaultClientChangeEventImpl implements ClientChangeEvent {
*
* @param inetHost 服务端ip
* @param inetPort 服务端端口
* @param serverId 服务端ID
* @param clientId 客户端
*/
@Override
public void clientOnLine(String inetHost, int inetPort, String serverId, String clientId) {
public void clientOnLine(String inetHost, int inetPort, String clientId) {
LazyNettyServerProperties lazyNettyServerProperties = new LazyNettyServerProperties();
lazyNettyServerProperties.setClientId(clientId);
lazyNettyServerProperties.setInetHost(inetHost);
@@ -92,11 +91,10 @@ public class DefaultClientChangeEventImpl implements ClientChangeEvent {
*
* @param inetHost 服务端ip
* @param inetPort 服务端端口
* @param serverId
* @param clientId 客户端
*/
@Override
public void clientOffLine(String inetHost, int inetPort, String serverId, String clientId) {
public void clientOffLine(String inetHost, int inetPort, String clientId) {
LazyNettyServerProperties lazyNettyServerProperties = new LazyNettyServerProperties();
lazyNettyServerProperties.setClientId(clientId);
lazyNettyServerProperties.setInetHost(inetHost);

View File

@@ -41,8 +41,8 @@ public class ClientHandleTcpChannelTransferTypeAdvancedHandleDistributeTcpDistri
log.debug("接收到服务端需要内网穿透的数据:{}" , nettyProxyMsg);
String clientId = nettyClientProperties.getClientId();
byte[] visitorPort = nettyProxyMsg.getVisitorPort();
byte[] clientTargetIp = nettyProxyMsg.getClientTargetIp();
byte[] clientTargetPort = nettyProxyMsg.getClientTargetPort();
byte[] clientTargetIp = nettyProxyMsg.getTargetIp();
byte[] clientTargetPort = nettyProxyMsg.getTargetPort();
byte[] visitorId = nettyProxyMsg.getVisitorId();
// 真实服务通道
// Channel realChannel = NettyRealIdContext.getReal(new String(visitorId));

View File

@@ -31,8 +31,8 @@ public class ClientHandleTcpClientChannelActiveAdvanced extends AbstractHandleTc
protected void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
Channel channel = nettyChannelContext.channel();
// 缓存当前通道
byte[] clientIdByte = nettyProxyMsg.getClientId();
String clientId = new String(clientIdByte);
String clientId = nettyProxyMsg.clientId();
ChannelContext.push(channel, clientId);
ChannelAttributeKeyUtils.buildClientId(channel, clientId);
}

View File

@@ -24,7 +24,8 @@ import java.util.List;
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
public class ClientHandleTcpDistributeClientPermeateClientInitTypeAdvanced extends AbstractHandleTcpDistributeClientPermeateClientInitTypeAdvanced<NettyProxyMsg> {
public class ClientHandleTcpDistributeClientPermeateClientInitTypeAdvanced
extends AbstractHandleTcpDistributeClientPermeateClientInitTypeAdvanced<NettyProxyMsg> {
/**
* 处理当前数据
@@ -35,14 +36,14 @@ public class ClientHandleTcpDistributeClientPermeateClientInitTypeAdvanced exten
@Override
public void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
// 初始化 客户端渗透服务端socket
byte[] fromClientIdBytes = nettyProxyMsg.getClientId();
byte[] originClientIdBytes = nettyProxyMsg.getClientId();
byte[] visitorPortBytes = nettyProxyMsg.getVisitorPort();
byte[] clientTargetIpBytes = nettyProxyMsg.getClientTargetIp();
byte[] clientTargetPortBytes = nettyProxyMsg.getClientTargetPort();
byte[] toClientIdBytes = nettyProxyMsg.getData();
byte[] clientTargetIpBytes = nettyProxyMsg.getTargetIp();
byte[] clientTargetPortBytes = nettyProxyMsg.getTargetPort();
byte[] targetClientIdBytes = nettyProxyMsg.getData();
String fromClientId = new String(fromClientIdBytes);
String toClientId = new String(toClientIdBytes);
String originClientId = new String(originClientIdBytes);
String targetClientId = new String(targetClientIdBytes);
Integer visitorPort = Integer.parseInt(new String(visitorPortBytes));
String clientTargetIp = new String(clientTargetIpBytes);
Integer clientTargetPort = Integer.parseInt(new String(clientTargetPortBytes));
@@ -50,17 +51,17 @@ public class ClientHandleTcpDistributeClientPermeateClientInitTypeAdvanced exten
List<HandleChannelTypeAdvanced> handleChannelTypeAdvancedList = new ArrayList<>(SpringContextHolder.getApplicationContext().getBeansOfType(HandleChannelTypeAdvanced.class).values());
// ChannelFlowAdapter channelFlowAdapter = SpringContextHolder.getBean(ChannelFlowAdapter.class);
NettyClientProperties nettyClientProperties = SpringContextHolder.getBean(NettyClientProperties.class);
log.info("client permeate client from client_id:【{}】 to_client_id【{}】with visitor_port【{}】, clientTargetIp:【{}】clientTargetPort:【{}】",
fromClientId, toClientId, visitorPort, clientTargetIp, clientTargetPort);
log.info("client permeate client from client_id:【{}】 target_client_id【{}】with visitor_port【{}】, clientTargetIp:【{}】clientTargetPort:【{}】",
originClientId, targetClientId, visitorPort, clientTargetIp, clientTargetPort);
NettyTcpClientPermeateClientVisitorSocket nettyTcpClientPermeateClientVisitorSocket =
NettyTcpClientPermeateClientVisitorSocket.NettyClientPermeateClientVisitorSocketBuilder.builder()
.builderClientId(fromClientId)
.builderClientId(originClientId)
.builderClientTargetIp(clientTargetIp)
.builderClientTargetPort(clientTargetPort)
.builderVisitorPort(visitorPort)
.builderNettyClientProperties(nettyClientProperties)
//.builderChannelFlowAdapter(channelFlowAdapter)
.builderToClientId(toClientId)
.builderToClientId(targetClientId)
.builderHandleChannelTypeAdvancedList(handleChannelTypeAdvancedList)
.build();

View File

@@ -43,8 +43,8 @@ public class ClientHandleTcpDistributeClientPermeateServerInitTypeAdvanced exten
// 初始化 客户端渗透服务端socket
byte[] clientIdBytes = nettyProxyMsg.getClientId();
byte[] visitorPort = nettyProxyMsg.getVisitorPort();
byte[] clientTargetIp = nettyProxyMsg.getClientTargetIp();
byte[] clientTargetPort = nettyProxyMsg.getClientTargetPort();
byte[] clientTargetIp = nettyProxyMsg.getTargetIp();
byte[] clientTargetPort = nettyProxyMsg.getTargetPort();
List<HandleChannelTypeAdvanced> handleChannelTypeAdvancedList = new ArrayList<>(SpringContextHolder.getApplicationContext().getBeansOfType(HandleChannelTypeAdvanced.class).values());
NettyTcpClientPermeateServerVisitorSocket nettyTcpClientPermeateServerVisitorSocket = NettyTcpClientPermeateServerVisitorSocket.NettyVisitorSocketBuilder.builder()

View File

@@ -34,8 +34,8 @@ public class ClientHandleTcpDistributeClientPermeateServerTransferTypeAdvanced e
Channel channel = nettyChannelContext.channel();
log.debug("客户端渗透服务端返回数据:{}" , new String(nettyProxyMsg.getData()));
byte[] visitorPort = nettyProxyMsg.getVisitorPort();
byte[] clientTargetIp = nettyProxyMsg.getClientTargetIp();
byte[] clientTargetPort = nettyProxyMsg.getClientTargetPort();
byte[] clientTargetIp = nettyProxyMsg.getTargetIp();
byte[] clientTargetPort = nettyProxyMsg.getTargetPort();
byte[] visitorId = nettyProxyMsg.getVisitorId();
// 真实服务通道
// Channel realChannel = NettyRealIdContext.getReal(new String(visitorId));

View File

@@ -37,8 +37,8 @@ public class ClientHandleTcpDistributeClientTransferClientPermeateChannelConnect
public void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
// 创建connect 然后发送创建成功
byte[] msgClientId = nettyProxyMsg.getClientId();
byte[] msgClientTargetIp = nettyProxyMsg.getClientTargetIp();
byte[] msgClientTargetPort = nettyProxyMsg.getClientTargetPort();
byte[] msgClientTargetIp = nettyProxyMsg.getTargetIp();
byte[] msgClientTargetPort = nettyProxyMsg.getTargetPort();
byte[] msgVisitorId = nettyProxyMsg.getVisitorId();
byte[] msgVisitorPort = nettyProxyMsg.getVisitorPort();

View File

@@ -36,8 +36,8 @@ public class ClientHandleTcpDistributeClientTransferClientPermeateChannelInitSuc
Channel channel = nettyChannelContext.channel();
// 连接成功 开启自动读取写
byte[] msgClientId = nettyProxyMsg.getClientId();
byte[] msgClientTargetIp = nettyProxyMsg.getClientTargetIp();
byte[] msgClientTargetPort = nettyProxyMsg.getClientTargetPort();
byte[] msgClientTargetIp = nettyProxyMsg.getTargetIp();
byte[] msgClientTargetPort = nettyProxyMsg.getTargetPort();
byte[] msgVisitorId = nettyProxyMsg.getVisitorId();
byte[] msgVisitorPort = nettyProxyMsg.getVisitorPort();

View File

@@ -41,8 +41,8 @@ public class ClientHandleTcpDistributeServicePermeateClientRealConnectTypeAdvanc
// 创建真实端口监听
byte[] clientIdBytes = msg.getClientId();
byte[] visitorPort = msg.getVisitorPort();
byte[] clientTargetIp = msg.getClientTargetIp();
byte[] clientTargetPort = msg.getClientTargetPort();
byte[] clientTargetIp = msg.getTargetIp();
byte[] clientTargetPort = msg.getTargetPort();
byte[] visitorIdBytes = msg.getVisitorId();
InternalNetworkPenetrationRealClient internalNetworkPenetrationRealClient =
InternalNetworkPenetrationRealClient

View File

@@ -8,9 +8,9 @@ import io.netty.handler.timeout.IdleState;
import io.netty.handler.timeout.IdleStateEvent;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.socket.NettyTcpClientSocket;
import org.framework.lazy.cloud.network.heartbeat.common.constant.TcpMessageType;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.constant.TcpMessageType;
import java.nio.charset.StandardCharsets;
import java.util.Date;
@@ -56,7 +56,7 @@ public class NettyTcpClientHandler extends SimpleChannelInboundHandler<NettyProx
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
// 建立连接时
log.info("When establishing a connection{}" , new Date());
log.info("When establishing a connection{}", new Date());
ctx.fireChannelActive();
String clientId = nettyTcpClientSocket.getClientId();
// 处理客户端连接成功
@@ -65,8 +65,6 @@ public class NettyTcpClientHandler extends SimpleChannelInboundHandler<NettyProx
nettyMsg.setType(TcpMessageType.TCP_CLIENT_CHANNEL_ACTIVE);
nettyMsg.setClientId(clientId);
channelTypeAdapter.handler(ctx, nettyMsg);
}
/**
@@ -75,8 +73,8 @@ public class NettyTcpClientHandler extends SimpleChannelInboundHandler<NettyProx
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
//服务端主动关闭当前客户端连接时
log.info("When the server actively closes the current client connection{}" , new Date());
final EventLoop eventLoop = ctx.channel().eventLoop();
log.info("When the server actively closes the current client connection{}", new Date());
EventLoop eventLoop = ctx.channel().eventLoop();
eventLoop.schedule(() -> {
try {
nettyTcpClientSocket.newConnect2Server();

View File

@@ -139,8 +139,8 @@ public class NettyTcpClientPermeateClientRealSocket {
NettyProxyMsg nettyProxyMsg = new NettyProxyMsg();
nettyProxyMsg.setVisitorId(visitorId);
nettyProxyMsg.setClientId(clientId);
nettyProxyMsg.setClientTargetIp(clientTargetIp);
nettyProxyMsg.setClientTargetPort(clientTargetPort);
nettyProxyMsg.setTargetIp(clientTargetIp);
nettyProxyMsg.setTargetPort(clientTargetPort);
nettyProxyMsg.setVisitorPort(visitorPort);
nettyProxyMsg.setType(TcpMessageType.TCP_REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CHANNEL_INIT_SUCCESSFUL);
transferChannel.writeAndFlush(nettyProxyMsg);

View File

@@ -141,7 +141,7 @@ public class NettyTcpClientPermeateClientVisitorSocket implements PermeateVisito
/**
* 目标客户端ID
*/
private String toClientId;
private String targetClientId;
/**
* 流量适配器
@@ -249,11 +249,11 @@ public class NettyTcpClientPermeateClientVisitorSocket implements PermeateVisito
/**
* 目标客户端ID
*
* @param toClientId 目标客户端ID
* @param targetClientId 目标客户端ID
* @return 当前对象
*/
public NettyClientPermeateClientVisitorSocketBuilder builderToClientId(String toClientId) {
this.toClientId = toClientId;
public NettyClientPermeateClientVisitorSocketBuilder builderToClientId(String targetClientId) {
this.targetClientId = targetClientId;
return this;
}
public NettyTcpClientPermeateClientVisitorSocket build() {
@@ -268,8 +268,8 @@ public class NettyTcpClientPermeateClientVisitorSocket implements PermeateVisito
}
NettyClientPermeateClientVisitor nettyClientPermeateClientVisitor = new NettyClientPermeateClientVisitor();
nettyClientPermeateClientVisitor.setFromClientId(nettyClientProperties.getClientId());
nettyClientPermeateClientVisitor.setToClientId(toClientId);
nettyClientPermeateClientVisitor.setOriginClientId(nettyClientProperties.getClientId());
nettyClientPermeateClientVisitor.setTargetClientId(targetClientId);
nettyClientPermeateClientVisitor.setTargetIp(clientTargetIp);
nettyClientPermeateClientVisitor.setTargetPort(clientTargetPort);
nettyClientPermeateClientVisitor.setVisitorPort(visitorPort);

View File

@@ -57,10 +57,10 @@ public class NettyTcpClientPermeateClientVisitorTransferSocket {
String visitorId = ChannelAttributeKeyUtils.getVisitorId(visitorChannel);
Integer visitorPort = nettyClientPermeateClientVisitor.getVisitorPort();
String toClientId = nettyClientPermeateClientVisitor.getToClientId();
String targetClientId = nettyClientPermeateClientVisitor.getTargetClientId();
// 客户端新建访客通道 连接服务端IP:{},连接服务端端口:{}
log.info("Client creates a new visitor channel to connect to server IP: {}, connecting to server port: {} with clientId:【{}】 toClientId:【{}】 & visitorId:【{}】", inetHost, inetPort, clientId, toClientId, visitorId);
log.info("Client creates a new visitor channel to connect to server IP: {}, connecting to server port: {} with clientId:【{}】 targetClientId:【{}】 & visitorId:【{}】", inetHost, inetPort, clientId, targetClientId, visitorId);
ChannelFuture future = bootstrap.connect(inetHost, inetPort);
// 使用的客户端ID:{}
@@ -70,11 +70,12 @@ public class NettyTcpClientPermeateClientVisitorTransferSocket {
NettyProxyMsg nettyProxyMsg = new NettyProxyMsg();
nettyProxyMsg.setType(TcpMessageType.TCP_REPORT_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL);
// other clientId
nettyProxyMsg.setClientId(toClientId);
nettyProxyMsg.setClientId(targetClientId);
nettyProxyMsg.setVisitorPort(visitorPort);
nettyProxyMsg.setClientTargetIp(targetIp);
nettyProxyMsg.setClientTargetPort(targetPort);
nettyProxyMsg.setTargetIp(targetIp);
nettyProxyMsg.setTargetPort(targetPort);
nettyProxyMsg.setVisitorId(visitorId);
transferChannel.writeAndFlush(nettyProxyMsg);

View File

@@ -74,8 +74,8 @@ public class NettyTcpClientPermeateServerVisitorTransferSocket {
myMsg.setType(TcpMessageType.TCP_REPORT_CLIENT_TRANSFER_SERVER_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL);
myMsg.setClientId(clientId);
myMsg.setVisitorPort(visitorPort);
myMsg.setClientTargetIp(targetIp);
myMsg.setClientTargetPort(targetPort);
myMsg.setTargetIp(targetIp);
myMsg.setTargetPort(targetPort);
myMsg.setVisitorId(visitorId);
ChannelAttributeKeyUtils.buildVisitorId(transferChannel, visitorId);
ChannelAttributeKeyUtils.buildClientId(transferChannel, clientId);

View File

@@ -10,11 +10,11 @@ import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.NettyClientSocket;
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.event.ClientChangeEvent;
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.filter.NettyTcpClientFilter;
import org.framework.lazy.cloud.network.heartbeat.common.constant.TcpMessageType;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.NettyServerContext;
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.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.constant.TcpMessageType;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import java.net.InetAddress;
@@ -41,10 +41,6 @@ public class NettyTcpClientSocket implements NettyClientSocket {
@Getter
private final String clientId;
/**
* 当前连接的服务端ID
*/
private final String serverId;
private final String appKey;
private final String appSecret;
/**
@@ -57,7 +53,6 @@ public class NettyTcpClientSocket implements NettyClientSocket {
public NettyTcpClientSocket(String inetHost,
int inetPort,
String clientId,
String serverId,
String appKey,
String appSecret,
ClientChangeEvent clientChangeEvent,
@@ -65,7 +60,6 @@ public class NettyTcpClientSocket implements NettyClientSocket {
this.inetHost = inetHost;
this.inetPort = inetPort;
this.clientId = clientId;
this.serverId = serverId;
this.appKey = appKey;
this.appSecret = appSecret;
this.clientChangeEvent = clientChangeEvent;
@@ -73,7 +67,7 @@ public class NettyTcpClientSocket implements NettyClientSocket {
}
protected void newTcpConnect2Server(String inetHost, int inetPort, String clientId, String serverId, ClientChangeEvent clientChangeEvent) throws InterruptedException {
protected void newTcpConnect2Server(String inetHost, int inetPort, String clientId, ClientChangeEvent clientChangeEvent) throws InterruptedException {
Bootstrap bootstrap = new Bootstrap();
bootstrap.group(eventLoopGroup)
.channel(NioSocketChannel.class)
@@ -88,7 +82,7 @@ public class NettyTcpClientSocket implements NettyClientSocket {
.option(ChannelOption.WRITE_BUFFER_WATER_MARK, new WriteBufferWaterMark(1024 * 1024, 1024 * 1024 * 2))
.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);
// 客户端连接服务端的channel
Channel serviceChannel = future.channel();
@@ -96,7 +90,7 @@ public class NettyTcpClientSocket implements NettyClientSocket {
future.addListener((ChannelFutureListener) futureListener -> {
if (futureListener.isSuccess()) {
log.info("clientId:{},connect to server IP:{},server port :{} isSuccess ", clientId, inetHost, inetPort);
log.info("clientId:{},connect to server IP:{},server port :{} isSuccess ", clientId, inetHost, inetPort);
// 告诉服务端这条连接是client的连接
NettyProxyMsg nettyMsg = new NettyProxyMsg();
nettyMsg.setType(TcpMessageType.TCP_REPORT_CLIENT_CONNECT_SUCCESS);
@@ -109,17 +103,17 @@ public class NettyTcpClientSocket implements NettyClientSocket {
ChannelAttributeKeyUtils.buildClientId(serviceChannel, clientId);
serviceChannel.writeAndFlush(nettyMsg);
NettyServerContext.pushServerEndpointChannel(serverId, clientId, serviceChannel);
NettyServerContext.pushServerEndpointChannel(clientId, serviceChannel);
// 在线 客户端注册服务端成功
clientChangeEvent.clientOnLine(inetHost, inetPort,serverId, clientId);
clientChangeEvent.clientOnLine(inetHost, inetPort, clientId);
} else {
log.warn("Reconnect every 2 seconds....");
// 离线
NettyServerContext.removeServerEndpointChannels(serverId, clientId);
clientChangeEvent.clientOffLine(inetHost, inetPort,serverId, clientId);
NettyServerContext.removeServerEndpointChannels(clientId);
clientChangeEvent.clientOffLine(inetHost, inetPort, clientId);
eventLoopGroup.schedule(() -> {
try {
newTcpConnect2Server(inetHost, inetPort, clientId, serverId, clientChangeEvent);
newTcpConnect2Server(inetHost, inetPort, clientId, clientChangeEvent);
} catch (InterruptedException e) {
e.printStackTrace();
}
@@ -145,6 +139,6 @@ public class NettyTcpClientSocket implements NettyClientSocket {
*/
@Override
public void newConnect2Server() throws InterruptedException {
newTcpConnect2Server(inetHost, inetPort, clientId, serverId, clientChangeEvent);
newTcpConnect2Server(inetHost, inetPort, clientId, clientChangeEvent);
}
}

View File

@@ -181,8 +181,8 @@ public class NettyTcpServerPermeateClientRealSocket {
myMsg.setType(TcpMessageType.TCP_REPORT_SINGLE_CLIENT_REAL_CONNECT);
myMsg.setClientId(visitorClientId);
myMsg.setVisitorPort(visitorPort);
myMsg.setClientTargetIp(clientTargetIp);
myMsg.setClientTargetPort(clientTargetPort);
myMsg.setTargetIp(clientTargetIp);
myMsg.setTargetPort(clientTargetPort);
myMsg.setVisitorId(visitorId);
transferChannel.writeAndFlush(myMsg);

View File

@@ -41,8 +41,8 @@ public class ClientHandleUdpChannelTransferTypeAdvancedHandleDistribute extends
log.debug("接收到服务端需要内网穿透的数据:{}" , nettyProxyMsg);
String clientId = nettyClientProperties.getClientId();
byte[] visitorPort = nettyProxyMsg.getVisitorPort();
byte[] clientTargetIp = nettyProxyMsg.getClientTargetIp();
byte[] clientTargetPort = nettyProxyMsg.getClientTargetPort();
byte[] clientTargetIp = nettyProxyMsg.getTargetIp();
byte[] clientTargetPort = nettyProxyMsg.getTargetPort();
byte[] visitorId = nettyProxyMsg.getVisitorId();
// 真实服务通道
// Channel realChannel = NettyRealIdContext.getReal(new String(visitorId));

View File

@@ -33,6 +33,7 @@ public class ClientHandleUdpClientChannelActiveAdvanced extends AbstractHandleUd
// 缓存当前通道
byte[] clientIdByte = nettyProxyMsg.getClientId();
String clientId = new String(clientIdByte);
String serverId = new String(clientIdByte);
ChannelContext.push(channel, clientId);
ChannelAttributeKeyUtils.buildClientId(channel, clientId);
}

View File

@@ -35,14 +35,14 @@ public class ClientHandleUdpDistributeClientPermeateClientInitTypeAdvanced exten
@Override
public void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
// 初始化 客户端渗透服务端socket
byte[] fromClientIdBytes = nettyProxyMsg.getClientId();
byte[] originClientIdBytes = nettyProxyMsg.getClientId();
byte[] visitorPortBytes = nettyProxyMsg.getVisitorPort();
byte[] clientTargetIpBytes = nettyProxyMsg.getClientTargetIp();
byte[] clientTargetPortBytes = nettyProxyMsg.getClientTargetPort();
byte[] toClientIdBytes = nettyProxyMsg.getData();
byte[] clientTargetIpBytes = nettyProxyMsg.getTargetIp();
byte[] clientTargetPortBytes = nettyProxyMsg.getTargetPort();
byte[] targetClientIdBytes = nettyProxyMsg.getData();
String fromClientId = new String(fromClientIdBytes);
String toClientId = new String(toClientIdBytes);
String originClientId = new String(originClientIdBytes);
String targetClientId = new String(targetClientIdBytes);
Integer visitorPort = Integer.parseInt(new String(visitorPortBytes));
String clientTargetIp = new String(clientTargetIpBytes);
Integer clientTargetPort = Integer.parseInt(new String(clientTargetPortBytes));
@@ -50,17 +50,17 @@ public class ClientHandleUdpDistributeClientPermeateClientInitTypeAdvanced exten
List<HandleChannelTypeAdvanced> handleChannelTypeAdvancedList = new ArrayList<>(SpringContextHolder.getApplicationContext().getBeansOfType(HandleChannelTypeAdvanced.class).values());
// ChannelFlowAdapter channelFlowAdapter = SpringContextHolder.getBean(ChannelFlowAdapter.class);
NettyClientProperties nettyClientProperties = SpringContextHolder.getBean(NettyClientProperties.class);
log.info("client permeate client from client_id:【{}】 to_client_id【{}】with visitor_port【{}】, clientTargetIp:【{}】clientTargetPort:【{}】",
fromClientId, toClientId, visitorPort, clientTargetIp, clientTargetPort);
log.info("client permeate client from client_id:【{}】 target_client_id【{}】with visitor_port【{}】, clientTargetIp:【{}】clientTargetPort:【{}】",
originClientId, targetClientId, visitorPort, clientTargetIp, clientTargetPort);
NettyUdpClientPermeateClientVisitorSocket nettyTcpClientPermeateClientVisitorSocket =
NettyUdpClientPermeateClientVisitorSocket.NettyClientPermeateClientVisitorSocketBuilder.builder()
.builderClientId(fromClientId)
.builderClientId(originClientId)
.builderClientTargetIp(clientTargetIp)
.builderClientTargetPort(clientTargetPort)
.builderVisitorPort(visitorPort)
.builderNettyClientProperties(nettyClientProperties)
// .builderChannelFlowAdapter(channelFlowAdapter)
.builderToClientId(toClientId)
.builderToClientId(targetClientId)
.builderHandleChannelTypeAdvancedList(handleChannelTypeAdvancedList)
.build();

View File

@@ -43,8 +43,8 @@ public class ClientHandleUdpDistributeClientPermeateServerInitTypeAdvanced exten
// 初始化 客户端渗透服务端socket
byte[] clientIdBytes = nettyProxyMsg.getClientId();
byte[] visitorPort = nettyProxyMsg.getVisitorPort();
byte[] clientTargetIp = nettyProxyMsg.getClientTargetIp();
byte[] clientTargetPort = nettyProxyMsg.getClientTargetPort();
byte[] clientTargetIp = nettyProxyMsg.getTargetIp();
byte[] clientTargetPort = nettyProxyMsg.getTargetPort();
List<HandleChannelTypeAdvanced> handleChannelTypeAdvancedList = new ArrayList<>(SpringContextHolder.getApplicationContext().getBeansOfType(HandleChannelTypeAdvanced.class).values());
NettyUdpClientPermeateServerVisitorSocket nettyTcpClientPermeateServerVisitorSocket = NettyUdpClientPermeateServerVisitorSocket.NettyVisitorSocketBuilder.builder()

View File

@@ -34,8 +34,8 @@ public class ClientHandleUdpDistributeClientPermeateServerTransferTypeAdvanced e
Channel channel = nettyChannelContext.channel();
log.debug("客户端渗透服务端返回数据:{}" , new String(nettyProxyMsg.getData()));
byte[] visitorPort = nettyProxyMsg.getVisitorPort();
byte[] clientTargetIp = nettyProxyMsg.getClientTargetIp();
byte[] clientTargetPort = nettyProxyMsg.getClientTargetPort();
byte[] clientTargetIp = nettyProxyMsg.getTargetIp();
byte[] clientTargetPort = nettyProxyMsg.getTargetPort();
byte[] visitorId = nettyProxyMsg.getVisitorId();
// 真实服务通道
// Channel realChannel = NettyRealIdContext.getReal(new String(visitorId));

View File

@@ -36,8 +36,8 @@ public class ClientHandleUdpDistributeClientTransferClientPermeateChannelConnect
public void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
// 创建connect 然后发送创建成功
byte[] msgClientId = nettyProxyMsg.getClientId();
byte[] msgClientTargetIp = nettyProxyMsg.getClientTargetIp();
byte[] msgClientTargetPort = nettyProxyMsg.getClientTargetPort();
byte[] msgClientTargetIp = nettyProxyMsg.getTargetIp();
byte[] msgClientTargetPort = nettyProxyMsg.getTargetPort();
byte[] msgVisitorId = nettyProxyMsg.getVisitorId();
byte[] msgVisitorPort = nettyProxyMsg.getVisitorPort();

View File

@@ -36,8 +36,8 @@ public class ClientHandleUdpDistributeClientTransferClientPermeateChannelInitSuc
Channel channel = nettyChannelContext.channel();
// 连接成功 开启自动读取写
byte[] msgClientId = nettyProxyMsg.getClientId();
byte[] msgClientTargetIp = nettyProxyMsg.getClientTargetIp();
byte[] msgClientTargetPort = nettyProxyMsg.getClientTargetPort();
byte[] msgClientTargetIp = nettyProxyMsg.getTargetIp();
byte[] msgClientTargetPort = nettyProxyMsg.getTargetPort();
byte[] msgVisitorId = nettyProxyMsg.getVisitorId();
byte[] msgVisitorPort = nettyProxyMsg.getVisitorPort();

View File

@@ -40,8 +40,8 @@ public class ClientHandleUdpDistributeServicePermeateClientRealConnectTypeAdvanc
// 创建真实端口监听
byte[] clientIdBytes = msg.getClientId();
byte[] visitorPort = msg.getVisitorPort();
byte[] clientTargetIp = msg.getClientTargetIp();
byte[] clientTargetPort = msg.getClientTargetPort();
byte[] clientTargetIp = msg.getTargetIp();
byte[] clientTargetPort = msg.getTargetPort();
byte[] visitorIdBytes = msg.getVisitorId();
InternalNetworkPenetrationRealClient internalNetworkPenetrationRealClient =
InternalNetworkPenetrationRealClient

View File

@@ -59,11 +59,13 @@ public class NettyUdpClientHandler extends SimpleChannelInboundHandler<NettyProx
log.info("When establishing a connection{}" , new Date());
ctx.fireChannelActive();
String clientId = nettyUdpClientSocket.getClientId();
// 处理客户端连接成功
Channel channel = ctx.channel();
NettyProxyMsg nettyMsg = new NettyProxyMsg();
nettyMsg.setType(UdpMessageType.UDP_CLIENT_CHANNEL_ACTIVE);
nettyMsg.setClientId(clientId);
channelTypeAdapter.handler(ctx, nettyMsg);

View File

@@ -139,8 +139,8 @@ public class NettyUdpClientPermeateClientRealSocket {
NettyProxyMsg nettyProxyMsg = new NettyProxyMsg();
nettyProxyMsg.setVisitorId(visitorId);
nettyProxyMsg.setClientId(clientId);
nettyProxyMsg.setClientTargetIp(clientTargetIp);
nettyProxyMsg.setClientTargetPort(clientTargetPort);
nettyProxyMsg.setTargetIp(clientTargetIp);
nettyProxyMsg.setTargetPort(clientTargetPort);
nettyProxyMsg.setVisitorPort(visitorPort);
nettyProxyMsg.setType(UdpMessageType.UDP_REPORT_CLIENT_PERMEATE_CLIENT_TRANSFER_CHANNEL_INIT_SUCCESSFUL);
transferChannel.writeAndFlush(nettyProxyMsg);

View File

@@ -140,7 +140,7 @@ public class NettyUdpClientPermeateClientVisitorSocket implements PermeateVisito
/**
* 目标客户端ID
*/
private String toClientId;
private String targetClientId;
/**
* 流量适配器
@@ -248,11 +248,11 @@ public class NettyUdpClientPermeateClientVisitorSocket implements PermeateVisito
/**
* 目标客户端ID
*
* @param toClientId 目标客户端ID
* @param targetClientId 目标客户端ID
* @return 当前对象
*/
public NettyClientPermeateClientVisitorSocketBuilder builderToClientId(String toClientId) {
this.toClientId = toClientId;
public NettyClientPermeateClientVisitorSocketBuilder builderToClientId(String targetClientId) {
this.targetClientId = targetClientId;
return this;
}
public NettyUdpClientPermeateClientVisitorSocket build() {
@@ -267,8 +267,8 @@ public class NettyUdpClientPermeateClientVisitorSocket implements PermeateVisito
}
NettyClientPermeateClientVisitor nettyClientPermeateClientVisitor = new NettyClientPermeateClientVisitor();
nettyClientPermeateClientVisitor.setFromClientId(nettyClientProperties.getClientId());
nettyClientPermeateClientVisitor.setToClientId(toClientId);
nettyClientPermeateClientVisitor.setOriginClientId(nettyClientProperties.getClientId());
nettyClientPermeateClientVisitor.setTargetClientId(targetClientId);
nettyClientPermeateClientVisitor.setTargetIp(clientTargetIp);
nettyClientPermeateClientVisitor.setTargetPort(clientTargetPort);
nettyClientPermeateClientVisitor.setVisitorPort(visitorPort);

View File

@@ -57,10 +57,10 @@ public class NettyUdpClientPermeateClientVisitorTransferSocket {
String visitorId = ChannelAttributeKeyUtils.getVisitorId(visitorChannel);
Integer visitorPort = nettyClientPermeateClientVisitor.getVisitorPort();
String toClientId = nettyClientPermeateClientVisitor.getToClientId();
String targetClientId = nettyClientPermeateClientVisitor.getTargetClientId();
// 客户端新建访客通道 连接服务端IP:{},连接服务端端口:{}
log.info("Client creates a new visitor channel to connect to server IP: {}, connecting to server port: {} with clientId:【{}】 toClientId:【{}】 & visitorId:【{}】", inetHost, inetPort, clientId, toClientId, visitorId);
log.info("Client creates a new visitor channel to connect to server IP: {}, connecting to server port: {} with clientId:【{}】 targetClientId:【{}】 & visitorId:【{}】", inetHost, inetPort, clientId, targetClientId, visitorId);
ChannelFuture future = bootstrap.connect(inetHost, inetPort);
// 使用的客户端ID:{}
@@ -71,10 +71,10 @@ public class NettyUdpClientPermeateClientVisitorTransferSocket {
NettyProxyMsg nettyProxyMsg = new NettyProxyMsg();
nettyProxyMsg.setType(UdpMessageType.UDP_REPORT_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL);
// other clientId
nettyProxyMsg.setClientId(toClientId);
nettyProxyMsg.setClientId(targetClientId);
nettyProxyMsg.setVisitorPort(visitorPort);
nettyProxyMsg.setClientTargetIp(targetIp);
nettyProxyMsg.setClientTargetPort(targetPort);
nettyProxyMsg.setTargetIp(targetIp);
nettyProxyMsg.setTargetPort(targetPort);
nettyProxyMsg.setVisitorId(visitorId);
transferChannel.writeAndFlush(nettyProxyMsg);

View File

@@ -74,8 +74,8 @@ public class NettyUdpClientPermeateServerVisitorTransferSocket {
myMsg.setType(UdpMessageType.UDP_REPORT_CLIENT_TRANSFER_SERVER_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL);
myMsg.setClientId(clientId);
myMsg.setVisitorPort(visitorPort);
myMsg.setClientTargetIp(targetIp);
myMsg.setClientTargetPort(targetPort);
myMsg.setTargetIp(targetIp);
myMsg.setTargetPort(targetPort);
myMsg.setVisitorId(visitorId);
ChannelAttributeKeyUtils.buildVisitorId(transferChannel, visitorId);
ChannelAttributeKeyUtils.buildClientId(transferChannel, clientId);

View File

@@ -41,10 +41,6 @@ public class NettyUdpClientSocket implements NettyClientSocket {
@Getter
private final String clientId;
/**
* 当前连接的服务端ID
*/
private final String serverId;
private final String appKey;
private final String appSecret;
/**
@@ -57,7 +53,6 @@ public class NettyUdpClientSocket implements NettyClientSocket {
public NettyUdpClientSocket(String inetHost,
int inetPort,
String clientId,
String serverId,
String appKey,
String appSecret,
ClientChangeEvent clientChangeEvent,
@@ -65,7 +60,6 @@ public class NettyUdpClientSocket implements NettyClientSocket {
this.inetHost = inetHost;
this.inetPort = inetPort;
this.clientId = clientId;
this.serverId = serverId;
this.appKey = appKey;
this.appSecret = appSecret;
this.clientChangeEvent = clientChangeEvent;
@@ -73,10 +67,10 @@ public class NettyUdpClientSocket implements NettyClientSocket {
}
public void newConnect2Server() throws InterruptedException {
newConnect2Server(inetHost, inetPort, clientId, serverId, clientChangeEvent);
newConnect2Server(inetHost, inetPort, clientId, clientChangeEvent);
}
protected void newConnect2Server(String inetHost, int inetPort, String clientId, String serverId, ClientChangeEvent clientChangeEvent) throws InterruptedException {
protected void newConnect2Server(String inetHost, int inetPort, String clientId, ClientChangeEvent clientChangeEvent) throws InterruptedException {
Bootstrap bootstrap = new Bootstrap();
bootstrap.group(eventLoopGroup)
.channel(NioDatagramChannel.class)
@@ -113,17 +107,17 @@ public class NettyUdpClientSocket implements NettyClientSocket {
ChannelAttributeKeyUtils.buildClientId(serviceChannel, clientId);
serviceChannel.writeAndFlush(nettyMsg);
NettyServerContext.pushServerEndpointChannel(serverId, clientId, serviceChannel);
NettyServerContext.pushServerEndpointChannel(clientId, serviceChannel);
// 在线 客户端注册服务端成功
clientChangeEvent.clientOnLine(inetHost, inetPort,serverId, clientId);
clientChangeEvent.clientOnLine(inetHost, inetPort, clientId);
} else {
log.warn("Reconnect every 2 seconds....");
// 离线
NettyServerContext.removeServerEndpointChannels(serverId, clientId);
clientChangeEvent.clientOffLine(inetHost, inetPort,serverId, clientId);
NettyServerContext.removeServerEndpointChannels(clientId);
clientChangeEvent.clientOffLine(inetHost, inetPort, clientId);
eventLoopGroup.schedule(() -> {
try {
newConnect2Server(inetHost, inetPort, clientId, serverId, clientChangeEvent);
newConnect2Server(inetHost, inetPort, clientId, clientChangeEvent);
} catch (InterruptedException e) {
e.printStackTrace();
}

View File

@@ -182,8 +182,8 @@ public class NettyUdpServerPermeateClientRealSocket {
myMsg.setType(UdpMessageType.UDP_REPORT_SINGLE_CLIENT_REAL_CONNECT);
myMsg.setClientId(visitorClientId);
myMsg.setVisitorPort(visitorPort);
myMsg.setClientTargetIp(clientTargetIp);
myMsg.setClientTargetPort(clientTargetPort);
myMsg.setTargetIp(clientTargetIp);
myMsg.setTargetPort(clientTargetPort);
myMsg.setVisitorId(visitorId);
transferChannel.writeAndFlush(myMsg);

View File

@@ -36,8 +36,8 @@ public class ClientHandleDistributeHttpClientProxyClientConnectionTransferSucces
// 客户端主动连接服务端创建一个传输通道
byte[] msgClientId = nettyProxyMsg.getClientId();
byte[] msgClientTargetIp = nettyProxyMsg.getClientTargetIp();
byte[] msgClientTargetPort = nettyProxyMsg.getClientTargetPort();
byte[] msgClientTargetIp = nettyProxyMsg.getTargetIp();
byte[] msgClientTargetPort = nettyProxyMsg.getTargetPort();
byte[] msgVisitorId = nettyProxyMsg.getVisitorId();
String clientId = new String(msgClientId);

View File

@@ -31,8 +31,8 @@ public class ClientHandleDistributeHttpServerProxyClientConnectionSuccessfulType
// 创建一个传输通道
byte[] msgClientId = nettyProxyMsg.getClientId();
byte[] msgClientTargetIp = nettyProxyMsg.getClientTargetIp();
byte[] msgClientTargetPort = nettyProxyMsg.getClientTargetPort();
byte[] msgClientTargetIp = nettyProxyMsg.getTargetIp();
byte[] msgClientTargetPort = nettyProxyMsg.getTargetPort();
byte[] msgVisitorId = nettyProxyMsg.getVisitorId();
String clientId = new String(msgClientId);

View File

@@ -34,8 +34,8 @@ public class ClientHandleHttpClientProxyClientTypeAdvanced extends
@Override
protected void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
Channel channel = nettyChannelContext.channel();
String targetPortString = nettyProxyMsg.getTargetPortString();
String targetIpString = nettyProxyMsg.getTargetIpString();
String targetPortString = nettyProxyMsg.targetPort();
String targetIpString = nettyProxyMsg.targetIp();
byte[] data = nettyProxyMsg.getData();
byte[] clientId = nettyProxyMsg.getClientId();
List<HandleChannelTypeAdvanced> handleChannelTypeAdvancedList = new ArrayList<>(SpringContextHolder.getApplicationContext().getBeansOfType(HandleChannelTypeAdvanced.class).values());

View File

@@ -34,8 +34,8 @@ public class ClientHandleHttpClientProxyServerTypeAdvanced extends
protected void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
Channel channel = nettyChannelContext.channel();
String targetPortString = nettyProxyMsg.getTargetPortString();
String targetIpString = nettyProxyMsg.getTargetIpString();
String targetPortString = nettyProxyMsg.targetPort();
String targetIpString = nettyProxyMsg.targetIp();
byte[] data = nettyProxyMsg.getData();
List<HandleChannelTypeAdvanced> handleChannelTypeAdvancedList = new ArrayList<>(SpringContextHolder.getApplicationContext().getBeansOfType(HandleChannelTypeAdvanced.class).values());
NettyClientProperties nettyClientProperties = SpringContextHolder.getBean(NettyClientProperties.class);

View File

@@ -3,7 +3,6 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.proxy.http.socke
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.*;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioSocketChannel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
@@ -60,7 +59,7 @@ public class NettyHttpClientProxyClientProxySocket {
// 客户端链接服务端
log.info("Client creates a new proxy channel to connect to server IP: {}, connecting to server port: {} with clientId:【{}】 toClientId:【{}】 & visitorId:【{}】",
log.info("Client creates a new proxy channel to connect to server IP: {}, connecting to server port: {} with clientId:【{}】 targetClientId:【{}】 & visitorId:【{}】",
inetHost, inetPort, clientId, targetClientId, visitorId);
ChannelFuture future = bootstrap.connect(inetHost, inetPort);
@@ -73,8 +72,8 @@ public class NettyHttpClientProxyClientProxySocket {
nettyProxyMsg.setType(ProxyMessageType.HTTP_REPORT_CLIENT_PROXY_CLIENT_TRANSFER_CONNECTION_);
// other clientId
nettyProxyMsg.setClientId(targetClientId);
nettyProxyMsg.setClientTargetIp(targetIp);
nettyProxyMsg.setClientTargetPort(targetPort);
nettyProxyMsg.setTargetIp(targetIp);
nettyProxyMsg.setTargetPort(targetPort);
nettyProxyMsg.setData(data);
nettyProxyMsg.setVisitorId(visitorId);

View File

@@ -139,8 +139,8 @@ public class NettyHttpClientProxyClientRealSocket {
NettyProxyMsg nettyProxyMsg = new NettyProxyMsg();
nettyProxyMsg.setVisitorId(visitorId);
nettyProxyMsg.setClientId(clientId);
nettyProxyMsg.setClientTargetIp(clientTargetIp);
nettyProxyMsg.setClientTargetPort(clientTargetPort);
nettyProxyMsg.setTargetIp(clientTargetIp);
nettyProxyMsg.setTargetPort(clientTargetPort);
nettyProxyMsg.setType(ProxyMessageType.HTTP_REPORT_CLIENT_PROXY_CLIENT_TRANSFER_CHANNEL_INIT_SUCCESSFUL_);
transferChannel.writeAndFlush(nettyProxyMsg);

View File

@@ -64,7 +64,7 @@ public class NettyHttpClientProxyServerProxySocket {
// 客户端新建访客通道 连接服务端IP:{},连接服务端端口:{}
log.info("Client creates a new visitor channel to connect to server IP: {}, connecting to server port: {} with clientId:【{}】 toClientId:【{}】 & visitorId:【{}】", inetHost, inetPort, clientId, clientId, visitorId);
log.info("Client creates a new visitor channel to connect to server IP: {}, connecting to server port: {} with clientId:【{}】 targetClientId:【{}】 & visitorId:【{}】", inetHost, inetPort, clientId, clientId, visitorId);
ChannelFuture future = bootstrap.connect(inetHost, inetPort);
// 使用的客户端ID:{}
@@ -79,8 +79,8 @@ public class NettyHttpClientProxyServerProxySocket {
String hostAddress = InetAddress.getLocalHost().getHostAddress();
nettyProxyMsg.setOriginalIpString(hostAddress);
nettyProxyMsg.setClientTargetIp(targetIp);
nettyProxyMsg.setClientTargetPort(targetPort);
nettyProxyMsg.setTargetIp(targetIp);
nettyProxyMsg.setTargetPort(targetPort);
nettyProxyMsg.setData(data);
nettyProxyMsg.setVisitorId(visitorId);

View File

@@ -139,8 +139,8 @@ public class NettyHttpServerProxyClientRealSocket {
NettyProxyMsg nettyProxyMsg = new NettyProxyMsg();
nettyProxyMsg.setVisitorId(visitorId);
nettyProxyMsg.setClientId(clientId);
nettyProxyMsg.setClientTargetIp(clientTargetIp);
nettyProxyMsg.setClientTargetPort(clientTargetPort);
nettyProxyMsg.setTargetIp(clientTargetIp);
nettyProxyMsg.setTargetPort(clientTargetPort);
nettyProxyMsg.setType(ProxyMessageType.HTTP_REPORT_SERVER_PROXY_CLIENT_TRANSFER_CHANNEL_INIT_SUCCESSFUL_);
transferChannel.writeAndFlush(nettyProxyMsg);

View File

@@ -32,10 +32,10 @@ public class ClientHandleDistributeSocksClientProxyClientOtherConnectionTransfer
@Override
protected void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
Channel channel = nettyChannelContext.channel();
String clientId = nettyProxyMsg.getClientIdString();
String clientId = nettyProxyMsg.clientId();
byte[] visitorId = nettyProxyMsg.getVisitorId();
String targetIp = nettyProxyMsg.getTargetIpString();
Integer targetPort = Integer.parseInt(nettyProxyMsg.getTargetPortString());
String targetIp = nettyProxyMsg.targetIp();
Integer targetPort = Integer.parseInt(nettyProxyMsg.targetPort());
List<HandleChannelTypeAdvanced> handleChannelTypeAdvancedList = new ArrayList<>(SpringContextHolder.getApplicationContext().getBeansOfType(HandleChannelTypeAdvanced.class).values());
NettyClientProperties nettyClientProperties = SpringContextHolder.getBean(NettyClientProperties.class);

View File

@@ -37,8 +37,8 @@ public class ClientHandleNettySocketProtocolHandleSocketClientProxyClientStartTy
NettySocketChannelContext nettySocketChannelContext = (NettySocketChannelContext) nettyChannelContext;
Channel proxyChannel = nettySocketChannelContext.channel();
String host = nettyProxyMsg.getTargetIpString();
Integer port = Integer.parseInt(nettyProxyMsg.getTargetPortString());
String host = nettyProxyMsg.targetIp();
Integer port = Integer.parseInt(nettyProxyMsg.targetPort());
byte[] clientId = nettyProxyMsg.getClientId();
byte[] visitorId = nettyProxyMsg.getVisitorId();

View File

@@ -40,8 +40,8 @@ public class ClientHandleNettySocketProtocolHandleSocketClientProxyServerStartTy
NettySocketChannelContext nettySocketChannelContext = (NettySocketChannelContext) nettyChannelContext;
Channel proxyChannel = nettySocketChannelContext.channel();
String host = nettyProxyMsg.getTargetIpString();
Integer port = Integer.parseInt(nettyProxyMsg.getTargetPortString());
String host = nettyProxyMsg.targetIp();
Integer port = Integer.parseInt(nettyProxyMsg.targetPort());
Socks5AddressType socks5AddressType = nettySocketChannelContext.getSocks5AddressType();

View File

@@ -1,7 +1,6 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.proxy.socks.advanced;
import io.netty.channel.Channel;
import io.netty.handler.codec.socksx.v5.Socks5AddressType;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
import org.framework.lazy.cloud.network.heartbeat.client.netty.proxy.socks.NettySocksClientProxyClient;
@@ -37,10 +36,10 @@ public class ClientHandleSocksDistributeServerProxyClientConnectionInitTypeAdvan
// 绑定真实通道
Channel channel = nettyChannelContext.channel();
String clientId = nettyProxyMsg.getClientIdString();
String clientId = nettyProxyMsg.clientId();
byte[] visitorId = nettyProxyMsg.getVisitorId();
String targetIp = nettyProxyMsg.getTargetIpString();
Integer targetPort = Integer.parseInt(nettyProxyMsg.getTargetPortString());
String targetIp = nettyProxyMsg.targetIp();
Integer targetPort = Integer.parseInt(nettyProxyMsg.targetPort());
List<HandleChannelTypeAdvanced> handleChannelTypeAdvancedList = new ArrayList<>(SpringContextHolder.getApplicationContext().getBeansOfType(HandleChannelTypeAdvanced.class).values());

View File

@@ -63,6 +63,8 @@ public class NettySocksServerProxyClientTransferHandler extends SimpleChannelInb
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
cause.printStackTrace();
log.error(cause.getMessage());
super.exceptionCaught(ctx, cause);
}
}

View File

@@ -134,8 +134,8 @@ public class NettySocksClientProxyClientRealSocket {
NettyProxyMsg nettyProxyMsg = new NettyProxyMsg();
nettyProxyMsg.setVisitorId(visitorId);
nettyProxyMsg.setClientId(clientId);
nettyProxyMsg.setClientTargetIp(clientTargetIp);
nettyProxyMsg.setClientTargetPort(clientTargetPort);
nettyProxyMsg.setTargetIp(clientTargetIp);
nettyProxyMsg.setTargetPort(clientTargetPort);
nettyProxyMsg.setType(ProxyMessageType.SOCKS_REPORT_CLIENT_PROXY_CLIENT_OTHER_TRANSFER_CONNECTION_SUCCESS_);
transferChannel.writeAndFlush(nettyProxyMsg);

View File

@@ -9,7 +9,6 @@ import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
import org.framework.lazy.cloud.network.heartbeat.client.netty.proxy.socks.NettySocksClientProxyClient;
import org.framework.lazy.cloud.network.heartbeat.client.netty.proxy.socks.filter.NettySocksClientProxyClientVisitorTransferFilter;
import org.framework.lazy.cloud.network.heartbeat.client.netty.proxy.socks.filter.NettySocksClientProxyServerTransferFilter;
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.constant.ProxyMessageType;
@@ -69,9 +68,10 @@ public class NettySocksClientProxyClientVisitorTransferSocket {
NettyProxyMsg nettyProxyMsg = new NettyProxyMsg();
nettyProxyMsg.setType(ProxyMessageType.SOCKS_REPORT_CLIENT_PROXY_CLIENT_TRANSFER_CONNECTION_);
// other clientId
nettyProxyMsg.setClientTargetIp(targetIp);
nettyProxyMsg.setClientTargetPort(targetPort);
nettyProxyMsg.setTargetIp(targetIp);
nettyProxyMsg.setTargetPort(targetPort);
nettyProxyMsg.setClientId(targetClientId);
nettyProxyMsg.setVisitorId(visitorId);
nettyProxyMsg.setData(new byte[]{socks5AddressTypeByteValue});

View File

@@ -69,8 +69,8 @@ public class NettySocksClientProxyServerSocket {
NettyProxyMsg nettyProxyMsg = new NettyProxyMsg();
nettyProxyMsg.setType(ProxyMessageType.SOCKS_REPORT_CLIENT_PROXY_SERVER_TRANSFER_CONNECTION_);
// other clientId
nettyProxyMsg.setClientTargetIp(targetIp);
nettyProxyMsg.setClientTargetPort(targetPort);
nettyProxyMsg.setTargetIp(targetIp);
nettyProxyMsg.setTargetPort(targetPort);
nettyProxyMsg.setClientId(clientId);
nettyProxyMsg.setVisitorId(visitorId);

View File

@@ -6,8 +6,6 @@ import io.netty.channel.*;
import io.netty.channel.socket.nio.NioSocketChannel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
import org.framework.lazy.cloud.network.heartbeat.client.netty.proxy.socks.filter.NettySocksClientProxyClientRealFilter;
import org.framework.lazy.cloud.network.heartbeat.client.netty.proxy.socks.filter.NettySocksClientProxyClientTransferFilter;
import org.framework.lazy.cloud.network.heartbeat.client.netty.proxy.socks.filter.NettySocksServerProxyClientRealFilter;
import org.framework.lazy.cloud.network.heartbeat.client.netty.proxy.socks.filter.NettySocksServerProxyClientTransferFilter;
import org.framework.lazy.cloud.network.heartbeat.common.NettyRealIdContext;
@@ -130,24 +128,23 @@ public class NettySocksServerProxyClientRealSocket {
Channel transferChannel = futureListener.channel();
if (futureListener.isSuccess()) {
log.info("服务端代理客户端socks客户端连接服务端传输通道成功");
realChannel.config().setOption(ChannelOption.AUTO_READ, true);
// 通知服务端访客连接成功
NettyProxyMsg nettyProxyMsg = new NettyProxyMsg();
nettyProxyMsg.setVisitorId(visitorId);
nettyProxyMsg.setClientId(clientId);
nettyProxyMsg.setClientTargetIp(targetIp);
nettyProxyMsg.setClientTargetPort(targetPort);
nettyProxyMsg.setType(ProxyMessageType.SOCKS_REPORT_SERVER_PROXY_CLIENT_CONNECTION_SUCCESS_);
transferChannel.writeAndFlush(nettyProxyMsg);
// 绑定下一个通道
ChannelAttributeKeyUtils.buildNextChannel(transferChannel, realChannel);
ChannelAttributeKeyUtils.buildNextChannel(realChannel, transferChannel);
// 绑定客户端真实通信通道
ChannelAttributeKeyUtils.buildVisitorId(transferChannel, visitorId);
ChannelAttributeKeyUtils.buildClientId(transferChannel, clientId);
// 开始读取数据
realChannel.config().setOption(ChannelOption.AUTO_READ, true);
// 通知服务端访客连接成功
NettyProxyMsg nettyProxyMsg = new NettyProxyMsg();
nettyProxyMsg.setVisitorId(visitorId);
nettyProxyMsg.setClientId(clientId);
nettyProxyMsg.setTargetIp(targetIp);
nettyProxyMsg.setTargetPort(targetPort);
nettyProxyMsg.setType(ProxyMessageType.SOCKS_REPORT_SERVER_PROXY_CLIENT_CONNECTION_SUCCESS_);
transferChannel.writeAndFlush(nettyProxyMsg);
} else {
log.info("无法连接到服务端....");
eventLoopGroup.schedule(() -> {

View File

@@ -5,7 +5,7 @@
<link rel="icon" href="./favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Java 使用 Lazy ORM 网络穿透客户端!</title>
<script type="module" crossorigin src="./assets/index-DjZ671Nk.js"></script>
<script type="module" crossorigin src="./assets/index-BmaHpnnF.js"></script>
<link rel="stylesheet" crossorigin href="./assets/index-BEQZ9T9z.css">
</head>
<body>

View File

@@ -6,14 +6,14 @@
<parent>
<groupId>top.wu2020</groupId>
<artifactId>wu-lazy-cloud-network</artifactId>
<version>1.3.1-JDK17-SNAPSHOT</version>
<version>1.3.1-JDK24-SNAPSHOT</version>
</parent>
<artifactId>wu-lazy-cloud-heartbeat-common</artifactId>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>24</maven.compiler.source>
<maven.compiler.target>24</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
@@ -29,6 +29,11 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
</dependency>
<dependency>
<groupId>top.wu2020</groupId>
<artifactId>wu-framework-queue</artifactId>
<version>1.3.1-JDK24-SNAPSHOT</version>
</dependency>
</dependencies>
</project>

View File

@@ -19,8 +19,9 @@ import java.util.stream.Collectors;
@Slf4j
public class ChannelContext {
private final static ConcurrentHashMap<String/*clientId*/, List<Channel>/*通道*/>
channelIdClientChannelDTOConcurrentHashMap = new ConcurrentHashMap<>();
private final static
ConcurrentHashMap<String/*clientId*/, List<Channel>/*通道*/>
cacheClientChannelConcurrentHashMap = new ConcurrentHashMap<>();
/**
* 新增通道
@@ -29,25 +30,24 @@ public class ChannelContext {
* @param clientId 客户端ID
*/
public static void push(Channel channel, String clientId) {
// 如果客户端已经存在 移除
if (channelIdClientChannelDTOConcurrentHashMap.containsKey(clientId)) {
// clear(clientId);
// 如果服务端已经存在 移除
if (cacheClientChannelConcurrentHashMap.containsKey(clientId)) {
List<Channel> existChannelList = new ArrayList<>();
List<Channel> oldChannels = channelIdClientChannelDTOConcurrentHashMap.get(clientId);
List<Channel> oldChannels = cacheClientChannelConcurrentHashMap.get(clientId);
for (Channel existChannel : oldChannels) {
if (existChannel != null) {
if(existChannel.isActive()){
if (existChannel.isActive()) {
existChannelList.add(existChannel);
}else {
log.warn("close channel with client:{}", ChannelAttributeKeyUtils.getClientId(existChannel));
} else {
log.warn("close channel with client:{}", ChannelAttributeKeyUtils.getClientId(existChannel));
existChannel.close();
}
}
}
existChannelList.add(channel);
channelIdClientChannelDTOConcurrentHashMap.put(clientId, existChannelList);
}else {
channelIdClientChannelDTOConcurrentHashMap.putIfAbsent(clientId, Collections.synchronizedList(new ArrayList<>(List.of(channel))));
cacheClientChannelConcurrentHashMap.put(clientId, existChannelList);
} else {
cacheClientChannelConcurrentHashMap.putIfAbsent(clientId, Collections.synchronizedList(new ArrayList<>(List.of(channel))));
}
}
@@ -58,25 +58,26 @@ public class ChannelContext {
* @param channel 通道
* @param clientId 客户端ID
*/
public static void push(Channel channel, byte[] clientId) {
push(channel,new String(clientId, StandardCharsets.UTF_8));
public static void push(Channel channel, byte[] clientId) {
push(channel, new String(clientId, StandardCharsets.UTF_8));
}
/**
* 获取指定服务端所有通道
*
* @return 返回所有通道信息
*/
public static ConcurrentMap<String/*clientId*/, List<Channel>/*通道*/> getChannels() {
return cacheClientChannelConcurrentHashMap;
}
/**
* 获取所有通道
*
* @return 返回所有通道信息
*/
public static ConcurrentMap<String/*clientId*/, List<Channel>/*通道*/> getChannels() {
return channelIdClientChannelDTOConcurrentHashMap;
}
/**
* 获取所有通道
*
* @return 返回所有通道信息
*/
public static List<String> getClientIds() {
return new ArrayList<>(channelIdClientChannelDTOConcurrentHashMap.keySet().stream().toList());
return new ArrayList<>(cacheClientChannelConcurrentHashMap.keySet().stream().toList());
}
@@ -87,15 +88,15 @@ public class ChannelContext {
* @return 通道信息
*/
public static List<Channel> get(byte[] clientId) {
if (channelIdClientChannelDTOConcurrentHashMap
.containsKey(new String(clientId))) {
return channelIdClientChannelDTOConcurrentHashMap
.get(new String(clientId));
} else {
try {
return cacheClientChannelConcurrentHashMap.get(new String(clientId, StandardCharsets.UTF_8));
} catch (Exception e) {
e.printStackTrace();
// 无法通过客户端ID[{}]获取通道信息
log.error("Unable to obtain channel information through client ID [{}]",new String(clientId));
log.error("Unable to obtain channel information through client ID [{}]", new String(clientId));
return null;
}
}
/**
@@ -107,6 +108,7 @@ public class ChannelContext {
public static List<Channel> get(String clientId) {
return get(clientId.getBytes(StandardCharsets.UTF_8));
}
/**
* 根据通道ID获取通道信息
*
@@ -115,11 +117,11 @@ public class ChannelContext {
*/
public static Channel getLoadBalance(byte[] clientId) {
List<Channel> channels = get(clientId);
if(ObjectUtils.isEmpty(channels)){
if (ObjectUtils.isEmpty(channels)) {
return null;
}
channels = channels.stream().filter(Channel::isActive).collect(Collectors.toList());
if(ObjectUtils.isEmpty(channels)){
if (ObjectUtils.isEmpty(channels)) {
return null;
}
// TODO 负载问题
@@ -153,7 +155,7 @@ public class ChannelContext {
} else {
// log warm
// 无法通过客户ID:[{}]移除客户端
log.warn("Unable to remove client through customer ID: [{}]", clientId);
log.warn("Unable to remove client through clientId: [{}]", clientId);
}
}
@@ -165,10 +167,10 @@ public class ChannelContext {
public static void remove(byte[] clientId) {
List<Channel> clientChannel = get(clientId);
if (clientChannel != null) {
channelIdClientChannelDTOConcurrentHashMap.remove(new String(clientId));
cacheClientChannelConcurrentHashMap.remove(new String(clientId, StandardCharsets.UTF_8));
} else {
// log warm 无法通过客户ID:[{}]移除客户端
log.warn("Unable to remove client through customer ID: [{}]", new String(clientId));
log.warn("Unable to remove client through clientId: [{}]", new String(clientId));
}
}
@@ -180,10 +182,10 @@ public class ChannelContext {
public static void remove(String clientId) {
List<Channel> clientChannel = get(clientId);
if (clientChannel != null) {
channelIdClientChannelDTOConcurrentHashMap.remove(clientId);
cacheClientChannelConcurrentHashMap.remove(clientId);
} else {
// log warm 无法通过客户ID:[{}]移除客户端
log.warn("Unable to remove client through customer ID: [{}]", clientId);
log.warn("Unable to remove client through clientId: {}", clientId);
}
}

View File

@@ -16,6 +16,7 @@ import lombok.experimental.Accessors;
public class InternalNetworkPenetrationRealClient {
/**
* 客户端ID
*/

View File

@@ -19,9 +19,5 @@ public class NettyClientChannel {
* 客户端通道
*/
private Channel channel;
/**
* 服务端ID
*/
private String serverId;
}

View File

@@ -1,7 +1,6 @@
package org.framework.lazy.cloud.network.heartbeat.common;
import io.netty.channel.Channel;
import org.wu.framework.core.utils.ObjectUtils;
import java.util.ArrayList;
import java.util.Collection;
@@ -15,94 +14,70 @@ import java.util.stream.Collectors;
public class NettyServerContext {
protected static final ConcurrentHashMap<String/*serverId*/, List<NettyClientChannel>/*NettyClientChannel*/>
protected static final ConcurrentHashMap<String/*clientId*/, List<NettyClientChannel>/*NettyClientChannel*/>
NETTY_CLIENT_CHANNEL_SOCKET = new ConcurrentHashMap<>();
/**
* 添加访客
*
* @param serverId 服务端ID
* @param clientId 客户端ID
* @param channel channel
*/
public static <T> void pushServerEndpointChannel(String serverId, String clientId, Channel channel) {
List<NettyClientChannel> nettyClientChannelList = getServerEndpointChannels(serverId);
public static <T> void pushServerEndpointChannel(String clientId, Channel channel) {
List<NettyClientChannel> nettyClientChannelList = getServerEndpointChannels(clientId);
// 关闭旧的通道
nettyClientChannelList.stream().filter(nettyClientChannel -> nettyClientChannel.getClientId().equals(clientId) && nettyClientChannel.getServerId().equals(serverId)).forEach(nettyClientChannel -> {
nettyClientChannelList.forEach(nettyClientChannel -> {
Channel oldChannel = nettyClientChannel.getChannel();
if (oldChannel != null && oldChannel.isActive()) {
oldChannel.close();
}
});
List<NettyClientChannel> activeNettyClientChannelList = nettyClientChannelList
.stream()
.filter(nettyClientChannel ->
!nettyClientChannel.getClientId().equals(clientId) && !nettyClientChannel.getServerId().equals(serverId))
nettyClientChannel.getClientId().equals(clientId) && nettyClientChannel.getChannel().isActive())
.collect(Collectors.toList());
NettyClientChannel nettyClientChannel = new NettyClientChannel(clientId, channel, serverId);
NettyClientChannel nettyClientChannel = new NettyClientChannel(clientId, channel);
activeNettyClientChannelList.add(nettyClientChannel);
NETTY_CLIENT_CHANNEL_SOCKET.put(serverId, activeNettyClientChannelList);
NETTY_CLIENT_CHANNEL_SOCKET.put(clientId, activeNettyClientChannelList);
}
/**
* 通过客户端ID获取客户端使用的访客socket
*
* @param serverId 服务端ID
* @param clientId 客户端ID
* @return 客户端通道
*/
public static List<NettyClientChannel> getServerEndpointChannels(String serverId) {
return NETTY_CLIENT_CHANNEL_SOCKET.getOrDefault(serverId, new ArrayList<>());
public static List<NettyClientChannel> getServerEndpointChannels(String clientId) {
return NETTY_CLIENT_CHANNEL_SOCKET.getOrDefault(clientId, new ArrayList<>());
}
/**
* 通过客户端ID获取客户端使用的访客socket
*
* @return 客户端通道
*/
public static List<NettyClientChannel> getServerEndpointChannels() {
return NETTY_CLIENT_CHANNEL_SOCKET
.values()
.stream()
.collect(Collectors.flatMapping(Collection::stream,Collectors.toList()));
.collect(Collectors.flatMapping(Collection::stream, Collectors.toList()));
}
/**
* 移除 客户端通道
*
* @param serverId 服务端ID
* @param clientId 客户端ID
*/
public static void removeServerEndpointChannels(String serverId) {
for (NettyClientChannel nettyClientChannel : getServerEndpointChannels(serverId)) {
public static void removeServerEndpointChannels(String clientId) {
for (NettyClientChannel nettyClientChannel : getServerEndpointChannels(clientId)) {
if (nettyClientChannel.getChannel() != null && nettyClientChannel.getChannel().isActive()) {
nettyClientChannel.getChannel().close();
}
}
NETTY_CLIENT_CHANNEL_SOCKET.remove(serverId);
}
/**
* 移除 客户端通道
*
* @param serverId 服务端ID
* @param clientId 客户端ID
*/
public static <T> void removeServerEndpointChannels(String serverId, String clientId) {
List<NettyClientChannel> nettyClientChannelList = NETTY_CLIENT_CHANNEL_SOCKET.get(serverId);
if (!ObjectUtils.isEmpty(nettyClientChannelList)) {
// 关闭指定服务端对应客户端通道
nettyClientChannelList.stream().filter(nettyClientChannel -> nettyClientChannel.getClientId().equals(clientId))
.forEach(nettyClientChannel -> {
if (nettyClientChannel.getChannel() != null && nettyClientChannel.getChannel().isActive()) {
nettyClientChannel.getChannel().close();
}
});
// 过滤后数据
List<NettyClientChannel> clientChannelList = nettyClientChannelList.stream().filter(nettyClientChannel -> !nettyClientChannel.getClientId().equals(clientId))
.collect(Collectors.toList());
NETTY_CLIENT_CHANNEL_SOCKET.put(serverId, clientChannelList);
}
NETTY_CLIENT_CHANNEL_SOCKET.remove(clientId);
}

View File

@@ -2,11 +2,18 @@ package org.framework.lazy.cloud.network.heartbeat.common.adapter;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.flow.ChannelFlow;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.flow.HandleChannelFlowAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.flow.permeate.ChannelFlow;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.flow.permeate.HandleChannelFlowAdvanced;
import org.framework.wu.framework.queue.Message;
import org.framework.wu.framework.queue.MessageQueue;
import org.framework.wu.framework.queue.MessageQueueFactory;
import org.springframework.boot.CommandLineRunner;
import org.wu.framework.core.utils.ObjectUtils;
import java.util.List;
import java.util.concurrent.*;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
* 通道流量适配器
@@ -14,16 +21,16 @@ import java.util.concurrent.*;
* @see HandleChannelFlowAdvanced
*/
@Slf4j
public class ChannelFlowAdapter {
public class ChannelFlowAdapter implements CommandLineRunner {
private static final String QUEUE_NAME = "channel_permeate_flow";
ThreadPoolExecutor CHANNEL_FLOW_ADAPTER_EXECUTOR =
new ThreadPoolExecutor(20, 200, 3L, TimeUnit.MINUTES,
new LinkedBlockingDeque<>(500),new ThreadPoolExecutor.AbortPolicy());
new ThreadPoolExecutor(10, 20, 3L, TimeUnit.MINUTES,
new LinkedBlockingDeque<>(50), new ThreadPoolExecutor.AbortPolicy());
// 线程使用完后使用主线程执行
MessageQueue queue = MessageQueueFactory.getQueue(QUEUE_NAME);
protected final List<HandleChannelFlowAdvanced> handleChannelFlowAdvancedList;
public ChannelFlowAdapter(List<HandleChannelFlowAdvanced> handleChannelFlowAdvancedList) {
@@ -54,8 +61,25 @@ public class ChannelFlowAdapter {
* @param channelFlow 通道数据
*/
public void asyncHandler(Channel channel, ChannelFlow channelFlow) {
// TODO 流量并发异常
CHANNEL_FLOW_ADAPTER_EXECUTOR.submit(() -> handler(channel, channelFlow));
// TODO 流量并发异常
Message message = new Message("channel_permeate_flow_topic", channelFlow);
// 消息发送到队列
queue.send(message);
}
@Override
public void run(String... args) throws Exception {
// 创建监听线程
Thread thread = new Thread(() -> {
while (true) {
Message receive = queue.receive();
if (ObjectUtils.isNotEmpty(receive)) {
Object body = receive.getBody();
handler(null, (ChannelFlow) body);
}
}
});
CHANNEL_FLOW_ADAPTER_EXECUTOR.submit(thread::start);
}
}

View File

@@ -2,11 +2,17 @@ package org.framework.lazy.cloud.network.heartbeat.common.adapter;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.flow.HandleChannelFlowAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.flow.permeate.HandleChannelFlowAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.flow.proxy.ChannelProxyFlow;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.flow.proxy.HandleChannelProxyFlowAdvanced;
import org.framework.wu.framework.queue.Message;
import org.framework.wu.framework.queue.MessageQueue;
import org.framework.wu.framework.queue.MessageQueueFactory;
import org.springframework.boot.CommandLineRunner;
import org.wu.framework.core.utils.ObjectUtils;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
@@ -17,15 +23,17 @@ import java.util.concurrent.TimeUnit;
* @see HandleChannelFlowAdvanced
*/
@Slf4j
public class ChannelProxyFlowAdapter {
public class ChannelProxyFlowAdapter implements CommandLineRunner {
private static final String QUEUE_NAME = "channel_proxy_flow";
ThreadPoolExecutor CHANNEL_FLOW_ADAPTER_EXECUTOR =
new ThreadPoolExecutor(20, 200, 3L, TimeUnit.MINUTES,
new LinkedBlockingDeque<>(500),new ThreadPoolExecutor.AbortPolicy());
new ThreadPoolExecutor(10, 20, 3L, TimeUnit.MINUTES,
new LinkedBlockingDeque<>(50),new ThreadPoolExecutor.AbortPolicy());
// 线程使用完后使用主线程执行
MessageQueue queue = MessageQueueFactory.getQueue(QUEUE_NAME);
protected final List<HandleChannelProxyFlowAdvanced> handleChannelProxyFlowAdvancedList;
@@ -59,7 +67,25 @@ public class ChannelProxyFlowAdapter {
*/
public void asyncHandler(Channel channel, ChannelProxyFlow channelProxyFlow) {
// TODO 流量并发异常
CHANNEL_FLOW_ADAPTER_EXECUTOR.submit(() -> handler(channel, channelProxyFlow));
Message message = new Message("channel_proxy_flow_topic", channelProxyFlow);
// 消息发送到队列
queue.send(message);
}
@Override
public void run(String... args) throws Exception {
// 创建监听线程
Thread thread = new Thread(() -> {
while (true) {
Message receive = queue.receive();
if(ObjectUtils.isNotEmpty(receive)) {
Object body = receive.getBody();
handler(null, (ChannelProxyFlow) body);
}
}
});
CHANNEL_FLOW_ADAPTER_EXECUTOR.submit(thread::start);
}
}

View File

@@ -2,9 +2,9 @@ package org.framework.lazy.cloud.network.heartbeat.common.advanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.springframework.core.Ordered;
import org.framework.lazy.cloud.network.heartbeat.common.constant.TcpMessageType;
import org.framework.lazy.cloud.network.heartbeat.common.enums.TcpMessageTypeEnums;
import org.springframework.core.Ordered;
/**
* 通道不同数据类型处理器

View File

@@ -1,4 +1,4 @@
package org.framework.lazy.cloud.network.heartbeat.common.advanced.flow;
package org.framework.lazy.cloud.network.heartbeat.common.advanced.flow.permeate;
import io.netty.channel.Channel;

View File

@@ -1,4 +1,4 @@
package org.framework.lazy.cloud.network.heartbeat.common.advanced.flow;
package org.framework.lazy.cloud.network.heartbeat.common.advanced.flow.permeate;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ChannelFlowEnum;

View File

@@ -1,4 +1,4 @@
package org.framework.lazy.cloud.network.heartbeat.common.advanced.flow;
package org.framework.lazy.cloud.network.heartbeat.common.advanced.flow.permeate;
import io.netty.channel.Channel;

View File

@@ -15,7 +15,7 @@ import java.nio.charset.StandardCharsets;
@Setter
@Getter
public class NettyProxyMsg {
// body 长度 type 1 isSsl 1 appKey 4 appSecret 4 clientId 4 originalIp 4 clientTargetIp 4 clientTargetPort 4 visitorPort 4 visitorId 4 data 4
// body 长度 type 1 isSsl 1 appKey 4 appSecret 4 clientId 4 originalIp 4 targetIp 4 targetPort 4 visitorPort 4 visitorId 4 data 4
public static final int bodyLength = 1 + 1 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4;
@@ -55,6 +55,7 @@ public class NettyProxyMsg {
* @since 1.2.9
*/
private byte[] originalIp;
/**
* 客户端ID
* byte[] 长度 4
@@ -64,13 +65,13 @@ public class NettyProxyMsg {
* 客户端目标地址
* byte[] 长度 4
*/
private byte[] clientTargetIp;
private byte[] targetIp;
/**
* 客户端目标端口
* byte[] 长度 4
*/
private byte[] clientTargetPort;
private byte[] targetPort;
/**
* 客户端目使用的代理端口
* byte[] 长度 4
@@ -92,8 +93,8 @@ public class NettyProxyMsg {
public String toString() {
return "NettyProxyMsg [type=" + type +
",clientId=" + (clientId == null ? null : new String(clientId)) +
",clientTargetIp=" + (clientTargetIp == null ? null : new String(clientTargetIp)) +
",clientTargetPort=" + (clientTargetPort == null ? null : new String(clientTargetPort)) +
",targetIp=" + (targetIp == null ? null : new String(targetIp)) +
",targetPort=" + (targetPort == null ? null : new String(targetPort)) +
",visitorPort=" + (visitorPort == null ? null : new String(visitorPort)) +
"]";
}
@@ -107,6 +108,8 @@ public class NettyProxyMsg {
}
public void setAppKeyString(String appKey) {
if (ObjectUtils.isEmpty(appKey)) {
this.appKey = null;
@@ -172,40 +175,42 @@ public class NettyProxyMsg {
return new String(originalIp, StandardCharsets.UTF_8);
}
public String getClientIdString() {
public String clientId() {
if (ObjectUtils.isEmpty(clientId)) {
return null;
}
return new String(clientId, StandardCharsets.UTF_8);
}
/**
* 客户端目标地址
*
* @return 客户端目标地址
*/
public String getTargetIpString() {
if (ObjectUtils.isEmpty(clientTargetIp)) {
public String targetIp() {
if (ObjectUtils.isEmpty(targetIp)) {
return null;
}
return new String(clientTargetIp, StandardCharsets.UTF_8);
return new String(targetIp, StandardCharsets.UTF_8);
}
/**
* 客户端目标端口
*
* @return 客户端目标端口
*/
public String getTargetPortString() {
if (ObjectUtils.isEmpty(clientTargetPort)) {
public String targetPort() {
if (ObjectUtils.isEmpty(targetPort)) {
return null;
}
return new String(clientTargetPort, StandardCharsets.UTF_8);
return new String(targetPort, StandardCharsets.UTF_8);
}
/**
* 获取访客ID
* @return
*/
public String getVisitorIdString() {
public String visitorId() {
if (ObjectUtils.isEmpty(visitorId)) {
return null;
}
@@ -219,20 +224,20 @@ public class NettyProxyMsg {
return Integer.valueOf(new String(visitorPort, StandardCharsets.UTF_8));
}
public void setClientTargetIp(byte[] clientTargetIp) {
this.clientTargetIp = clientTargetIp;
public void setTargetIp(byte[] targetIp) {
this.targetIp = targetIp;
}
public void setClientTargetIp(String clientTargetIp) {
this.clientTargetIp = clientTargetIp.getBytes(StandardCharsets.UTF_8);
public void setTargetIp(String clientTargetIp) {
this.targetIp = clientTargetIp.getBytes(StandardCharsets.UTF_8);
}
public void setClientTargetPort(Integer clientTargetPort) {
this.clientTargetPort = String.valueOf(clientTargetPort).getBytes(StandardCharsets.UTF_8);
public void setTargetPort(Integer targetPort) {
this.targetPort = String.valueOf(targetPort).getBytes(StandardCharsets.UTF_8);
}
public void setClientTargetPort(byte[] clientTargetPort) {
this.clientTargetPort = clientTargetPort;
public void setTargetPort(byte[] targetPort) {
this.targetPort = targetPort;
}
public void setVisitorPort(byte[] visitorPort) {

View File

@@ -1,9 +1,9 @@
package org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.AbstractHandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.enums.TcpMessageTypeEnums;

View File

@@ -1,9 +1,9 @@
package org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.client;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.AbstractHandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.enums.TcpMessageTypeEnums;

View File

@@ -1,9 +1,9 @@
package org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.client;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.AbstractHandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.enums.TcpMessageTypeEnums;

View File

@@ -1,9 +1,9 @@
package org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.client;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.AbstractHandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.enums.TcpMessageTypeEnums;

View File

@@ -1,9 +1,9 @@
package org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.client;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.AbstractHandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.enums.TcpMessageTypeEnums;

View File

@@ -1,9 +1,9 @@
package org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.client;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.AbstractHandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.enums.TcpMessageTypeEnums;

View File

@@ -1,9 +1,9 @@
package org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.client;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.AbstractHandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.enums.TcpMessageTypeEnums;

View File

@@ -1,9 +1,9 @@
package org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.client;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.AbstractHandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.enums.TcpMessageTypeEnums;

View File

@@ -1,9 +1,9 @@
package org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.client;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.AbstractHandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.enums.TcpMessageTypeEnums;

View File

@@ -1,9 +1,9 @@
package org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.client;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.AbstractHandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.enums.TcpMessageTypeEnums;

View File

@@ -1,9 +1,9 @@
package org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.client;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.AbstractHandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.enums.TcpMessageTypeEnums;

View File

@@ -1,9 +1,9 @@
package org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.client;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.AbstractHandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.enums.TcpMessageTypeEnums;

View File

@@ -1,9 +1,9 @@
package org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.client;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.AbstractHandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.enums.TcpMessageTypeEnums;
/**

View File

@@ -1,9 +1,9 @@
package org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.client;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.AbstractHandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.enums.TcpMessageTypeEnums;

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