Compare commits
179 Commits
1.2.7-JDK1
...
c34f1239d8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c34f1239d8 | ||
|
|
edaa4b84d7 | ||
|
|
6c6584fdb9 | ||
|
|
221623e9c0 | ||
|
|
ff150eb31c | ||
|
|
e1de673b52 | ||
|
|
01a2937414 | ||
|
|
e8383c78ad | ||
|
|
1a08fe64e9 | ||
|
|
ca87968469 | ||
|
|
903ba88787 | ||
|
|
0505d6d201 | ||
|
|
556cb3fd1b | ||
|
|
ddb709c3a8 | ||
|
|
9cd85abe1d | ||
|
|
664bafdc86 | ||
|
|
3b9379a7aa | ||
|
|
17306c348a | ||
|
|
e518e20cc1 | ||
|
|
a27506299e | ||
|
|
40de2dbe4d | ||
|
|
06869dcd2f | ||
|
|
c9b866885a | ||
|
|
f496f12fe3 | ||
|
|
6e6ce666b8 | ||
|
|
f82e9e5f0a | ||
|
|
26e4990f0a | ||
|
|
833e97a89d | ||
|
|
dab44fc1a2 | ||
|
|
200a636379 | ||
|
|
08b8e2dbb8 | ||
|
|
e7df027d65 | ||
|
|
071b844d68 | ||
|
|
afa4d5c360 | ||
|
|
c057d7b2d5 | ||
|
|
7f9cebec8a | ||
|
|
32a641ce99 | ||
|
|
a3c88ffa9f | ||
|
|
466faacb93 | ||
|
|
687770e086 | ||
|
|
32c757ef5e | ||
|
|
68f4c92366 | ||
|
|
ad7fa61067 | ||
|
|
fe3adeee03 | ||
|
|
2e40988ef4 | ||
|
|
5528ef6ebd | ||
|
|
9401c27572 | ||
|
|
c852e3b351 | ||
|
|
17b220a76a | ||
|
|
191e23fc83 | ||
|
|
96929044fa | ||
|
|
965142793c | ||
|
|
9a44a598ef | ||
|
|
c2c350a28a | ||
|
|
8cc3b4858a | ||
|
|
3c32a5d157 | ||
|
|
578429777a | ||
|
|
5eba201979 | ||
|
|
f8a9ca4264 | ||
|
|
7af14b4251 | ||
|
|
24fe9e4bc9 | ||
|
|
2adf5e4749 | ||
|
|
b7f099d3a4 | ||
|
|
f0fd22ccd4 | ||
|
|
7b26e9cb60 | ||
|
|
6e79901be3 | ||
|
|
f88e0e2b7f | ||
|
|
9324b516fd | ||
|
|
a6c46c3cba | ||
|
|
66956636b9 | ||
|
|
9dc36fe8e9 | ||
|
|
f2a22c177e | ||
|
|
98587b442c | ||
|
|
e51ad201de | ||
|
|
d8a8b630ae | ||
|
|
e0f461460a | ||
|
|
75acddadca | ||
|
|
50e67f54e3 | ||
|
|
3444e90d3d | ||
|
|
b1b329aae1 | ||
|
|
26283de998 | ||
|
|
9c5000f995 | ||
|
|
532d05d4a8 | ||
|
|
402f6f0ac1 | ||
|
|
a5a3d7d6f2 | ||
|
|
e4c33f34c1 | ||
|
|
394dfdf337 | ||
|
|
9b44a199be | ||
|
|
fe8a2c865a | ||
|
|
ba8ca7bcd9 | ||
|
|
9a211ad200 | ||
|
|
40ab82de35 | ||
|
|
8728cd5d54 | ||
|
|
3f7f10bcd5 | ||
|
|
269a0f2ba2 | ||
|
|
8f02c03d42 | ||
|
|
9e1da9649e | ||
|
|
074ab4f217 | ||
|
|
07e8b20449 | ||
|
|
2a98ec0589 | ||
|
|
3321e0dd7b | ||
|
|
cf9438a7da | ||
|
|
4690bc85b3 | ||
|
|
2389a25e11 | ||
|
|
cf10347939 | ||
|
|
98b4701978 | ||
|
|
7da5f58263 | ||
|
|
a019561c06 | ||
|
|
f985cdac8f | ||
|
|
7429cff23a | ||
|
|
9fa3359569 | ||
|
|
fac28c4fc8 | ||
|
|
f9188037a0 | ||
|
|
f19b1cae68 | ||
|
|
0df0a42b2c | ||
|
|
2b3c7cb7c2 | ||
|
|
daeba59a43 | ||
|
|
cb4c9c0b41 | ||
|
|
0ceb88bfe3 | ||
|
|
42bc37c712 | ||
|
|
41a81133f1 | ||
|
|
ddaa5568e0 | ||
|
|
9b64c622cc | ||
|
|
f11200cee9 | ||
|
|
0f04f29cd0 | ||
|
|
3568292ac2 | ||
|
|
1924e87c7d | ||
|
|
30e1141ecf | ||
|
|
79b09ecfea | ||
|
|
5a079fcba8 | ||
|
|
20bb29350c | ||
|
|
ea2fb01b7e | ||
|
|
ba960a70ab | ||
|
|
4de7cdb6be | ||
|
|
1c6f56d31e | ||
|
|
8952d2277f | ||
|
|
dab6e580e4 | ||
|
|
9edb6f3d4d | ||
|
|
3740a4f4ea | ||
|
|
3b57ee1c23 | ||
|
|
b76f7a8f62 | ||
|
|
aa056dbe07 | ||
|
|
810579178f | ||
|
|
240de53888 | ||
|
|
2eb6dc2775 | ||
|
|
c665bf687d | ||
|
|
1e2f58b5a3 | ||
|
|
381f8a6960 | ||
|
|
a04499ab4b | ||
|
|
477d8cfaac | ||
|
|
b2cd1eee0a | ||
|
|
b7d571ccc1 | ||
|
|
55ce3ff359 | ||
|
|
42e8e5afec | ||
|
|
4977348113 | ||
|
|
89f9207367 | ||
|
|
70cf9fe3ac | ||
|
|
ecd5288929 | ||
|
|
571fe7893d | ||
|
|
1e89813793 | ||
|
|
0dd5b986a2 | ||
|
|
67c2537823 | ||
|
|
8dc1272109 | ||
|
|
9ae2f162e2 | ||
|
|
c2a4926888 | ||
|
|
a5176c3cf1 | ||
|
|
600706ccc1 | ||
|
|
fb086d6e95 | ||
|
|
98811a18c3 | ||
|
|
0493c1ce5e | ||
|
|
dd6daa5421 | ||
|
|
6c7f6b807f | ||
|
|
97f50d1701 | ||
|
|
5e3216a2a4 | ||
|
|
68d9713cf9 | ||
|
|
2d15abcc9f | ||
|
|
ec4c1cd7e4 | ||
|
|
bab2ce0242 | ||
|
|
6408239029 |
25
ClientPermeateClient.md
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
### 背景:国庆期间的问题,如何在老家访问杭州办公室的网络呢
|
||||
#### 实现方案:异地组网
|
||||
#### 实现语言:Java
|
||||
#### 环境:三个网络,一台拥有公网IP的服务器、一台杭州本地机房内服务器、你老家所在网络中的一台电脑(用你自己的就好了)
|
||||
#### 实现原理:
|
||||
|
||||
#### 操作步骤:拥有公网ip的服务器开发6001(web)、7001端口(tcp),然后执行命令启动服务端
|
||||
```shell
|
||||
docker run -d -it -p 6001:6001 -p 7001:7001 -e spring.profiles.active=prod -e MAIN_DB_HOST=localhost:3306 -e MAIN_DB_PASSWORD=root -e MAIN_DB_PASSWORD=root --name wu-lazy-cloud-heartbeat-server-start registry.cn-hangzhou.aliyuncs.com/wu-lazy/wu-lazy-cloud-heartbeat-server-start:1.3.1-JDK17-SNAPSHOT
|
||||
```
|
||||
|
||||
#### 操作步骤:杭州本地机房所在网络服务器启动客户端、你老家所在网络中启动客户端,命令如下
|
||||
```shell
|
||||
docker run -d -it --privileged --name hangzhou-client --restart=always -e spring.lazy.netty.client.inet-host=公网IP -e spring.lazy.netty.client.inet-port=7001 -e spring.lazy.netty.client.client-id="hangzhou-jifang" registry.cn-hangzhou.aliyuncs.com/wu-lazy/wu-lazy-cloud-heartbeat-client-start:1.3.1-JDK17-SNAPSHOT
|
||||
```
|
||||
```shell
|
||||
docker run -d -it --privileged --name my-home-client --restart=always -e spring.lazy.netty.client.inet-host=公网IP -e spring.lazy.netty.client.inet-port=7001 -e spring.lazy.netty.client.client-id="my-home" registry.cn-hangzhou.aliyuncs.com/wu-lazy/wu-lazy-cloud-heartbeat-client-start:1.3.1-JDK17-SNAPSHOT
|
||||
```
|
||||
#### 操作步骤:配置端口
|
||||

|
||||
#### 操作步骤:打开页面配置菜单看到如下界面(from客户端ID:你老家网络中的电脑,to客户端ID)
|
||||

