133 Commits

Author SHA1 Message Date
wujiawei
ac38d8dfd7 [update] 1.3.4-JDK24-SNAPSHOT 2025-07-21 22:18:05 +08:00
wujiawei
6142105ac3 [update] 1.3.3-JDK24 2025-07-21 22:07:44 +08:00
wujiawei
ff3681fc46 [update] 1.3.1-JDK24 2025-07-21 16:59:53 +08:00
wujiawei
9e1a47f4e9 [update] 1.3.1-JDK24 2025-07-19 22:57:56 +08:00
wujiawei
13858a0b7c [add] 修改中央仓库https://central.sonatype.com/account 2025-07-17 19:25:36 +08:00
wujiawei
caff71be87 [add] 修改中央仓库https://central.sonatype.com/account 2025-07-17 00:06:24 +08:00
wujiawei
04c683cb9a [add] 修改中央仓库https://central.sonatype.com/account 2025-07-16 23:49:03 +08:00
wujiawei
e5f53b520b 【fix】授权调整 2025-07-16 21:49:01 +08:00
wujiawei
50b2b1866c 【fix】授权调整 2025-07-16 21:30:09 +08:00
wujiawei
841c24a6ed 【fix】注释udp、通道关闭验证通道关联通道是否存在 2025-07-15 16:20:06 +08:00
wujiawei
e387a43437 【fix】ui 调整 2025-07-15 15:17:19 +08:00
wujiawei
438198bcc5 【fix】ui 调整 2025-07-15 15:16:07 +08:00
wujiawei
afe1a1417f 【fix】ui 调整 2025-07-15 13:24:36 +08:00
wujiawei
d9d82a99d5 【fix】ui 调整 2025-07-15 13:23:53 +08:00
wujiawei
c5aeb6f0f7 【fix】proxy代理支持令牌验证 2025-07-14 18:54:10 +08:00
wujiawei
f8f485a14a 【fix】本地代理支持代理日志记录 2025-07-13 14:52:18 +08:00
wujiawei
7178974abb 【fix】 本地socket代理通道添加属性。目标ip、目标端口、访客ID 2025-07-12 12:07:40 +08:00
wujiawei
f2fede4a96 【fix】 添加版本记录 2025-07-09 22:15:54 +08:00
wujiawei
74eab26478 [add] 修改inethost字段长度 2025-07-01 20:28:44 +08:00
wujiawei
faabae3d19 [add] 添加socks授权验证 2025-06-26 21:00:20 +08:00
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
wujiawei
6c6584fdb9 [fix] 修复native打包与mapper不兼容问题,切换至自定义bean拷贝 2025-06-09 16:41:24 +08:00
wujiawei
221623e9c0 [fix] 修复native打包与mapper不兼容问题,切换至自定义bean拷贝 2025-06-09 16:23:25 +08:00
wujiawei
ff150eb31c [fix] 修复native打包与mapper不兼容问题,切换至自定义bean拷贝 2025-06-09 16:19:55 +08:00
wujiawei
e1de673b52 [fix] 修复native打包与mapper不兼容问题,切换至自定义bean拷贝 2025-06-09 14:56:45 +08:00
wujiawei
01a2937414 [fix] 修复native打包与mapper不兼容问题,切换至自定义bean拷贝 2025-06-09 14:40:06 +08:00
wujiawei
e8383c78ad [fix] 添加代理流量监控 2025-06-07 11:13:34 +08:00
wujiawei
1a08fe64e9 [fix] 修改唯一索引问题 2025-06-07 01:31:43 +08:00
wujiawei
ca87968469 [fix] 修改唯一索引问题 2025-06-07 01:25:08 +08:00
wujiawei
903ba88787 [fix] 修改枚举问题 2025-06-07 00:36:20 +08:00
wujiawei
0505d6d201 [fix] 添加代理流量统计 2025-06-07 00:27:02 +08:00
wujiawei
556cb3fd1b [fix] 添加代理流量统计 2025-06-07 00:26:37 +08:00
wujiawei
ddb709c3a8 [fix] socks、http代理 添加流量计费 2025-06-06 23:13:01 +08:00
wujiawei
9cd85abe1d [fix] socks、http代理 添加流量计费 2025-06-06 23:01:52 +08:00
wujiawei
664bafdc86 Merge remote-tracking branch 'origin/master' 2025-06-06 22:14:20 +08:00
wujiawei
3b9379a7aa [fix] socks、http代理 添加流量计费 2025-06-06 21:25:31 +08:00
WJWJW
17306c348a fix 2025-06-04 15:58:15 +08:00
wujiawei
e518e20cc1 Merge remote-tracking branch 'origin/master'
# Conflicts:
#	wu-lazy-cloud-heartbeat-start/wu-lazy-cloud-heartbeat-client-start/pom.xml
2025-06-03 13:42:24 +08:00
wujiawei
a27506299e [fix] 测试mapstruct 打包native异常问题 2025-06-03 13:41:54 +08:00
wujiawei
40de2dbe4d [fix] 2025-06-02 14:25:12 +08:00
wujiawei
06869dcd2f 【fix】 cgroup2fs环境 2025-05-31 18:49:33 +08:00
wujiawei
c9b866885a 【fix】 cgroup2fs环境 2025-05-31 18:36:34 +08:00
wujiawei
f496f12fe3 【fix】 cgroup2fs环境 2025-05-31 18:25:49 +08:00
wujiawei
6e6ce666b8 【fix】注释 <!-- <dependency>-->
<!--            <groupId>org.springframework.boot</groupId>-->
        <!--            <artifactId>spring-boot-starter-actuator</artifactId>-->
        <!--        </dependency>-->
        原因与服务器架构x86 飞牛os不兼容
2025-05-31 18:23:55 +08:00
WJWJW
f82e9e5f0a fix 2025-05-31 17:53:45 +08:00
wujiawei
26e4990f0a 【fix】注释 <!-- <dependency>-->
<!--            <groupId>org.springframework.boot</groupId>-->
        <!--            <artifactId>spring-boot-starter-actuator</artifactId>-->
        <!--        </dependency>-->
        原因与服务器架构x86 飞牛os不兼容