|
||||
|
||||
#### 连接使用:在你老家使用my-home这个客户端所在机器上的ip+13306 即可访问杭州机房内的数据库的服务3306
|
||||
@@ -3,7 +3,7 @@
|
||||
#### 模块说明
|
||||
|
||||
| 模块 | 所属层级 | 描述 | 端口 |
|
||||
|------------------------------------------------------------------------------------|------|------------------------|----------------------------------------------------------------|
|
||||
|------------------------------------------------------------------|------|------------------------|----------------------------------------------------------------|
|
||||
| [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 |
|
||||
|
||||
61
LazyDNS.puml
Normal file
@@ -0,0 +1,61 @@
|
||||
|
||||
|
||||
@startuml
|
||||
|
||||
title 动态DNS
|
||||
|
||||
actor 访客 as User
|
||||
|
||||
package "服务端(公网)" as dns_server_{
|
||||
component [服务端私有网络A]{
|
||||
[mysql:(172.1.1.4:3306)] as dns_server_remote_local_
|
||||
[clickhouse:(172.1.1.5:3306)]
|
||||
}
|
||||
component [服务端私有网络B]{
|
||||
[mysql:(172.1.2.4:3306)]
|
||||
[clickhouse:(172.1.2.5:3306)]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
package "客户端(私有网络)" as dns_remote_local_{
|
||||
|
||||
component [客户端私有网络A]{
|
||||
[mysql:(162.1.1.4:3306)] as dns_client_remote_local_
|
||||
[clickhouse:(162.1.1.5:3306)]
|
||||
}
|
||||
component [客户端私有网络B]{
|
||||
[mysql:(162.1.2.4:3306)]
|
||||
[clickhouse:(162.1.2.5:3306)]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
package "客户端(用户本地)" as dns_local_ {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
note "用户本地网络" as local_net_
|
||||
note "服务端网络" as server_net_
|
||||
note "客户端私有网络" as remote_net_
|
||||
|
||||
'(User) .... local_condition_
|
||||
'local_condition_ ... (target)
|
||||
|
||||
[User] ...right...> dns_local_: DNS连接到本地
|
||||
dns_local_ ...right...> local_net_: 访问本地网络(本地DNS)
|
||||
dns_local_ ...up...> dns_server_remote_local_: 远程DNS解析
|
||||
|
||||
dns_server_ ...up...> server_net_: server本地的网络
|
||||
dns_server_ ...down...> dns_remote_local_: 访问的地址在远程的客户端中
|
||||
dns_remote_local_ ...down...> dns_client_remote_local_: 远程客户端所在的私有网络
|
||||
dns_remote_local_ ...down...> remote_net_: 远程客户端中的其他网络
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@enduml
|
||||
|
||||
140
NetworkPermeate1.0.puml
Normal file
@@ -0,0 +1,140 @@
|
||||
|
||||
|
||||
@startuml
|
||||
|
||||
title 服务端渗透客户端
|
||||
|
||||
actor 访客 as User
|
||||
|
||||
package "服务端(公网)"{
|
||||
component [服务端开放端口]{
|
||||
[默认UI页面端口:6001]
|
||||
[默认tcp端口:7001] as tcp
|
||||
[开放给客户端访问的端口:13306]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
package "客户端(私有网络)"{
|
||||
|
||||
component [客户端端口]{
|
||||
[默认UI页面端口:6004]
|
||||
}
|
||||
|
||||
database "客户端所在网络中的mysql:3306" as target {
|
||||
}
|
||||
}
|
||||
|
||||
[User] ...right...> [开放给客户端访问的端口:13306]: 发送请求到 http://ip:13306
|
||||
[开放给客户端访问的端口:13306] ...down...> [target]: 发送真实二进制请求到真实服务
|
||||
|
||||
note "无法直接访问" as N2
|
||||
(User) .... N2
|
||||
N2 ... (target)
|
||||
|
||||
@enduml
|
||||
|
||||
|
||||
@startuml
|
||||
|
||||
title 服务端渗透服务端
|
||||
|
||||
actor 访客 as User
|
||||
|
||||
package "服务端(局域网)"{
|
||||
component [服务端开放端口]{
|
||||
[默认UI页面端口:6001]
|
||||
[默认tcp端口:7001] as tcp
|
||||
[开放给服务端访问的端口:13306]
|
||||
}
|
||||
database "服务端所在网络中的mysql:3306" as target {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[User] ...right...> [开放给服务端访问的端口:13306]: 发送请求到 http://ip:13306
|
||||
[开放给服务端访问的端口:13306] ...down...> [target]: 发送真实二进制请求到真实服务
|
||||
|
||||
note "无法直接访问" as N2
|
||||
(User) .. N2
|
||||
N2 .. (target)
|
||||
|
||||
|
||||
@enduml
|
||||
|
||||
@startuml
|
||||
|
||||
title 客户端渗透服务端
|
||||
|
||||
actor 访客 as User
|
||||
|
||||
package "服务端(公网)"{
|
||||
component [服务端开放端口]{
|
||||
[默认UI页面端口:6001]
|
||||
[默认tcp端口:7001] as tcp
|
||||
}
|
||||
|
||||
database "服务端所在网络中的mysql:3306" as target {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
package "客户端(私有网络)"{
|
||||
|
||||
component [客户端端口]{
|
||||
[默认UI页面端口:6004]
|
||||
[客户端开放端口:13306]
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
[User] ...right...> [客户端开放端口:13306]: 发送请求到 http://ip:13306
|
||||
[客户端开放端口:13306] ...up...> [target]: 发送真实二进制请求到真实服务
|
||||
|
||||
note "无法直接访问" as N2
|
||||
(User) ...up... N2
|
||||
N2 ...up.. (target)
|
||||
|
||||
@enduml
|
||||
|
||||
@startuml
|
||||
|
||||
title 客户端渗透客户端
|
||||
|
||||
actor 访客杭州 as User
|
||||
|
||||
package "服务端(公网)" as server{
|
||||
component [服务端开放端口]{
|
||||
[默认UI页面端口:6001]
|
||||
[默认tcp端口:7001] as tcp
|
||||
}
|
||||
}
|
||||
|
||||
package "客户端(私有网络--杭州)" as client_hangzhou{
|
||||
|
||||
component [客户端端口]{
|
||||
[默认UI页面端口:6004]
|
||||
[客户端开放端口:13306]
|
||||
}
|
||||
}
|
||||
|
||||
package "客户端(私有网络--上海)" as client_shanghai{
|
||||
component [上海客户端端口]{
|
||||
[上海默认UI页面端口:6004]
|
||||
}
|
||||
database "服务端所在网络中的mysql:3306" as target {
|
||||
}
|
||||
}
|
||||
|
||||
server ...down...> client_hangzhou
|
||||
server <...right... client_shanghai
|
||||
|
||||
[User] ...right...> [客户端开放端口:13306]: 发送请求到 http://ip:13306
|
||||
[客户端开放端口:13306] ...up...> [target]: 发送真实二进制请求到真实服务
|
||||
|
||||
note "无法直接访问" as N2
|
||||
(User) ...up... N2
|
||||
N2 ...up.. (target)
|
||||
|
||||
@enduml
|
||||
BIN
NetworkPermeateClientPermeateClient.png
Normal file
|
After Width: | Height: | Size: 60 KiB |
BIN
NetworkPermeateClientPermeateServer.png
Normal file
|
After Width: | Height: | Size: 50 KiB |
BIN
NetworkPermeateServerPermeateClient.png
Normal file
|
After Width: | Height: | Size: 48 KiB |
BIN
NetworkPermeateServerPermeateServer.png
Normal file
|
After Width: | Height: | Size: 41 KiB |
BIN
Proxies_Config_1.png
Normal file
|
After Width: | Height: | Size: 542 KiB |
BIN
Proxies_Config_2.png
Normal file
|
After Width: | Height: | Size: 528 KiB |
BIN
Proxies_Config_3.png
Normal file
|
After Width: | Height: | Size: 547 KiB |
BIN
Proxies_Config_4.png
Normal file
|
After Width: | Height: | Size: 553 KiB |
BIN
Proxifier3.8.0.dmg
Normal file
33
Proxy.md
Normal file
@@ -0,0 +1,33 @@
|
||||
### 使用手册
|
||||
#### Mac 使用方式
|
||||
##### 获取socks或者http代理服务器信息
|
||||
如:ip:127.0.0.1 port:9001(socks)、8001(http)
|
||||
##### 使用Wi-Fi代理
|
||||
注意如下方式只能代理浏览器请求,无法代理其他应用请求
|
||||

|
||||

|
||||
|
||||
##### 使用第三方软件全局代理[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配置
|
||||

|
||||
- 配置socks服务器地址
|
||||

|
||||

|
||||
- 配置代理路由
|
||||

|
||||
- 展示效果
|
||||

|
||||
|
||||
#### Windows 使用方式
|
||||
##### 使用Wi-Fi代理
|
||||

|
||||
278
README.md
@@ -33,11 +33,32 @@
|
||||
|
||||
wu-lazy-cloud-network
|
||||
是一款基于([wu-framework-parent](https://gitee.com/wujiawei1207537021/wu-framework-parent))孵化出的项目,内部使用Lazy
|
||||
ORM操作数据库,主要功能是网络穿透,对于没有公网IP的服务进行公网IP映射
|
||||
使用环境JDK17 Spring Boot 3.0.2
|
||||
ORM操作数据库,使用环境JDK17 Spring Boot 3.0.2。的网络穿透、渗透工具支持Tcp、Http、Socks
|
||||
主要功能:
|
||||
- 服务端渗透客户端(网络穿透),对于没有公网IP的服务进行公网IP映射
|
||||
- 
|
||||
- 服务端渗透服务端----本地同局域网内端口映射
|
||||
- 
|
||||
- 客户端渗透服务端----本地端口映射到另一个服务端中的局域网端口
|
||||
- 
|
||||
- 客户端渗透客户端----本地端口映射到另一个局域网端口
|
||||
- 
|
||||
- 客户端代理服务端、客户端代理客户端、服务端代理服务端、服务端代理客户端(VPN)----异地组网搭建代理
|
||||
- 
|
||||
|
||||
[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)
|
||||
@@ -48,191 +69,6 @@ ORM操作数据库,主要功能是网络穿透,对于没有公网IP的服务
|
||||
|
||||

|
||||
|
||||
#### 实现原理
|
||||
|
||||
##### 服务端创建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.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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
##### 通过客户端与服务端建立的连接进行访客端口绑定
|
||||
|
||||
@@ -246,27 +82,27 @@ public class NettyClientSocket {
|
||||
1.内网穿透
|
||||
2.服务端自主下发数据到客户端
|
||||
3.流量监控
|
||||
4.网络代理(socks、http)
|
||||
|
||||
### 项目结构
|
||||
|
||||
| 模块 | 版本 | 描述 |
|
||||
|-----------------------------------------------------------------------------------------------------------------------------------------|----------------------|------------------------------|
|
||||
| [wu-lazy-cloud-heartbeat-common](wu-lazy-cloud-heartbeat-common) | 1.2.7-JDK17-SNAPSHOT | 内网穿透公共模块(声明接口、枚举、常量、适配器、解析器) |
|
||||
| [wu-lazy-cloud-heartbeat-client](wu-lazy-cloud-heartbeat-client) | 1.2.7-JDK17-SNAPSHOT | 客户端(支持二次开发) |
|
||||
| [wu-lazy-cloud-heartbeat-server](wu-lazy-cloud-heartbeat-server) | 1.2.7-JDK17-SNAPSHOT | 服务端(支持二次开发) |
|
||||
| [wu-lazy-cloud-network-ui](wu-lazy-cloud-heartbeat-server-ui) | 1.2.7-JDK17-SNAPSHOT | 服务端页面 |
|
||||
| [wu-lazy-cloud-heartbeat-client-start](wu-lazy-cloud-heartbeat-sample/wu-lazy-cloud-heartbeat-client-sample) | 1.2.7-JDK17-SNAPSHOT | 客户端样例 |
|
||||
| [wu-lazy-cloud-heartbeat-server-start](wu-lazy-cloud-heartbeat-sample/wu-lazy-cloud-heartbeat-server-sample) | 1.2.7-JDK17-SNAPSHOT | 服务端样例 |
|
||||
|------------------------------------------------------------------------------------------------------------|----------------------|------------------------------|
|
||||
| [wu-lazy-cloud-heartbeat-common](wu-lazy-cloud-heartbeat-common) | 1.3.1-JDK17-SNAPSHOT | 内网穿透公共模块(声明接口、枚举、常量、适配器、解析器) |
|
||||
| [wu-lazy-cloud-heartbeat-client](wu-lazy-cloud-heartbeat-client) | 1.3.1-JDK17-SNAPSHOT | 客户端(支持二次开发) |
|
||||
| [wu-lazy-cloud-heartbeat-server](wu-lazy-cloud-heartbeat-server) | 1.3.1-JDK17-SNAPSHOT | 服务端(支持二次开发) |
|
||||
| [wu-lazy-cloud-heartbeat-client-start](wu-lazy-cloud-heartbeat-start/wu-lazy-cloud-heartbeat-server-start) | 1.3.1-JDK17-SNAPSHOT | 客户端样例 |
|
||||
| [wu-lazy-cloud-heartbeat-server-start](wu-lazy-cloud-heartbeat-start/wu-lazy-cloud-heartbeat-client-start) | 1.3.1-JDK17-SNAPSHOT | 服务端样例 |
|
||||
|
||||
### 使用技术
|
||||
|
||||
| 框架 | 版本 | 描述 |
|
||||
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------|--------------|
|
||||
| spring-boot | 3.0.7 | springboot框架 |
|
||||
| [wu-framework-web](https://gitee.com/wujiawei1207537021/wu-framework-parent/tree/master/wu-framework-web) | 1.2.7-JDK17-SNAPSHOT | web容器 |
|
||||
| [Lazy -ORM](https://gitee.com/wujiawei1207537021/wu-framework-parent/tree/master/wu-inner-intergration/wu-database-parent) | 1.2.7-JDK17-SNAPSHOT | ORM |
|
||||
| [wu-framework-web](https://gitee.com/wujiawei1207537021/wu-framework-parent/tree/master/wu-framework-web) | 1.3.1-JDK17-SNAPSHOT | web容器 |
|
||||
| [Lazy -ORM](https://gitee.com/wujiawei1207537021/wu-framework-parent/tree/master/wu-inner-intergration/wu-database-parent) | 1.3.1-JDK17-SNAPSHOT | ORM |
|
||||
| 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.2.7-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-JDK17-SNAPSHOT | 用户授权体系 |
|
||||
|
||||
### 使用环境
|
||||
|
||||
@@ -275,28 +111,29 @@ 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.2.7-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-JDK17-SNAPSHOT
|
||||
|
||||
http://127.0.0.1:18080/swagger-ui/index.html
|
||||
|
||||
源码启动
|
||||
### 代理工具使用[Proxy.md](Proxy.md)
|
||||
|
||||
#### 页面操作
|
||||
|
||||
启动项目后打开服务端界面
|
||||

|
||||

|
||||
|
||||
默认账号密码:admin/admin
|
||||

|
||||

|
||||
|
||||
初始化项目
|
||||

|
||||

|
||||
添加角色
|
||||

|
||||

|
||||
为用户授权
|
||||

|
||||
|
||||
@@ -306,12 +143,26 @@ public class NettyClientSocket {
|
||||
客户端管理(客户端会自动注册)
|
||||

|
||||
|
||||
网络映射管理(修改后者新增需要映射的客户端)
|
||||

|
||||
## 服务端渗透
|
||||
- 服务端口池管理(服务器端需要开放的端口)
|
||||

|
||||
|
||||
访客端口池管理(服务器端需要开放的端口)
|
||||

|
||||
- 服务端渗透客户端(内网穿透)(修改后者新增需要映射的客户端)
|
||||

|
||||
|
||||
- 服务端渗透服务端
|
||||

|
||||
|
||||
## 客户端渗透
|
||||
- 客户端渗透端口池管理
|
||||

|
||||
|
||||
- 客户端渗透客户端
|
||||

|
||||
- 客户端渗透服务端
|
||||

|
||||
|
||||
## 报表
|
||||
流量管理(每个客户端使用的流量)
|
||||

|
||||
|
||||
@@ -320,3 +171,16 @@ public class NettyClientSocket {
|
||||
|
||||
客户端近七天使用流量
|
||||

|
||||
|
||||
## 路由
|
||||
- 客户端路由管理
|
||||

|
||||
- 客户端虚拟路由管理
|
||||
- 创建一个虚拟的不存在的IP,代理到指定的IP
|
||||

|
||||
|
||||
- 服务端路由管理
|
||||

|
||||
- 服务端虚拟路由管理
|
||||
- 创建一个虚拟的不存在的IP,代理到指定的IP
|
||||

|
||||
489
client-k8s.yaml
Normal file
@@ -0,0 +1,489 @@
|
||||
|
||||
---
|
||||
kind: Deployment
|
||||
apiVersion: apps/v1
|
||||
metadata:
|
||||
name: wu-lazy-cloud-heartbeat-local-client-start
|
||||
namespace: default
|
||||
labels:
|
||||
k8s.kuboard.cn/layer: monitor
|
||||
k8s.kuboard.cn/name: wu-lazy-cloud-heartbeat-local-client-start
|
||||
annotations:
|
||||
k8s.kuboard.cn/displayName: 内网穿透服务端(云下)
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
k8s.kuboard.cn/layer: monitor
|
||||
k8s.kuboard.cn/name: wu-lazy-cloud-heartbeat-local-client-start
|
||||
template:
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
k8s.kuboard.cn/layer: monitor
|
||||
k8s.kuboard.cn/name: wu-lazy-cloud-heartbeat-local-client-start
|
||||
annotations:
|
||||
kubectl.kubernetes.io/restartedAt: '2025-01-16T22:39:39+08:00'
|
||||
spec:
|
||||
containers:
|
||||
- name: wu-lazy-cloud-heartbeat-local-client-start
|
||||
image: >-
|
||||
registry.cn-hangzhou.aliyuncs.com/wu-lazy/wu-lazy-cloud-heartbeat-client-start:1.3.1-JDK17-SNAPSHOT
|
||||
env:
|
||||
- name: spring.lazy.netty.client.inet-host
|
||||
value: 124.222.48.62
|
||||
- name: spring.lazy.netty.client.inet-port
|
||||
value: '30560'
|
||||
- name: spring.lazy.netty.client.client-id
|
||||
value: tencent
|
||||
- name: JAVA_OPTS
|
||||
value: '-Xms32m -Xmx64m'
|
||||
- name: logging1.level.root
|
||||
value: DEBUG
|
||||
resources: {}
|
||||
terminationMessagePath: /dev/termination-log
|
||||
terminationMessagePolicy: File
|
||||
imagePullPolicy: Always
|
||||
securityContext:
|
||||
privileged: true
|
||||
runAsUser: 0
|
||||
restartPolicy: Always
|
||||
terminationGracePeriodSeconds: 30
|
||||
dnsPolicy: ClusterFirst
|
||||
securityContext: {}
|
||||
schedulerName: default-scheduler
|
||||
strategy:
|
||||
type: RollingUpdate
|
||||
rollingUpdate:
|
||||
maxUnavailable: 25%
|
||||
maxSurge: 25%
|
||||
revisionHistoryLimit: 10
|
||||
progressDeadlineSeconds: 600
|
||||
|
||||
---
|
||||
kind: StatefulSet
|
||||
apiVersion: apps/v1
|
||||
metadata:
|
||||
name: cloud-mysql
|
||||
namespace: default
|
||||
labels:
|
||||
k8s.eip.work/layer: db
|
||||
k8s.eip.work/name: cloud-mysql
|
||||
k8s.kuboard.cn/name: cloud-mysql
|
||||
annotations:
|
||||
analysis.crane.io/replicas-recommendation: |
|
||||
replicas: 1
|
||||
analysis.crane.io/resource-recommendation: |
|
||||
containers:
|
||||
- containerName: mysql
|
||||
target:
|
||||
cpu: 229m
|
||||
memory: 2070Mi
|
||||
k8s.eip.work/displayName: 数据库
|
||||
k8s.eip.work/ingress: 'false'
|
||||
k8s.eip.work/service: NodePort
|
||||
k8s.eip.work/workload: cloud-mysql
|
||||
k8s.kuboard.cn/workload: cloud-mysql
|
||||
spec:
|
||||
replicas: 0
|
||||
selector:
|
||||
matchLabels:
|
||||
k8s.eip.work/layer: db
|
||||
k8s.eip.work/name: cloud-mysql
|
||||
k8s.kuboard.cn/name: cloud-mysql
|
||||
template:
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
k8s.eip.work/layer: db
|
||||
k8s.eip.work/name: cloud-mysql
|
||||
k8s.kuboard.cn/name: cloud-mysql
|
||||
annotations:
|
||||
kubectl.kubernetes.io/restartedAt: '2023-10-07T09:38:51+08:00'
|
||||
spec:
|
||||
volumes:
|
||||
- name: mysql-cnf-map
|
||||
configMap:
|
||||
name: mysql-cnf
|
||||
items:
|
||||
- key: cnf
|
||||
path: custom.cnf
|
||||
defaultMode: 420
|
||||
- name: tz
|
||||
hostPath:
|
||||
path: /usr/share/zoneinfo/Asia/Shanghai
|
||||
type: File
|
||||
containers:
|
||||
- name: mysql
|
||||
image: 'mysql:8.0.28'
|
||||
env:
|
||||
- name: MYSQL_ROOT_PASSWORD
|
||||
value: wujiawei
|
||||
resources:
|
||||
limits:
|
||||
cpu: 500m
|
||||
memory: 256Mi
|
||||
requests:
|
||||
cpu: 500m
|
||||
memory: 256Mi
|
||||
volumeMounts:
|
||||
- name: mysql-data
|
||||
mountPath: /var/lib/mysql
|
||||
- name: mysql-cnf-map
|
||||
mountPath: /etc/mysql/conf.d/custom.cnf
|
||||
subPath: custom.cnf
|
||||
- name: tz
|
||||
mountPath: /etc/localtime
|
||||
terminationMessagePath: /dev/termination-log
|
||||
terminationMessagePolicy: File
|
||||
imagePullPolicy: IfNotPresent
|
||||
restartPolicy: Always
|
||||
terminationGracePeriodSeconds: 30
|
||||
dnsPolicy: ClusterFirst
|
||||
securityContext: {}
|
||||
schedulerName: default-scheduler
|
||||
volumeClaimTemplates:
|
||||
- kind: PersistentVolumeClaim
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: mysql-data
|
||||
creationTimestamp: null
|
||||
annotations:
|
||||
k8s.eip.work/pvcType: Dynamic
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteMany
|
||||
resources:
|
||||
requests:
|
||||
storage: 10Gi
|
||||
storageClassName: nfs-storage
|
||||
volumeMode: Filesystem
|
||||
status:
|
||||
phase: Pending
|
||||
serviceName: cloud-mysql
|
||||
podManagementPolicy: OrderedReady
|
||||
updateStrategy:
|
||||
type: RollingUpdate
|
||||
rollingUpdate:
|
||||
partition: 0
|
||||
revisionHistoryLimit: 10
|
||||
persistentVolumeClaimRetentionPolicy:
|
||||
whenDeleted: Retain
|
||||
whenScaled: Retain
|
||||
|
||||
---
|
||||
kind: Service
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: cloud-mysql
|
||||
namespace: default
|
||||
labels:
|
||||
k8s.eip.work/layer: db
|
||||
k8s.eip.work/name: cloud-mysql
|
||||
k8s.kuboard.cn/name: cloud-mysql
|
||||
spec:
|
||||
ports:
|
||||
- name: zmac2s
|
||||
protocol: TCP
|
||||
port: 3306
|
||||
targetPort: 3306
|
||||
nodePort: 30512
|
||||
selector:
|
||||
k8s.eip.work/layer: db
|
||||
k8s.eip.work/name: cloud-mysql
|
||||
type: NodePort
|
||||
sessionAffinity: None
|
||||
externalTrafficPolicy: Cluster
|
||||
ipFamilies:
|
||||
- IPv4
|
||||
ipFamilyPolicy: SingleStack
|
||||
internalTrafficPolicy: Cluster
|
||||
|
||||
---
|
||||
kind: Service
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: wu-lazy-cloud-heartbeat-local-client-start
|
||||
namespace: default
|
||||
labels:
|
||||
k8s.kuboard.cn/layer: monitor
|
||||
k8s.kuboard.cn/name: wu-lazy-cloud-heartbeat-local-client-start
|
||||
spec:
|
||||
ports:
|
||||
- name: net
|
||||
protocol: TCP
|
||||
port: 6001
|
||||
targetPort: 6001
|
||||
- name: nas
|
||||
protocol: TCP
|
||||
port: 100
|
||||
targetPort: 100
|
||||
- name: kuboard
|
||||
protocol: TCP
|
||||
port: 101
|
||||
targetPort: 101
|
||||
- name: netty-client
|
||||
protocol: TCP
|
||||
port: 6004
|
||||
targetPort: 6004
|
||||
- name: nas-web-dav
|
||||
protocol: TCP
|
||||
port: 102
|
||||
targetPort: 102
|
||||
- name: rustdesk
|
||||
protocol: TCP
|
||||
port: 103
|
||||
targetPort: 103
|
||||
- name: nastool
|
||||
protocol: TCP
|
||||
port: 104
|
||||
targetPort: 104
|
||||
- name: jellyfin
|
||||
protocol: TCP
|
||||
port: 105
|
||||
targetPort: 105
|
||||
- name: qb
|
||||
protocol: TCP
|
||||
port: 106
|
||||
targetPort: 106
|
||||
- name: jackett
|
||||
protocol: TCP
|
||||
port: 107
|
||||
targetPort: 107
|
||||
- name: rustdesk-tcp
|
||||
protocol: TCP
|
||||
port: 108
|
||||
targetPort: 108
|
||||
- name: rustdesk-ip-tcp
|
||||
protocol: TCP
|
||||
port: 109
|
||||
targetPort: 109
|
||||
- name: rustdesk-ip-udp
|
||||
protocol: UDP
|
||||
port: 109
|
||||
targetPort: 109
|
||||
- name: nas-ssh
|
||||
protocol: TCP
|
||||
port: 110
|
||||
targetPort: 110
|
||||
selector:
|
||||
k8s.kuboard.cn/layer: monitor
|
||||
k8s.kuboard.cn/name: wu-lazy-cloud-heartbeat-local-client-start
|
||||
type: ClusterIP
|
||||
sessionAffinity: None
|
||||
ipFamilies:
|
||||
- IPv4
|
||||
ipFamilyPolicy: SingleStack
|
||||
internalTrafficPolicy: Cluster
|
||||
|
||||
---
|
||||
kind: Ingress
|
||||
apiVersion: networking.k8s.io/v1
|
||||
metadata:
|
||||
name: wu-lazy-cloud-heartbeat-local-client-start
|
||||
namespace: default
|
||||
labels:
|
||||
k8s.kuboard.cn/layer: monitor
|
||||
k8s.kuboard.cn/name: wu-lazy-cloud-heartbeat-local-client-start
|
||||
spec:
|
||||
ingressClassName: traefik
|
||||
rules:
|
||||
- host: net.wu-framework.cn
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: wu-lazy-cloud-heartbeat-local-client-start
|
||||
port:
|
||||
number: 6001
|
||||
- host: nas.wu-framework.cn
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: wu-lazy-cloud-heartbeat-local-client-start
|
||||
port:
|
||||
number: 100
|
||||
- host: kuboard.wu-framework.cn
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: wu-lazy-cloud-heartbeat-local-client-start
|
||||
port:
|
||||
number: 101
|
||||
- host: client.wu-framework.cn
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: wu-lazy-cloud-heartbeat-local-client-start
|
||||
port:
|
||||
number: 6004
|
||||
- host: nas-dav.wu-framework.cn
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: wu-lazy-cloud-heartbeat-local-client-start
|
||||
port:
|
||||
number: 102
|
||||
- host: rustdesk.wu-framework.cn
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: wu-lazy-cloud-heartbeat-local-client-start
|
||||
port:
|
||||
number: 103
|
||||
- host: nastool.wu-framework.cn
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: wu-lazy-cloud-heartbeat-local-client-start
|
||||
port:
|
||||
number: 104
|
||||
- host: jellyfin.wu-framework.cn
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: wu-lazy-cloud-heartbeat-local-client-start
|
||||
port:
|
||||
number: 105
|
||||
- host: qb.wu-framework.cn
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: wu-lazy-cloud-heartbeat-local-client-start
|
||||
port:
|
||||
number: 106
|
||||
- host: jackett.wu-framework.cn
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: wu-lazy-cloud-heartbeat-local-client-start
|
||||
port:
|
||||
number: 107
|
||||
- host: rustdesk-tcp.wu-framework.cn
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: wu-lazy-cloud-heartbeat-local-client-start
|
||||
port:
|
||||
number: 108
|
||||
- host: rustdesk-ip.wu-framework.cn
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: wu-lazy-cloud-heartbeat-local-client-start
|
||||
port:
|
||||
number: 109
|
||||
- host: nas-ssh.wu-framework.cn
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: wu-lazy-cloud-heartbeat-local-client-start
|
||||
port:
|
||||
number: 110
|
||||
|
||||
---
|
||||
kind: ConfigMap
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: mysql-cnf
|
||||
namespace: default
|
||||
data:
|
||||
cnf: >-
|
||||
[mysql]
|
||||
|
||||
no-auto-rehash
|
||||
|
||||
[mysqld]
|
||||
|
||||
skip-host-cache
|
||||
|
||||
skip-name-resolve
|
||||
|
||||
max_connections=100
|
||||
|
||||
lower_case_table_names=0
|
||||
|
||||
table_open_cache=64
|
||||
|
||||
default-time-zone='+08:00'
|
||||
|
||||
sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'
|
||||
|
||||
log_timestamps='SYSTEM'
|
||||
|
||||
performance_schema_max_table_instances=400 #设置效果不明显
|
||||
|
||||
performance_schema=off #效果明显
|
||||
|
||||
table_definition_cache=400
|
||||
|
||||
slow_query_log=ON
|
||||
|
||||
binlog_expire_logs_seconds = 2
|
||||
|
||||
innodb_flush_log_at_trx_commit=2
|
||||
|
||||
group_concat_max_len=512
|
||||
|
||||
# 全局参数
|
||||
|
||||
innodb_buffer_pool_size = 20M
|
||||
|
||||
innodb_buffer_pool_chunk_size=20M #效果不明显
|
||||
|
||||
key_buffer_size = 1M
|
||||
|
||||
# 排序和连接参数
|
||||
|
||||
sort_buffer_size = 256K
|
||||
|
||||
join_buffer_size = 256K
|
||||
|
||||
# 线程缓存参数
|
||||
|
||||
thread_cache_size = 4
|
||||
|
||||
# 日志参数
|
||||
|
||||
innodb_log_file_size = 5M
|
||||
|
||||
innodb_log_buffer_size = 1M
|
||||
|
||||
BIN
client_permeate_client_mapping.png
Normal file
|
After Width: | Height: | Size: 130 KiB |
BIN
client_permeate_port_pool.png
Normal file
|
After Width: | Height: | Size: 114 KiB |
BIN
client_permeate_server_mapping.png
Normal file
|
After Width: | Height: | Size: 110 KiB |
BIN
client_route.png
Normal file
|
After Width: | Height: | Size: 108 KiB |
BIN
client_virtual_route.png
Normal file
|
After Width: | Height: | Size: 115 KiB |
BIN
cloud_client.png
|
Before Width: | Height: | Size: 113 KiB After Width: | Height: | Size: 86 KiB |
BIN
init_role.png
|
Before Width: | Height: | Size: 124 KiB After Width: | Height: | Size: 100 KiB |
28
install.md
Normal 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-JDK17-SNAPSHOT
|
||||
|
||||
```
|
||||
##### 启动客户端
|
||||
|
||||
- 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-JDK17-SNAPSHOT
|
||||
```
|
||||
BIN
mac_http_proxy.png
Normal file
|
After Width: | Height: | Size: 46 KiB |
BIN
mac_socks_proxy.png
Normal file
|
After Width: | Height: | Size: 46 KiB |
BIN
mapping.png
|
Before Width: | Height: | Size: 148 KiB |
122
pom.xml
@@ -8,12 +8,12 @@
|
||||
<parent>
|
||||
<artifactId>wu-framework-parent</artifactId>
|
||||
<groupId>top.wu2020</groupId>
|
||||
<version>1.2.7-JDK17-SNAPSHOT</version>
|
||||
<version>1.3.1-JDK17-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>wu-lazy-cloud-network</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>1.2.7-JDK17-SNAPSHOT</version>
|
||||
<version>1.3.1-JDK17-SNAPSHOT</version>
|
||||
<description>云上云下</description>
|
||||
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
<module>wu-lazy-cloud-heartbeat-server-cluster</module>
|
||||
<module>wu-lazy-cloud-heartbeat-client</module>
|
||||
<module>wu-lazy-cloud-heartbeat-common</module>
|
||||
<module>wu-lazy-cloud-heartbeat-dns</module>
|
||||
<module>wu-lazy-cloud-heartbeat-protocol-proxy</module>
|
||||
|
||||
<!-- 样例 -->
|
||||
<module>wu-lazy-cloud-heartbeat-start</module>
|
||||
@@ -46,12 +48,12 @@
|
||||
<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>
|
||||
@@ -70,19 +72,12 @@
|
||||
<dependency>
|
||||
<groupId>top.wu2020</groupId>
|
||||
<artifactId>wu-framework-dependencies</artifactId>
|
||||
<version>1.2.7-JDK17-SNAPSHOT</version>
|
||||
<version>1.3.1-JDK17-SNAPSHOT</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>maven_central</id>
|
||||
<name>Maven Central</name>
|
||||
<url>https://repo.maven.apache.org/maven2/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
|
||||
<profiles>
|
||||
@@ -183,33 +178,45 @@
|
||||
<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>
|
||||
<version>0.9.28</version>
|
||||
<!-- 使用graalvm提供的可达性元数据,很多第三方库就直接可以构建成可执行文件了 -->
|
||||
<configuration>
|
||||
<!-- for agent -->
|
||||
<agent>
|
||||
<defaultMode>Standard</defaultMode>
|
||||
<options>
|
||||
<builtinCallerFilter>true</builtinCallerFilter>
|
||||
<builtinHeuristicFilter>true</builtinHeuristicFilter>
|
||||
<enableExperimentalPredefinedClasses>true
|
||||
</enableExperimentalPredefinedClasses>
|
||||
<enableExperimentalUnsafeAllocationTracing>true
|
||||
</enableExperimentalUnsafeAllocationTracing>
|
||||
<trackReflectionMetadata>true</trackReflectionMetadata>
|
||||
</options>
|
||||
<metadataCopy>
|
||||
<merge>true</merge>
|
||||
</metadataCopy>
|
||||
</agent>
|
||||
<!-- for metadata repository -->
|
||||
<metadataRepository>
|
||||
<enabled>true</enabled>
|
||||
</metadataRepository>
|
||||
<classesDirectory>${project.build.outputDirectory}</classesDirectory>
|
||||
<requiredVersion>22.3</requiredVersion>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
@@ -218,19 +225,48 @@
|
||||
<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>test-native</id>
|
||||
<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>
|
||||
<phase>test</phase>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>build-native</id>
|
||||
<goals>
|
||||
<goal>compile-no-fork</goal>
|
||||
</goals>
|
||||
<phase>package</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
BIN
proxy_inner_net_ui.png
Normal file
|
After Width: | Height: | Size: 71 KiB |
BIN
server_permeate_client_mapping.png
Normal file
|
After Width: | Height: | Size: 120 KiB |
BIN
server_permeate_port_pool.png
Normal file
|
After Width: | Height: | Size: 95 KiB |
BIN
server_permeate_server_mapping.png
Normal file
|
After Width: | Height: | Size: 104 KiB |
BIN
server_route.png
Normal file
|
After Width: | Height: | Size: 122 KiB |
BIN
server_virtual_route.png
Normal file
|
After Width: | Height: | Size: 119 KiB |
BIN
url_info.png
|
Before Width: | Height: | Size: 428 KiB After Width: | Height: | Size: 398 KiB |
19
version.md
@@ -19,4 +19,21 @@
|
||||
sudo sysctl -w net.core.wmem_default=4194304
|
||||
sudo sysctl -w net.core.wmem_max=4194304
|
||||
[fix] 修复下线客户端、删除映射无法刷新问题
|
||||
#### 下一版本计划内网渗透
|
||||
#### 1.2.8-JDK17-SNAPSHOT
|
||||
[change] 原《内网穿透》更改为服务端渗透客户端
|
||||
[change] 新增服务端渗透服务端----本地同局域网内端口映射
|
||||
[change] 新增客户端渗透服务端----本地端口映射到另一个服务端中的局域网端口
|
||||
[change] 新增客户端渗透客户端----本地端口映射到另一个局域网端口
|
||||
#### 1.2.9-JDK17-SNAPSHOT
|
||||
[change] 添加appkey&appsecret 验证
|
||||
[change] 支持同一个客户端ID多次注册
|
||||
[change] 修复通道关闭导致调度线程池submit异常问题
|
||||
[change] 添加记录客户端IP
|
||||
[change] 1.2.9为大版本,报文中添加数据无法向下兼容,建议服务端与客户端保持版本一致
|
||||
#### 1.3.1-JDK17-SNAPSHOT
|
||||
[add] 新增http代理(客户端代理服务端、客户端代理客户杜安、服务端代理客户端、服务端代理服务端)
|
||||
[add] 新增socks代理(客户端代理服务端、客户端代理客户杜安、服务端代理客户端、服务端代理服务端)
|
||||
[add] 新增客户端路由管理、新增服务端路由管理
|
||||
[add] 支持新增虚拟IP,代理到指定的IP
|
||||
[add] 通过页面配置,代理支持控制端口代理控制
|
||||
#### 下一版本计划
|
||||
BIN
windows_wifi_proxy.png
Normal file
|
After Width: | Height: | Size: 309 KiB |
BIN
wlcn-proxy1.0-.png
Normal file
|
After Width: | Height: | Size: 76 KiB |
84
wlcn-proxy1.0.puml
Normal 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
|
||||
@@ -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
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>top.wu2020</groupId>
|
||||
<artifactId>wu-lazy-cloud-network</artifactId>
|
||||
<version>1.2.7-JDK17-SNAPSHOT</version>
|
||||
<version>1.3.1-JDK17-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -23,15 +23,16 @@
|
||||
<groupId>top.wu2020</groupId>
|
||||
<artifactId>wu-lazy-cloud-heartbeat-common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>top.wu2020</groupId>
|
||||
<artifactId>wu-lazy-cloud-heartbeat-protocol-proxy</artifactId>
|
||||
<version>1.3.1-JDK17-SNAPSHOT</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>
|
||||
@@ -40,7 +41,11 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>top.wu2020</groupId>
|
||||
<artifactId>wu-database-lazy-plus-starter</artifactId>
|
||||
<artifactId>wu-framework-web-spring-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>top.wu2020</groupId>
|
||||
<artifactId>wu-database-lazy-orm-plus-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
@@ -5,5 +5,5 @@ import org.wu.framework.lazy.orm.core.stereotype.LazyScan;
|
||||
|
||||
@ComponentScan(basePackages = "org.framework.lazy.cloud.network.heartbeat.client")
|
||||
@LazyScan(scanBasePackages = "org.framework.lazy.cloud.network.heartbeat.client.infrastructure.entity")
|
||||
public class EnableHeartbeatClientAutoConfiguration {
|
||||
public class EnableClientAutoConfiguration {
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.application;
|
||||
|
||||
|
||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.event.ClientChangeEvent;
|
||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.event.ClientChangeEvent;
|
||||
|
||||
/**
|
||||
* 客户端状态变更事件
|
||||
|
||||
@@ -66,7 +66,17 @@ public class LazyNettyServerPropertiesQueryListCommand {
|
||||
*/
|
||||
@Schema(description ="类型(配置、DB)",name ="type",example = "")
|
||||
private PropertiesType type;
|
||||
/**
|
||||
* 令牌key
|
||||
*/
|
||||
@Schema(description = "令牌key", name = "appKey", example = "")
|
||||
private String appKey;
|
||||
|
||||
/**
|
||||
* 令牌密钥
|
||||
*/
|
||||
@Schema(description = "令牌密钥", name = "appSecret", example = "")
|
||||
private String appSecret;
|
||||
/**
|
||||
*
|
||||
* 更新时间
|
||||
|
||||
@@ -65,7 +65,17 @@ public class LazyNettyServerPropertiesQueryOneCommand {
|
||||
*/
|
||||
@Schema(description ="类型(配置、DB)",name ="type",example = "")
|
||||
private PropertiesType type;
|
||||
/**
|
||||
* 令牌key
|
||||
*/
|
||||
@Schema(description = "令牌key", name = "appKey", example = "")
|
||||
private String appKey;
|
||||
|
||||
/**
|
||||
* 令牌密钥
|
||||
*/
|
||||
@Schema(description = "令牌密钥", name = "appSecret", example = "")
|
||||
private String appSecret;
|
||||
/**
|
||||
*
|
||||
* 更新时间
|
||||
|
||||
@@ -66,7 +66,17 @@ public class LazyNettyServerPropertiesRemoveCommand {
|
||||
*/
|
||||
@Schema(description ="类型(配置、DB)",name ="type",example = "")
|
||||
private PropertiesType type;
|
||||
/**
|
||||
* 令牌key
|
||||
*/
|
||||
@Schema(description = "令牌key", name = "appKey", example = "")
|
||||
private String appKey;
|
||||
|
||||
/**
|
||||
* 令牌密钥
|
||||
*/
|
||||
@Schema(description = "令牌密钥", name = "appSecret", example = "")
|
||||
private String appSecret;
|
||||
/**
|
||||
*
|
||||
* 更新时间
|
||||
|
||||
@@ -65,7 +65,17 @@ public class LazyNettyServerPropertiesStoryCommand {
|
||||
*/
|
||||
@Schema(description ="类型(配置、DB)",name ="type",example = "")
|
||||
private PropertiesType type;
|
||||
/**
|
||||
* 令牌key
|
||||
*/
|
||||
@Schema(description = "令牌key", name = "appKey", example = "")
|
||||
private String appKey;
|
||||
|
||||
/**
|
||||
* 令牌密钥
|
||||
*/
|
||||
@Schema(description = "令牌密钥", name = "appSecret", example = "")
|
||||
private String appSecret;
|
||||
/**
|
||||
*
|
||||
* 更新时间
|
||||
|
||||
@@ -65,7 +65,17 @@ public class LazyNettyServerPropertiesUpdateCommand {
|
||||
*/
|
||||
@Schema(description ="类型(配置、DB)",name ="type",example = "")
|
||||
private PropertiesType type;
|
||||
/**
|
||||
* 令牌key
|
||||
*/
|
||||
@Schema(description = "令牌key", name = "appKey", example = "")
|
||||
private String appKey;
|
||||
|
||||
/**
|
||||
* 令牌密钥
|
||||
*/
|
||||
@Schema(description = "令牌密钥", name = "appSecret", example = "")
|
||||
private String appSecret;
|
||||
/**
|
||||
*
|
||||
* 更新时间
|
||||
|
||||
@@ -65,7 +65,17 @@ public class LazyNettyServerPropertiesDTO {
|
||||
*/
|
||||
@Schema(description ="类型(配置、DB)",name ="type",example = "")
|
||||
private PropertiesType type;
|
||||
/**
|
||||
* 令牌key
|
||||
*/
|
||||
@Schema(description = "令牌key", name = "appKey", example = "")
|
||||
private String appKey;
|
||||
|
||||
/**
|
||||
* 令牌密钥
|
||||
*/
|
||||
@Schema(description = "令牌密钥", name = "appSecret", example = "")
|
||||
private String appSecret;
|
||||
/**
|
||||
*
|
||||
* 更新时间
|
||||
|
||||
@@ -2,21 +2,24 @@ package org.framework.lazy.cloud.network.heartbeat.client.application.impl;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.framework.lazy.cloud.network.heartbeat.client.application.assembler.LazyNettyServerPropertiesDTOAssembler;
|
||||
import org.framework.lazy.cloud.network.heartbeat.client.application.dto.LazyNettyServerPropertiesDTO;
|
||||
import org.framework.lazy.cloud.network.heartbeat.client.domain.model.lazy.netty.server.properties.LazyNettyServerProperties;
|
||||
import org.framework.lazy.cloud.network.heartbeat.client.domain.model.lazy.netty.server.properties.LazyNettyServerPropertiesRepository;
|
||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.socket.NettyClientSocket;
|
||||
import org.framework.lazy.cloud.network.heartbeat.client.application.LazyNettyServerPropertiesApplication;
|
||||
import org.framework.lazy.cloud.network.heartbeat.client.application.assembler.LazyNettyServerPropertiesDTOAssembler;
|
||||
import org.framework.lazy.cloud.network.heartbeat.client.application.command.lazy.netty.server.properties.*;
|
||||
import org.framework.lazy.cloud.network.heartbeat.client.application.dto.LazyNettyServerPropertiesDTO;
|
||||
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
|
||||
import org.framework.lazy.cloud.network.heartbeat.client.config.PropertiesType;
|
||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.event.ClientChangeEvent;
|
||||
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.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.socket.NettyTcpClientSocket;
|
||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.udp.socket.NettyUdpClientSocket;
|
||||
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;
|
||||
@@ -186,16 +189,35 @@ public class LazyNettyServerPropertiesApplicationImpl implements LazyNettyServer
|
||||
String inetHost = lazyNettyServerProperties.getInetHost();
|
||||
Integer inetPort = lazyNettyServerProperties.getInetPort();
|
||||
String clientId = lazyNettyServerProperties.getClientId();
|
||||
|
||||
NettyClientSocket nettyClientSocket = new
|
||||
NettyClientSocket(inetHost, inetPort, clientId,
|
||||
NormalUsedString.DEFAULT,
|
||||
String appKey = lazyNettyServerProperties.getAppKey();
|
||||
String appSecret = lazyNettyServerProperties.getAppSecret();
|
||||
ProtocolType protocolType = lazyNettyServerProperties.getProtocolType();
|
||||
NettyClientSocket nettyClientSocket;
|
||||
if (ProtocolType.TCP.equals(protocolType)) {
|
||||
nettyClientSocket = new
|
||||
NettyTcpClientSocket(inetHost, inetPort, clientId,
|
||||
NormalUsedString.DEFAULT, appKey, appSecret,
|
||||
clientChangeEvent, handleChannelTypeAdvancedList);
|
||||
} else if (ProtocolType.UDP.equals(protocolType)) {
|
||||
nettyClientSocket = new
|
||||
NettyUdpClientSocket(inetHost, inetPort, clientId,
|
||||
NormalUsedString.DEFAULT, appKey, appSecret,
|
||||
clientChangeEvent, handleChannelTypeAdvancedList);
|
||||
} else {
|
||||
nettyClientSocket = null;
|
||||
}
|
||||
|
||||
if (nettyClientSocket == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
cacheNettyClientSocketMap.put(lazyNettyServerProperties, nettyClientSocket);
|
||||
|
||||
// 更新状态为运行中
|
||||
lazyNettyServerProperties.setConnectStatus(NettyClientStatus.RUNNING);
|
||||
lazyNettyServerPropertiesRepository.story(lazyNettyServerProperties);
|
||||
|
||||
|
||||
Thread thread = new Thread(() -> {
|
||||
try {
|
||||
nettyClientSocket.newConnect2Server();
|
||||
@@ -235,7 +257,7 @@ public class LazyNettyServerPropertiesApplicationImpl implements LazyNettyServer
|
||||
@Override
|
||||
public void destroyOneClientSocket(LazyNettyServerProperties needCloseLazyNettyServerProperties) {
|
||||
// 关闭指定socket
|
||||
cacheNettyClientSocketMap.forEach(((nettyServerProperties, nettyClientSocket) -> {
|
||||
cacheNettyClientSocketMap.forEach(((nettyServerProperties, nettyTcpClientSocket) -> {
|
||||
String clientId = nettyServerProperties.getClientId();
|
||||
String inetHost = nettyServerProperties.getInetHost();
|
||||
Integer inetPort = nettyServerProperties.getInetPort();
|
||||
@@ -245,7 +267,7 @@ public class LazyNettyServerPropertiesApplicationImpl implements LazyNettyServer
|
||||
if (Objects.equals(clientId, needCloseClientId)
|
||||
&& Objects.equals(inetPort, needCloseInetPort)
|
||||
&& Objects.equals(inetHost, needCloseInetHost)) {
|
||||
nettyClientSocket.shutdown();
|
||||
nettyTcpClientSocket.shutdown();
|
||||
// 关闭客户端:{}与服务端连接:{}:{}
|
||||
log.warn("Close client: {} Connect to server: {}: {}", clientId, inetHost, inetPort);
|
||||
}
|
||||
@@ -258,8 +280,8 @@ public class LazyNettyServerPropertiesApplicationImpl implements LazyNettyServer
|
||||
@Override
|
||||
public void destroyClientSocket() {
|
||||
// 关闭socket
|
||||
cacheNettyClientSocketMap.forEach(((nettyServerProperties, nettyClientSocket) -> {
|
||||
nettyClientSocket.shutdown();
|
||||
cacheNettyClientSocketMap.forEach(((nettyServerProperties, nettyTcpClientSocket) -> {
|
||||
nettyTcpClientSocket.shutdown();
|
||||
String clientId = nettyServerProperties.getClientId();
|
||||
String inetHost = nettyServerProperties.getInetHost();
|
||||
Integer inetPort = nettyServerProperties.getInetPort();
|
||||
|
||||
@@ -1,82 +1,459 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.config;
|
||||
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.socket.NettyClientSocket;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.framework.lazy.cloud.network.heartbeat.client.context.NettyClientSocketApplicationListener;
|
||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.event.ClientChangeEvent;
|
||||
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;
|
||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.event.ClientChangeEvent;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
|
||||
import org.wu.framework.core.NormalUsedString;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.context.annotation.Role;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@Import({NettyClientSocketApplicationListener.class})
|
||||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
@ConditionalOnProperty(prefix = NettyClientProperties.PREFIX, name = "enabled", havingValue = "true", matchIfMissing = true)
|
||||
public class ClientAutoConfiguration {
|
||||
|
||||
/**
|
||||
* description 自动配置
|
||||
|
||||
@Configuration()
|
||||
static class ClientTcpConfiguration {
|
||||
/**
|
||||
* 服务端 处理客户端心跳
|
||||
*
|
||||
* @author 吴佳伟
|
||||
* @date 2023/09/12 18:22
|
||||
* @see InitConfig
|
||||
* @return ClientHandleTcpChannelHeartbeatTypeAdvanced
|
||||
*/
|
||||
@Deprecated
|
||||
@Slf4j
|
||||
public class ClientAutoConfiguration implements CommandLineRunner {
|
||||
|
||||
private final NettyClientProperties nettyClientProperties;
|
||||
private final ClientChangeEvent clientChangeEvent;
|
||||
|
||||
private final List<HandleChannelTypeAdvanced> handleChannelTypeAdvancedList; // 处理服务端发送过来的数据类型
|
||||
|
||||
|
||||
public static final ThreadPoolExecutor NETTY_CLIENT_EXECUTOR = new ThreadPoolExecutor(1, 1, 200, TimeUnit.MILLISECONDS,
|
||||
new ArrayBlockingQueue<>(1));
|
||||
|
||||
public ClientAutoConfiguration(NettyClientProperties nettyClientProperties,
|
||||
ClientChangeEvent clientChangeEvent,
|
||||
List<HandleChannelTypeAdvanced> handleChannelTypeAdvancedList) {
|
||||
this.nettyClientProperties = nettyClientProperties;
|
||||
this.clientChangeEvent = clientChangeEvent;
|
||||
this.handleChannelTypeAdvancedList = handleChannelTypeAdvancedList;
|
||||
}
|
||||
|
||||
|
||||
@Bean(destroyMethod = "shutdown")
|
||||
public NettyClientSocket nettyClientSocket() {
|
||||
String inetHost = nettyClientProperties.getInetHost();
|
||||
int inetPort = nettyClientProperties.getInetPort();
|
||||
String clientId = nettyClientProperties.getClientId();
|
||||
return new NettyClientSocket(inetHost, inetPort, clientId, NormalUsedString.DEFAULT, clientChangeEvent, handleChannelTypeAdvancedList);
|
||||
@Bean
|
||||
public ClientHandleTcpChannelHeartbeatTypeAdvanced clientHandleTcpChannelHeartbeatTypeAdvanced() {
|
||||
return new ClientHandleTcpChannelHeartbeatTypeAdvanced();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param args
|
||||
* @throws Exception
|
||||
* 处理 客户端代理的真实端口自动读写
|
||||
*
|
||||
* @return ClientHandleTcpDistributeSingleClientRealAutoReadConnectTypeAdvanced
|
||||
*/
|
||||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
|
||||
|
||||
String inetHost = nettyClientProperties.getInetHost();
|
||||
int inetPort = nettyClientProperties.getInetPort();
|
||||
String clientId = nettyClientProperties.getClientId();
|
||||
NettyClientSocket nettyClientSocket = new NettyClientSocket(
|
||||
inetHost, inetPort,
|
||||
clientId, NormalUsedString.DEFAULT,
|
||||
clientChangeEvent, handleChannelTypeAdvancedList);
|
||||
Thread thread = new Thread(() -> {
|
||||
try {
|
||||
nettyClientSocket.newConnect2Server();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
@Bean
|
||||
public ClientHandleTcpDistributeSingleClientRealAutoReadConnectTypeAdvanced clientHandleTcpDistributeSingleClientRealAutoReadConnectTypeAdvanced() {
|
||||
return new ClientHandleTcpDistributeSingleClientRealAutoReadConnectTypeAdvanced();
|
||||
}
|
||||
|
||||
});
|
||||
log.info("当前服务连接Netty客户端:{},Netty端口:{}", inetHost, inetPort);
|
||||
NETTY_CLIENT_EXECUTOR.execute(thread);
|
||||
/**
|
||||
* 处理 接收服务端发送过来的聊天信息
|
||||
*
|
||||
* @return ClientHandleTcpDistributeSingleClientMessageTypeAdvanced
|
||||
*/
|
||||
@Bean
|
||||
public ClientHandleTcpDistributeSingleClientMessageTypeAdvanced clientHandleTcpDistributeSingleClientMessageTypeAdvanced() {
|
||||
return new ClientHandleTcpDistributeSingleClientMessageTypeAdvanced();
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理 客户端渗透服务端数据传输通道连接成功
|
||||
*
|
||||
* @return ClientHandleTcpDistributeClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced
|
||||
*/
|
||||
@Bean
|
||||
public ClientHandleTcpDistributeClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced clientHandleTcpDistributeClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced() {
|
||||
return new ClientHandleTcpDistributeClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced();
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理 客户端渗透客户端数据传输通道连接成功
|
||||
*
|
||||
* @return ClientHandleTcpDistributeClientTransferClientPermeateChannelConnectionSuccessfulTypeAdvanced
|
||||
*/
|
||||
@Bean
|
||||
public ClientHandleTcpDistributeClientTransferClientPermeateChannelConnectionSuccessfulTypeAdvanced clientHandleTcpDistributeClientTransferClientPermeateChannelConnectionSuccessfulTypeAdvanced() {
|
||||
return new ClientHandleTcpDistributeClientTransferClientPermeateChannelConnectionSuccessfulTypeAdvanced();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHandleTcpDistributeClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced clientHandleTcpDistributeClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced() {
|
||||
return new ClientHandleTcpDistributeClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHandleTcpDistributeClientTransferClientRequestTypeAdvanced clientHandleTcpDistributeClientTransferClientRequestTypeAdvanced() {
|
||||
return new ClientHandleTcpDistributeClientTransferClientRequestTypeAdvanced();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHandleTcpDistributeServicePermeateClientTransferClientResponseTypeAdvanced clientHandleTcpDistributeServicePermeateClientTransferClientResponseTypeAdvanced() {
|
||||
return new ClientHandleTcpDistributeServicePermeateClientTransferClientResponseTypeAdvanced();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHandleTcpDistributeSingleClientRealCloseVisitorTypeAdvanced clientHandleTcpDistributeSingleClientRealCloseVisitorTypeAdvanced() {
|
||||
return new ClientHandleTcpDistributeSingleClientRealCloseVisitorTypeAdvanced();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHandleTcpChannelTransferTypeAdvancedHandleDistributeTcpDistribute clientHandleTcpChannelTransferTypeAdvancedHandleDistributeTcpDistribute(NettyClientProperties nettyClientProperties) {
|
||||
return new ClientHandleTcpChannelTransferTypeAdvancedHandleDistributeTcpDistribute(nettyClientProperties);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHandleTcpDistributeConnectSuccessNotificationTypeAdvancedHandle clientHandleTcpDistributeConnectSuccessNotificationTypeAdvancedHandle(ClientChangeEvent clientChangeEvent) {
|
||||
return new ClientHandleTcpDistributeConnectSuccessNotificationTypeAdvancedHandle(clientChangeEvent);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHandleTcpClientChannelActiveAdvanced clientHandleTcpClientChannelActiveAdvanced(NettyClientProperties nettyClientProperties) {
|
||||
return new ClientHandleTcpClientChannelActiveAdvanced(nettyClientProperties);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHandleTcpDistributeDisconnectTypeAdvancedHandle clientHandleTcpDistributeDisconnectTypeAdvancedHandle(ClientChangeEvent clientChangeEvent) {
|
||||
return new ClientHandleTcpDistributeDisconnectTypeAdvancedHandle(clientChangeEvent);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHandleTcpDistributeStagingClosedTypeAdvanced clientHandleTcpDistributeStagingClosedTypeAdvanced() {
|
||||
return new ClientHandleTcpDistributeStagingClosedTypeAdvanced();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHandleTcpDistributeStagingOpenedTypeAdvanced clientHandleTcpDistributeStagingOpenedTypeAdvanced() {
|
||||
return new ClientHandleTcpDistributeStagingOpenedTypeAdvanced();
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理 客户端渗透服务端init信息
|
||||
*
|
||||
* @return ClientHandleTcpDistributeClientPermeateServerInitTypeAdvanced
|
||||
*/
|
||||
@Bean
|
||||
public ClientHandleTcpDistributeClientPermeateServerInitTypeAdvanced clientHandleTcpDistributeClientPermeateServerInitTypeAdvanced(NettyClientProperties nettyClientProperties) {
|
||||
return new ClientHandleTcpDistributeClientPermeateServerInitTypeAdvanced(nettyClientProperties);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理 客户端渗透服务端init close 信息
|
||||
*
|
||||
* @return ClientHandleTcpDistributeClientPermeateServerCloseTypeAdvanced
|
||||
*/
|
||||
@Bean
|
||||
public ClientHandleTcpDistributeClientPermeateServerCloseTypeAdvanced clientHandleTcpDistributeClientPermeateServerCloseTypeAdvanced() {
|
||||
return new ClientHandleTcpDistributeClientPermeateServerCloseTypeAdvanced();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHandleTcpDistributeClientPermeateServerTransferTypeAdvanced clientHandleTcpDistributeClientPermeateServerTransferTypeAdvanced() {
|
||||
return new ClientHandleTcpDistributeClientPermeateServerTransferTypeAdvanced();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHandleTcpDistributeClientPermeateClientCloseTypeAdvanced clientHandleTcpDistributeClientPermeateClientCloseTypeAdvanced() {
|
||||
return new ClientHandleTcpDistributeClientPermeateClientCloseTypeAdvanced();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHandleTcpDistributeClientPermeateClientInitTypeAdvanced clientHandleTcpDistributeClientPermeateClientInitTypeAdvanced() {
|
||||
return new ClientHandleTcpDistributeClientPermeateClientInitTypeAdvanced();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHandleTcpDistributeClientPermeateClientTransferCloseTypeAdvanced clientHandleTcpDistributeClientPermeateClientTransferCloseTypeAdvanced() {
|
||||
return new ClientHandleTcpDistributeClientPermeateClientTransferCloseTypeAdvanced();
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public ClientHandleTcpDistributeServicePermeateClientRealConnectTypeAdvanced clientHandleTcpDistributeServicePermeateClientRealConnectTypeAdvanced(
|
||||
NettyClientProperties nettyClientProperties) {
|
||||
return new ClientHandleTcpDistributeServicePermeateClientRealConnectTypeAdvanced(nettyClientProperties);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHandleTcpDistributeClientPermeateServerTransferCloseTypeAdvanced clientHandleTcpDistributeClientPermeateServerTransferCloseTypeAdvanced() {
|
||||
return new ClientHandleTcpDistributeClientPermeateServerTransferCloseTypeAdvanced();
|
||||
}
|
||||
}
|
||||
|
||||
@Configuration()
|
||||
static class ClientUdpConfiguration {
|
||||
/**
|
||||
* 服务端 处理客户端心跳
|
||||
*
|
||||
* @return ClientHandleUdpChannelHeartbeatTypeAdvanced
|
||||
*/
|
||||
@Bean
|
||||
public ClientHandleUdpChannelHeartbeatTypeAdvanced clientHandleUdpChannelHeartbeatTypeAdvanced() {
|
||||
return new ClientHandleUdpChannelHeartbeatTypeAdvanced();
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理 客户端代理的真实端口自动读写
|
||||
*
|
||||
* @return ClientHandleUdpDistributeSingleClientRealAutoReadConnectTypeAdvanced
|
||||
*/
|
||||
@Bean
|
||||
public ClientHandleUdpDistributeSingleClientRealAutoReadConnectTypeAdvanced clientHandleUdpDistributeSingleClientRealAutoReadConnectTypeAdvanced() {
|
||||
return new ClientHandleUdpDistributeSingleClientRealAutoReadConnectTypeAdvanced();
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理 接收服务端发送过来的聊天信息
|
||||
*
|
||||
* @return ClientHandleUdpDistributeSingleClientMessageTypeAdvanced
|
||||
*/
|
||||
@Bean
|
||||
public ClientHandleUdpDistributeSingleClientMessageTypeAdvanced clientHandleUdpDistributeSingleClientMessageTypeAdvanced() {
|
||||
return new ClientHandleUdpDistributeSingleClientMessageTypeAdvanced();
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理 客户端渗透服务端数据传输通道连接成功
|
||||
*
|
||||
* @return ClientHandleUdpDistributeClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced
|
||||
*/
|
||||
@Bean
|
||||
public ClientHandleUdpDistributeClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced clientHandleUdpDistributeClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced() {
|
||||
return new ClientHandleUdpDistributeClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced();
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理 客户端渗透客户端数据传输通道连接成功
|
||||
*
|
||||
* @return ClientHandleUdpDistributeClientTransferClientPermeateChannelConnectionSuccessfulTypeAdvanced
|
||||
*/
|
||||
@Bean
|
||||
public ClientHandleUdpDistributeClientTransferClientPermeateChannelConnectionSuccessfulTypeAdvanced clientHandleUdpDistributeClientTransferClientPermeateChannelConnectionSuccessfulTypeAdvanced() {
|
||||
return new ClientHandleUdpDistributeClientTransferClientPermeateChannelConnectionSuccessfulTypeAdvanced();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHandleUdpDistributeClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced clientHandleUdpDistributeClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced() {
|
||||
return new ClientHandleUdpDistributeClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHandleUdpDistributeClientTransferClientRequestTypeAdvanced clientHandleUdpDistributeClientTransferClientRequestTypeAdvanced() {
|
||||
return new ClientHandleUdpDistributeClientTransferClientRequestTypeAdvanced();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHandleUdpDistributeServicePermeateClientTransferClientResponseTypeAdvanced clientHandleUdpDistributeServicePermeateClientTransferClientResponseTypeAdvanced() {
|
||||
return new ClientHandleUdpDistributeServicePermeateClientTransferClientResponseTypeAdvanced();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHandleUdpDistributeSingleClientRealCloseVisitorTypeAdvanced clientHandleUdpDistributeSingleClientRealCloseVisitorTypeAdvanced() {
|
||||
return new ClientHandleUdpDistributeSingleClientRealCloseVisitorTypeAdvanced();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHandleUdpChannelTransferTypeAdvancedHandleDistribute clientHandleUdpChannelTransferTypeAdvancedHandleDistribute(NettyClientProperties nettyClientProperties) {
|
||||
return new ClientHandleUdpChannelTransferTypeAdvancedHandleDistribute(nettyClientProperties);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHandleUdpDistributeConnectSuccessNotificationTypeAdvancedHandle clientHandleUdpDistributeConnectSuccessNotificationTypeAdvancedHandle(ClientChangeEvent clientChangeEvent) {
|
||||
return new ClientHandleUdpDistributeConnectSuccessNotificationTypeAdvancedHandle(clientChangeEvent);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHandleUdpClientChannelActiveAdvanced clientHandleUdpClientChannelActiveAdvanced(NettyClientProperties nettyClientProperties) {
|
||||
return new ClientHandleUdpClientChannelActiveAdvanced(nettyClientProperties);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHandleUdpDistributeDisconnectTypeAdvancedHandle clientHandleUdpDistributeDisconnectTypeAdvancedHandle(ClientChangeEvent clientChangeEvent) {
|
||||
return new ClientHandleUdpDistributeDisconnectTypeAdvancedHandle(clientChangeEvent);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHandleUdpDistributeStagingClosedTypeAdvanced clientHandleUdpDistributeStagingClosedTypeAdvanced() {
|
||||
return new ClientHandleUdpDistributeStagingClosedTypeAdvanced();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHandleUdpDistributeStagingOpenedTypeAdvanced clientHandleUdpDistributeStagingOpenedTypeAdvanced() {
|
||||
return new ClientHandleUdpDistributeStagingOpenedTypeAdvanced();
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理 客户端渗透服务端init信息
|
||||
*
|
||||
* @return ClientHandleUdpDistributeClientPermeateServerInitTypeAdvanced
|
||||
*/
|
||||
@Bean
|
||||
public ClientHandleUdpDistributeClientPermeateServerInitTypeAdvanced clientHandleUdpDistributeClientPermeateServerInitTypeAdvanced(NettyClientProperties nettyClientProperties) {
|
||||
return new ClientHandleUdpDistributeClientPermeateServerInitTypeAdvanced(nettyClientProperties);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理 客户端渗透服务端init close 信息
|
||||
*
|
||||
* @return ClientHandleUdpDistributeClientPermeateServerCloseTypeAdvanced
|
||||
*/
|
||||
@Bean
|
||||
public ClientHandleUdpDistributeClientPermeateServerCloseTypeAdvanced clientHandleUdpDistributeClientPermeateServerCloseTypeAdvanced() {
|
||||
return new ClientHandleUdpDistributeClientPermeateServerCloseTypeAdvanced();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHandleUdpDistributeClientPermeateServerTransferTypeAdvanced clientHandleUdpDistributeClientPermeateServerTransferTypeAdvanced() {
|
||||
return new ClientHandleUdpDistributeClientPermeateServerTransferTypeAdvanced();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHandleUdpDistributeClientPermeateClientCloseTypeAdvanced clientHandleUdpDistributeClientPermeateClientCloseTypeAdvanced() {
|
||||
return new ClientHandleUdpDistributeClientPermeateClientCloseTypeAdvanced();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHandleUdpDistributeClientPermeateClientInitTypeAdvanced clientHandleUdpDistributeClientPermeateClientInitTypeAdvanced() {
|
||||
return new ClientHandleUdpDistributeClientPermeateClientInitTypeAdvanced();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHandleUdpDistributeClientPermeateClientTransferCloseTypeAdvanced clientHandleUdpDistributeClientPermeateClientTransferCloseTypeAdvanced() {
|
||||
return new ClientHandleUdpDistributeClientPermeateClientTransferCloseTypeAdvanced();
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public ClientHandleUdpDistributeServicePermeateClientRealConnectTypeAdvanced clientHandleUdpDistributeServicePermeateClientRealConnectTypeAdvanced(
|
||||
NettyClientProperties nettyClientProperties) {
|
||||
return new ClientHandleUdpDistributeServicePermeateClientRealConnectTypeAdvanced(nettyClientProperties);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHandleUdpDistributeClientPermeateServerTransferCloseTypeAdvanced clientHandleUdpDistributeClientPermeateServerTransferCloseTypeAdvanced() {
|
||||
return new ClientHandleUdpDistributeClientPermeateServerTransferCloseTypeAdvanced();
|
||||
}
|
||||
}
|
||||
|
||||
@Configuration
|
||||
static class HttpProxyConfiguration {
|
||||
|
||||
@Bean
|
||||
public ClientHandleDistributeHttpClientProxyServerTransferTypeAdvanced clientHandleDistributeHttpClientProxyServerTypeAdvanced() {
|
||||
return new ClientHandleDistributeHttpClientProxyServerTransferTypeAdvanced();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHandleHttpClientProxyClientTypeAdvanced clientHandleHttpClientClientProxyClientTypeAdvanced() {
|
||||
return new ClientHandleHttpClientProxyClientTypeAdvanced();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHandleHttpClientProxyServerTypeAdvanced clientHandleHttpClientClientProxyServerTypeAdvanced() {
|
||||
return new ClientHandleHttpClientProxyServerTypeAdvanced();
|
||||
}
|
||||
|
||||
@Bean
|
||||
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();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHandleDistributeHttpClientProxyClientTransferRequestAdvanced clientHandleDistributeHttpClientProxyClientTransferRequestAdvanced() {
|
||||
return new ClientHandleDistributeHttpClientProxyClientTransferRequestAdvanced();
|
||||
}
|
||||
@Bean
|
||||
public ClientHandleHttpDistributeClientProxyClientTransferResponseTypeAdvanced clientHandleHttpDistributeClientProxyClientTransferResponseTypeAdvanced(){
|
||||
return new ClientHandleHttpDistributeClientProxyClientTransferResponseTypeAdvanced();
|
||||
}
|
||||
@Bean
|
||||
public ClientHandleHttpDistributeClientProxyClientTransferCLoseTypeAdvanced clientHandleHttpDistributeClientProxyClientTransferCLoseTypeAdvanced(){
|
||||
return new ClientHandleHttpDistributeClientProxyClientTransferCLoseTypeAdvanced();
|
||||
}
|
||||
@Bean
|
||||
public ClientHandleDistributeHttpServerProxyClientConnectionSuccessfulTypeAdvanced clientHandleDistributeHttpServerProxyClientConnectionSuccessfulTypeAdvanced(){
|
||||
return new ClientHandleDistributeHttpServerProxyClientConnectionSuccessfulTypeAdvanced();
|
||||
}
|
||||
@Bean
|
||||
public ClientHandleDistributeHttpServerProxyClientTransferRequestAdvanced clientHandleDistributeHttpServerProxyClientTransferRequestAdvanced(){
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,165 +0,0 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.config;
|
||||
|
||||
|
||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.advanced.*;
|
||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.event.ClientChangeEvent;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Role;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
@ConditionalOnProperty(prefix = NettyClientProperties.PREFIX, name = "enabled", havingValue = "true", matchIfMissing = true)
|
||||
public class HeartbeatClientConfiguration {
|
||||
|
||||
/**
|
||||
* 服务端 处理客户端心跳
|
||||
*
|
||||
* @return ClientHandleChannelHeartbeatTypeAdvanced
|
||||
*/
|
||||
@Bean
|
||||
public ClientHandleChannelHeartbeatTypeAdvanced clientChannelHeartbeatTypeAdvanced() {
|
||||
return new ClientHandleChannelHeartbeatTypeAdvanced();
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理 客户端代理的真实端口自动读写
|
||||
*
|
||||
* @return ClientHandleDistributeSingleClientRealAutoReadConnectTypeAdvanced
|
||||
*/
|
||||
@Bean
|
||||
public ClientHandleDistributeSingleClientRealAutoReadConnectTypeAdvanced handleDistributeSingleClientRealAutoReadConnectTypeAdvanced() {
|
||||
return new ClientHandleDistributeSingleClientRealAutoReadConnectTypeAdvanced();
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理 接收服务端发送过来的聊天信息
|
||||
*
|
||||
* @return ClientHandleDistributeSingleClientMessageTypeAdvanced
|
||||
*/
|
||||
@Bean
|
||||
public ClientHandleDistributeSingleClientMessageTypeAdvanced handleDistributeSingleClientMessageTypeAdvanced() {
|
||||
return new ClientHandleDistributeSingleClientMessageTypeAdvanced();
|
||||
}
|
||||
/**
|
||||
* 处理 客户端渗透服务端数据传输通道连接成功
|
||||
*
|
||||
* @return ClientHandleDistributeClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced
|
||||
*/
|
||||
@Bean
|
||||
public ClientHandleDistributeClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced clientHandleDistributeClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced() {
|
||||
return new ClientHandleDistributeClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced();
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理 客户端渗透客户端数据传输通道连接成功
|
||||
*
|
||||
* @return ClientHandleDistributeClientTransferClientPermeateChannelConnectionSuccessfulTypeAdvanced
|
||||
*/
|
||||
@Bean
|
||||
public ClientHandleDistributeClientTransferClientPermeateChannelConnectionSuccessfulTypeAdvanced clientHandleDistributeClientTransferClientPermeateChannelConnectionSuccessfulTypeAdvanced() {
|
||||
return new ClientHandleDistributeClientTransferClientPermeateChannelConnectionSuccessfulTypeAdvanced();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHandleDistributeClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced clientHandleDistributeClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced() {
|
||||
return new ClientHandleDistributeClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHandleDistributeClientTransferClientRequestTypeAdvanced clientHandleDistributeClientTransferClientTypeAdvanced() {
|
||||
return new ClientHandleDistributeClientTransferClientRequestTypeAdvanced();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHandleDistributeServicePermeateClientTransferClientResponseTypeAdvanced clientHandleDistributeClientTransferClientResponseTypeAdvanced() {
|
||||
return new ClientHandleDistributeServicePermeateClientTransferClientResponseTypeAdvanced();
|
||||
}
|
||||
@Bean
|
||||
public ClientHandleDistributeSingleClientRealCloseVisitorTypeAdvanced handleDistributeSingleClientRealCloseVisitorTypeAdvanced() {
|
||||
return new ClientHandleDistributeSingleClientRealCloseVisitorTypeAdvanced();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHandleChannelTransferTypeAdvancedHandleDistributeDistribute handleChannelTransferTypeAdvancedHandleDistribute(NettyClientProperties nettyClientProperties) {
|
||||
return new ClientHandleChannelTransferTypeAdvancedHandleDistributeDistribute(nettyClientProperties);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public HandleDistributeConnectSuccessNotificationTypeAdvancedHandle handleDistributeConnectSuccessNotificationTypeAdvancedHandle(ClientChangeEvent clientChangeEvent) {
|
||||
return new HandleDistributeConnectSuccessNotificationTypeAdvancedHandle(clientChangeEvent);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public HandleClientChannelActiveAdvanced handleClientChannelActiveAdvanced(NettyClientProperties nettyClientProperties) {
|
||||
return new HandleClientChannelActiveAdvanced(nettyClientProperties);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public HandleDistributeDisconnectTypeAdvancedHandle handleDistributeDisconnectTypeAdvancedHandle(ClientChangeEvent clientChangeEvent) {
|
||||
return new HandleDistributeDisconnectTypeAdvancedHandle(clientChangeEvent);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public HandleDistributeStagingClosedTypeAdvanced handleDistributeStagingClosedTypeAdvanced() {
|
||||
return new HandleDistributeStagingClosedTypeAdvanced();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public HandleDistributeStagingOpenedTypeAdvanced handleDistributeStagingOpenedTypeAdvanced() {
|
||||
return new HandleDistributeStagingOpenedTypeAdvanced();
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理 客户端渗透服务端init信息
|
||||
*
|
||||
* @return ClientHandleDistributeClientPermeateServerInitTypeAdvanced
|
||||
*/
|
||||
@Bean
|
||||
public ClientHandleDistributeClientPermeateServerInitTypeAdvanced clientHandleDistributeClientPermeateServerInitTypeAdvanced(NettyClientProperties nettyClientProperties) {
|
||||
return new ClientHandleDistributeClientPermeateServerInitTypeAdvanced(nettyClientProperties);
|
||||
}
|
||||
/**
|
||||
* 处理 客户端渗透服务端init close 信息
|
||||
*
|
||||
* @return ClientHandleDistributeClientPermeateServerCloseTypeAdvanced
|
||||
*/
|
||||
@Bean
|
||||
public ClientHandleDistributeClientPermeateServerCloseTypeAdvanced clientHandleDistributeClientPermeateServerCloseTypeAdvanced( ) {
|
||||
return new ClientHandleDistributeClientPermeateServerCloseTypeAdvanced();
|
||||
}
|
||||
@Bean
|
||||
public ClientHandleDistributeClientPermeateServerTransferTypeAdvanced clientHandleDistributeClientPermeateServerTransferTypeAdvanced( ) {
|
||||
return new ClientHandleDistributeClientPermeateServerTransferTypeAdvanced();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHandleDistributeClientPermeateClientCloseTypeAdvanced clientHandleDistributeClientPermeateClientCloseTypeAdvanced() {
|
||||
return new ClientHandleDistributeClientPermeateClientCloseTypeAdvanced();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHandleDistributeClientPermeateClientInitTypeAdvanced clientHandleDistributeClientPermeateClientInitTypeAdvanced() {
|
||||
return new ClientHandleDistributeClientPermeateClientInitTypeAdvanced();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHandleDistributeClientPermeateClientTransferCloseTypeAdvanced clientHandleDistributeClientPermeateClientTransferCloseTypeAdvanced() {
|
||||
return new ClientHandleDistributeClientPermeateClientTransferCloseTypeAdvanced();
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public ClientHandleDistributeServicePermeateClientRealConnectTypeAdvanced clientHandleDistributeSingleClientRealConnectTypeAdvanced(NettyClientProperties nettyClientProperties,
|
||||
List<HandleChannelTypeAdvanced> handleChannelTypeAdvancedList) {
|
||||
return new ClientHandleDistributeServicePermeateClientRealConnectTypeAdvanced(nettyClientProperties, handleChannelTypeAdvancedList);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHandleHandleDistributeClientPermeateServerTransferCloseTypeAdvanced clientHandleHandleDistributeClientPermeateServerTransferCloseTypeAdvanced() {
|
||||
return new ClientHandleHandleDistributeClientPermeateServerTransferCloseTypeAdvanced();
|
||||
}
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.config;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.framework.lazy.cloud.network.heartbeat.client.infrastructure.entity.LazyNettyServerPropertiesDO;
|
||||
import org.framework.lazy.cloud.network.heartbeat.client.application.LazyNettyServerPropertiesApplication;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Role;
|
||||
import org.wu.framework.lazy.orm.database.lambda.stream.lambda.LazyLambdaStream;
|
||||
import org.wu.framework.lazy.orm.database.lambda.stream.wrapper.LazyWrappers;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 初始化配置
|
||||
*/
|
||||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
@Slf4j
|
||||
@Configuration
|
||||
public class InitConfig implements CommandLineRunner, DisposableBean {
|
||||
|
||||
private final NettyClientProperties nettyClientProperties;
|
||||
private final LazyLambdaStream lazyLambdaStream;
|
||||
|
||||
private final LazyNettyServerPropertiesApplication lazyNettyServerPropertiesApplication;
|
||||
|
||||
public InitConfig(NettyClientProperties nettyClientProperties, LazyLambdaStream lazyLambdaStream, LazyNettyServerPropertiesApplication lazyNettyServerPropertiesApplication) {
|
||||
this.nettyClientProperties = nettyClientProperties;
|
||||
this.lazyLambdaStream = lazyLambdaStream;
|
||||
this.lazyNettyServerPropertiesApplication = lazyNettyServerPropertiesApplication;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
try {
|
||||
// 存储配置到db
|
||||
initDb2Config();
|
||||
// 启动客户端连接
|
||||
lazyNettyServerPropertiesApplication.starterAllClientSocket();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 存储配置到db
|
||||
*/
|
||||
public void initDb2Config() {
|
||||
|
||||
String clientId = nettyClientProperties.getClientId();
|
||||
String inetHost = nettyClientProperties.getInetHost();
|
||||
int inetPort = nettyClientProperties.getInetPort();
|
||||
if (Objects.isNull(clientId) ||
|
||||
Objects.isNull(inetHost)) {
|
||||
log.warn("配置信息为空,请通过页面添加配置信息:{}", nettyClientProperties);
|
||||
return;
|
||||
}
|
||||
LazyNettyServerPropertiesDO lazyNettyServerPropertiesDO = new LazyNettyServerPropertiesDO();
|
||||
lazyNettyServerPropertiesDO.setClientId(clientId);
|
||||
lazyNettyServerPropertiesDO.setInetHost(inetHost);
|
||||
lazyNettyServerPropertiesDO.setInetPort(inetPort);
|
||||
lazyNettyServerPropertiesDO.setType(PropertiesType.CONFIG);
|
||||
lazyNettyServerPropertiesDO.setIsDeleted(false);
|
||||
// 根据服务端端口、port 唯一性验证
|
||||
boolean exists = lazyLambdaStream.exists(LazyWrappers.<LazyNettyServerPropertiesDO>lambdaWrapper()
|
||||
.eq(LazyNettyServerPropertiesDO::getInetHost, inetHost)
|
||||
.eq(LazyNettyServerPropertiesDO::getInetPort, inetPort)
|
||||
.eq(LazyNettyServerPropertiesDO::getClientId, clientId)
|
||||
);
|
||||
if (!exists) {
|
||||
lazyLambdaStream.insert(lazyNettyServerPropertiesDO);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 程序关闭后执行
|
||||
*/
|
||||
@Override
|
||||
public void destroy() {
|
||||
lazyNettyServerPropertiesApplication.destroyClientSocket();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.config;
|
||||
|
||||
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;
|
||||
|
||||
@@ -29,6 +30,22 @@ public class NettyClientProperties {
|
||||
*/
|
||||
private String clientId;
|
||||
|
||||
/**
|
||||
* 协议类型
|
||||
*/
|
||||
private ProtocolType protocolType = ProtocolType.TCP;
|
||||
/**
|
||||
*
|
||||
* 令牌key
|
||||
*/
|
||||
private String appKey;
|
||||
|
||||
/**
|
||||
*
|
||||
* 令牌密钥
|
||||
*/
|
||||
private String appSecret;
|
||||
|
||||
/**
|
||||
* 是否开启 默认是
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.context;
|
||||
|
||||
import jakarta.annotation.PreDestroy;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.framework.lazy.cloud.network.heartbeat.client.application.LazyNettyServerPropertiesApplication;
|
||||
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
|
||||
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.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.boot.context.event.ApplicationStartedEvent;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.wu.framework.lazy.orm.database.lambda.stream.lambda.LazyLambdaStream;
|
||||
import org.wu.framework.lazy.orm.database.lambda.stream.wrapper.LazyWrappers;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class NettyClientSocketApplicationListener implements ApplicationListener<ApplicationStartedEvent>, DisposableBean {
|
||||
|
||||
|
||||
private final NettyClientProperties nettyClientProperties;
|
||||
private final LazyLambdaStream lazyLambdaStream;
|
||||
|
||||
private final LazyNettyServerPropertiesApplication lazyNettyServerPropertiesApplication;
|
||||
|
||||
public NettyClientSocketApplicationListener(NettyClientProperties nettyClientProperties, LazyLambdaStream lazyLambdaStream, LazyNettyServerPropertiesApplication lazyNettyServerPropertiesApplication) {
|
||||
this.nettyClientProperties = nettyClientProperties;
|
||||
this.lazyLambdaStream = lazyLambdaStream;
|
||||
this.lazyNettyServerPropertiesApplication = lazyNettyServerPropertiesApplication;
|
||||
}
|
||||
|
||||
/**
|
||||
* 存储配置到db
|
||||
*/
|
||||
public void initDb2Config() {
|
||||
|
||||
try {
|
||||
String clientId = nettyClientProperties.getClientId();
|
||||
String inetHost = nettyClientProperties.getInetHost();
|
||||
int inetPort = nettyClientProperties.getInetPort();
|
||||
String appKey = nettyClientProperties.getAppKey();
|
||||
String appSecret = nettyClientProperties.getAppSecret();
|
||||
ProtocolType protocolType = nettyClientProperties.getProtocolType();
|
||||
if (Objects.isNull(clientId) ||
|
||||
Objects.isNull(inetHost)) {
|
||||
log.warn("配置信息为空,请通过页面添加配置信息:{}", nettyClientProperties);
|
||||
return;
|
||||
}
|
||||
LazyNettyServerPropertiesDO lazyNettyServerPropertiesDO = new LazyNettyServerPropertiesDO();
|
||||
lazyNettyServerPropertiesDO.setClientId(clientId);
|
||||
lazyNettyServerPropertiesDO.setInetHost(inetHost);
|
||||
lazyNettyServerPropertiesDO.setInetPort(inetPort);
|
||||
lazyNettyServerPropertiesDO.setType(PropertiesType.CONFIG);
|
||||
lazyNettyServerPropertiesDO.setIsDeleted(false);
|
||||
lazyNettyServerPropertiesDO.setAppKey(appKey);
|
||||
lazyNettyServerPropertiesDO.setAppSecret(appSecret);
|
||||
lazyNettyServerPropertiesDO.setProtocolType(protocolType);
|
||||
|
||||
|
||||
// 根据服务端端口、port 唯一性验证
|
||||
boolean exists = lazyLambdaStream.exists(LazyWrappers.<LazyNettyServerPropertiesDO>lambdaWrapper()
|
||||
.eq(LazyNettyServerPropertiesDO::getInetHost, inetHost)
|
||||
.eq(LazyNettyServerPropertiesDO::getInetPort, inetPort)
|
||||
.eq(LazyNettyServerPropertiesDO::getClientId, clientId)
|
||||
.eq(LazyNettyServerPropertiesDO::getProtocolType, protocolType)
|
||||
);
|
||||
if (!exists) {
|
||||
lazyLambdaStream.insert(lazyNettyServerPropertiesDO);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Handle an application event.
|
||||
*
|
||||
* @param event the event to respond to
|
||||
*/
|
||||
@Override
|
||||
public void onApplicationEvent(ApplicationStartedEvent event) {
|
||||
try {
|
||||
// 存储配置到db
|
||||
initDb2Config();
|
||||
// 启动客户端连接
|
||||
lazyNettyServerPropertiesApplication.starterAllClientSocket();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@PreDestroy
|
||||
@Override
|
||||
public void destroy() throws Exception {
|
||||
lazyNettyServerPropertiesApplication.destroyClientSocket();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,14 +1,13 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.domain.model.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 org.framework.lazy.cloud.network.heartbeat.common.enums.ProtocolType;
|
||||
|
||||
import java.lang.String;
|
||||
import java.time.LocalDateTime;
|
||||
import java.lang.Integer;
|
||||
/**
|
||||
* describe 服务端配置信息
|
||||
*
|
||||
@@ -66,6 +65,22 @@ public class LazyNettyServerProperties {
|
||||
@Schema(description ="类型(配置、DB)",name ="type",example = "")
|
||||
private PropertiesType type;
|
||||
|
||||
/**
|
||||
* 协议类型
|
||||
*/
|
||||
@Schema(description = "协议类型", name = "protocol_type", example = "")
|
||||
private ProtocolType protocolType;
|
||||
/**
|
||||
* 令牌key
|
||||
*/
|
||||
@Schema(description = "令牌key", name = "appKey", example = "")
|
||||
private String appKey;
|
||||
|
||||
/**
|
||||
* 令牌密钥
|
||||
*/
|
||||
@Schema(description = "令牌密钥", name = "appSecret", example = "")
|
||||
private String appSecret;
|
||||
/**
|
||||
*
|
||||
* 更新时间
|
||||
|
||||
@@ -2,8 +2,8 @@ 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.mapstruct.factory.Mappers;
|
||||
/**
|
||||
* describe 服务端配置信息
|
||||
*
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.infrastructure.entity;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
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 org.framework.lazy.cloud.network.heartbeat.common.enums.ProtocolType;
|
||||
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.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import org.wu.framework.lazy.orm.core.stereotype.LazyTableFieldId;
|
||||
import org.wu.framework.lazy.orm.core.stereotype.LazyTableFieldUnique;
|
||||
|
||||
import java.lang.String;
|
||||
import java.time.LocalDateTime;
|
||||
import java.lang.Integer;
|
||||
/**
|
||||
* describe 服务端配置信息
|
||||
*
|
||||
@@ -26,6 +26,13 @@ import java.lang.Integer;
|
||||
public class LazyNettyServerPropertiesDO {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* 主键ID
|
||||
*/
|
||||
@Schema(description ="主键ID",name ="id",example = "")
|
||||
@LazyTableFieldId(name = "id", comment = "主键ID")
|
||||
private Long id;
|
||||
/**
|
||||
*
|
||||
* 客户身份ID
|
||||
@@ -75,6 +82,20 @@ public class LazyNettyServerPropertiesDO {
|
||||
@LazyTableField(name="is_deleted",comment="是否删除")
|
||||
private Boolean isDeleted;
|
||||
|
||||
|
||||
/**
|
||||
* 令牌key
|
||||
*/
|
||||
@Schema(description = "令牌key", name = "appKey", example = "")
|
||||
@LazyTableField(name = "app_key", comment = "令牌key")
|
||||
private String appKey;
|
||||
|
||||
/**
|
||||
* 令牌密钥
|
||||
*/
|
||||
@Schema(description = "令牌密钥", name = "appSecret", example = "")
|
||||
@LazyTableField(name = "app_secret", comment = "令牌密钥")
|
||||
private String appSecret;
|
||||
/**
|
||||
*
|
||||
* 类型(配置、DB)
|
||||
@@ -83,6 +104,13 @@ public class LazyNettyServerPropertiesDO {
|
||||
@LazyTableField(name="type",comment="类型(配置、DB)",columnType="varchar(255)")
|
||||
private PropertiesType type;
|
||||
|
||||
/**
|
||||
* 协议类型
|
||||
*/
|
||||
@Schema(description ="协议类型",name ="protocol_type",example = "")
|
||||
@LazyTableField(name="protocol_type",comment="协议类型",columnType="varchar(255)")
|
||||
private ProtocolType protocolType;
|
||||
|
||||
/**
|
||||
*
|
||||
* 更新时间
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.advanced;
|
||||
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.MessageType;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.advanced.AbstractHandleChannelHeartbeatTypeAdvanced;
|
||||
|
||||
|
||||
/**
|
||||
* 服务端 处理客户端心跳
|
||||
* TYPE_HEARTBEAT
|
||||
*/
|
||||
public class ClientHandleChannelHeartbeatTypeAdvanced extends AbstractHandleChannelHeartbeatTypeAdvanced<NettyProxyMsg> {
|
||||
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param channel 当前通道
|
||||
* @param msg 通道数据
|
||||
*/
|
||||
@Override
|
||||
public void doHandler(Channel channel, NettyProxyMsg msg) {
|
||||
NettyProxyMsg hb = new NettyProxyMsg();
|
||||
hb.setType(MessageType.TYPE_HEARTBEAT);
|
||||
// channel.writeAndFlush(hb);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.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.socket.NettyClientPermeateClientVisitorSocket;
|
||||
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.client.AbstractHandleDistributeClientPermeateClientTransferCloseTypeAdvanced;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
|
||||
import org.wu.framework.spring.utils.SpringContextHolder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 下发客户端渗透客户端通信通道关闭
|
||||
*
|
||||
* @see MessageTypeEnums#DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE
|
||||
*/
|
||||
@Slf4j
|
||||
public class ClientHandleDistributeClientPermeateClientTransferCloseTypeAdvanced extends AbstractHandleDistributeClientPermeateClientTransferCloseTypeAdvanced<NettyProxyMsg> {
|
||||
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param channel 当前通道
|
||||
* @param nettyProxyMsg 通道数据
|
||||
*/
|
||||
@Override
|
||||
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
|
||||
// 关闭客户端真实通道、访客通道
|
||||
Channel realChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
|
||||
realChannel.close();// 真实通道关闭
|
||||
channel.close(); // 数据传输通道关闭
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.advanced;
|
||||
|
||||
|
||||
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.client.AbstractHandleDistributeClientTransferClientRequestTypeAdvanced;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
|
||||
|
||||
|
||||
/**
|
||||
* 下发客户端渗透客户端数据传输
|
||||
*
|
||||
*
|
||||
* @see MessageTypeEnums#DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_REQUEST
|
||||
*/
|
||||
@Slf4j
|
||||
public class ClientHandleDistributeClientTransferClientRequestTypeAdvanced extends AbstractHandleDistributeClientTransferClientRequestTypeAdvanced<NettyProxyMsg> {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param channel 当前通道
|
||||
* @param nettyProxyMsg 通道数据
|
||||
*/
|
||||
@Override
|
||||
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
|
||||
// 把数据转到真实服务
|
||||
ByteBuf buf = channel.config().getAllocator().buffer(nettyProxyMsg.getData().length);
|
||||
buf.writeBytes(nettyProxyMsg.getData());
|
||||
log.info("client permeate client send request to real socket byte:{} ",new String(nettyProxyMsg.getData()));
|
||||
nextChannel.writeAndFlush(buf);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.advanced;
|
||||
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.handler.NettyClientPermeateServerVisitorHandler;
|
||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.socket.NettyClientPermeateServerVisitorTransferSocket;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.advanced.client.AbstractHandleDistributeClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
|
||||
|
||||
|
||||
/**
|
||||
* 客户端渗透服务端数据传输通道连接成功
|
||||
* @see NettyClientPermeateServerVisitorTransferSocket
|
||||
* @see NettyClientPermeateServerVisitorHandler
|
||||
*
|
||||
* @see MessageTypeEnums#DISTRIBUTE_CLIENT_TRANSFER_SERVER_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL
|
||||
*/
|
||||
@Slf4j
|
||||
public class ClientHandleDistributeClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced extends AbstractHandleDistributeClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced<NettyProxyMsg> {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param transferChannel 当前通道
|
||||
* @param nettyProxyMsg 通道数据
|
||||
*/
|
||||
@Override
|
||||
public void doHandler(Channel transferChannel, NettyProxyMsg nettyProxyMsg) {
|
||||
// 连接成功 开启自动读取写
|
||||
byte[] msgVisitorId = nettyProxyMsg.getVisitorId();
|
||||
String visitorId = new String(msgVisitorId);
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(transferChannel);
|
||||
nextChannel.config().setOption(ChannelOption.AUTO_READ, true);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.advanced;
|
||||
|
||||
|
||||
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.client.AbstractHandleDistributeServicePermeateClientTransferClientResponseTypeAdvanced;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
|
||||
|
||||
|
||||
/**
|
||||
* 下发客户端渗透客户端数据传输响应
|
||||
*
|
||||
*
|
||||
* @see MessageTypeEnums#DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_RESPONSE
|
||||
*/
|
||||
@Slf4j
|
||||
public class ClientHandleDistributeServicePermeateClientTransferClientResponseTypeAdvanced extends AbstractHandleDistributeServicePermeateClientTransferClientResponseTypeAdvanced<NettyProxyMsg> {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param channel 当前通道
|
||||
* @param nettyProxyMsg 通道数据
|
||||
*/
|
||||
@Override
|
||||
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
|
||||
// 把数据转到真实服务
|
||||
ByteBuf buf = channel.config().getAllocator().buffer(nettyProxyMsg.getData().length);
|
||||
buf.writeBytes(nettyProxyMsg.getData());
|
||||
|
||||
nextChannel.writeAndFlush(buf);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.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.client.AbstractHandleDistributeSingleClientMessageTypeAdvanced;
|
||||
|
||||
/**
|
||||
* 接收服务端发送过来的聊天信息
|
||||
*/
|
||||
@Slf4j
|
||||
public class ClientHandleDistributeSingleClientMessageTypeAdvanced extends AbstractHandleDistributeSingleClientMessageTypeAdvanced<NettyProxyMsg> {
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param channel 当前通道
|
||||
* @param nettyProxyMsg 通道数据
|
||||
*/
|
||||
@Override
|
||||
protected void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
|
||||
byte[] clientId = nettyProxyMsg.getClientId();
|
||||
byte[] data = nettyProxyMsg.getData();
|
||||
log.info("接收客户端:{},发送过来的聊天信息:{}", new String(clientId), new String(data));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.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.client.AbstractHandleDistributeSingleClientRealCloseVisitorTypeAdvanced;
|
||||
|
||||
@Slf4j
|
||||
public class ClientHandleDistributeSingleClientRealCloseVisitorTypeAdvanced extends AbstractHandleDistributeSingleClientRealCloseVisitorTypeAdvanced<NettyProxyMsg> {
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param channel 当前通道
|
||||
* @param nettyProxyMsg 通道数据
|
||||
*/
|
||||
@Override
|
||||
protected void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
|
||||
// 关闭代理的真实通道
|
||||
byte[] visitorId = nettyProxyMsg.getVisitorId();
|
||||
NettyRealIdContext.clear(visitorId);
|
||||
NettyCommunicationIdContext.clear(visitorId);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.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.common.NettyProxyMsg;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.advanced.client.AbstractHandleDistributeClientPermeateServerTransferCloseTypeAdvanced;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.utils.ChannelAttributeKeyUtils;
|
||||
|
||||
|
||||
/**
|
||||
* 下发 客户端渗透服务端通信通道关闭
|
||||
*
|
||||
* @see MessageTypeEnums#DISTRIBUTE_CLIENT_PERMEATE_SERVER_TRANSFER_CLOSE
|
||||
*/
|
||||
@Slf4j
|
||||
public class ClientHandleHandleDistributeClientPermeateServerTransferCloseTypeAdvanced extends AbstractHandleDistributeClientPermeateServerTransferCloseTypeAdvanced<NettyProxyMsg> {
|
||||
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param channel 当前通道
|
||||
* @param nettyProxyMsg 通道数据
|
||||
*/
|
||||
@Override
|
||||
public void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
|
||||
// 关闭本地通信通道
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
|
||||
channel.close();
|
||||
nextChannel.close();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.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.event.ClientChangeEvent;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.advanced.client.AbstractHandleDistributeConnectSuccessNotificationTypeAdvancedHandle;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 客户端连接成功通知
|
||||
*/
|
||||
@Slf4j
|
||||
public class HandleDistributeConnectSuccessNotificationTypeAdvancedHandle extends AbstractHandleDistributeConnectSuccessNotificationTypeAdvancedHandle<NettyProxyMsg> {
|
||||
|
||||
private final ClientChangeEvent clientChangeEvent;
|
||||
|
||||
|
||||
public HandleDistributeConnectSuccessNotificationTypeAdvancedHandle(ClientChangeEvent clientChangeEvent) {
|
||||
this.clientChangeEvent = clientChangeEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param channel 当前通道
|
||||
* @param msg 通道数据
|
||||
*/
|
||||
@Override
|
||||
protected void doHandler(Channel channel, NettyProxyMsg msg) {
|
||||
// 客户端ID:{},客户端:{}连接成功
|
||||
log.warn("Client ID: {}, Client Data : {} Connection successful", new String(msg.getClientId()), new String(msg.getData()));
|
||||
|
||||
|
||||
// 存储其他客户端状态
|
||||
List<String> clientIdList = JSONObject.parseArray(new String(msg.getData()), String.class);
|
||||
for (String tenantId : clientIdList) {
|
||||
clientChangeEvent.clientOnLine(tenantId);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.advanced;
|
||||
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.event.ClientChangeEvent;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.advanced.client.AbstractHandleDistributeDisconnectTypeAdvancedHandle;
|
||||
|
||||
|
||||
/**
|
||||
* 服务端处理客户端断开连接处理
|
||||
* TYPE_DISCONNECT
|
||||
*/
|
||||
@Slf4j
|
||||
public class HandleDistributeDisconnectTypeAdvancedHandle extends AbstractHandleDistributeDisconnectTypeAdvancedHandle<NettyProxyMsg> {
|
||||
|
||||
|
||||
private final ClientChangeEvent clientChangeEvent;
|
||||
|
||||
public HandleDistributeDisconnectTypeAdvancedHandle(ClientChangeEvent clientChangeEvent) {
|
||||
this.clientChangeEvent = clientChangeEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param channel 当前通道
|
||||
* @param msg 通道数据
|
||||
*/
|
||||
@Override
|
||||
public void doHandler(Channel channel, NettyProxyMsg msg) {
|
||||
// 服务下线
|
||||
byte[] data = msg.getData();
|
||||
byte[] clientId = msg.getClientId();
|
||||
String tenantId = new String(clientId);
|
||||
//客户端:{}下线
|
||||
log.warn("Client: {} Offline", tenantId);
|
||||
clientChangeEvent.clientOffLine(tenantId);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.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.client.AbstractHandleDistributeStagingClosedTypeAdvanced;
|
||||
|
||||
/**
|
||||
* 服务端下发暂存关闭消息处理
|
||||
*/
|
||||
@Slf4j
|
||||
public class HandleDistributeStagingClosedTypeAdvanced extends AbstractHandleDistributeStagingClosedTypeAdvanced<NettyProxyMsg> {
|
||||
|
||||
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param channel 当前通道
|
||||
* @param msg 通道数据
|
||||
*/
|
||||
@Override
|
||||
protected void doHandler(Channel channel, NettyProxyMsg msg) {
|
||||
String clientId = new String(msg.getClientId());
|
||||
log.info("客户端:{}离线暂存关闭", clientId);
|
||||
// 修改redis 客户端暂存状态
|
||||
// String stagingStatusKey = StagingConfigKeyConstant.getStagingStatusKey(clientId);
|
||||
// stringRedisTemplate.opsForValue().set(stagingStatusKey, StagingStatus.CLOSED.name());
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.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.client.AbstractHandleDistributeStagingOpenedTypeAdvanced;
|
||||
|
||||
/**
|
||||
* 服务端下发暂存开启消息处理
|
||||
*/
|
||||
@Slf4j
|
||||
public class HandleDistributeStagingOpenedTypeAdvanced extends AbstractHandleDistributeStagingOpenedTypeAdvanced<NettyProxyMsg> {
|
||||
|
||||
|
||||
public HandleDistributeStagingOpenedTypeAdvanced() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param channel 当前通道
|
||||
* @param msg 通道数据
|
||||
*/
|
||||
@Override
|
||||
protected void doHandler(Channel channel, NettyProxyMsg msg) {
|
||||
String clientId = new String(msg.getClientId());
|
||||
//客户端:{}离线暂存开启
|
||||
log.warn("Client: {} Offline temporary storage enabled", new String(msg.getClientId()));
|
||||
// 修改redis 客户端暂存状态
|
||||
// String stagingStatusKey = StagingConfigKeyConstant.getStagingStatusKey(clientId);
|
||||
// stringRedisTemplate.opsForValue().set(stagingStatusKey, StagingStatus.OPENED.name());
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty;
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -11,7 +11,7 @@ import java.util.List;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class InternalNetworkClientPermeateClientVisitor implements InternalNetworkPermeate {
|
||||
public class NettyClientPermeateClientVisitor implements InternalNetworkPermeate {
|
||||
|
||||
/**
|
||||
* 当前客户端ID
|
||||
@@ -56,4 +56,9 @@ public class InternalNetworkClientPermeateClientVisitor implements InternalNetwo
|
||||
* 访客ID
|
||||
*/
|
||||
private String visitorId;
|
||||
|
||||
/**
|
||||
* 是否是ssl
|
||||
*/
|
||||
private boolean isSsl;
|
||||
}
|
||||
@@ -1,17 +1,16 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty;
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.framework.lazy.cloud.network.heartbeat.client.config.NettyClientProperties;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.InternalNetworkPermeate;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelFlowAdapter;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class InternalNetworkPermeateServerVisitor implements InternalNetworkPermeate {
|
||||
public class NettyClientPermeateServerVisitor implements InternalNetworkPermeate {
|
||||
|
||||
/**
|
||||
* 目标地址
|
||||
@@ -38,4 +37,10 @@ public class InternalNetworkPermeateServerVisitor implements InternalNetworkPerm
|
||||
*/
|
||||
private List<HandleChannelTypeAdvanced> handleChannelTypeAdvancedList;
|
||||
|
||||
|
||||
/**
|
||||
* 是否是ssl
|
||||
*/
|
||||
private boolean isSsl;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate;
|
||||
|
||||
public interface NettyClientSocket {
|
||||
|
||||
/**
|
||||
* 创建客户端链接服务端
|
||||
* @throws InterruptedException 异常信息
|
||||
*/
|
||||
void newConnect2Server() throws InterruptedException;
|
||||
|
||||
/**
|
||||
* 关闭链接
|
||||
*/
|
||||
void shutdown();
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.event;
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.event;
|
||||
|
||||
/**
|
||||
* 客户端状态变更事件
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.event;
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.event;
|
||||
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
@@ -0,0 +1,32 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
|
||||
|
||||
|
||||
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 nettyChannelContext 当前通道
|
||||
* @param msg 通道数据
|
||||
*/
|
||||
@Override
|
||||
public void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg msg) {
|
||||
NettyProxyMsg hb = new NettyProxyMsg();
|
||||
hb.setType(TcpMessageType.TCP_TYPE_HEARTBEAT);
|
||||
// nettyChannelContext.writeAndFlush(hb);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
|
||||
|
||||
|
||||
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.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;
|
||||
|
||||
|
||||
/**
|
||||
* 服务端处理客户端数据传输
|
||||
*
|
||||
* @see TcpMessageTypeEnums#TCP_DISTRIBUTE_CLIENT_TRANSFER
|
||||
*/
|
||||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
@Slf4j
|
||||
public class ClientHandleTcpChannelTransferTypeAdvancedHandleDistributeTcpDistribute extends AbstractHandleTcpDistributeServicePermeateClientTransferTypeAdvanced<NettyProxyMsg> {
|
||||
|
||||
private final NettyClientProperties nettyClientProperties;
|
||||
|
||||
public ClientHandleTcpChannelTransferTypeAdvancedHandleDistributeTcpDistribute(NettyClientProperties nettyClientProperties) {
|
||||
this.nettyClientProperties = nettyClientProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param nettyChannelContext 当前通道
|
||||
* @param nettyProxyMsg 通道数据
|
||||
*/
|
||||
@Override
|
||||
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[] visitorId = nettyProxyMsg.getVisitorId();
|
||||
// 真实服务通道
|
||||
// Channel realChannel = NettyRealIdContext.getReal(new String(visitorId));
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
|
||||
if (nextChannel == null) {
|
||||
log.error("无法获取访客:{} 真实服务", new String(visitorId));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// 把数据转到真实服务
|
||||
ByteBuf buf = channel.config().getAllocator().buffer(nettyProxyMsg.getData().length);
|
||||
buf.writeBytes(nettyProxyMsg.getData());
|
||||
|
||||
nextChannel.writeAndFlush(buf);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,30 +1,35 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.advanced;
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
|
||||
|
||||
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.client.AbstractHandleClientChannelActiveAdvanced;
|
||||
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
|
||||
*/
|
||||
public class HandleClientChannelActiveAdvanced extends AbstractHandleClientChannelActiveAdvanced<NettyProxyMsg> {
|
||||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
public class ClientHandleTcpClientChannelActiveAdvanced extends AbstractHandleTcpClientChannelActiveAdvanced<NettyProxyMsg> {
|
||||
private final NettyClientProperties nettyClientProperties;
|
||||
|
||||
public HandleClientChannelActiveAdvanced(NettyClientProperties nettyClientProperties) {
|
||||
public ClientHandleTcpClientChannelActiveAdvanced(NettyClientProperties nettyClientProperties) {
|
||||
this.nettyClientProperties = nettyClientProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @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);
|
||||
@@ -1,33 +1,35 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.advanced;
|
||||
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.client.AbstractHandleDistributeClientPermeateClientCloseTypeAdvanced;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.advanced.client.AbstractHandleDistributeClientPermeateServerCloseTypeAdvanced;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
* 客户端渗透客户端init close 信息
|
||||
*
|
||||
* @see MessageTypeEnums#DISTRIBUTE_CLIENT_PERMEATE_CLIENT_CLOSE
|
||||
* @see TcpMessageTypeEnums#TCP_DISTRIBUTE_CLIENT_PERMEATE_CLIENT_CLOSE
|
||||
*/
|
||||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
@Slf4j
|
||||
public class ClientHandleDistributeClientPermeateClientCloseTypeAdvanced extends AbstractHandleDistributeClientPermeateClientCloseTypeAdvanced<NettyProxyMsg> {
|
||||
public class ClientHandleTcpDistributeClientPermeateClientCloseTypeAdvanced extends AbstractHandleTcpDistributeClientPermeateClientCloseTypeAdvanced<NettyProxyMsg> {
|
||||
|
||||
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @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));
|
||||
@@ -0,0 +1,74 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
|
||||
|
||||
|
||||
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.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;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 客户端渗透客户端init信息
|
||||
*
|
||||
* @see TcpMessageTypeEnums#TCP_DISTRIBUTE_CLIENT_PERMEATE_CLIENT_INIT
|
||||
*/
|
||||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
@Slf4j
|
||||
public class ClientHandleTcpDistributeClientPermeateClientInitTypeAdvanced extends AbstractHandleTcpDistributeClientPermeateClientInitTypeAdvanced<NettyProxyMsg> {
|
||||
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param nettyChannelContext 当前通道
|
||||
* @param nettyProxyMsg 通道数据
|
||||
*/
|
||||
@Override
|
||||
public void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
|
||||
// 初始化 客户端渗透服务端socket
|
||||
byte[] fromClientIdBytes = nettyProxyMsg.getClientId();
|
||||
byte[] visitorPortBytes = nettyProxyMsg.getVisitorPort();
|
||||
byte[] clientTargetIpBytes = nettyProxyMsg.getClientTargetIp();
|
||||
byte[] clientTargetPortBytes = nettyProxyMsg.getClientTargetPort();
|
||||
byte[] toClientIdBytes = nettyProxyMsg.getData();
|
||||
|
||||
String fromClientId = new String(fromClientIdBytes);
|
||||
String toClientId = new String(toClientIdBytes);
|
||||
Integer visitorPort = Integer.parseInt(new String(visitorPortBytes));
|
||||
String clientTargetIp = new String(clientTargetIpBytes);
|
||||
Integer clientTargetPort = Integer.parseInt(new String(clientTargetPortBytes));
|
||||
|
||||
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);
|
||||
NettyTcpClientPermeateClientVisitorSocket nettyTcpClientPermeateClientVisitorSocket =
|
||||
NettyTcpClientPermeateClientVisitorSocket.NettyClientPermeateClientVisitorSocketBuilder.builder()
|
||||
.builderClientId(fromClientId)
|
||||
.builderClientTargetIp(clientTargetIp)
|
||||
.builderClientTargetPort(clientTargetPort)
|
||||
.builderVisitorPort(visitorPort)
|
||||
.builderNettyClientProperties(nettyClientProperties)
|
||||
//.builderChannelFlowAdapter(channelFlowAdapter)
|
||||
.builderToClientId(toClientId)
|
||||
.builderHandleChannelTypeAdvancedList(handleChannelTypeAdvancedList)
|
||||
|
||||
.build();
|
||||
try {
|
||||
nettyTcpClientPermeateClientVisitorSocket.start();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
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.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;
|
||||
|
||||
|
||||
/**
|
||||
* 下发客户端渗透客户端通信通道关闭
|
||||
*
|
||||
* @see TcpMessageTypeEnums#TCP_DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_CLOSE
|
||||
*/
|
||||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
@Slf4j
|
||||
public class ClientHandleTcpDistributeClientPermeateClientTransferCloseTypeAdvanced extends AbstractHandleTcpDistributeClientPermeateClientTransferCloseTypeAdvanced<NettyProxyMsg> {
|
||||
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param nettyChannelContext 当前通道
|
||||
* @param nettyProxyMsg 通道数据
|
||||
*/
|
||||
@Override
|
||||
public void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
|
||||
Channel channel = nettyChannelContext.channel();
|
||||
// 关闭客户端真实通道、访客通道
|
||||
Channel realChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
|
||||
realChannel.close();// 真实通道关闭
|
||||
channel.close(); // 数据传输通道关闭
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,33 +1,35 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.advanced;
|
||||
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.socket.NettyClientPermeateServerVisitorSocket;
|
||||
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.client.AbstractHandleDistributeClientPermeateServerCloseTypeAdvanced;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
* 客户端渗透服务端init close 信息
|
||||
*
|
||||
* @see MessageTypeEnums#DISTRIBUTE_CLIENT_PERMEATE_SERVER_CLOSE
|
||||
* @see TcpMessageTypeEnums#TCP_DISTRIBUTE_CLIENT_PERMEATE_SERVER_CLOSE
|
||||
*/
|
||||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
@Slf4j
|
||||
public class ClientHandleDistributeClientPermeateServerCloseTypeAdvanced extends AbstractHandleDistributeClientPermeateServerCloseTypeAdvanced<NettyProxyMsg> {
|
||||
public class ClientHandleTcpDistributeClientPermeateServerCloseTypeAdvanced extends AbstractHandleTcpDistributeClientPermeateServerCloseTypeAdvanced<NettyProxyMsg> {
|
||||
|
||||
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @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));
|
||||
@@ -1,45 +1,45 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.advanced;
|
||||
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.socket.NettyClientPermeateServerVisitorSocket;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelFlowAdapter;
|
||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.socket.NettyTcpClientPermeateServerVisitorSocket;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.advanced.client.AbstractHandleDistributeClientPermeateServerInitTypeAdvanced;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
|
||||
import org.wu.framework.inner.lazy.orm.spring.SpringConnectionHandler;
|
||||
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;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* 客户端渗透服务端init信息
|
||||
*
|
||||
* @see MessageTypeEnums#DISTRIBUTE_CLIENT_PERMEATE_SERVER_INIT
|
||||
* @see TcpMessageTypeEnums#TCP_DISTRIBUTE_CLIENT_PERMEATE_SERVER_INIT
|
||||
*/
|
||||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
@Slf4j
|
||||
public class ClientHandleDistributeClientPermeateServerInitTypeAdvanced extends AbstractHandleDistributeClientPermeateServerInitTypeAdvanced<NettyProxyMsg> {
|
||||
public class ClientHandleTcpDistributeClientPermeateServerInitTypeAdvanced extends AbstractHandleTcpDistributeClientPermeateServerInitTypeAdvanced<NettyProxyMsg> {
|
||||
|
||||
private final NettyClientProperties nettyClientProperties;
|
||||
|
||||
public ClientHandleDistributeClientPermeateServerInitTypeAdvanced(NettyClientProperties nettyClientProperties) {
|
||||
public ClientHandleTcpDistributeClientPermeateServerInitTypeAdvanced(NettyClientProperties nettyClientProperties) {
|
||||
this.nettyClientProperties = nettyClientProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @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();
|
||||
@@ -47,7 +47,7 @@ public class ClientHandleDistributeClientPermeateServerInitTypeAdvanced extends
|
||||
byte[] clientTargetPort = nettyProxyMsg.getClientTargetPort();
|
||||
|
||||
List<HandleChannelTypeAdvanced> handleChannelTypeAdvancedList = new ArrayList<>(SpringContextHolder.getApplicationContext().getBeansOfType(HandleChannelTypeAdvanced.class).values());
|
||||
NettyClientPermeateServerVisitorSocket nettyClientPermeateServerVisitorSocket = NettyClientPermeateServerVisitorSocket.NettyVisitorSocketBuilder.builder()
|
||||
NettyTcpClientPermeateServerVisitorSocket nettyTcpClientPermeateServerVisitorSocket = NettyTcpClientPermeateServerVisitorSocket.NettyVisitorSocketBuilder.builder()
|
||||
.builderClientId(new String(clientIdBytes))
|
||||
.builderClientTargetIp(new String(clientTargetIp))
|
||||
.builderClientTargetPort(Integer.parseInt(new String(clientTargetPort)))
|
||||
@@ -56,8 +56,9 @@ public class ClientHandleDistributeClientPermeateServerInitTypeAdvanced extends
|
||||
.builderHandleChannelTypeAdvancedList(handleChannelTypeAdvancedList)
|
||||
.build();
|
||||
try {
|
||||
nettyClientPermeateServerVisitorSocket.start();
|
||||
nettyTcpClientPermeateServerVisitorSocket.start();
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
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.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;
|
||||
|
||||
|
||||
/**
|
||||
* 下发 客户端渗透服务端通信通道关闭
|
||||
*
|
||||
* @see TcpMessageTypeEnums#TCP_DISTRIBUTE_CLIENT_PERMEATE_SERVER_TRANSFER_CLOSE
|
||||
*/
|
||||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
@Slf4j
|
||||
public class ClientHandleTcpDistributeClientPermeateServerTransferCloseTypeAdvanced extends AbstractHandleTcpDistributeClientPermeateServerTransferCloseTypeAdvanced<NettyProxyMsg> {
|
||||
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param nettyChannelContext 当前通道
|
||||
* @param nettyProxyMsg 通道数据
|
||||
*/
|
||||
@Override
|
||||
public void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
|
||||
Channel channel = nettyChannelContext.channel();
|
||||
// 关闭本地通信通道
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
|
||||
channel.close();
|
||||
nextChannel.close();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,33 +1,37 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.advanced;
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
|
||||
|
||||
|
||||
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.client.AbstractHandleDistributeClientPermeateServerTransferTypeAdvanced;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
* 服务端处理客户端数据传输
|
||||
*
|
||||
* @see MessageTypeEnums#DISTRIBUTE_CLIENT_TRANSFER
|
||||
* @see TcpMessageTypeEnums#TCP_DISTRIBUTE_CLIENT_TRANSFER
|
||||
*/
|
||||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
@Slf4j
|
||||
public class ClientHandleDistributeClientPermeateServerTransferTypeAdvanced extends AbstractHandleDistributeClientPermeateServerTransferTypeAdvanced<NettyProxyMsg> {
|
||||
public class ClientHandleTcpDistributeClientPermeateServerTransferTypeAdvanced extends AbstractHandleTcpDistributeClientPermeateServerTransferTypeAdvanced<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();
|
||||
log.debug("客户端渗透服务端返回数据:{}" , new String(nettyProxyMsg.getData()));
|
||||
byte[] visitorPort = nettyProxyMsg.getVisitorPort();
|
||||
byte[] clientTargetIp = nettyProxyMsg.getClientTargetIp();
|
||||
@@ -0,0 +1,64 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
|
||||
|
||||
|
||||
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.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;
|
||||
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 nettyChannelContext 当前通道
|
||||
* @param nettyProxyMsg 通道数据
|
||||
*/
|
||||
@Override
|
||||
public void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
|
||||
// 创建connect 然后发送创建成功
|
||||
byte[] msgClientId = nettyProxyMsg.getClientId();
|
||||
byte[] msgClientTargetIp = nettyProxyMsg.getClientTargetIp();
|
||||
byte[] msgClientTargetPort = nettyProxyMsg.getClientTargetPort();
|
||||
byte[] msgVisitorId = nettyProxyMsg.getVisitorId();
|
||||
byte[] msgVisitorPort = nettyProxyMsg.getVisitorPort();
|
||||
|
||||
String clientId=new String(msgClientId);
|
||||
String clientTargetIp=new String(msgClientTargetIp);
|
||||
Integer clientTargetPort=Integer.parseInt(new String(msgClientTargetPort));
|
||||
String visitorId=new String(msgVisitorId);
|
||||
Integer visitorPort=Integer.parseInt(new String(msgVisitorPort));
|
||||
NettyClientProperties nettyClientProperties = SpringContextHolder.getBean(NettyClientProperties.class);
|
||||
List<HandleChannelTypeAdvanced> handleChannelTypeAdvancedList = new ArrayList<>(SpringContextHolder.getApplicationContext().getBeansOfType(HandleChannelTypeAdvanced.class).values());
|
||||
NettyTcpClientPermeateClientRealSocket.buildRealServer(
|
||||
clientId,
|
||||
clientTargetIp,
|
||||
clientTargetPort,
|
||||
visitorPort,
|
||||
visitorId,
|
||||
nettyClientProperties,
|
||||
handleChannelTypeAdvancedList
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,36 +1,39 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.advanced;
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
|
||||
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.socket.NettyClientPermeateClientRealSocket;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyProxyMsg;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.advanced.client.AbstractHandleDistributeClientTransferClientPermeateChannelConnectionSuccessfulTypeAdvanced;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.advanced.client.AbstractHandleDistributeClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.enums.MessageTypeEnums;
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
* 下发 客户端渗透客户端数据传输通道init 成功
|
||||
*
|
||||
*
|
||||
* @see MessageTypeEnums#DISTRIBUTE_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL
|
||||
* @see TcpMessageTypeEnums#TCP_DISTRIBUTE_CLIENT_TRANSFER_CLIENT_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL
|
||||
*/
|
||||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
@Slf4j
|
||||
public class ClientHandleDistributeClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced extends AbstractHandleDistributeClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced<NettyProxyMsg> {
|
||||
public class ClientHandleTcpDistributeClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced extends AbstractHandleTcpDistributeClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced<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();
|
||||
// 连接成功 开启自动读取写
|
||||
byte[] msgClientId = nettyProxyMsg.getClientId();
|
||||
byte[] msgClientTargetIp = nettyProxyMsg.getClientTargetIp();
|
||||
@@ -0,0 +1,46 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
|
||||
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.Channel;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
* 下发客户端渗透客户端数据传输
|
||||
*
|
||||
*
|
||||
* @see TcpMessageTypeEnums#TCP_DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_REQUEST
|
||||
*/
|
||||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
@Slf4j
|
||||
public class ClientHandleTcpDistributeClientTransferClientRequestTypeAdvanced extends AbstractHandleTcpDistributeClientTransferClientRequestTypeAdvanced<NettyProxyMsg> {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param nettyChannelContext 当前通道
|
||||
* @param nettyProxyMsg 通道数据
|
||||
*/
|
||||
@Override
|
||||
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);
|
||||
buf.writeBytes(nettyProxyMsg.getData());
|
||||
log.debug("client permeate client send request to real socket byte:{} ",new String(nettyProxyMsg.getData()));
|
||||
nextChannel.writeAndFlush(buf);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
|
||||
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
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.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;
|
||||
|
||||
|
||||
/**
|
||||
* 客户端渗透服务端数据传输通道连接成功
|
||||
* @see NettyTcpClientPermeateServerVisitorTransferSocket
|
||||
* @see NettyTcpClientPermeateServerVisitorHandler
|
||||
*
|
||||
* @see TcpMessageTypeEnums#TCP_DISTRIBUTE_CLIENT_TRANSFER_SERVER_PERMEATE_CHANNEL_CONNECTION_SUCCESSFUL
|
||||
*/
|
||||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
@Slf4j
|
||||
public class ClientHandleTcpDistributeClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced extends AbstractHandleTcpDistributeClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced<NettyProxyMsg> {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param nettyChannelContext 当前通道
|
||||
* @param nettyProxyMsg 通道数据
|
||||
*/
|
||||
@Override
|
||||
public void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
|
||||
Channel channel = nettyChannelContext.channel();
|
||||
// 连接成功 开启自动读取写
|
||||
byte[] msgVisitorId = nettyProxyMsg.getVisitorId();
|
||||
String visitorId = new String(msgVisitorId);
|
||||
Channel nextChannel = ChannelAttributeKeyUtils.getNextChannel(channel);
|
||||
nextChannel.config().setOption(ChannelOption.AUTO_READ, true);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
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.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> {
|
||||
|
||||
private final ClientChangeEvent clientChangeEvent;
|
||||
|
||||
|
||||
public ClientHandleTcpDistributeConnectSuccessNotificationTypeAdvancedHandle(ClientChangeEvent clientChangeEvent) {
|
||||
this.clientChangeEvent = clientChangeEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param nettyChannelContext 当前通道
|
||||
* @param msg 通道数据
|
||||
*/
|
||||
@Override
|
||||
protected void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg msg) {
|
||||
// 客户端ID:{},客户端:{}连接成功
|
||||
log.warn("Client ID: {}, Client Data : {} Connection successful", new String(msg.getClientId()), new String(msg.getData()));
|
||||
|
||||
|
||||
// 存储其他客户端状态
|
||||
List<String> clientIdList = JSONObject.parseArray(new String(msg.getData()), String.class);
|
||||
for (String clientId : clientIdList) {
|
||||
clientChangeEvent.clientOnLine(clientId);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
|
||||
|
||||
|
||||
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.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> {
|
||||
|
||||
|
||||
private final ClientChangeEvent clientChangeEvent;
|
||||
|
||||
public ClientHandleTcpDistributeDisconnectTypeAdvancedHandle(ClientChangeEvent clientChangeEvent) {
|
||||
this.clientChangeEvent = clientChangeEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param nettyChannelContext 当前通道
|
||||
* @param msg 通道数据
|
||||
*/
|
||||
@Override
|
||||
public void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg msg) {
|
||||
// 服务下线
|
||||
byte[] data = msg.getData();
|
||||
byte[] clientId = msg.getClientId();
|
||||
String tenantId = new String(clientId);
|
||||
//客户端:{}下线
|
||||
log.warn("Client: {} Offline", tenantId);
|
||||
clientChangeEvent.clientOffLine(tenantId);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
|
||||
|
||||
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.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;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 客户端创建真实代理同奥
|
||||
*/
|
||||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
@Slf4j
|
||||
public class ClientHandleTcpDistributeServicePermeateClientRealConnectTypeAdvanced extends AbstractHandleTcpDistributeServicePermeateClientRealConnectTypeAdvanced<NettyProxyMsg> {
|
||||
|
||||
private final NettyClientProperties nettyClientProperties;// 服务端地址信息
|
||||
|
||||
|
||||
public ClientHandleTcpDistributeServicePermeateClientRealConnectTypeAdvanced(NettyClientProperties nettyClientProperties) {
|
||||
this.nettyClientProperties = nettyClientProperties;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param nettyChannelContext 当前通道
|
||||
* @param msg 通道数据
|
||||
*/
|
||||
@Override
|
||||
protected void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg msg) {
|
||||
// 创建真实端口监听
|
||||
byte[] clientIdBytes = msg.getClientId();
|
||||
byte[] visitorPort = msg.getVisitorPort();
|
||||
byte[] clientTargetIp = msg.getClientTargetIp();
|
||||
byte[] clientTargetPort = msg.getClientTargetPort();
|
||||
byte[] visitorIdBytes = msg.getVisitorId();
|
||||
InternalNetworkPenetrationRealClient internalNetworkPenetrationRealClient =
|
||||
InternalNetworkPenetrationRealClient
|
||||
.builder()
|
||||
.clientId(new String(clientIdBytes))
|
||||
.visitorPort(Integer.valueOf(new String(visitorPort)))
|
||||
.clientTargetIp(new String(clientTargetIp))
|
||||
.clientTargetPort(Integer.valueOf(new String(clientTargetPort)))
|
||||
.visitorId(new String(visitorIdBytes))
|
||||
.build();
|
||||
|
||||
List<HandleChannelTypeAdvanced> handleChannelTypeAdvancedList = new ArrayList<>(SpringContextHolder.getApplicationContext().getBeansOfType(HandleChannelTypeAdvanced.class).values());
|
||||
// 绑定真实服务端口
|
||||
NettyTcpServerPermeateClientRealSocket.buildRealServer(internalNetworkPenetrationRealClient, nettyClientProperties, handleChannelTypeAdvancedList);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
|
||||
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.Channel;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
* 下发客户端渗透客户端数据传输响应
|
||||
*
|
||||
*
|
||||
* @see TcpMessageTypeEnums#TCP_DISTRIBUTE_CLIENT_PERMEATE_CLIENT_TRANSFER_RESPONSE
|
||||
*/
|
||||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
@Slf4j
|
||||
public class ClientHandleTcpDistributeServicePermeateClientTransferClientResponseTypeAdvanced extends AbstractHandleTcpDistributeServicePermeateClientTransferClientResponseTypeAdvanced<NettyProxyMsg> {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param nettyChannelContext 当前通道
|
||||
* @param nettyProxyMsg 通道数据
|
||||
*/
|
||||
@Override
|
||||
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);
|
||||
buf.writeBytes(nettyProxyMsg.getData());
|
||||
|
||||
nextChannel.writeAndFlush(buf);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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 nettyChannelContext 当前通道
|
||||
* @param nettyProxyMsg 通道数据
|
||||
*/
|
||||
@Override
|
||||
protected void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
|
||||
byte[] clientId = nettyProxyMsg.getClientId();
|
||||
byte[] data = nettyProxyMsg.getData();
|
||||
log.info("接收客户端:{},发送过来的聊天信息:{}", new String(clientId), new String(data));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,28 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.advanced;
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
|
||||
|
||||
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.client.AbstractHandleDistributeSingleClientRealAutoReadConnectTypeAdvanced;
|
||||
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 ClientHandleDistributeSingleClientRealAutoReadConnectTypeAdvanced extends AbstractHandleDistributeSingleClientRealAutoReadConnectTypeAdvanced<NettyProxyMsg> {
|
||||
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();
|
||||
// 获取访客对应的真实代理通道
|
||||
@@ -0,0 +1,29 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.NettyCommunicationIdContext;
|
||||
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 nettyChannelContext 当前通道
|
||||
* @param nettyProxyMsg 通道数据
|
||||
*/
|
||||
@Override
|
||||
protected void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg nettyProxyMsg) {
|
||||
// 关闭代理的真实通道
|
||||
byte[] visitorId = nettyProxyMsg.getVisitorId();
|
||||
NettyRealIdContext.clear(visitorId);
|
||||
NettyCommunicationIdContext.clear(visitorId);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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> {
|
||||
|
||||
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param nettyChannelContext 当前通道
|
||||
* @param msg 通道数据
|
||||
*/
|
||||
@Override
|
||||
protected void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg msg) {
|
||||
String clientId = new String(msg.getClientId());
|
||||
log.info("客户端:{}离线暂存关闭", clientId);
|
||||
// 修改redis 客户端暂存状态
|
||||
// String stagingStatusKey = StagingConfigKeyConstant.getStagingStatusKey(clientId);
|
||||
// stringRedisTemplate.opsForValue().set(stagingStatusKey, StagingStatus.CLOSED.name());
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.advanced;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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> {
|
||||
|
||||
|
||||
public ClientHandleTcpDistributeStagingOpenedTypeAdvanced() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param nettyChannelContext 当前通道
|
||||
* @param msg 通道数据
|
||||
*/
|
||||
@Override
|
||||
protected void doHandler(NettyChannelContext nettyChannelContext, NettyProxyMsg msg) {
|
||||
String clientId = new String(msg.getClientId());
|
||||
//客户端:{}离线暂存开启
|
||||
log.warn("Client: {} Offline temporary storage enabled", new String(msg.getClientId()));
|
||||
// 修改redis 客户端暂存状态
|
||||
// String stagingStatusKey = StagingConfigKeyConstant.getStagingStatusKey(clientId);
|
||||
// stringRedisTemplate.opsForValue().set(stagingStatusKey, StagingStatus.OPENED.name());
|
||||
}
|
||||
}
|
||||
@@ -1,26 +1,26 @@
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.filter;
|
||||
package org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.filter;
|
||||
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
import io.netty.channel.socket.SocketChannel;
|
||||
import io.netty.handler.codec.string.StringDecoder;
|
||||
import io.netty.handler.codec.string.StringEncoder;
|
||||
import io.netty.handler.timeout.IdleStateHandler;
|
||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.handler.NettyClientHandler;
|
||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.socket.NettyClientSocket;
|
||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.handler.NettyTcpClientHandler;
|
||||
import org.framework.lazy.cloud.network.heartbeat.client.netty.permeate.tcp.socket.NettyTcpClientSocket;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelTypeAdapter;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.decoder.NettyProxyMsgDecoder;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.encoder.NettyProxyMsgEncoder;
|
||||
import org.framework.lazy.cloud.network.heartbeat.common.filter.DebugChannelInitializer;
|
||||
|
||||
public class NettyClientFilter extends DebugChannelInitializer<SocketChannel> {
|
||||
public class NettyTcpClientFilter extends DebugChannelInitializer<SocketChannel> {
|
||||
|
||||
|
||||
private final ChannelTypeAdapter channelTypeAdapter;
|
||||
private final NettyClientSocket nettyClientSocket;
|
||||
private final NettyTcpClientSocket nettyTcpClientSocket;
|
||||
|
||||
public NettyClientFilter(ChannelTypeAdapter channelTypeAdapter, NettyClientSocket nettyClientSocket) {
|
||||
public NettyTcpClientFilter(ChannelTypeAdapter channelTypeAdapter, NettyTcpClientSocket nettyTcpClientSocket) {
|
||||
this.channelTypeAdapter = channelTypeAdapter;
|
||||
this.nettyClientSocket = nettyClientSocket;
|
||||
this.nettyTcpClientSocket = nettyTcpClientSocket;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -40,6 +40,6 @@ public class NettyClientFilter extends DebugChannelInitializer<SocketChannel> {
|
||||
pipeline.addLast(new IdleStateHandler(0, 4, 0));
|
||||
pipeline.addLast("decoder", new StringDecoder());
|
||||
pipeline.addLast("encoder", new StringEncoder());
|
||||
pipeline.addLast("doHandler", new NettyClientHandler(channelTypeAdapter, nettyClientSocket)); //客户端的逻辑
|
||||
pipeline.addLast("doHandler", new NettyTcpClientHandler(channelTypeAdapter, nettyTcpClientSocket)); //客户端的逻辑
|
||||
}
|
||||
}
|
||||