2025-05-31 17:50:26 +08:00
wujiawei
833e97a89d 【fix】 2025-05-30 16:51:00 +08:00
wujiawei
dab44fc1a2 【fix】 2025-05-27 11:04:18 +08:00
wujiawei
200a636379 【fix】 2025-05-27 09:58:14 +08:00
wujiawei
08b8e2dbb8 【fix】md 2025-05-26 10:58:40 +08:00
wujiawei
e7df027d65 【fix】md 2025-05-23 11:32:32 +08:00
wujiawei
071b844d68 【fix】md 2025-05-22 17:00:08 +08:00
wujiawei
afa4d5c360 【fix】添加流程图 2025-05-22 15:14:40 +08:00
wujiawei
c057d7b2d5 【fix】修复服务端socks代理客户端时断时续问题 2025-05-20 15:59:37 +08:00
wujiawei
7f9cebec8a 【fix】init route ip 2025-05-13 21:32:19 +08:00
wujiawei
32a641ce99 【fix】init route ip 2025-05-13 11:15:21 +08:00
wujiawei
a3c88ffa9f 【fix】init route ip 2025-05-08 12:34:55 +08:00
wujiawei
466faacb93 【fix】log 2025-05-08 11:43:48 +08:00
wujiawei
687770e086 【fix】log 2025-05-08 10:35:28 +08:00
wujiawei
32c757ef5e 【fix】error 2025-05-08 09:47:44 +08:00
wujiawei
68f4c92366 【fix】修改 * 端口问题 2025-05-08 09:09:09 +08:00
wujiawei
ad7fa61067 【fix】修改虚拟路由问题 2025-05-08 08:50:40 +08:00
wujiawei
fe3adeee03 【fix】添加 @Role(BeanDefinition.ROLE_INFRASTRUCTURE) 2025-05-07 17:47:23 +08:00
wujiawei
2e40988ef4 【fix】添加 @Role(BeanDefinition.ROLE_INFRASTRUCTURE) 2025-05-07 15:59:45 +08:00
wujiawei
5528ef6ebd 【fix】添加虚拟路由管理 2025-05-07 14:33:27 +08:00
wujiawei
9401c27572 【fix】添加虚拟路由管理 2025-05-07 12:13:20 +08:00
wujiawei
c852e3b351 【fix】添加虚拟路由管理 2025-05-07 12:04:40 +08:00
wujiawei
17b220a76a 【fix】添加虚拟路由管理 2025-05-07 11:27:14 +08:00
wujiawei
191e23fc83 【fix】添加虚拟路由管理 2025-05-07 11:13:56 +08:00
wujiawei
96929044fa 【fix】添加虚拟路由管理 2025-05-07 11:09:19 +08:00
wujiawei
965142793c 【fix】添加虚拟路由管理 2025-05-06 17:48:41 +08:00
wujiawei
9a44a598ef 【fix】添加虚拟路由管理 2025-05-06 17:27:35 +08:00
wujiawei
c2c350a28a 【fix】bug 2025-05-06 09:43:39 +08:00
wujiawei
8cc3b4858a 【fix】bug 2025-05-05 23:41:14 +08:00
wujiawei
3c32a5d157 【fix】客户端代理客户端 2025-05-05 23:20:54 +08:00
wujiawei
578429777a 【fix】客户端代理客户端 2025-05-05 23:12:04 +08:00
wujiawei
5eba201979 【fix】新增本地socks代理服务端 2025-05-05 21:47:04 +08:00
wujiawei
f8a9ca4264 【fix】新增本地socks代理服务端 2025-05-05 20:20:58 +08:00
wujiawei
7af14b4251 【fix】新增本地socks代理服务端 2025-05-04 13:35:09 +08:00
wujiawei
24fe9e4bc9 【fix】新增本地socks代理服务端 2025-05-03 23:34:28 +08:00
wujiawei
2adf5e4749 【fix】新增本地socks代理服务端 2025-05-03 22:39:41 +08:00
wujiawei
b7f099d3a4 【fix】新增本地socks代理服务端 2025-05-03 22:36:21 +08:00
wujiawei
f0fd22ccd4 【fix】1.3.1-JDK17-SNAPSHOT 2025-05-03 10:41:36 +08:00
wujiawei
7b26e9cb60 【fix】1.3.1-JDK17-SNAPSHOT 2025-05-03 10:40:46 +08:00
wujiawei
6e79901be3 【fix】修复无法启动问题 2025-04-30 18:53:36 +08:00
wujiawei
f88e0e2b7f 【fix】修复无法启动问题 2025-04-30 18:18:32 +08:00
wujiawei
9324b516fd 【fix】修复无法启动问题 2025-04-30 16:59:10 +08:00
wujiawei
a6c46c3cba 【fix】修复无法启动问题 2025-04-30 16:12:51 +08:00
wujiawei
66956636b9 【fix】修复无法启动问题 2025-04-30 16:08:53 +08:00
wujiawei
9dc36fe8e9 【fix】修复无法启动问题 2025-04-30 16:02:07 +08:00
wujiawei
f2a22c177e 【fix】 2025-04-30 15:19:56 +08:00
wujiawei
98587b442c 【fix】 添加socket5代理demo 2025-04-30 13:54:40 +08:00
wujiawei
e51ad201de 【fix】 优化代理 2025-04-29 09:15:59 +08:00
1080 changed files with 20786 additions and 8942 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.0-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
```
#### 操作步骤:杭州本地机房所在网络服务器启动客户端、你老家所在网络中启动客户端,命令如下
```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.0-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
```
```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.0-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
```
#### 操作步骤:配置端口
![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

@@ -2,8 +2,8 @@
#### 模块说明
| 模块 | 所属层级 | 描述 | 端口 |
|------------------------------------------------------------------------------------|------|------------------------|----------------------------------------------------------------|
| 模块 | 所属层级 | 描述 | 端口 |
|------------------------------------------------------------------|------|------------------------|----------------------------------------------------------------|
| [wu-lazy-cloud-heartbeat-common](wu-lazy-cloud-heartbeat-common) | 基础模块 | 基于Netty数据解码、编码、通道处理器声明 | 无 |
| [wu-lazy-cloud-heartbeat-server](wu-lazy-cloud-heartbeat-server) | 启动模块 | 内网穿透服务端 | http端口6001、tcp端口:7001 (默认tcp端口=http端口+1000 如6001+1000=7001) |
| [wu-lazy-cloud-heartbeat-client](wu-lazy-cloud-heartbeat-client) | 启动模块 | 内网穿透客户端 | 6004 |

BIN
Proxies_Config_1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 542 KiB

BIN
Proxies_Config_2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 528 KiB

BIN
Proxies_Config_3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 547 KiB

BIN
Proxies_Config_4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 553 KiB

BIN
Proxifier3.8.0.dmg Normal file

Binary file not shown.

33
Proxy.md Normal file
View File

@@ -0,0 +1,33 @@
### 使用手册
#### Mac 使用方式
##### 获取socks或者http代理服务器信息
ip127.0.0.1 port9001socks、8001http
##### 使用Wi-Fi代理
注意如下方式只能代理浏览器请求,无法代理其他应用请求
![mac_http_proxy.png](mac_http_proxy.png)
![mac_socks_proxy.png](mac_socks_proxy.png)
##### 使用第三方软件全局代理[Proxifier3.8.0.dmg](Proxifier3.8.0.dmg)
注册码
# Proxifier Mac
cracked@macked.app
8TB85-UWT64-AKK2R-XGBDY-F2UP5
# Proxifier Standard Edition
cracked@macked.app
4JB8X-9YMEZ-BD332-PPNN3-46P48
# Proxifier Portable Edition
cracked@macked.app
FXBZZ-U2FPK-G5KW9-KAANW-TLGPL
- Proxifier配置
![Proxies_Config_1.png](Proxies_Config_1.png)
- 配置socks服务器地址
![Proxies_Config_2.png](Proxies_Config_2.png)
![Proxies_Config_3.png](Proxies_Config_3.png)
- 配置代理路由
![Proxies_Config_4.png](Proxies_Config_4.png)
- 展示效果
![proxy_inner_net_ui.png](proxy_inner_net_ui.png)
#### Windows 使用方式
##### 使用Wi-Fi代理
![windows_wifi_proxy.png](windows_wifi_proxy.png)

244
README.md
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。
ORM操作数据库使用环境JDK24 Spring Boot 3.5.0。的网络穿透、渗透工具支持Tcp、Http、Socks
主要功能:
- 服务端渗透客户端网络穿透对于没有公网IP的服务进行公网IP映射
- ![NetworkPermeateServerPermeateClient.png](NetworkPermeateServerPermeateClient.png)
@@ -43,10 +46,22 @@ ORM操作数据库使用环境JDK17 Spring Boot 3.0.2。
- ![NetworkPermeateClientPermeateServer.png](NetworkPermeateClientPermeateServer.png)
- 客户端渗透客户端----本地端口映射到另一个局域网端口
- ![NetworkPermeateClientPermeateClient.png](NetworkPermeateClientPermeateClient.png)
- 客户端代理服务端、客户端代理客户端、服务端代理服务端、服务端代理客户端VPN----异地组网搭建代理
- ![wlcn-proxy1.0-.png](wlcn-proxy1.0-.png)
[UI](https://gitee.com/wujiawei1207537021/wu-lazy-cloud-network-server-ui)
### 内网穿透
| 模块 | 所属层级 | 描述 | 快照版本 | 发布版本 |
|--------------------------------------|------|------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| wu-lazy-cloud-heartbeat-common | 组件 | 内网穿透公共模块(声明接口、枚举、常量、适配器、解析器) | <a target="_blank" href="https://search.maven.org/search?q=wu-lazy-cloud-heartbeat-common%20wu-bionic-parent"><img src="https://img.shields.io/nexus/s/top.wu2020/wu-bionic-parent?server=https%3A%2F%2Foss.sonatype.org&style=flat&logo=log" alt="Maven" /></a> | <a target="_blank" href="https://search.maven.org/search?q=wu-lazy-cloud-heartbeat-common%20wu-lazy-cloud-heartbeat-common"><img src="https://img.shields.io/maven-central/v/top.wu2020/wu-lazy-cloud-heartbeat-common" alt="Maven" /></a> |
| wu-lazy-cloud-heartbeat-client | 组件 | 客户端(支持二次开发) | <a target="_blank" href="https://search.maven.org/search?q=wu-lazy-cloud-heartbeat-client%20wu-lazy-cloud-heartbeat-client"><img src="https://img.shields.io/nexus/s/top.wu2020/wu-lazy-cloud-heartbeat-client?server=https%3A%2F%2Foss.sonatype.org&style=flat&logo=log" alt="Maven" /></a> | <a target="_blank" href="https://search.maven.org/search?q=wu-lazy-cloud-heartbeat-client%20wu-lazy-cloud-heartbeat-client"><img src="https://img.shields.io/maven-central/v/top.wu2020/wu-lazy-cloud-heartbeat-client" alt="Maven" /></a> |
| wu-lazy-cloud-heartbeat-server | 组件 | 服务端(支持二次开发) | <a target="_blank" href="https://search.maven.org/search?q=wu-lazy-cloud-heartbeat-server%20wu-lazy-cloud-heartbeat-server"><img src="https://img.shields.io/nexus/s/top.wu2020/wu-lazy-cloud-heartbeat-server?server=https%3A%2F%2Foss.sonatype.org&style=flat&logo=log" alt="Maven" /></a> | <a target="_blank" href="https://search.maven.org/search?q=wu-lazy-cloud-heartbeat-server%20wu-lazy-cloud-heartbeat-server"><img src="https://img.shields.io/maven-central/v/top.wu2020/wu-lazy-cloud-heartbeat-server" alt="Maven" /></a> |
| wu-lazy-cloud-ui | ui | 服务端页面 | | |
| wu-lazy-cloud-heartbeat-client-start | 客户端 | 客户端 | <a target="_blank" href="https://search.maven.org/search?q=wu-lazy-cloud-heartbeat-client-start%20wu-lazy-cloud-heartbeat-client-start"><img src="https://img.shields.io/nexus/s/top.wu2020/wu-lazy-cloud-heartbeat-client-start?server=https%3A%2F%2Foss.sonatype.org&style=flat&logo=log" alt="Maven" /></a> | <a target="_blank" href="https://search.maven.org/search?q=wu-lazy-cloud-heartbeat-client-start%20wu-lazy-cloud-heartbeat-client-start"><img src="https://img.shields.io/maven-central/v/top.wu2020/wu-lazy-cloud-heartbeat-client-start" alt="Maven" /></a> |
| wu-lazy-cloud-heartbeat-server-start | 服务端 | 服务端 | <a target="_blank" href="https://search.maven.org/search?q=wu-lazy-cloud-heartbeat-server-start%20wu-lazy-cloud-heartbeat-server-start"><img src="https://img.shields.io/nexus/s/top.wu2020/wu-lazy-cloud-heartbeat-server-start?server=https%3A%2F%2Foss.sonatype.org&style=flat&logo=log" alt="Maven" /></a> | <a target="_blank" href="https://search.maven.org/search?q=wu-lazy-cloud-heartbeat-server-start%20wu-lazy-cloud-heartbeat-server-start"><img src="https://img.shields.io/maven-central/v/top.wu2020/wu-lazy-cloud-heartbeat-server-start" alt="Maven" /></a> |
#### 项目地址
[Gitee](https://gitee.com/wujiawei1207537021/wu-lazy-cloud-network)
@@ -57,191 +72,6 @@ ORM操作数据库使用环境JDK17 Spring Boot 3.0.2。
![architecture.png](architecture.png)
#### 实现原理
##### 服务端创建socket服务端绑定本地端口用于客户端连接
```java
package org.framework.lazy.cloud.network.heartbeat.server.netty.socket;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import filter.netty.org.framework.lazy.cloud.network.heartbeat.server.NettyServerFilter;
public class NettyOnCloudNettyServerSocket {
private final EventLoopGroup bossGroup = new NioEventLoopGroup();
private final EventLoopGroup workerGroup = new NioEventLoopGroup();
private final NettyServerFilter nettyServerFilter;// 通道业务处理
private ChannelFuture channelFuture;
public NettyOnCloudNettyServerSocket(NettyServerFilter nettyServerFilter) {
this.nettyServerFilter = nettyServerFilter;
}
/**
* 启动服务端
*
* @throws Exception
*/
public void startServer(int serverPort) throws Exception {
try {
ServerBootstrap b = new ServerBootstrap();
b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class)
// 给服务端channel设置属性
.option(ChannelOption.SO_BACKLOG, 128)
.childOption(ChannelOption.SO_KEEPALIVE, true)
.childHandler(nettyServerFilter)
;
channelFuture = b.bind(serverPort).sync();
channelFuture.addListener((ChannelFutureListener) channelFuture -> {
// 服务器已启动
});
channelFuture.channel().closeFuture().sync();
} finally {
shutdown();
// 服务器已关闭
}
}
public void shutdown() {
if (channelFuture != null) {
channelFuture.channel().close().syncUninterruptibly();
}
if ((bossGroup != null) && (!bossGroup.isShutdown())) {
bossGroup.shutdownGracefully();
}
if ((workerGroup != null) && (!workerGroup.isShutdown())) {
workerGroup.shutdownGracefully();
}
}
}
```
##### 客户端通过class NettyClientSocket 连接服务端
```java
package org.framework.lazy.cloud.network.heartbeat.client.netty.socket;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioSocketChannel;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.application.ClientChangeEvent;
import filter.netty.org.framework.lazy.cloud.heartbeat.client.NettyClientFilter;
import org.framework.lazy.cloud.network.heartbeat.common.MessageType;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import adapter.org.framework.lazy.cloud.network.heartbeat.common.ChannelTypeAdapter;
import advanced.org.framework.lazy.cloud.network.heartbeat.common.HandleChannelTypeAdvanced;
import utils.org.framework.lazy.cloud.network.heartbeat.common.ChannelAttributeKeyUtils;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
* 客户端连接服务端
*/
@Slf4j
public class NettyClientSocket {
private static final EventLoopGroup eventLoopGroup = new NioEventLoopGroup();
/**
* 服务端host
*/
private final String inetHost;
/**
* 服务端端口
*/
private final int inetPort;
/**
* 当前客户端id
*/
@Getter
private final String clientId;
/**
* nacos配置信息处理应用
*/
@Getter
private final ClientNettyConfigApplication clientChangeEvent;
private final List<HandleChannelTypeAdvanced> handleChannelTypeAdvancedList; // 处理服务端发送过来的数据类型
public NettyClientSocket(String inetHost, int inetPort, String clientId, ClientNettyConfigApplication clientChangeEvent, List<HandleChannelTypeAdvanced> handleChannelTypeAdvancedList) {
this.inetHost = inetHost;
this.inetPort = inetPort;
this.clientId = clientId;
this.clientChangeEvent = clientChangeEvent;
this.handleChannelTypeAdvancedList = handleChannelTypeAdvancedList;
}
public void newConnect2Server() throws InterruptedException {
newConnect2Server(inetHost, inetPort, clientId, clientChangeEvent);
}
protected void newConnect2Server(String inetHost, int inetPort, String clientId, ClientNettyConfigApplication clientChangeEvent) throws InterruptedException {
Bootstrap bootstrap = new Bootstrap();
bootstrap.group(eventLoopGroup)
.channel(NioSocketChannel.class)
.handler(new NettyClientFilter(new ChannelTypeAdapter(handleChannelTypeAdvancedList), this))
;
log.info("连接服务端IP:{},连接服务端端口:{}", inetHost, inetPort);
ChannelFuture future = bootstrap.connect(inetHost, inetPort);
Channel channel = future.channel();
log.info("使用的客户端ID:" + clientId);
future.addListener((ChannelFutureListener) futureListener -> {
if (futureListener.isSuccess()) {
log.info("连接服务端成功");
// 告诉服务端这条连接是client的连接
NettyProxyMsg nettyMsg = new NettyProxyMsg();
nettyMsg.setType(MessageType.TCP_REPORT_CLIENT_CONNECT_SUCCESS);
nettyMsg.setClientId(clientId);
nettyMsg.setData((clientId).getBytes());
ChannelAttributeKeyUtils.buildClientId(channel, clientId);
channel.writeAndFlush(nettyMsg);
// 在线
clientChangeEvent.clientOnLine(clientId);
} else {
log.info("每隔2s重连....");
// 离线
clientChangeEvent.clientOffLine(clientId);
futureListener.channel().eventLoop().schedule(() -> {
try {
newConnect2Server(inetHost, inetPort, clientId, clientChangeEvent);
} catch (InterruptedException e) {
e.printStackTrace();
}
}, 2, TimeUnit.SECONDS);
}
});
}
/**
* 关闭连接
*/
public void shutdown() {
if ((eventLoopGroup != null) && (!eventLoopGroup.isShutdown())) {
eventLoopGroup.shutdownGracefully();
}
}
}
```
##### 通过客户端与服务端建立的连接进行访客端口绑定
@@ -255,26 +85,27 @@ public class NettyClientSocket {
1.内网穿透
2.服务端自主下发数据到客户端
3.流量监控
4.网络代理socks、http
### 项目结构
| 模块 | 版本 | 描述 |
|------------------------------------------------------------------------------------------------------------|----------------------|------------------------------|
| [wu-lazy-cloud-heartbeat-common](wu-lazy-cloud-heartbeat-common) | 1.3.0-JDK17-SNAPSHOT | 内网穿透公共模块(声明接口、枚举、常量、适配器、解析器) |
| [wu-lazy-cloud-heartbeat-client](wu-lazy-cloud-heartbeat-client) | 1.3.0-JDK17-SNAPSHOT | 客户端(支持二次开发) |
| [wu-lazy-cloud-heartbeat-server](wu-lazy-cloud-heartbeat-server) | 1.3.0-JDK17-SNAPSHOT | 服务端(支持二次开发) |
| [wu-lazy-cloud-heartbeat-client-start](wu-lazy-cloud-heartbeat-start/wu-lazy-cloud-heartbeat-server-start) | 1.3.0-JDK17-SNAPSHOT | 客户端样例 |
| [wu-lazy-cloud-heartbeat-server-start](wu-lazy-cloud-heartbeat-start/wu-lazy-cloud-heartbeat-client-start) | 1.3.0-JDK17-SNAPSHOT | 服务端样例 |
| [wu-lazy-cloud-heartbeat-common](wu-lazy-cloud-heartbeat-common) | 1.3.1-JDK24 | 内网穿透公共模块(声明接口、枚举、常量、适配器、解析器) |
| [wu-lazy-cloud-heartbeat-client](wu-lazy-cloud-heartbeat-client) | 1.3.1-JDK24 | 客户端(支持二次开发) |
| [wu-lazy-cloud-heartbeat-server](wu-lazy-cloud-heartbeat-server) | 1.3.1-JDK24 | 服务端(支持二次开发) |
| [wu-lazy-cloud-heartbeat-client-start](wu-lazy-cloud-heartbeat-start/wu-lazy-cloud-heartbeat-server-start) | 1.3.1-JDK24 | 客户端样例 |
| [wu-lazy-cloud-heartbeat-server-start](wu-lazy-cloud-heartbeat-start/wu-lazy-cloud-heartbeat-client-start) | 1.3.1-JDK24 | 服务端样例 |
### 使用技术
| 框架 | 版本 | 描述 |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------|--------------|
| spring-boot | 3.0.7 | springboot框架 |
| [wu-framework-web](https://gitee.com/wujiawei1207537021/wu-framework-parent/tree/master/wu-framework-web) | 1.3.0-JDK17-SNAPSHOT | web容器 |
| [Lazy -ORM](https://gitee.com/wujiawei1207537021/wu-framework-parent/tree/master/wu-inner-intergration/wu-database-parent) | 1.3.0-JDK17-SNAPSHOT | ORM |
| [wu-framework-web](https://gitee.com/wujiawei1207537021/wu-framework-parent/tree/master/wu-framework-web) | 1.3.1-JDK24 | web容器 |
| [Lazy -ORM](https://gitee.com/wujiawei1207537021/wu-framework-parent/tree/master/wu-inner-intergration/wu-database-parent) | 1.3.1-JDK24 | 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.0-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 | 用户授权体系 |
### 使用环境
@@ -283,15 +114,16 @@ public class NettyClientSocket {
JAVA >=13
MAVEN
### 启动
### 启动[install.md](install.md)
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.0-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
http://127.0.0.1:18080/swagger-ui/index.html
源码启动
### 代理工具使用[Proxy.md](Proxy.md)
#### 页面操作
@@ -341,4 +173,20 @@ public class NettyClientSocket {
![clientPerDayFlow.png](clientPerDayFlow.png)
客户端近七天使用流量
![clientPortPerDayFlow.png](clientPortPerDayFlow.png)
![clientPortPerDayFlow.png](clientPortPerDayFlow.png)
## 路由
- 客户端路由管理
![client_route.png](client_route.png)
- 客户端虚拟路由管理
- 创建一个虚拟的不存在的IP代理到指定的IP
![client_virtual_route.png](client_virtual_route.png)
- 服务端路由管理
![server_route.png](server_route.png)
- 服务端虚拟路由管理
- 创建一个虚拟的不存在的IP代理到指定的IP
![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.0-JDK17-SNAPSHOT
registry.cn-hangzhou.aliyuncs.com/wu-lazy/wu-lazy-cloud-heartbeat-client-start:1.3.1-JDK24
env:
- name: spring.lazy.netty.client.inet-host
value: 124.222.48.62

Binary file not shown.

After

Width:  |  Height:  |  Size: 206 KiB

BIN
client_route.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
client_virtual_route.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 KiB

28
install.md Normal file
View File

@@ -0,0 +1,28 @@
#### docker环境安装wlcn
##### 启动服务端
- 6001端口 webui
- 7001端口 tcp连接端口
- 8001端口 http代理端口
- 9001端口 socks代理端口
- 1001端口 自定义需要代理到客户端端口
- 打开浏览器访问界面 http://127.0.0.1:6001/netty-server-ui/index.html
```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-JDK24
```
##### 启动客户端
- 6004端口 webui
- 8001端口 http代理端口
- 9001端口 socks代理端口
- 环境变量
- spring.lazy.netty.client.inet-host 服务端IP
- spring.lazy.netty.client.inet-port 服务端tcp端口
- spring.lazy.netty.client.client-id 客户端ID
- 打开浏览器访问界面 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-JDK24
```

BIN
mac_http_proxy.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

BIN
mac_socks_proxy.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

229
pom.xml
View File

@@ -8,14 +8,33 @@
<parent>
<artifactId>wu-framework-parent</artifactId>
<groupId>top.wu2020</groupId>
<version>1.3.0-JDK17-SNAPSHOT</version>
<version>1.3.4-JDK24-SNAPSHOT</version>
</parent>
<artifactId>wu-lazy-cloud-network</artifactId>
<packaging>pom</packaging>
<version>1.3.0-JDK17-SNAPSHOT</version>
<version>1.3.4-JDK24-SNAPSHOT</version>
<description>云上云下</description>
<name>wlcn项目</name>
<url>https://gitee.com/wujiawei1207537021/wu-lazy-cloud-network</url>
<!-->开发者的信息<-->
<developers>
<developer>
<name>Jia Wei Wu</name>
<email>1207537021@qq.com</email>
</developer>
</developers>
<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0</url>
<distribution>repo</distribution>
</license>
</licenses>
<!-->项目的版本管理地址<-->
<scm>
<url>https://gitee.com/wujiawei1207537021/wu-lazy-cloud-network</url>
</scm>
<modules>
<!-- 云上服务组件 -->
@@ -38,7 +57,7 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.32</version>
<version>1.18.38</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
@@ -48,22 +67,24 @@
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>1.6.0.Beta1</version>
<version>1.6.3</version>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>1.6.0.Beta1</version>
<version>1.6.3</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<version>3.5.3</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<version>${spring-boot-starter.version}</version>
</dependency>
</dependencies>
@@ -72,7 +93,7 @@
<dependency>
<groupId>top.wu2020</groupId>
<artifactId>wu-framework-dependencies</artifactId>
<version>1.3.0-JDK17-SNAPSHOT</version>
<version>1.3.4-JDK24-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
@@ -80,200 +101,6 @@
</dependencyManagement>
<profiles>
<profile>
<id>oss</id>
<build>
<plugins>
<!-- Source -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Javadoc -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<locale>en_US</locale>
<encoding>UTF-8</encoding>
<charset>UTF-8</charset>
<doclint>none</doclint>
</configuration>
</execution>
</executions>
</plugin>
<!-- GPG -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>${maven-gpg-plugin.version}</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- flatten -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<version>${flatten-maven-plugin.version}</version>
<configuration>
<updatePomFile>true</updatePomFile>
<flattenMode>resolveCiFriendliesOnly</flattenMode>
</configuration>
<executions>
<execution>
<id>flatten</id>
<phase>process-resources</phase>
<goals>
<goal>flatten</goal>
</goals>
</execution>
<execution>
<id>flatten.clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<!-->发布的地址<-->
<distributionManagement>
<snapshotRepository>
<id>oss-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</snapshotRepository>
<repository>
<id>oss-snapshots</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
</profile>
<profile>
<id>native</id>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Spring-Boot-Native-Processed>true</Spring-Boot-Native-Processed>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<image>
<builder>paketobuildpacks/builder-jammy-tiny:latest</builder>
<env>
<BP_NATIVE_IMAGE>true</BP_NATIVE_IMAGE>
</env>
</image>
</configuration>
<executions>
<execution>
<id>process-aot</id>
<goals>
<goal>process-aot</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<configuration>
<classesDirectory>${project.build.outputDirectory}</classesDirectory>
<requiredVersion>22.3</requiredVersion>
</configuration>
<executions>
<execution>
<id>add-reachability-metadata</id>
<goals>
<goal>add-reachability-metadata</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
<profile>
<id>nativeTest</id>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>process-test-aot</id>
<goals>
<goal>process-test-aot</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<configuration>
<classesDirectory>${project.build.outputDirectory}</classesDirectory>
<requiredVersion>22.3</requiredVersion>
</configuration>
<executions>
<execution>
<id>native-test</id>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

BIN
proxy_inner_net_ui.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

BIN
server_route.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 KiB

BIN
server_virtual_route.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 KiB

View File

@@ -24,10 +24,24 @@
[change] 新增服务端渗透服务端----本地同局域网内端口映射
[change] 新增客户端渗透服务端----本地端口映射到另一个服务端中的局域网端口
[change] 新增客户端渗透客户端----本地端口映射到另一个局域网端口
#### 1.3.0-JDK17-SNAPSHOT
#### 1.2.9-JDK17-SNAPSHOT
[change] 添加appkey&appsecret 验证
[change] 支持同一个客户端ID多次注册
[change] 修复通道关闭导致调度线程池submit异常问题
[change] 添加记录客户端IP
[change] 1.2.9为大版本,报文中添加数据无法向下兼容,建议服务端与客户端保持版本一致
#### 下一版本计划https
#### 1.3.1-JDK17-SNAPSHOT
[add] 新增http代理客户端代理服务端、客户端代理客户杜安、服务端代理客户端、服务端代理服务端
[add] 新增socks代理客户端代理服务端、客户端代理客户杜安、服务端代理客户端、服务端代理服务端
[add] 新增客户端路由管理、新增服务端路由管理
[add] 支持新增虚拟IP代理到指定的IP
[add] 通过页面配置,代理支持控制端口代理控制
#### 1.3.1-JDK17
[add] 新增代理流量监控
[add] docker仓库上架dockerhub搜索https://hub.docker.com/search?q=wlcn
#### 1.3.1-JDK24
[add] 新增代理流量监控
[add] 升级使用jdk24、springboot 3.5.0
[add] 添加socks授权验证
#### 下一版本计划

BIN
windows_wifi_proxy.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 309 KiB

BIN
wlcn-proxy1.0-.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

84
wlcn-proxy1.0.puml Normal file
View File

@@ -0,0 +1,84 @@
@startuml
title 网络代理
package "服务端" as "服务端"{
node "12.16.5.xx"{
[12.16.5.1]
[wlcn_s_a] as "wlcn服务端"
}
}
package "杭州客户端"{
node "172.16.5.xx"{
[172.16.5.1]
[wlcn_c_a] as "wlcn客户端9001"
actor Navicat_c_a as "本地Navicat"
actor App_c_a as "本地App"
actor Chrome_c_a as "本地浏览器"
[socks_proxy_a] as "杭州本地用户socks代理软件"
[socks_proxy_a]<--up--> [wlcn_c_a]:访客通过软件代理本地socks网络
[Navicat_c_a]<..up..> [socks_proxy_a]:访问服务端所在网段12.16.5.xx
[App_c_a]<..up..> [socks_proxy_a]:访问访问本地所在网段172.16.5.xx
[Chrome_c_a]<..up..> [socks_proxy_a]:访问访问另一个客户端所在网段162.16.5.xx
}
}
package "上海客户端" as "上海客户端"{
node "162.16.5.xx"{
[162.16.5.1]
[wlcn_c_b] as "wlcn客户端9001"
actor Navicat_c_b as "本地Navicat"
actor App_c_b as "本地App"
actor Chrome_c_b as "本地浏览器"
[socks_proxy_b] as "上海本地用户socks代理软件"
[socks_proxy_b]<--up--> [wlcn_c_b]:访客通过软件代理本地socks网络
[Navicat_c_b]<..up..> [socks_proxy_b]:访问服务端所在网段12.16.5.xx
[App_c_b]<..up..> [socks_proxy_b]:访问访问本地所在网段172.16.5.xx
[Chrome_c_b]<..up..> [socks_proxy_b]:访问访问另一个客户端所在网段162.16.5.xx
}
}
package "第三方局域网"{
node "152.16.5.xx"{
[152.16.5.1]
actor Navicat_c_c as "本地Navicat"
actor App_c_c as "本地App"
actor Chrome_c_c as "本地浏览器"
[socks_proxy_c] as "上海本地用户socks代理软件"
[Navicat_c_c]<..up..> [socks_proxy_c]:访问服务端所在网段12.16.5.xx
[App_c_c]<..up..> [socks_proxy_c]:访问访问上海在网段172.16.5.xx
[Chrome_c_c]<..up..> [socks_proxy_c]:访问访问杭州客户端所在网段162.16.5.xx
}
}
[wlcn_s_a] <==down==> [wlcn_c_a]: 客户端连接服务端
[wlcn_s_a] <==down==> [wlcn_c_b]: 客户端连接服务端
[wlcn_s_a]<--down--> [socks_proxy_c]:访客通过软件代理本地socks网络
@enduml

View File

@@ -10,8 +10,8 @@ mvn native:build -Pnative
### 构建docker镜像
```shell
docker build -t docker-registry.wujiawei.com/lazy/lazy-under-cloud-heartbeat-client:lazy-2.4.2-native-SNAPSHOT_latest -f Native-Dockerfile .
docker push docker-registry.wujiawei.com/lazy/lazy-under-cloud-heartbeat-client:lazy-2.4.2-native-SNAPSHOT_latest
docker build -t docker-registry.wujiawei.com/lazy/lazy-under-cloud-heartbeat-client:lazy-2.4.2-NATIVE-SNAPSHOT_latest -f Native-Dockerfile .
docker push docker-registry.wujiawei.com/lazy/lazy-under-cloud-heartbeat-client:lazy-2.4.2-NATIVE-SNAPSHOT_latest
```
## BUILD IMAGE

View File

@@ -5,16 +5,36 @@
<parent>
<groupId>top.wu2020</groupId>
<artifactId>wu-lazy-cloud-network</artifactId>
<version>1.3.0-JDK17-SNAPSHOT</version>
<version>1.3.4-JDK24-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>wu-lazy-cloud-heartbeat-client</artifactId>
<description>云下心跳客户端</description>
<name>wlcn客户端模块</name>
<url>https://gitee.com/wujiawei1207537021/wu-lazy-cloud-network</url>
<!-->开发者的信息<-->
<developers>
<developer>
<name>Jia Wei Wu</name>
<email>1207537021@qq.com</email>
</developer>
</developers>
<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0</url>
<distribution>repo</distribution>
</license>
</licenses>
<!-->项目的版本管理地址<-->
<scm>
<url>https://gitee.com/wujiawei1207537021/wu-lazy-cloud-network</url>
</scm>
<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>
@@ -22,30 +42,34 @@
<dependency>
<groupId>top.wu2020</groupId>
<artifactId>wu-lazy-cloud-heartbeat-common</artifactId>
<version>${wu-lazy-cloud-heartbeat-common.version}</version>
</dependency>
<dependency>
<groupId>top.wu2020</groupId>
<artifactId>wu-lazy-cloud-heartbeat-protocol-proxy</artifactId>
<version>1.3.0-JDK17-SNAPSHOT</version>
<version>${wu-lazy-cloud-heartbeat-protocol-proxy.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>2.0.50</version>
</dependency>
<dependency>
<groupId>top.wu2020</groupId>
<artifactId>wu-framework-web-spring-starter</artifactId>
</dependency>
<!-- h2数据库驱动 -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>2.3.232</version>
</dependency>
<dependency>
<groupId>top.wu2020</groupId>
<artifactId>wu-database-lazy-plus-starter</artifactId>
<artifactId>wu-framework-web-spring-starter</artifactId>
<version>${wu-framework-web-spring-starter.version}</version>
</dependency>
<dependency>
<groupId>top.wu2020</groupId>
<artifactId>wu-database-lazy-orm-plus-starter</artifactId>
<version>${wu-database-lazy-orm-plus-starter.version}</version>
</dependency>
</dependencies>

View File

@@ -7,87 +7,86 @@ import org.framework.lazy.cloud.network.heartbeat.client.application.command.laz
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.mapstruct.factory.Mappers;
import org.mapstruct.Mapper;
import org.wu.framework.core.mapper.LazyStructMappers;
import org.wu.framework.core.mapper.LazyStructMapper;
/**
* describe 服务端配置信息
* describe 服务端配置信息
*
* @author Jia wei Wu
* @date 2024/04/03 03:00 下午
* @see org.wu.framework.lazy.orm.core.persistence.reverse.lazy.ddd.DefaultDDDLazyAssembler
* @see org.wu.framework.lazy.orm.core.persistence.reverse.lazy.ddd.DefaultDDDLazyAssembler
**/
@Mapper
@LazyStructMapper
public interface LazyNettyServerPropertiesDTOAssembler {
/**
* describe MapStruct 创建的代理对象
*
* @author Jia wei Wu
* @date 2024/04/03 03:00 下午
**/
LazyNettyServerPropertiesDTOAssembler INSTANCE = Mappers.getMapper(LazyNettyServerPropertiesDTOAssembler.class);
LazyNettyServerPropertiesDTOAssembler INSTANCE = LazyStructMappers.getMapper(LazyNettyServerPropertiesDTOAssembler.class);
// LazyNettyServerPropertiesDTOAssembler INSTANCE = new LazyNettyServerPropertiesDTOAssemblerImpl();
/**
* describe 应用层存储入参转换成 领域对象
*
* @param lazyNettyServerPropertiesStoryCommand 保存服务端配置信息对象
* @param lazyNettyServerPropertiesStoryCommand 保存服务端配置信息对象
* @return {@link LazyNettyServerProperties} 服务端配置信息领域对象
* @author Jia wei Wu
* @date 2024/04/03 03:00 下午
**/
LazyNettyServerProperties toLazyNettyServerProperties(LazyNettyServerPropertiesStoryCommand lazyNettyServerPropertiesStoryCommand);
LazyNettyServerProperties toLazyNettyServerProperties(LazyNettyServerPropertiesStoryCommand lazyNettyServerPropertiesStoryCommand);
/**
* describe 应用层更新入参转换成 领域对象
*
* @param lazyNettyServerPropertiesUpdateCommand 更新服务端配置信息对象
* @return {@link LazyNettyServerProperties} 服务端配置信息领域对象
* @param lazyNettyServerPropertiesUpdateCommand 更新服务端配置信息对象
* @return {@link LazyNettyServerProperties} 服务端配置信息领域对象
* @author Jia wei Wu
* @date 2024/04/03 03:00 下午
**/
LazyNettyServerProperties toLazyNettyServerProperties(LazyNettyServerPropertiesUpdateCommand lazyNettyServerPropertiesUpdateCommand);
LazyNettyServerProperties toLazyNettyServerProperties(LazyNettyServerPropertiesUpdateCommand lazyNettyServerPropertiesUpdateCommand);
/**
* describe 应用层查询入参转换成 领域对象
*
* @param lazyNettyServerPropertiesQueryOneCommand 查询单个服务端配置信息对象参数
* @return {@link LazyNettyServerProperties} 服务端配置信息领域对象
* @param lazyNettyServerPropertiesQueryOneCommand 查询单个服务端配置信息对象参数
* @return {@link LazyNettyServerProperties} 服务端配置信息领域对象
* @author Jia wei Wu
* @date 2024/04/03 03:00 下午
**/
LazyNettyServerProperties toLazyNettyServerProperties(LazyNettyServerPropertiesQueryOneCommand lazyNettyServerPropertiesQueryOneCommand);
LazyNettyServerProperties toLazyNettyServerProperties(LazyNettyServerPropertiesQueryOneCommand lazyNettyServerPropertiesQueryOneCommand);
/**
* describe 应用层查询入参转换成 领域对象
*
* @param lazyNettyServerPropertiesQueryListCommand 查询集合服务端配置信息对象参数
* @return {@link LazyNettyServerProperties} 服务端配置信息领域对象
* @param lazyNettyServerPropertiesQueryListCommand 查询集合服务端配置信息对象参数
* @return {@link LazyNettyServerProperties} 服务端配置信息领域对象
* @author Jia wei Wu
* @date 2024/04/03 03:00 下午
**/
LazyNettyServerProperties toLazyNettyServerProperties(LazyNettyServerPropertiesQueryListCommand lazyNettyServerPropertiesQueryListCommand);
LazyNettyServerProperties toLazyNettyServerProperties(LazyNettyServerPropertiesQueryListCommand lazyNettyServerPropertiesQueryListCommand);
/**
* describe 应用层删除入参转换成 领域对象
*
* @param lazyNettyServerPropertiesRemoveCommand 删除服务端配置信息对象参数
* @return {@link LazyNettyServerProperties} 服务端配置信息领域对象
* @param lazyNettyServerPropertiesRemoveCommand 删除服务端配置信息对象参数
* @return {@link LazyNettyServerProperties} 服务端配置信息领域对象
* @author Jia wei Wu
* @date 2024/04/03 03:00 下午
**/
LazyNettyServerProperties toLazyNettyServerProperties(LazyNettyServerPropertiesRemoveCommand lazyNettyServerPropertiesRemoveCommand);
LazyNettyServerProperties toLazyNettyServerProperties(LazyNettyServerPropertiesRemoveCommand lazyNettyServerPropertiesRemoveCommand);
/**
* describe 持久层领域对象转换成DTO对象
*
* @param lazyNettyServerProperties 服务端配置信息领域对象
* @return {@link LazyNettyServerPropertiesDTO} 服务端配置信息DTO对象
* @param lazyNettyServerProperties 服务端配置信息领域对象
* @return {@link LazyNettyServerPropertiesDTO} 服务端配置信息DTO对象
* @author Jia wei Wu
* @date 2024/04/03 03:00 下午
**/
LazyNettyServerPropertiesDTO fromLazyNettyServerProperties(LazyNettyServerProperties lazyNettyServerProperties);
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,9 +17,8 @@ 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.database.lazy.web.plus.stereotype.LazyApplication;
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;
import java.util.List;
@@ -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

@@ -6,6 +6,7 @@ import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.event.Cl
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced.*;
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.advanced.*;
import org.framework.lazy.cloud.network.heartbeat.client.netty.proxy.http.advanced.*;
import org.framework.lazy.cloud.network.heartbeat.client.netty.proxy.socks.advanced.*;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
@@ -351,12 +352,20 @@ public class ClientAutoConfiguration {
public ClientHandleDistributeHttpClientProxyServerServerRouteTypeAdvanced clientHandleDistributeHttpClientProxyServerServerRouteTypeAdvanced() {
return new ClientHandleDistributeHttpClientProxyServerServerRouteTypeAdvanced();
}
@Bean
public ClientHandleDistributeHttpClientProxyServerServerRouteCloseTypeAdvanced clientHandleDistributeHttpClientProxyServerServerRouteCloseTypeAdvanced(){
return new ClientHandleDistributeHttpClientProxyServerServerRouteCloseTypeAdvanced();
}
@Bean
public ClientHandleDistributeHttpClientProxyServerClientRouteTypeAdvanced clientHandleDistributeHttpClientProxyServerClientRouteTypeAdvanced() {
return new ClientHandleDistributeHttpClientProxyServerClientRouteTypeAdvanced();
}
@Bean
public ClientHandleDistributeHttpClientProxyServerClientRouteCloseTypeAdvanced clientHandleDistributeHttpClientProxyServerClientRouteCloseTypeAdvanced(){
return new ClientHandleDistributeHttpClientProxyServerClientRouteCloseTypeAdvanced();
}
@Bean
public ClientHandleDistributeHttpClientProxyClientConnectionTransferSuccessfulAdvanced clientHandleDistributeHttpClientProxyClientConnectionTransferSuccessfulAdvanced() {
return new ClientHandleDistributeHttpClientProxyClientConnectionTransferSuccessfulAdvanced();
@@ -383,4 +392,68 @@ public class ClientAutoConfiguration {
return new ClientHandleDistributeHttpServerProxyClientTransferRequestAdvanced();
}
}
@Configuration
static class SocksProxyConfiguration {
@Bean
public ClientHandleNettySocketProtocolHandleSocketClientProxyServerStartTypeAdvanced nettySocketProtocolHandleSocketClientProxyServerTypeAdvanced() {
return new ClientHandleNettySocketProtocolHandleSocketClientProxyServerStartTypeAdvanced();
}
@Bean
public ClientHandleDistributeSocksClientProxyServerConnectionTransferSuccessfulAdvanced clientHandleDistributeSocksClientProxyServerConnectionTransferSuccessfulAdvanced() {
return new ClientHandleDistributeSocksClientProxyServerConnectionTransferSuccessfulAdvanced();
}
@Bean
public ClientHandleDistributeSocksClientProxyServerConnectionTransferFailAdvanced clientHandleDistributeSocksClientProxyServerConnectionTransferFailAdvanced() {
return new ClientHandleDistributeSocksClientProxyServerConnectionTransferFailAdvanced();
}
@Bean
public ClientHandleDistributeSocksClientProxyServerTransferTransferResponseAdvanced clientHandleDistributeSocksClientProxyServerTransferTransferResponseAdvanced() {
return new ClientHandleDistributeSocksClientProxyServerTransferTransferResponseAdvanced();
}
@Bean
public ClientHandleDistributeSocksClientProxyServerTransferCloseAdvanced clientHandleDistributeSocksClientProxyServerTransferCloseAdvanced() {
return new ClientHandleDistributeSocksClientProxyServerTransferCloseAdvanced();
}
@Bean
public ClientHandleDistributeSocksClientProxyClientConnectionTransferFailAdvanced clientHandleDistributeSocksClientProxyClientConnectionTransferFailAdvanced(){
return new ClientHandleDistributeSocksClientProxyClientConnectionTransferFailAdvanced();
}
@Bean
public ClientHandleDistributeSocksClientProxyClientConnectionTransferSuccessfulAdvanced clientHandleDistributeSocksClientProxyClientConnectionTransferSuccessfulAdvanced(){
return new ClientHandleDistributeSocksClientProxyClientConnectionTransferSuccessfulAdvanced();
}
@Bean
public ClientHandleDistributeSocksClientProxyClientTransferCloseAdvanced clientHandleDistributeSocksClientProxyClientTransferCloseAdvanced(){
return new ClientHandleDistributeSocksClientProxyClientTransferCloseAdvanced();
}
@Bean
public ClientHandleDistributeSocksClientProxyClientTransferTransferResponseAdvanced clientHandleDistributeSocksClientProxyClientTransferTransferResponseAdvanced(){
return new ClientHandleDistributeSocksClientProxyClientTransferTransferResponseAdvanced();
}
@Bean
public ClientHandleDistributeSocksClientProxyClientOtherConnectionTransferAdvanced clientHandleDistributeSocksClientProxyClientOtherConnectionTransferAdvanced1(){
return new ClientHandleDistributeSocksClientProxyClientOtherConnectionTransferAdvanced();
}
@Bean
public ClientHandleDistributeSocksClientProxyClientTransferTransferRequestAdvanced clientHandleDistributeSocksClientProxyClientTransferTransferRequestAdvanced(){
return new ClientHandleDistributeSocksClientProxyClientTransferTransferRequestAdvanced();
}
@Bean
public ClientHandleSocksDistributeServerProxyClientConnectionInitTypeAdvanced clientHandleSocksDistributeServerProxyClientConnectionInitTypeAdvanced(){
return new ClientHandleSocksDistributeServerProxyClientConnectionInitTypeAdvanced();
}
@Bean
public ClientHandleSocksDistributeServerProxyClientRequestTypeAdvanced clientHandleSocksDistributeServerProxyClientRequestTypeAdvanced(){
return new ClientHandleSocksDistributeServerProxyClientRequestTypeAdvanced();
}
@Bean
public ClientHandleSocksDistributeServerProxyClientTransferCloseAdvanced clientHandleSocksDistributeServerProxyClientTransferCloseAdvanced(){
return new ClientHandleSocksDistributeServerProxyClientTransferCloseAdvanced();
}
}
}

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

@@ -7,6 +7,8 @@ import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientPrope
import org.framework.lazy.cloud.network.heartbeat.client.config.PropertiesType;
import org.framework.lazy.cloud.network.heartbeat.client.infrastructure.entity.LazyNettyServerPropertiesDO;
import org.framework.lazy.cloud.network.heartbeat.common.enums.ProtocolType;
import org.framework.lazy.cloud.network.heartbeat.protocol.token.AuthenticationToken;
import org.framework.lazy.cloud.network.heartbeat.protocol.token.AuthenticationTokenContext;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.context.ApplicationListener;
@@ -26,7 +28,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;
@@ -49,7 +53,9 @@ public class NettyClientSocketApplicationListener implements ApplicationListener
log.warn("配置信息为空,请通过页面添加配置信息:{}", nettyClientProperties);
return;
}
LazyNettyServerPropertiesDO lazyNettyServerPropertiesDO = new LazyNettyServerPropertiesDO();
lazyNettyServerPropertiesDO.setClientId(clientId);
lazyNettyServerPropertiesDO.setInetHost(inetHost);
lazyNettyServerPropertiesDO.setInetPort(inetPort);
@@ -70,6 +76,12 @@ public class NettyClientSocketApplicationListener implements ApplicationListener
if (!exists) {
lazyLambdaStream.insert(lazyNettyServerPropertiesDO);
}
// 添加本地token
AuthenticationToken authenticationToken = new AuthenticationToken();
authenticationToken.setUsedByClientId(clientId);
authenticationToken.setAppKey(appKey);
authenticationToken.setAppSecret(appSecret);
AuthenticationTokenContext.setAuthenticationToken(clientId, appKey, appSecret);
}catch (Exception e){
e.printStackTrace();
}

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,47 +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.mapstruct.factory.Mappers;
import org.mapstruct.Mapper;
import org.wu.framework.core.mapper.LazyStructMapper;
import org.wu.framework.core.mapper.LazyStructMappers;
/**
* describe 服务端配置信息
* describe 服务端配置信息
*
* @author Jia wei Wu
* @date 2024/04/03 03:00 下午
* @see org.wu.framework.lazy.orm.core.persistence.reverse.lazy.ddd.DefaultDDDLazyInfrastructureConverter
* @see org.wu.framework.lazy.orm.core.persistence.reverse.lazy.ddd.DefaultDDDLazyInfrastructureConverter
**/
@Mapper
@LazyStructMapper
public interface LazyNettyServerPropertiesConverter {
/**
* describe MapStruct 创建的代理对象
*
* @author Jia wei Wu
* @date 2024/04/03 03:00 下午
**/
LazyNettyServerPropertiesConverter INSTANCE = Mappers.getMapper(LazyNettyServerPropertiesConverter.class);
LazyNettyServerPropertiesConverter INSTANCE = LazyStructMappers.getMapper(LazyNettyServerPropertiesConverter.class);
// LazyNettyServerPropertiesConverter INSTANCE = new LazyNettyServerPropertiesConverterImpl();
/**
* describe 实体对象 转换成领域对象
*
* @param lazyNettyServerPropertiesDO 服务端配置信息实体对象
* @param lazyNettyServerPropertiesDO 服务端配置信息实体对象
* @return {@link LazyNettyServerProperties} 服务端配置信息领域对象
* @author Jia wei Wu
* @date 2024/04/03 03:00 下午
**/
LazyNettyServerProperties toLazyNettyServerProperties(LazyNettyServerPropertiesDO lazyNettyServerPropertiesDO);
/**
* describe 领域对象 转换成实体对象
*
* @param lazyNettyServerProperties 服务端配置信息领域对象
* @return {@link LazyNettyServerPropertiesDO} 服务端配置信息实体对象
* @param lazyNettyServerProperties 服务端配置信息领域对象
* @return {@link LazyNettyServerPropertiesDO} 服务端配置信息实体对象
* @author Jia wei Wu
* @date 2024/04/03 03:00 下午
**/
LazyNettyServerPropertiesDO fromLazyNettyServerProperties(LazyNettyServerProperties lazyNettyServerProperties);
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;
/**

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.entity.LazyNettyServerPropertiesDO;
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

@@ -1,29 +1,32 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
import io.netty.channel.Channel;
import org.framework.lazy.cloud.network.heartbeat.common.constant.TcpMessageType;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.AbstractTcpHandleChannelHeartbeatTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.constant.TcpMessageType;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
/**
* 服务端 处理客户端心跳
* TCP_TYPE_HEARTBEAT
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public class ClientHandleTcpChannelHeartbeatTypeAdvanced extends AbstractTcpHandleChannelHeartbeatTypeAdvanced<NettyProxyMsg> {
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyChannelContext 当前通道
* @param msg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg msg) {
public void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg msg) {
NettyProxyMsg hb = new NettyProxyMsg();
hb.setType(TcpMessageType.TCP_TYPE_HEARTBEAT);
// channel.writeAndFlush(hb);
// nettyChannelContext.writeAndFlush(hb);
}
}

View File

@@ -5,10 +5,13 @@ import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.client.AbstractHandleTcpDistributeServicePermeateClientTransferTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.enums.TcpMessageTypeEnums;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
/**
@@ -16,6 +19,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeK
*
* @see TcpMessageTypeEnums#TCP_DISTRIBUTE_CLIENT_TRANSFER
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
public class ClientHandleTcpChannelTransferTypeAdvancedHandleDistributeTcpDistribute extends AbstractHandleTcpDistributeServicePermeateClientTransferTypeAdvanced<NettyProxyMsg> {
@@ -28,16 +32,17 @@ public class ClientHandleTcpChannelTransferTypeAdvancedHandleDistributeTcpDistri
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyChannelContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
Channel channel = nettyChannelContext.channel();
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

@@ -3,13 +3,17 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.adv
import io.netty.channel.Channel;
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
import org.framework.lazy.cloud.network.heartbeat.common.ChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.client.AbstractHandleTcpClientChannelActiveAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
/**
* 客户端通道 is active
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public class ClientHandleTcpClientChannelActiveAdvanced extends AbstractHandleTcpClientChannelActiveAdvanced<NettyProxyMsg> {
private final NettyClientProperties nettyClientProperties;
@@ -20,14 +24,15 @@ public class ClientHandleTcpClientChannelActiveAdvanced extends AbstractHandleTc
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyChannelContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
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

@@ -1,13 +1,15 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.NettyVisitorPortContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.client.AbstractHandleTcpDistributeClientPermeateClientCloseTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.enums.TcpMessageTypeEnums;
import org.framework.lazy.cloud.network.heartbeat.common.socket.PermeateVisitorSocket;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
/**
@@ -15,6 +17,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.socket.PermeateVisitorS
*
* @see TcpMessageTypeEnums#TCP_DISTRIBUTE_CLIENT_PERMEATE_CLIENT_CLOSE
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
public class ClientHandleTcpDistributeClientPermeateClientCloseTypeAdvanced extends AbstractHandleTcpDistributeClientPermeateClientCloseTypeAdvanced<NettyProxyMsg> {
@@ -22,11 +25,11 @@ public class ClientHandleTcpDistributeClientPermeateClientCloseTypeAdvanced exte
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyChannelContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
// 初始化 客户端渗透服务端socket
byte[] msgVisitorPort = nettyProxyMsg.getVisitorPort();
Integer visitorPort = Integer.parseInt(new String(msgVisitorPort));

View File

@@ -1,14 +1,16 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.socket.NettyTcpClientPermeateClientVisitorSocket;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.client.AbstractHandleTcpDistributeClientPermeateClientInitTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.enums.TcpMessageTypeEnums;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
import org.wu.framework.spring.utils.SpringContextHolder;
import java.util.ArrayList;
@@ -20,26 +22,28 @@ import java.util.List;
*
* @see TcpMessageTypeEnums#TCP_DISTRIBUTE_CLIENT_PERMEATE_CLIENT_INIT
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
public class ClientHandleTcpDistributeClientPermeateClientInitTypeAdvanced extends AbstractHandleTcpDistributeClientPermeateClientInitTypeAdvanced<NettyProxyMsg> {
public class ClientHandleTcpDistributeClientPermeateClientInitTypeAdvanced
extends AbstractHandleTcpDistributeClientPermeateClientInitTypeAdvanced<NettyProxyMsg> {
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyChannelContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
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));
@@ -47,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

@@ -3,10 +3,13 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.adv
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.client.AbstractHandleTcpDistributeClientPermeateClientTransferCloseTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.enums.TcpMessageTypeEnums;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
/**
@@ -14,17 +17,19 @@ import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeK
*
* @see TcpMessageTypeEnums#TCP_DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
public class ClientHandleTcpDistributeClientPermeateClientTransferCloseTypeAdvanced extends AbstractHandleTcpDistributeClientPermeateClientTransferCloseTypeAdvanced<NettyProxyMsg> {
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyChannelContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
Channel channel = nettyChannelContext.channel();
// 关闭客户端真实通道、访客通道
Channel realChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
realChannel.close();// 真实通道关闭

View File

@@ -1,13 +1,15 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.NettyVisitorPortContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.client.AbstractHandleTcpDistributeClientPermeateServerCloseTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.enums.TcpMessageTypeEnums;
import org.framework.lazy.cloud.network.heartbeat.common.socket.PermeateVisitorSocket;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
/**
@@ -15,6 +17,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.socket.PermeateVisitorS
*
* @see TcpMessageTypeEnums#TCP_DISTRIBUTE_CLIENT_PERMEATE_SERVER_CLOSE
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
public class ClientHandleTcpDistributeClientPermeateServerCloseTypeAdvanced extends AbstractHandleTcpDistributeClientPermeateServerCloseTypeAdvanced<NettyProxyMsg> {
@@ -22,11 +25,11 @@ public class ClientHandleTcpDistributeClientPermeateServerCloseTypeAdvanced exte
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyChannelContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
// 初始化 客户端渗透服务端socket
byte[] msgVisitorPort = nettyProxyMsg.getVisitorPort();
Integer visitorPort = Integer.parseInt(new String(msgVisitorPort));

View File

@@ -1,14 +1,16 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.socket.NettyTcpClientPermeateServerVisitorSocket;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.client.AbstractHandleTcpDistributeClientPermeateServerInitTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.enums.TcpMessageTypeEnums;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
import org.wu.framework.spring.utils.SpringContextHolder;
import java.util.ArrayList;
@@ -20,6 +22,7 @@ import java.util.List;
*
* @see TcpMessageTypeEnums#TCP_DISTRIBUTE_CLIENT_PERMEATE_SERVER_INIT
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
public class ClientHandleTcpDistributeClientPermeateServerInitTypeAdvanced extends AbstractHandleTcpDistributeClientPermeateServerInitTypeAdvanced<NettyProxyMsg> {
@@ -32,16 +35,16 @@ public class ClientHandleTcpDistributeClientPermeateServerInitTypeAdvanced exten
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyChannelContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
// 初始化 客户端渗透服务端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

@@ -3,10 +3,13 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.adv
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.client.AbstractHandleTcpDistributeClientPermeateServerTransferCloseTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.enums.TcpMessageTypeEnums;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
/**
@@ -14,17 +17,19 @@ import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeK
*
* @see TcpMessageTypeEnums#TCP_DISTRIBUTE_CLIENT_PERMEATE_SERVER_TRANSFER_CLOSE
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
public class ClientHandleTcpDistributeClientPermeateServerTransferCloseTypeAdvanced extends AbstractHandleTcpDistributeClientPermeateServerTransferCloseTypeAdvanced<NettyProxyMsg> {
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyChannelContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
Channel channel = nettyChannelContext.channel();
// 关闭本地通信通道
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
channel.close();

View File

@@ -4,10 +4,13 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.adv
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.client.AbstractHandleTcpDistributeClientPermeateServerTransferTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.enums.TcpMessageTypeEnums;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
/**
@@ -15,6 +18,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeK
*
* @see TcpMessageTypeEnums#TCP_DISTRIBUTE_CLIENT_TRANSFER
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
public class ClientHandleTcpDistributeClientPermeateServerTransferTypeAdvanced extends AbstractHandleTcpDistributeClientPermeateServerTransferTypeAdvanced<NettyProxyMsg> {
@@ -22,15 +26,16 @@ public class ClientHandleTcpDistributeClientPermeateServerTransferTypeAdvanced e
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyChannelContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
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

@@ -1,14 +1,16 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.socket.NettyTcpClientPermeateClientRealSocket;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.client.AbstractHandleTcpDistributeClientTransferClientPermeateChannelConnectionSuccessfulTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.enums.TcpMessageTypeEnums;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
import org.wu.framework.spring.utils.SpringContextHolder;
import java.util.ArrayList;
@@ -21,21 +23,22 @@ import java.util.List;
*
* @see TcpMessageTypeEnums#TCP_DISTRIBUTE_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
public class ClientHandleTcpDistributeClientTransferClientPermeateChannelConnectionSuccessfulTypeAdvanced extends AbstractHandleTcpDistributeClientTransferClientPermeateChannelConnectionSuccessfulTypeAdvanced<NettyProxyMsg> {
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyChannelContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
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

@@ -4,10 +4,13 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.adv
import io.netty.channel.Channel;
import io.netty.channel.ChannelOption;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.client.AbstractHandleTcpDistributeClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.enums.TcpMessageTypeEnums;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
/**
@@ -16,6 +19,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeK
*
* @see TcpMessageTypeEnums#TCP_DISTRIBUTE_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
public class ClientHandleTcpDistributeClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced extends AbstractHandleTcpDistributeClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced<NettyProxyMsg> {
@@ -24,15 +28,16 @@ public class ClientHandleTcpDistributeClientTransferClientPermeateChannelInitSuc
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyChannelContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
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

@@ -4,10 +4,13 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.adv
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.client.AbstractHandleTcpDistributeClientTransferClientRequestTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.enums.TcpMessageTypeEnums;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
/**
@@ -16,6 +19,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeK
*
* @see TcpMessageTypeEnums#TCP_DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_REQUEST
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
public class ClientHandleTcpDistributeClientTransferClientRequestTypeAdvanced extends AbstractHandleTcpDistributeClientTransferClientRequestTypeAdvanced<NettyProxyMsg> {
@@ -24,11 +28,12 @@ public class ClientHandleTcpDistributeClientTransferClientRequestTypeAdvanced ex
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyChannelContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
Channel channel = nettyChannelContext.channel();
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
// 把数据转到真实服务
ByteBuf buf = channel.config().getAllocator().buffer(nettyProxyMsg.getData().length);

View File

@@ -6,10 +6,13 @@ import io.netty.channel.ChannelOption;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.handler.NettyTcpClientPermeateServerVisitorHandler;
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.socket.NettyTcpClientPermeateServerVisitorTransferSocket;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.client.AbstractHandleTcpDistributeClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.enums.TcpMessageTypeEnums;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
/**
@@ -19,6 +22,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeK
*
* @see TcpMessageTypeEnums#TCP_DISTRIBUTE_CLIENT_TRANSFER_SERVER_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
public class ClientHandleTcpDistributeClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced extends AbstractHandleTcpDistributeClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced<NettyProxyMsg> {
@@ -27,15 +31,16 @@ public class ClientHandleTcpDistributeClientTransferServerPermeateChannelConnect
/**
* 处理当前数据
*
* @param transferChannel 当前通道
* @param nettyChannelContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel transferChannel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
Channel channel = nettyChannelContext.channel();
// 连接成功 开启自动读取写
byte[] msgVisitorId = nettyProxyMsg.getVisitorId();
String visitorId = new String(msgVisitorId);
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(transferChannel);
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
nextChannel.config().setOption(ChannelOption.AUTO_READ, true);
}

View File

@@ -1,17 +1,20 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
import com.alibaba.fastjson.JSONObject;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.event.ClientChangeEvent;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.client.AbstractHandleTcpDistributeConnectSuccessNotificationTypeAdvancedHandle;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
import java.util.List;
/**
* 客户端连接成功通知
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
public class ClientHandleTcpDistributeConnectSuccessNotificationTypeAdvancedHandle extends AbstractHandleTcpDistributeConnectSuccessNotificationTypeAdvancedHandle<NettyProxyMsg> {
@@ -25,11 +28,11 @@ public class ClientHandleTcpDistributeConnectSuccessNotificationTypeAdvancedHand
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyChannelContext 当前通道
* @param msg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg msg) {
protected void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg msg) {
// 客户端ID{},客户端:{}连接成功
log.warn("Client ID: {}, Client Data : {} Connection successful", new String(msg.getClientId()), new String(msg.getData()));

View File

@@ -1,17 +1,20 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.event.ClientChangeEvent;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.client.AbstractHandleTcpDistributeDisconnectTypeAdvancedHandle;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
/**
* 服务端处理客户端断开连接处理
* TYPE_DISCONNECT
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
public class ClientHandleTcpDistributeDisconnectTypeAdvancedHandle extends AbstractHandleTcpDistributeDisconnectTypeAdvancedHandle<NettyProxyMsg> {
@@ -25,11 +28,11 @@ public class ClientHandleTcpDistributeDisconnectTypeAdvancedHandle extends Abstr
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyChannelContext 当前通道
* @param msg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg msg) {
public void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg msg) {
// 服务下线
byte[] data = msg.getData();
byte[] clientId = msg.getClientId();

View File

@@ -1,13 +1,15 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.socket.NettyTcpServerPermeateClientRealSocket;
import org.framework.lazy.cloud.network.heartbeat.common.InternalNetworkPenetrationRealClient;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.client.AbstractHandleTcpDistributeServicePermeateClientRealConnectTypeAdvanced;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
import org.wu.framework.spring.utils.SpringContextHolder;
import java.util.ArrayList;
@@ -16,6 +18,7 @@ import java.util.List;
/**
* 客户端创建真实代理同奥
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
public class ClientHandleTcpDistributeServicePermeateClientRealConnectTypeAdvanced extends AbstractHandleTcpDistributeServicePermeateClientRealConnectTypeAdvanced<NettyProxyMsg> {
@@ -30,16 +33,16 @@ public class ClientHandleTcpDistributeServicePermeateClientRealConnectTypeAdvanc
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyChannelContext 当前通道
* @param msg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg msg) {
protected void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg msg) {
// 创建真实端口监听
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

@@ -4,10 +4,13 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.adv
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.client.AbstractHandleTcpDistributeServicePermeateClientTransferClientResponseTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.enums.TcpMessageTypeEnums;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
/**
@@ -16,6 +19,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeK
*
* @see TcpMessageTypeEnums#TCP_DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_RESPONSE
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
public class ClientHandleTcpDistributeServicePermeateClientTransferClientResponseTypeAdvanced extends AbstractHandleTcpDistributeServicePermeateClientTransferClientResponseTypeAdvanced<NettyProxyMsg> {
@@ -24,11 +28,12 @@ public class ClientHandleTcpDistributeServicePermeateClientTransferClientRespons
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyChannelContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
Channel channel = nettyChannelContext.channel();
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
// 把数据转到真实服务
ByteBuf buf = channel.config().getAllocator().buffer(nettyProxyMsg.getData().length);

View File

@@ -1,23 +1,26 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.client.AbstractHandleTcpDistributeSingleClientMessageTypeAdvanced;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
/**
* 接收服务端发送过来的聊天信息
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
public class ClientHandleTcpDistributeSingleClientMessageTypeAdvanced extends AbstractHandleTcpDistributeSingleClientMessageTypeAdvanced<NettyProxyMsg> {
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyChannelContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
protected void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
byte[] clientId = nettyProxyMsg.getClientId();
byte[] data = nettyProxyMsg.getData();
log.info("接收客户端:{},发送过来的聊天信息:{}", new String(clientId), new String(data));

View File

@@ -3,21 +3,26 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.adv
import io.netty.channel.Channel;
import io.netty.channel.ChannelOption;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.NettyRealIdContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.client.AbstractHandleTcpDistributeSingleClientRealAutoReadConnectTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
public class ClientHandleTcpDistributeSingleClientRealAutoReadConnectTypeAdvanced extends AbstractHandleTcpDistributeSingleClientRealAutoReadConnectTypeAdvanced<NettyProxyMsg> {
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyChannelContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
protected void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
Channel channel = nettyChannelContext.channel();
// 获取访客ID
byte[] visitorId = nettyProxyMsg.getVisitorId();
// 获取访客对应的真实代理通道

View File

@@ -1,22 +1,25 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyCommunicationIdContext;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.NettyRealIdContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.client.AbstractHandleTcpDistributeSingleClientRealCloseVisitorTypeAdvanced;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
public class ClientHandleTcpDistributeSingleClientRealCloseVisitorTypeAdvanced extends AbstractHandleTcpDistributeSingleClientRealCloseVisitorTypeAdvanced<NettyProxyMsg> {
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyChannelContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
protected void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
// 关闭代理的真实通道
byte[] visitorId = nettyProxyMsg.getVisitorId();
NettyRealIdContext.clear(visitorId);

View File

@@ -1,13 +1,16 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.client.AbstractHandleTcpDistributeStagingClosedTypeAdvanced;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
/**
* 服务端下发暂存关闭消息处理
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
public class ClientHandleTcpDistributeStagingClosedTypeAdvanced extends AbstractHandleTcpDistributeStagingClosedTypeAdvanced<NettyProxyMsg> {
@@ -15,11 +18,11 @@ public class ClientHandleTcpDistributeStagingClosedTypeAdvanced extends Abstract
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyChannelContext 当前通道
* @param msg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg msg) {
protected void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg msg) {
String clientId = new String(msg.getClientId());
log.info("客户端:{}离线暂存关闭", clientId);
// 修改redis 客户端暂存状态

View File

@@ -1,13 +1,16 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.tcp.client.AbstractHandleTcpDistributeStagingOpenedTypeAdvanced;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
/**
* 服务端下发暂存开启消息处理
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
public class ClientHandleTcpDistributeStagingOpenedTypeAdvanced extends AbstractHandleTcpDistributeStagingOpenedTypeAdvanced<NettyProxyMsg> {
@@ -19,11 +22,11 @@ public class ClientHandleTcpDistributeStagingOpenedTypeAdvanced extends Abstract
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyChannelContext 当前通道
* @param msg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg msg) {
protected void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg msg) {
String clientId = new String(msg.getClientId());
//客户端:{}离线暂存开启
log.warn("Client: {} Offline temporary storage enabled", new String(msg.getClientId()));

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

View File

@@ -7,7 +7,7 @@ import io.netty.channel.SimpleChannelInboundHandler;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.constant.TcpMessageType;
import org.framework.lazy.cloud.network.heartbeat.common.NettyByteBuf;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
/**

View File

@@ -6,7 +6,7 @@ import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.constant.TcpMessageType;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
@@ -29,7 +29,7 @@ public class NettyTcpClientPermeateClientTransferHandler extends SimpleChannelIn
@Override
public void channelRead0(ChannelHandlerContext ctx, NettyProxyMsg nettyProxyMsg) throws Exception {
Channel channel = ctx.channel();
channelTypeAdapter.handler(channel, nettyProxyMsg);
channelTypeAdapter.handler(ctx, nettyProxyMsg);
}

View File

@@ -6,7 +6,7 @@ import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.constant.TcpMessageType;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
@@ -29,7 +29,7 @@ public class NettyTcpClientPermeateClientTransferRealHandler extends SimpleChann
@Override
public void channelRead0(ChannelHandlerContext ctx, NettyProxyMsg nettyProxyMsg) throws Exception {
Channel channel = ctx.channel();
channelTypeAdapter.handler(channel, nettyProxyMsg);
channelTypeAdapter.handler(ctx, nettyProxyMsg);
}

View File

@@ -14,7 +14,7 @@ import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.sock
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.socket.NettyTcpClientPermeateServerVisitorTransferSocket;
import org.framework.lazy.cloud.network.heartbeat.common.constant.TcpMessageType;
import org.framework.lazy.cloud.network.heartbeat.common.NettyCommunicationIdContext;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.NettyRealIdContext;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;

View File

@@ -8,7 +8,7 @@ import io.netty.handler.timeout.IdleState;
import io.netty.handler.timeout.IdleStateEvent;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.constant.TcpMessageType;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
@@ -31,7 +31,7 @@ public class NettyTcpClientPermeateServerTransferHandler extends SimpleChannelIn
@Override
public void channelRead0(ChannelHandlerContext ctx, NettyProxyMsg nettyProxyMsg) throws Exception {
Channel channel = ctx.channel();
channelTypeAdapter.handler(channel, nettyProxyMsg);
channelTypeAdapter.handler(ctx, nettyProxyMsg);
}

View File

@@ -12,7 +12,7 @@ import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.NettyCli
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced.ClientHandleTcpDistributeClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.socket.NettyTcpClientPermeateServerVisitorTransferSocket;
import org.framework.lazy.cloud.network.heartbeat.common.constant.TcpMessageType;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import java.util.UUID;

View File

@@ -8,7 +8,7 @@ import io.netty.channel.SimpleChannelInboundHandler;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.constant.TcpMessageType;
import org.framework.lazy.cloud.network.heartbeat.common.NettyByteBuf;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.wu.framework.core.utils.ObjectUtils;

View File

@@ -6,8 +6,8 @@ import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOption;
import io.netty.channel.SimpleChannelInboundHandler;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.*;
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.constant.TcpMessageType;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.wu.framework.core.utils.ObjectUtils;
@@ -31,7 +31,7 @@ public class NettyTcpServerPermeateClientTransferHandler extends SimpleChannelIn
@Override
public void channelRead0(ChannelHandlerContext ctx, NettyProxyMsg nettyProxyMsg) throws Exception {
Channel channel = ctx.channel();
channelTypeAdapter.handler(channel, nettyProxyMsg);
channelTypeAdapter.handler(ctx, nettyProxyMsg);
}

View File

@@ -11,6 +11,7 @@ import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.filt
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.filter.NettyTcpClientPermeateClientTransferRealFilter;
import org.framework.lazy.cloud.network.heartbeat.common.*;
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.constant.TcpMessageType;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
@@ -138,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

@@ -10,7 +10,7 @@ import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientPrope
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.NettyClientPermeateClientVisitor;
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.filter.NettyTcpClientPermeateClientTransferFilter;
import org.framework.lazy.cloud.network.heartbeat.common.constant.TcpMessageType;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
@@ -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

@@ -10,7 +10,7 @@ import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientPrope
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.NettyClientPermeateServerVisitor;
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.filter.NettyTcpClientPermeateServerTransferFilter;
import org.framework.lazy.cloud.network.heartbeat.common.constant.TcpMessageType;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
@@ -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.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

@@ -11,6 +11,7 @@ import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.filt
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.filter.NettyTcpServerPermeateClientTransferFilter;
import org.framework.lazy.cloud.network.heartbeat.common.*;
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.constant.TcpMessageType;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
@@ -180,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

@@ -1,29 +1,32 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.advanced;
import io.netty.channel.Channel;
import org.framework.lazy.cloud.network.heartbeat.common.constant.UdpMessageType;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.udp.AbstractUdpHandleChannelHeartbeatTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.constant.UdpMessageType;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
/**
* 服务端 处理客户端心跳
* UDP_TYPE_HEARTBEAT
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public class ClientHandleUdpChannelHeartbeatTypeAdvanced extends AbstractUdpHandleChannelHeartbeatTypeAdvanced<NettyProxyMsg> {
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyChannelContext 当前通道
* @param msg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg msg) {
NettyProxyMsg hb = new NettyProxyMsg();
hb.setType(UdpMessageType.UDP_TYPE_HEARTBEAT);
// channel.writeAndFlush(hb);
public void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg msg) {
NettyProxyMsg nettyProxyMsg = new NettyProxyMsg();
nettyProxyMsg.setType(UdpMessageType.UDP_TYPE_HEARTBEAT);
// nettyChannelContext.writeAndFlush(nettyProxyMsg);
}
}

View File

@@ -5,10 +5,13 @@ import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.udp.client.AbstractHandleUdpDistributeServicePermeateClientTransferTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.enums.UdpMessageTypeEnums;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
/**
@@ -16,6 +19,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeK
*
* @see UdpMessageTypeEnums#UDP_DISTRIBUTE_CLIENT_TRANSFER
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
public class ClientHandleUdpChannelTransferTypeAdvancedHandleDistribute extends AbstractHandleUdpDistributeServicePermeateClientTransferTypeAdvanced<NettyProxyMsg> {
@@ -28,16 +32,17 @@ public class ClientHandleUdpChannelTransferTypeAdvancedHandleDistribute extends
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyChannelContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
Channel channel = nettyChannelContext.channel();
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

@@ -3,13 +3,17 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.adv
import io.netty.channel.Channel;
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
import org.framework.lazy.cloud.network.heartbeat.common.ChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.udp.client.AbstractHandleUdpClientChannelActiveAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
/**
* 客户端通道 is active
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public class ClientHandleUdpClientChannelActiveAdvanced extends AbstractHandleUdpClientChannelActiveAdvanced<NettyProxyMsg> {
private final NettyClientProperties nettyClientProperties;
@@ -20,14 +24,16 @@ public class ClientHandleUdpClientChannelActiveAdvanced extends AbstractHandleUd
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyChannelContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
protected void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
Channel channel = nettyChannelContext.channel();
// 缓存当前通道
byte[] clientIdByte = nettyProxyMsg.getClientId();
String clientId = new String(clientIdByte);
String serverId = new String(clientIdByte);
ChannelContext.push(channel, clientId);
ChannelAttributeKeyUtils.buildClientId(channel, clientId);
}

View File

@@ -1,13 +1,15 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.advanced;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.NettyVisitorPortContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.udp.client.AbstractHandleUdpDistributeClientPermeateClientCloseTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.enums.UdpMessageTypeEnums;
import org.framework.lazy.cloud.network.heartbeat.common.socket.PermeateVisitorSocket;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
/**
@@ -15,6 +17,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.socket.PermeateVisitorS
*
* @see UdpMessageTypeEnums#UDP_DISTRIBUTE_CLIENT_PERMEATE_CLIENT_CLOSE
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
public class ClientHandleUdpDistributeClientPermeateClientCloseTypeAdvanced extends AbstractHandleUdpDistributeClientPermeateClientCloseTypeAdvanced<NettyProxyMsg> {
@@ -22,11 +25,11 @@ public class ClientHandleUdpDistributeClientPermeateClientCloseTypeAdvanced exte
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyChannelContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
// 初始化 客户端渗透服务端socket
byte[] msgVisitorPort = nettyProxyMsg.getVisitorPort();
Integer visitorPort = Integer.parseInt(new String(msgVisitorPort));

View File

@@ -1,14 +1,16 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.advanced;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.socket.NettyUdpClientPermeateClientVisitorSocket;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.udp.client.AbstractHandleUdpDistributeClientPermeateClientInitTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.enums.TcpMessageTypeEnums;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
import org.wu.framework.spring.utils.SpringContextHolder;
import java.util.ArrayList;
@@ -20,26 +22,27 @@ import java.util.List;
*
* @see TcpMessageTypeEnums#TCP_DISTRIBUTE_CLIENT_PERMEATE_CLIENT_INIT
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
public class ClientHandleUdpDistributeClientPermeateClientInitTypeAdvanced extends AbstractHandleUdpDistributeClientPermeateClientInitTypeAdvanced<NettyProxyMsg> {
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyChannelContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
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));
@@ -47,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

@@ -3,10 +3,13 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.adv
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.udp.client.AbstractHandleUdpDistributeClientPermeateClientTransferCloseTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.enums.UdpMessageTypeEnums;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
/**
@@ -14,17 +17,19 @@ import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeK
*
* @see UdpMessageTypeEnums#UDP_DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
public class ClientHandleUdpDistributeClientPermeateClientTransferCloseTypeAdvanced extends AbstractHandleUdpDistributeClientPermeateClientTransferCloseTypeAdvanced<NettyProxyMsg> {
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyChannelContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
Channel channel = nettyChannelContext.channel();
// 关闭客户端真实通道、访客通道
Channel realChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
realChannel.close();// 真实通道关闭

View File

@@ -1,13 +1,15 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.advanced;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.NettyVisitorPortContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.udp.client.AbstractHandleUdpDistributeClientPermeateServerCloseTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.enums.UdpMessageTypeEnums;
import org.framework.lazy.cloud.network.heartbeat.common.socket.PermeateVisitorSocket;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
/**
@@ -15,6 +17,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.socket.PermeateVisitorS
*
* @see UdpMessageTypeEnums#UDP_DISTRIBUTE_CLIENT_PERMEATE_SERVER_CLOSE
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
public class ClientHandleUdpDistributeClientPermeateServerCloseTypeAdvanced extends AbstractHandleUdpDistributeClientPermeateServerCloseTypeAdvanced<NettyProxyMsg> {
@@ -22,11 +25,11 @@ public class ClientHandleUdpDistributeClientPermeateServerCloseTypeAdvanced exte
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyChannelContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
// 初始化 客户端渗透服务端socket
byte[] msgVisitorPort = nettyProxyMsg.getVisitorPort();
Integer visitorPort = Integer.parseInt(new String(msgVisitorPort));

View File

@@ -1,14 +1,16 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.advanced;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.socket.NettyUdpClientPermeateServerVisitorSocket;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.udp.client.AbstractHandleUdpDistributeClientPermeateServerInitTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.enums.TcpMessageTypeEnums;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
import org.wu.framework.spring.utils.SpringContextHolder;
import java.util.ArrayList;
@@ -20,6 +22,7 @@ import java.util.List;
*
* @see TcpMessageTypeEnums#TCP_DISTRIBUTE_CLIENT_PERMEATE_SERVER_INIT
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
public class ClientHandleUdpDistributeClientPermeateServerInitTypeAdvanced extends AbstractHandleUdpDistributeClientPermeateServerInitTypeAdvanced<NettyProxyMsg> {
@@ -32,16 +35,16 @@ public class ClientHandleUdpDistributeClientPermeateServerInitTypeAdvanced exten
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyChannelContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
// 初始化 客户端渗透服务端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

@@ -3,10 +3,13 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.adv
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.udp.client.AbstractHandleUdpDistributeClientPermeateServerTransferCloseTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.enums.UdpMessageTypeEnums;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
/**
@@ -14,17 +17,19 @@ import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeK
*
* @see UdpMessageTypeEnums#UDP_DISTRIBUTE_CLIENT_PERMEATE_SERVER_TRANSFER_CLOSE
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
public class ClientHandleUdpDistributeClientPermeateServerTransferCloseTypeAdvanced extends AbstractHandleUdpDistributeClientPermeateServerTransferCloseTypeAdvanced<NettyProxyMsg> {
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyChannelContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
Channel channel = nettyChannelContext.channel();
// 关闭本地通信通道
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
channel.close();

View File

@@ -4,10 +4,13 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.adv
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.udp.client.AbstractHandleUdpDistributeClientPermeateServerTransferTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.enums.UdpMessageTypeEnums;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
/**
@@ -15,6 +18,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeK
*
* @see UdpMessageTypeEnums#UDP_DISTRIBUTE_CLIENT_TRANSFER
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
public class ClientHandleUdpDistributeClientPermeateServerTransferTypeAdvanced extends AbstractHandleUdpDistributeClientPermeateServerTransferTypeAdvanced<NettyProxyMsg> {
@@ -22,15 +26,16 @@ public class ClientHandleUdpDistributeClientPermeateServerTransferTypeAdvanced e
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyChannelContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
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

@@ -1,13 +1,15 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.advanced;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.socket.NettyUdpClientPermeateClientRealSocket;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.udp.client.AbstractHandleUdpDistributeClientTransferClientPermeateChannelConnectionSuccessfulTypeAdvanced;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
import org.wu.framework.spring.utils.SpringContextHolder;
import java.util.ArrayList;
@@ -20,21 +22,22 @@ import java.util.List;
*
* @see MessageTypeEnums#UDP_DISTRIBUTE_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
public class ClientHandleUdpDistributeClientTransferClientPermeateChannelConnectionSuccessfulTypeAdvanced extends AbstractHandleUdpDistributeClientTransferClientPermeateChannelConnectionSuccessfulTypeAdvanced<NettyProxyMsg> {
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyChannelContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
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

@@ -4,10 +4,13 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.adv
import io.netty.channel.Channel;
import io.netty.channel.ChannelOption;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.udp.client.AbstractHandleUdpDistributeClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.enums.UdpMessageTypeEnums;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
/**
@@ -16,6 +19,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeK
*
* @see UdpMessageTypeEnums#UDP_DISTRIBUTE_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
public class ClientHandleUdpDistributeClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced extends AbstractHandleUdpDistributeClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced<NettyProxyMsg> {
@@ -24,15 +28,16 @@ public class ClientHandleUdpDistributeClientTransferClientPermeateChannelInitSuc
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyChannelContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
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

@@ -4,10 +4,13 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.adv
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.udp.client.AbstractHandleUdpDistributeClientTransferClientRequestTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.enums.UdpMessageTypeEnums;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
/**
@@ -16,6 +19,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeK
*
* @see UdpMessageTypeEnums#UDP_DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_REQUEST
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
public class ClientHandleUdpDistributeClientTransferClientRequestTypeAdvanced extends AbstractHandleUdpDistributeClientTransferClientRequestTypeAdvanced<NettyProxyMsg> {
@@ -24,11 +28,12 @@ public class ClientHandleUdpDistributeClientTransferClientRequestTypeAdvanced ex
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyChannelContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
Channel channel = nettyChannelContext.channel();
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
// 把数据转到真实服务
ByteBuf buf = channel.config().getAllocator().buffer(nettyProxyMsg.getData().length);

View File

@@ -6,10 +6,13 @@ import io.netty.channel.ChannelOption;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.handler.NettyUdpClientPermeateServerVisitorHandler;
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.socket.NettyUdpClientPermeateServerVisitorTransferSocket;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.udp.client.AbstractHandleUdpDistributeClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.enums.UdpMessageTypeEnums;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
/**
@@ -19,6 +22,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeK
*
* @see UdpMessageTypeEnums#UDP_DISTRIBUTE_CLIENT_TRANSFER_SERVER_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
public class ClientHandleUdpDistributeClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced extends AbstractHandleUdpDistributeClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced<NettyProxyMsg> {
@@ -27,15 +31,16 @@ public class ClientHandleUdpDistributeClientTransferServerPermeateChannelConnect
/**
* 处理当前数据
*
* @param transferChannel 当前通道
* @param nettyChannelContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel transferChannel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
Channel channel = nettyChannelContext.channel();
// 连接成功 开启自动读取写
byte[] msgVisitorId = nettyProxyMsg.getVisitorId();
String visitorId = new String(msgVisitorId);
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(transferChannel);
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
nextChannel.config().setOption(ChannelOption.AUTO_READ, true);
}

View File

@@ -1,17 +1,20 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.advanced;
import com.alibaba.fastjson.JSONObject;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.event.ClientChangeEvent;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.udp.client.AbstractHandleUdpDistributeConnectSuccessNotificationTypeAdvancedHandle;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
import java.util.List;
/**
* 客户端连接成功通知
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
public class ClientHandleUdpDistributeConnectSuccessNotificationTypeAdvancedHandle extends AbstractHandleUdpDistributeConnectSuccessNotificationTypeAdvancedHandle<NettyProxyMsg> {
@@ -25,11 +28,11 @@ public class ClientHandleUdpDistributeConnectSuccessNotificationTypeAdvancedHand
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyChannelContext 当前通道
* @param msg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg msg) {
protected void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg msg) {
// 客户端ID{},客户端:{}连接成功
log.warn("Client ID: {}, Client Data : {} Connection successful", new String(msg.getClientId()), new String(msg.getData()));

View File

@@ -1,17 +1,20 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.advanced;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.event.ClientChangeEvent;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.udp.client.AbstractHandleUdpDistributeDisconnectTypeAdvancedHandle;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
/**
* 服务端处理客户端断开连接处理
* TYPE_DISCONNECT
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
public class ClientHandleUdpDistributeDisconnectTypeAdvancedHandle extends AbstractHandleUdpDistributeDisconnectTypeAdvancedHandle<NettyProxyMsg> {
@@ -25,11 +28,11 @@ public class ClientHandleUdpDistributeDisconnectTypeAdvancedHandle extends Abstr
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyChannelContext 当前通道
* @param msg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg msg) {
public void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg msg) {
// 服务下线
byte[] data = msg.getData();
byte[] clientId = msg.getClientId();

View File

@@ -1,13 +1,15 @@
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.advanced;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.socket.NettyUdpServerPermeateClientRealSocket;
import org.framework.lazy.cloud.network.heartbeat.common.InternalNetworkPenetrationRealClient;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.udp.client.AbstractHandleUdpDistributeServicePermeateClientRealConnectTypeAdvanced;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
import org.wu.framework.spring.utils.SpringContextHolder;
import java.util.ArrayList;
@@ -16,6 +18,7 @@ import java.util.List;
/**
* 客户端创建真实代理同奥
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
public class ClientHandleUdpDistributeServicePermeateClientRealConnectTypeAdvanced extends AbstractHandleUdpDistributeServicePermeateClientRealConnectTypeAdvanced<NettyProxyMsg> {
@@ -29,16 +32,16 @@ public class ClientHandleUdpDistributeServicePermeateClientRealConnectTypeAdvanc
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyChannelContext 当前通道
* @param msg 通道数据
*/
@Override
protected void doHandler(Channel channel, NettyProxyMsg msg) {
protected void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg msg) {
// 创建真实端口监听
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

@@ -4,10 +4,13 @@ package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.adv
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyChannelContext;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.payload.NettyProxyMsg;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.permeate.udp.client.AbstractHandleUdpDistributeServicePermeateClientTransferClientResponseTypeAdvanced;
import org.framework.lazy.cloud.network.heartbeat.common.enums.UdpMessageTypeEnums;
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
/**
@@ -16,6 +19,7 @@ import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeK
*
* @see UdpMessageTypeEnums#UDP_DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_RESPONSE
*/
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
public class ClientHandleUdpDistributeServicePermeateClientTransferClientResponseTypeAdvanced extends AbstractHandleUdpDistributeServicePermeateClientTransferClientResponseTypeAdvanced<NettyProxyMsg> {
@@ -24,11 +28,12 @@ public class ClientHandleUdpDistributeServicePermeateClientTransferClientRespons
/**
* 处理当前数据
*
* @param channel 当前通道
* @param nettyChannelContext 当前通道
* @param nettyProxyMsg 通道数据
*/
@Override
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
public void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
Channel channel = nettyChannelContext.channel();
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
// 把数据转到真实服务
ByteBuf buf = channel.config().getAllocator().buffer(nettyProxyMsg.getData().length);

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