Compare commits
81
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
efb3a7015d | ||
|
|
47efe37a0e | ||
|
|
0ad05e7dc8 | ||
|
|
9576707660 | ||
|
|
168acd6bfe | ||
|
|
ad32e36ba2 | ||
|
|
00fd0bab84 | ||
|
|
8f90cf461d | ||
|
|
e44f6e195c | ||
|
|
5db0bf94cb | ||
|
|
99c79f612a | ||
|
|
4890b8783f | ||
|
|
8e150c7696 | ||
|
|
051a36a43e | ||
|
|
46bcc8a25d | ||
|
|
6c3d195afc | ||
|
|
00de9ee464 | ||
|
|
a1608ba1be | ||
|
|
e7bdd4a631 | ||
|
|
67c42a19bb | ||
|
|
d3c658fa4d | ||
|
|
bb96caca64 | ||
|
|
306cd66034 | ||
|
|
5ccf0d1936 | ||
|
|
1ad80a6d8b | ||
|
|
faf5ec9bdc | ||
|
|
a369ee1a15 | ||
|
|
9121ff37bb | ||
|
|
5e1a2f5620 | ||
|
|
7530fd7d9f | ||
|
|
57339dc56c | ||
|
|
d072c05d31 | ||
|
|
a21a786884 | ||
|
|
670f581185 | ||
|
|
e642e5f103 | ||
|
|
d551aaeff6 | ||
|
|
78f2488fe9 | ||
|
|
035283a757 | ||
|
|
644102996b | ||
|
|
2ee2a5f38e | ||
|
|
b883cac767 | ||
|
|
8fd9a24d7c | ||
|
|
40cc5c0c7c | ||
|
|
d23f907d03 | ||
|
|
438714e9ee | ||
|
|
7a173757f0 | ||
|
|
9f2198e32e | ||
|
|
6cbf2ecac4 | ||
|
|
781b14861c | ||
|
|
82d78d2e4b | ||
|
|
d40028365b | ||
|
|
90623b9146 | ||
|
|
aab26f5b9d | ||
|
|
169551445c | ||
|
|
00308c0f5c | ||
|
|
306f2ed4d3 | ||
|
|
bbdd1860cf | ||
|
|
a9fc8f4cb4 | ||
|
|
836252f85b | ||
|
|
ce053be992 | ||
|
|
323e7c6277 | ||
|
|
f4797d22ba | ||
|
|
7c9aa1ebdc | ||
|
|
9564e51c91 | ||
|
|
09f934bdd0 | ||
|
|
d54c4644cf | ||
|
|
4232be546a | ||
|
|
b5b82e0b80 | ||
|
|
0eaad35379 | ||
|
|
b754dd5456 | ||
|
|
035db05e70 | ||
|
|
f7c3e5b76b | ||
|
|
85d86e15c2 | ||
|
|
eea06908f9 | ||
|
|
7fc339e6c1 | ||
|
|
97714e02c5 | ||
|
|
d8d5cc61ab | ||
|
|
67bcbb4383 | ||
|
|
c8207097c1 | ||
|
|
8a89786a41 | ||
|
|
c9b501f334 |
@@ -12,7 +12,7 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
# see: https://docs.github.com/zh/actions/using-jobs/choosing-the-runner-for-a-job
|
||||
# os: ['ubuntu-20.04', 'macos-12']
|
||||
# os: ['ubuntu-20.04', 'macos-12']
|
||||
os: ['ubuntu-20.04']
|
||||
name: build - ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
@@ -30,12 +30,12 @@ jobs:
|
||||
run: |
|
||||
cd neutrino-proxy-admin
|
||||
npm install
|
||||
npm run build:docker
|
||||
npm run build:docker·
|
||||
cp -rf ./dist/ ./../neutrino-proxy-server/src/main/resources/static/
|
||||
- name: GitHub Action for GraalVM JDK 17
|
||||
- name: GitHub Action for GraalVM JDK 21
|
||||
uses: graalvm/setup-graalvm@v1
|
||||
with:
|
||||
java-version: '17.0.7' # for a specific JDK 17; or '17' for the latest JDK 17
|
||||
java-version: '21.0.1' # for a specific JDK 21
|
||||
distribution: 'graalvm' # New 'distribution' option
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Cache local Maven repository
|
||||
@@ -45,32 +45,41 @@ jobs:
|
||||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-maven-
|
||||
- name: Set vars
|
||||
shell: bash
|
||||
run: |
|
||||
OS=$(echo '${{ runner.os }}' | awk '{print tolower($0)}')
|
||||
[[ $OS == 'ubuntu' ]] && echo "OS=linux" >> $GITHUB_ENV || echo "OS=$OS" >> $GITHUB_ENV
|
||||
[[ $OS == 'macos' ]] && echo "OS=darwin" >> $GITHUB_ENV || echo "OS=$OS" >> $GITHUB_ENV
|
||||
echo "VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
|
||||
- name: Build with Maven (neutrino-proxy-server)
|
||||
run: |
|
||||
mvn clean install -pl neutrino-proxy-core -am -DskipTests --no-transfer-progress
|
||||
cd neutrino-proxy-server
|
||||
cd neutrino-proxy-server
|
||||
mvn clean native:compile -P native --file pom.xml --no-transfer-progress
|
||||
chmod +x target/neutrino-proxy-server
|
||||
cp target/neutrino-proxy-server ./../neutrino-proxy-server-${{ github.ref_name }}
|
||||
cp target/neutrino-proxy-server ./../neutrino-proxy-server-${{ env.VERSION }}
|
||||
cp target/classes/app-copy.yml ./../neutrino-proxy-server-${{ env.VERSION }}/app.yml
|
||||
- name: Archive zip (neutrino-proxy-server)
|
||||
uses: thedoctor0/zip-release@master
|
||||
with:
|
||||
type: 'zip'
|
||||
path: 'neutrino-proxy-server-${{ github.ref_name }}'
|
||||
filename: neutrino-proxy-server-${{ matrix.os }}-${{ github.ref_name }}.zip
|
||||
path: 'neutrino-proxy-server-${{ env.VERSION }}'
|
||||
filename: neutrino-proxy-server-${{ env.OS }}-${{ env.VERSION }}.zip
|
||||
- name: Build with Maven (neutrino-proxy-client)
|
||||
run: |
|
||||
cd neutrino-proxy-client
|
||||
mvn clean package --file pom.xml --no-transfer-progress
|
||||
mvn clean native:compile -P native --file pom.xml --no-transfer-progress
|
||||
chmod +x target/neutrino-proxy-client
|
||||
cp target/neutrino-proxy-client ./../neutrino-proxy-client-${{ github.ref_name }}
|
||||
cp target/neutrino-proxy-client ./../neutrino-proxy-client-${{ env.VERSION }}
|
||||
cp target/classes/app-copy.yml ./../neutrino-proxy-client-${{ env.VERSION }}/app.yml
|
||||
- name: Archive zip (neutrino-proxy-client)
|
||||
uses: thedoctor0/zip-release@master
|
||||
with:
|
||||
type: 'zip'
|
||||
path: 'neutrino-proxy-client-${{ github.ref_name }}'
|
||||
filename: neutrino-proxy-client-${{ matrix.os }}-${{ github.ref_name }}.zip
|
||||
path: 'neutrino-proxy-client-${{ env.VERSION }}'
|
||||
filename: neutrino-proxy-client-${{ env.OS }}-${{ env.VERSION }}.zip
|
||||
# GitHub 上创建 release
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
@@ -79,7 +88,7 @@ jobs:
|
||||
files: |
|
||||
neutrino-proxy-server/target/neutrino-proxy-server.jar
|
||||
neutrino-proxy-client/target/neutrino-proxy-client.jar
|
||||
neutrino-proxy-server-${{ matrix.os }}-${{ github.ref_name }}.zip
|
||||
neutrino-proxy-client-${{ matrix.os }}-${{ github.ref_name }}.zip
|
||||
neutrino-proxy-server-${{ env.OS }}-${{ env.VERSION }}.zip
|
||||
neutrino-proxy-client-${{ env.OS }}-${{ env.VERSION }}.zip
|
||||
prerelease: true
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
name: Build windows native image
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
@@ -31,10 +31,10 @@ jobs:
|
||||
npm install
|
||||
npm run build:docker
|
||||
cp -r ./dist/ ./../neutrino-proxy-server/src/main/resources/static/
|
||||
- name: GitHub Action for GraalVM JDK 17
|
||||
- name: GitHub Action for GraalVM JDK 21
|
||||
uses: graalvm/setup-graalvm@v1
|
||||
with:
|
||||
java-version: '17.0.7' # for a specific JDK 17; or '17' for the latest JDK 17
|
||||
java-version: '21.0.1' # for a specific JDK 21;
|
||||
distribution: 'graalvm' # New 'distribution' option
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Cache local Maven repository
|
||||
@@ -44,6 +44,13 @@ jobs:
|
||||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-maven-
|
||||
- name: Set vars
|
||||
shell: bash
|
||||
run: |
|
||||
OS=$(echo '${{ runner.os }}' | awk '{print tolower($0)}')
|
||||
[[ $OS == 'ubuntu' ]] && echo "OS=linux" >> $GITHUB_ENV || echo "OS=$OS" >> $GITHUB_ENV
|
||||
[[ $OS == 'macos' ]] && echo "OS=darwin" >> $GITHUB_ENV || echo "OS=$OS" >> $GITHUB_ENV
|
||||
echo "VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
|
||||
- name: Build with Maven (neutrino-proxy-server)
|
||||
run: |
|
||||
set MAVEN_OPTS="-Duser.language=UTF-8 -Dfile.encoding=UTF-8"
|
||||
@@ -56,7 +63,7 @@ jobs:
|
||||
with:
|
||||
type: 'zip'
|
||||
path: 'neutrino-proxy-server.exe'
|
||||
filename: neutrino-proxy-server-${{ matrix.os }}-${{ github.ref_name }}.zip
|
||||
filename: neutrino-proxy-server-${{ env.OS }}-${{ env.VERSION }}.zip
|
||||
- name: Build with Maven (neutrino-proxy-client)
|
||||
run: |
|
||||
set MAVEN_OPTS="-Duser.language=UTF-8 -Dfile.encoding=UTF-8"
|
||||
@@ -69,7 +76,7 @@ jobs:
|
||||
with:
|
||||
type: 'zip'
|
||||
path: 'neutrino-proxy-client.exe'
|
||||
filename: neutrino-proxy-client-${{ matrix.os }}-${{ github.ref_name }}.zip
|
||||
filename: neutrino-proxy-client-${{ env.OS }}-${{ env.VERSION }}.zip
|
||||
# GitHub 上创建 release
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
@@ -78,7 +85,7 @@ jobs:
|
||||
files: |
|
||||
neutrino-proxy-server/target/neutrino-proxy-server.jar
|
||||
neutrino-proxy-client/target/neutrino-proxy-client.jar
|
||||
neutrino-proxy-server-${{ matrix.os }}-${{ github.ref_name }}.zip
|
||||
neutrino-proxy-client-${{ matrix.os }}-${{ github.ref_name }}.zip
|
||||
neutrino-proxy-server-${{ env.OS }}-${{ env.VERSION }}.zip
|
||||
neutrino-proxy-client-${{ env.OS }}-${{ env.VERSION }}.zip
|
||||
prerelease: true
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
-52
@@ -1,52 +0,0 @@
|
||||
# 基础
|
||||
- [x] 服务端编译、启动成功
|
||||
- [x] 客户端编译、启动成功
|
||||
- [x] 配置
|
||||
- [x] 启动参数
|
||||
- [x] 外部配置文件
|
||||
- [x] 环境变量
|
||||
- [x] 日志
|
||||
- [x] 控制台输出
|
||||
- [x] debug启动有netty错误日志
|
||||
- [x] 文件输出
|
||||
- [x] 修改日志级别
|
||||
- [x] 心跳日志
|
||||
- [x] 传输报文日志
|
||||
- [x] 连接
|
||||
- [x] 隧道SSL连接
|
||||
- [x] 隧道非SSL连接
|
||||
- [x] 隧道SSL连接自定义证书
|
||||
|
||||
# 服务端管理后台
|
||||
- [x] 登录成功
|
||||
- [x] 首页统计
|
||||
- [x] 代理配置
|
||||
- [x] license管理
|
||||
- [x] 端口映射
|
||||
- [x] 系统管理
|
||||
- [x] 用户管理
|
||||
- [x] 端口分组管理
|
||||
- [x] 端口池管理
|
||||
- [x] 协议管理
|
||||
- [x] 调度管理
|
||||
- [x] 报表管理
|
||||
- [x] 用户流量报表
|
||||
- [x] License流量报表
|
||||
- [x] 用户流量月度明细
|
||||
- [x] License流量月度明细
|
||||
- [x] 日志管理
|
||||
- [x] 调度日志
|
||||
- [x] 登录日志
|
||||
- [x] 客户端连接日志
|
||||
|
||||
|
||||
# 客户端
|
||||
- [x] 重连机制
|
||||
|
||||
# 代理
|
||||
- [x] TCP代理
|
||||
- [x] HTTP(S)代理
|
||||
- [x] 端口访问
|
||||
- [x] HTTP域名访问
|
||||
- [x] HTTPS域名访问
|
||||
- [x] UDP代理
|
||||
@@ -88,6 +88,9 @@
|
||||
<a href="https://gitee.com/songyinyin" target="_blank">
|
||||
<img src="assets/developer/songyinyin.png" width="11%">
|
||||
</a>
|
||||
<a href="https://gitee.com/nichenxyx" target="_blank">
|
||||
<img src="assets/developer/NichenFly.jpg" width="11%">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
# ❤️ 感谢
|
||||
|
||||
@@ -72,3 +72,9 @@
|
||||
- jdk版本升级为17
|
||||
- 支持原生编译改造
|
||||
- 默认支持的数据库由sqlite改为h2
|
||||
|
||||
## 2.0.1
|
||||
- jdk版本升级为21
|
||||
- 解决HTTP(S)映射时使用tcp端口访问正常,使用域名访问偶现一直loading的问题
|
||||
- 新增安全组模块,支持黑名单、白名单限制
|
||||
- 支持对用户、license限速
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 458 KiB |
@@ -0,0 +1,86 @@
|
||||
# 从Neutrino-Proxy(中微子代理)到Solon Native
|
||||
|
||||
## Neutrino-Proxy(中微子代理)是啥
|
||||
#### 项目简介
|
||||
- [中微子代理(neutrino-proxy)](https://gitee.com/asgc/neutrino-proxy) 是一款基于netty的内网穿透神器。该项目采用最为宽松的MIT协议,因此您可以对它进行复制、修改、传播并用于任何个人或商业行为。
|
||||
- 市面上基于内网穿透的常见产品有:花生壳、TeamView、cpolar等。
|
||||
- 常见的使用场景:
|
||||
- 本地开发调试第三方回调
|
||||
- 本地开发异地接口连调
|
||||
- 远程登录内网windows机器
|
||||
- 将本地服务映射到外网,用于演示
|
||||
- Gitee仓库:https://gitee.com/dromara/neutrino-proxy
|
||||
- Github仓库:https://github.com/dromara/neutrino-proxy
|
||||
- 官网地址1: https://neutrino-proxy.dromara.org
|
||||
- 官网地址2: https://dromara.gitee.io/neutrino-proxy
|
||||
|
||||
#### 主要特点:
|
||||
- 1、流量监控:首页图表、报表管理多维度流量监控。全方位掌握实时、历史代理数据。
|
||||
- 2、用户/License:支持多用户、多客户端使用。后台禁用实时生效。
|
||||
- 3、端口池:对外端口统一管理,支持用户、License独占端口。
|
||||
- 4、端口映射:新增、编辑、删除、禁用实时生效。
|
||||
- 5、Docker:服务端/客户端支持Docker一键部署。
|
||||
- 6、SSL证书:隧道通信支持SSL加密,保护您的数据安全。
|
||||
- 7、域名映射:支持绑定子域名,方便本地调试三方回调
|
||||
- 8、多种协议:支持代理TCP、HTTP、HTTPS、UDP协议
|
||||
- 9、原生部署:支持编译为原生可执行文件,更低部署门槛、更少内存占用
|
||||
- 10、采用最为宽松的MIT协议,免去你的后顾之忧
|
||||
|
||||
## 为什么开发Neutrino-Proxy(中微子代理)
|
||||
2022年4月份左右,因工作原因需要用到内网穿透。此前一段时间使用的`coplar`,由于公司担心带来安全隐患,
|
||||
因此决定自己研究一下这一块。
|
||||
|
||||
对于常年写业务代码的一介码农来说,内网穿透就是一个黑盒。为了打开这个黑盒,我开始到处找相关的开源项目,其中包括lanproxy、ngrok、nps、frp等。
|
||||
|
||||
经过一翻努力,2022年6月份,实现了中微子代理1.0.0。此版本纯粹为了练手, 所以是基于自己手写的一套底层框架(包含Ioc、Aop、SqlMaper(简易版本的mybatis)、xxljob等),
|
||||
实现了客户端/服务端+纯配置文件版本的TCP代理。
|
||||
|
||||
千里之行,始于足下。1.0.0版本发布后,经过不断的迭代,如今2.0.0版本终于和大家见面了。
|
||||
|
||||
## 为什么选择Solon
|
||||
中微子1.0.0版本发布之后,大约7~8个月的时间,进行了大量的更新,主要围绕在底层基础框架、
|
||||
管理后台这一块。
|
||||
|
||||
此时中微子陆陆续续开始有了一些用户,开始迫切的需要加快代理相关功能的迭代进度。而此时自己手写
|
||||
的底层框架成为了最大的掣肘,单单底层框架各种细节优化、测试、参考借鉴其他框架源码这些就足以耗光
|
||||
我为数不多的业余时间,更别提在这个尚不成熟的框架上开发代理功能了。任何一次底层的优化调整,可能带来的
|
||||
是上层代理功能的大量重构。
|
||||
|
||||
于是,我开始搜寻其它替代框架。因日常工作一直都在用Spring体系,我始终相信多种技术两相印证之后学到的东西更为深刻,所以自己的开源项目始终将Spring体系作为优先级最低
|
||||
的选项。最终一个或偶然、或必然的机会,我了解到了Solon。
|
||||
|
||||
经过对Solon项目源码、官网文档、项目更新频率、生态完善度的深入了解,最终决定选择Solon作为中微子代理的底层框架。
|
||||
|
||||
2023年3月12日,中微子代理1.7.0版本发布,开始正式基于Solon框架。
|
||||
2023年10月30日,中微子代理2.0.0版本发布,基于Solon Native实现原生部署。
|
||||
|
||||
## Solon简介
|
||||
#### 项目简介
|
||||
- Solon是一个全新的java生态体系,给人带来一种与众不同的开发体验,让你能更快的构建自己的应用、更小的打包产出、更快的启动速度。
|
||||
- Gitee仓库:https://gitee.com/noear/solon
|
||||
- Github仓库:https://github.com/noear/solon
|
||||
- 官网地址:https://solon.noear.org/
|
||||
|
||||
#### 主要特性
|
||||
> 启动快 5 ~ 10 倍;qps 高 2~ 3 倍;运行时内存节省 1/3 ~ 1/2;打包可以缩到 1/2 ~ 1/10
|
||||
- 克制、简洁、高效、开放、生态
|
||||
- 支持 JDK8、JDK11、JDK17、JDK21
|
||||
- Http、WebSocket、Socket 三种信号统一的开发体验(俗称:三源合一)
|
||||
- 支持“注解”与“手动”两种模式,按需自由操控
|
||||
- Not Servlet,可以适配任何基础通讯框架(最小 0.3m 运行rpc架构)
|
||||
- 独特的 IOC/AOP 容器设计。不会因为插件变多而启动变很慢
|
||||
- 支持 Web、Data、Job、Remoting、Cloud 等任何开发场景
|
||||
- 兼顾 Handler + Context 和 Listener + Message 两种架构模式
|
||||
- 强调插件式扩展,可扩展可切换;适应不同的应用场景
|
||||
- 支持 GraalVm Native Image 打包
|
||||
- 允许业务插件“热插”、“热拔”、“热管理”
|
||||
|
||||
## 最后说点什么
|
||||
开源实属不易,开源国产生态型基础框架更是举步维艰。不仅需要长时间、持续、稳定的投入迭代、测试、文档撰写、bug修复、发版、推广,
|
||||
还经常需要面对来自四面八方汹涌如潮的质疑。
|
||||
|
||||
时光无言,它磨灭了一切、也证明着一切。
|
||||
|
||||
一千八百多个日日夜夜、五年的风雨兼程,Solon生态已经初具规模,社区汇聚了一大批开源爱好者。
|
||||
|
||||
大鹏一日通风起,扶摇直上九万里。我相信国产开源在大家的努力下,一定会越来越好!
|
||||
@@ -23,7 +23,7 @@
|
||||
"codemirror": "5.32.0",
|
||||
"dropzone": "5.2.0",
|
||||
"echarts": "3.8.5",
|
||||
"element-ui": "2.0.8",
|
||||
"element-ui": "^2.15.14",
|
||||
"file-saver": "1.3.3",
|
||||
"font-awesome": "4.7.0",
|
||||
"js-cookie": "2.2.0",
|
||||
@@ -70,7 +70,7 @@
|
||||
"friendly-errors-webpack-plugin": "1.6.1",
|
||||
"html-webpack-plugin": "2.30.1",
|
||||
"node-notifier": "5.1.2",
|
||||
"node-sass": "^4.7.2",
|
||||
"node-sass": "^9.0.0",
|
||||
"optimize-css-assets-webpack-plugin": "3.2.0",
|
||||
"ora": "1.3.0",
|
||||
"portfinder": "1.0.13",
|
||||
|
||||
@@ -44,3 +44,22 @@ export function updateEnableStatus(id, enable) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function portMappingBindSecurityGroup(id, securityGroupId) {
|
||||
return request({
|
||||
url: '/port-mapping/bind/security-group',
|
||||
method: 'post',
|
||||
data: {
|
||||
id: id,
|
||||
securityGroupId: securityGroupId
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function portMappingUnbindSecurityGroup(id) {
|
||||
return request({
|
||||
url: `/port-mapping/unbind/security-group?id=${id}`,
|
||||
method: 'post'
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export function fetchGroupPage(query) {
|
||||
return request({
|
||||
url: '/security/group/page',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
export function fetchGroupList() {
|
||||
return request({
|
||||
url: '/security/group/list',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function fetchGroupDetail(query) {
|
||||
return request({
|
||||
url: '/security/group/detail',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
export function createGroup(data) {
|
||||
return request({
|
||||
url: `/security/group/create`,
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function updateGroup(query) {
|
||||
return request({
|
||||
url: `/security/group/update`,
|
||||
method: 'post',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
export function deleteGroup(data) {
|
||||
return request({
|
||||
url: '/security/group/delete',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function updateGroupEnableStatus(id, enable) {
|
||||
return request({
|
||||
url: '/security/group/update/enable-status',
|
||||
method: 'post',
|
||||
data: {
|
||||
id: id,
|
||||
enable: enable
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function fetchRulePage(query) {
|
||||
return request({
|
||||
url: '/security/rule/page',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
export function fetchRuleList(query) {
|
||||
return request({
|
||||
url: '/security/rule/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
export function createRule(data) {
|
||||
return request({
|
||||
url: `/security/rule/create`,
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function updateRule(data) {
|
||||
return request({
|
||||
url: `/security/rule/update`,
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
export function deleteRule(query) {
|
||||
return request({
|
||||
url: '/security/rule/delete',
|
||||
method: 'post',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
export function updateRuleEnableStatus(id, enable) {
|
||||
return request({
|
||||
url: '/security/rule/update/enable-status',
|
||||
method: 'post',
|
||||
data: {
|
||||
id: id,
|
||||
enable: enable
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
<template>
|
||||
<el-popover
|
||||
placement="top"
|
||||
:width="width"
|
||||
v-model="visible">
|
||||
<p class="popper-p-css"><i class="el-icon-warning" style="color: #e6a23c"/>{{title}}</p>
|
||||
<div style="text-align: center; margin: 0">
|
||||
<el-button size="mini" @click="handleCancelClick">{{cancelText}}</el-button>
|
||||
<el-button type="primary" size="mini" @click="handleCommitClick">{{okText}}</el-button>
|
||||
</div>
|
||||
<el-link slot="reference" :underline="false" :type="type" :size="size" :icon="icon" :disabled="disabled" style="text-align: left; font-size: 12px">{{buttonText}}</el-link>
|
||||
</el-popover>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
export default {
|
||||
name: 'deleteLink',
|
||||
props: {
|
||||
width: {
|
||||
type: Number,
|
||||
default: 160
|
||||
},
|
||||
buttonText: {
|
||||
type: String,
|
||||
default: '删除'
|
||||
},
|
||||
type: {
|
||||
type: String,
|
||||
default: 'danger'
|
||||
},
|
||||
size: {
|
||||
type: String,
|
||||
default: 'mini'
|
||||
},
|
||||
icon: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
disabled: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
default: '确定删除吗?'
|
||||
},
|
||||
okText: {
|
||||
type: String,
|
||||
default: '确定'
|
||||
},
|
||||
cancelText: {
|
||||
type: String,
|
||||
default: '取消'
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
visible: false
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleCancelClick() {
|
||||
this.visible = false
|
||||
this.$emit('handleCancelClick')
|
||||
},
|
||||
handleCommitClick() {
|
||||
this.visible = false
|
||||
this.$emit('handleCommitClick')
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style rel="stylesheet/scss" lang="scss" scoped>
|
||||
.popper-p-css{
|
||||
margin-top: 0px !important;
|
||||
margin-bottom: 5px !important;
|
||||
.el-icon-warning{
|
||||
margin-right: 5px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -48,6 +48,8 @@ export default {
|
||||
user: '用户管理',
|
||||
system: '系统管理',
|
||||
portPool: '端口池管理',
|
||||
securityGroup: '安全组管理',
|
||||
securityRule: '安全规则管理',
|
||||
portGroup: '端口分组管理',
|
||||
protocal: '协议管理',
|
||||
proxy: '代理配置',
|
||||
@@ -128,6 +130,7 @@ export default {
|
||||
confirm: '确 定',
|
||||
userId: '用户ID',
|
||||
userName: '用户名',
|
||||
name: '名称',
|
||||
group: '分组',
|
||||
groupName: '分组名称',
|
||||
groupPossessor: '分组所属',
|
||||
@@ -169,7 +172,19 @@ export default {
|
||||
totalFlow: '总流量',
|
||||
protocalName: '协议',
|
||||
supportStatus: '支持状态',
|
||||
domainName: '域名'
|
||||
domainName: '域名',
|
||||
securityGroup: '安全组',
|
||||
defaultPassType: '默认放行类型',
|
||||
ruleName: '规则名称',
|
||||
rule: '规则内容',
|
||||
passType: '放行类型',
|
||||
priority: '优先级',
|
||||
ruleConfig: '配置规则',
|
||||
portMappingBindSecurityGroup: '绑定安全组',
|
||||
securityGroupBindPortMapping: '端口映射绑定',
|
||||
bind: '绑定',
|
||||
unbind: '解绑',
|
||||
bindOtherSecurityGroup: '已绑定其他安全组'
|
||||
},
|
||||
button: {
|
||||
lookOver: '查看'
|
||||
|
||||
@@ -77,6 +77,8 @@ export const asyncRouterMap = [
|
||||
{ path: 'user', component: _import('system/user'), name: 'user', meta: { title: 'user' }},
|
||||
{ path: 'portGroup', component: _import('system/portGroup'), name: 'portGroup', meta: { title: 'portGroup' }},
|
||||
{ path: 'portPool', component: _import('system/portPool'), name: 'portPool', meta: { title: 'portPool' }},
|
||||
{ path: 'securityGroup', component: _import('system/securityGroup'), name: 'securityGroup', meta: { title: 'securityGroup' }},
|
||||
{ path: 'securityRule', component: _import('system/securityRule'), name: 'securityRule', meta: { title: 'securityRule' }, hidden: true},
|
||||
{ path: 'protocal', component: _import('system/protocal'), name: 'protocal', meta: { title: 'protocal' }},
|
||||
{ path: 'jobManager', component: _import('system/jobManager'), name: 'jobManager', meta: { title: 'jobManager' }}
|
||||
]
|
||||
|
||||
@@ -36,6 +36,11 @@
|
||||
<span>{{scope.row.key}}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" :label="$t('限速')" width="100">
|
||||
<template slot-scope="scope">
|
||||
<span>{{scope.row.upLimitRate ? scope.row.upLimitRate : '--'}} / {{scope.row.downLimitRate ? scope.row.downLimitRate : '--'}}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column width="150px" align="center" :label="$t('table.createTime')">
|
||||
<template slot-scope="scope">
|
||||
<span>{{scope.row.createTime | parseTime('{y}-{m}-{d} {h}:{i}')}}</span>
|
||||
@@ -85,6 +90,12 @@
|
||||
<el-form-item :label="$t('License名称')" prop="name">
|
||||
<el-input v-model="temp.name"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('上传限速')" prop="upLimitRate">
|
||||
<el-input v-model="temp.upLimitRate" placeholder="如:10240B、500K、1M"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('下载限速')" prop="downLimitRate">
|
||||
<el-input v-model="temp.downLimitRate" placeholder="如:10240B、500K、1M"></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogFormVisible = false">{{$t('table.cancel')}}</el-button>
|
||||
|
||||
@@ -39,17 +39,17 @@
|
||||
<span>{{ scope.row.userName }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" :label="$t('table.licenseName')" width="130">
|
||||
<el-table-column align="center" :label="$t('table.licenseName')" width="120">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ scope.row.licenseName }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" :label="$t('table.protocalName')" width="100">
|
||||
<el-table-column align="center" :label="$t('table.protocalName')" width="80">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ scope.row.protocal }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" :label="$t('table.domainName')" width="200">
|
||||
<el-table-column align="center" :label="$t('table.domainName')" width="180">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ scope.row.domain }}</span>
|
||||
</template>
|
||||
@@ -64,17 +64,22 @@
|
||||
<span>{{ scope.row.clientIp }}:{{ scope.row.clientPort }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" :label="$t('限速')" width="100">
|
||||
<template slot-scope="scope">
|
||||
<span>{{scope.row.upLimitRate ? scope.row.upLimitRate : '--'}} / {{scope.row.downLimitRate ? scope.row.downLimitRate : '--'}}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" :label="$t('table.desc')" width="120">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ scope.row.description }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column width="150px" align="center" :label="$t('table.createTime')">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ scope.row.createTime | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- <el-table-column width="150px" align="center" :label="$t('table.createTime')">-->
|
||||
<!-- <template slot-scope="scope">-->
|
||||
<!-- <span>{{ scope.row.createTime | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>-->
|
||||
<!-- </template>-->
|
||||
<!-- </el-table-column>-->
|
||||
<el-table-column width="150px" align="center" :label="$t('table.updateTime')">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ scope.row.updateTime | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
|
||||
@@ -99,8 +104,7 @@
|
||||
<template slot-scope="scope">
|
||||
<el-button type="primary" size="mini" @click="handleUpdate(scope.row)">{{ $t('table.edit') }}</el-button>
|
||||
<el-button v-if="scope.row.enable == '1'" size="mini" type="danger" @click="handleModifyStatus(scope.row, 2)">{{$t('table.disable')}}</el-button>
|
||||
<el-button v-if="scope.row.enable == '2'" size="mini" type="success"
|
||||
@click="handleModifyStatus(scope.row, 1)">{{ $t('table.enable') }}</el-button>
|
||||
<el-button v-if="scope.row.enable == '2'" size="mini" type="success" @click="handleModifyStatus(scope.row, 1)">{{ $t('table.enable') }}</el-button>
|
||||
<!-- <el-button size="mini" type="danger" @click="handleDelete(scope.row,'deleted')">{{$t('table.delete')}}</el-button>-->
|
||||
<ButtonPopover @handleCommitClick="handleDelete2(scope.row)" style="margin-left: 10px" />
|
||||
|
||||
@@ -176,6 +180,18 @@
|
||||
<template slot="append">毫秒</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('table.securityGroup')" prop="securityGroup">
|
||||
<el-select style="width: 280px;" class="filter-item" v-model="temp.securityGroupId" clearable >
|
||||
<el-option v-for="item in securityGroupList" :key="item.id" :label="item.name" :value="item.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('上传限速')" prop="upLimitRate">
|
||||
<el-input v-model="temp.upLimitRate" placeholder="如:10240B、500K、1M"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('下载限速')" prop="downLimitRate">
|
||||
<el-input v-model="temp.downLimitRate" placeholder="如:10240B、500K、1M"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('描述')" prop="description">
|
||||
<el-input v-model="temp.description"></el-input>
|
||||
</el-form-item>
|
||||
@@ -204,6 +220,7 @@
|
||||
|
||||
<script>
|
||||
import { fetchList, createUserPortMapping, updateUserPortMapping, updateEnableStatus, deletePortMapping } from '@/api/portMapping'
|
||||
import { fetchGroupList } from '@/api/securityGroup'
|
||||
import { availablePortList, portAvailable } from '@/api/portPool'
|
||||
import { licenseList, licenseAuthList } from '@/api/license'
|
||||
import { protocalList } from '@/api/protocal'
|
||||
@@ -325,6 +342,7 @@ export default {
|
||||
licenseId:null,
|
||||
},
|
||||
more: true,
|
||||
securityGroupList: []
|
||||
}
|
||||
},
|
||||
filters: {
|
||||
@@ -359,6 +377,7 @@ export default {
|
||||
this.getLicenseList()
|
||||
this.getLicenseAuthList()
|
||||
this.getProtocalList()
|
||||
this.fetchSecurityGroupList()
|
||||
},
|
||||
methods: {
|
||||
getList() {
|
||||
@@ -380,6 +399,13 @@ export default {
|
||||
this.getList()
|
||||
})
|
||||
},
|
||||
fetchSecurityGroupList () {
|
||||
fetchGroupList().then(res => {
|
||||
if(res.data.code == 0) {
|
||||
this.securityGroupList = res.data.data
|
||||
}
|
||||
})
|
||||
},
|
||||
getDomainNameBindInfo() {
|
||||
domainNameBindInfo().then(response => {
|
||||
this.domainName = response.data.data
|
||||
@@ -484,6 +510,9 @@ export default {
|
||||
},
|
||||
handleUpdate(row) {
|
||||
this.temp = Object.assign({}, row) // copy obj
|
||||
if (row.securityGroupId === 0) {
|
||||
this.temp.securityGroupId = null
|
||||
}
|
||||
this.temp.timestamp = new Date(this.temp.timestamp)
|
||||
this.dialogStatus = 'update'
|
||||
this.dialogFormVisible = true
|
||||
|
||||
@@ -0,0 +1,463 @@
|
||||
<template>
|
||||
<div class="app-container calendar-list-container">
|
||||
<div class="filter-container">
|
||||
<el-input v-model="listQuery.name" style="width:145px;margin-right:10px" placeholder="请输入名称" />
|
||||
<el-input v-model="listQuery.description" style="width:145px;margin-right:10px" placeholder="请输入描述" />
|
||||
<el-select v-model="listQuery.defaultPassType" placeholder="请选择默认放行类型" clearable style="width:145px;margin-right:10px">
|
||||
<el-option v-for="item in selectObj.passType" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
<el-select v-model="listQuery.enable" placeholder="请选择启用状态" clearable style="width:145px;margin-right:10px">
|
||||
<el-option v-for="item in selectObj.statusOptions" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
<el-button class="filter-item" type="primary" v-waves icon="el-icon-search" @click="handleFilter">{{
|
||||
$t('table.search') }}
|
||||
</el-button>
|
||||
<el-button class="filter-item" style="margin-left: 10px;" @click="handleCreate" type="primary" icon="el-icon-edit">{{$t('table.add')}}</el-button>
|
||||
</div>
|
||||
|
||||
<el-table :key='tableKey' :data="list" v-loading="listLoading" element-loading-text="给我一点时间" border fit highlight-current-row
|
||||
style="width: 100%">
|
||||
<!-- <el-table-column align="center" width="40" type="selection" /> -->
|
||||
<el-table-column align="center" :label="$t('table.id')" width="60">
|
||||
<template slot-scope="scope">
|
||||
<span>{{scope.row.id}}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" :label="$t('table.name')">
|
||||
<template slot-scope="scope">
|
||||
<span>{{scope.row.name}}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" :label="$t('table.desc')">
|
||||
<template slot-scope="scope">
|
||||
<span>{{scope.row.description}}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" :label="$t('table.defaultPassType')">
|
||||
<template slot-scope="scope">
|
||||
<el-tag :type="scope.row.defaultPassType | passTypeFilter">{{ scope.row.defaultPassType | passTypeName }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" :label="$t('table.createTime')">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ scope.row.createTime | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" :label="$t('table.updateTime')">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ scope.row.updateTime | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column class-name="status-col" :label="$t('table.enableStatus')">
|
||||
<template slot-scope="scope">
|
||||
<el-tag :type="scope.row.enable | statusFilter">{{ scope.row.enable | statusName }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" :label="$t('table.actions')" class-name="small-padding fixed-width" style="display:flex;justify-content:center">
|
||||
<template slot-scope="scope">
|
||||
<div >
|
||||
<el-link :underline="false" type="primary" size="mini" @click="handleGoRulePage(scope.row)" style="font-size: 12px">{{$t('table.ruleConfig')}}</el-link>
|
||||
<el-link :underline="false" type="primary" size="mini" @click="handleUpdate(scope.row)" style="font-size: 12px">{{$t('table.edit')}}</el-link>
|
||||
<el-link :underline="false" v-if="scope.row.enable =='1'" size="mini" type="warning" @click="handleModifyStatus(scope.row, 2)" style="font-size: 12px">{{$t('table.disable')}}</el-link>
|
||||
<el-link :underline="false" v-if="scope.row.enable =='2'" size="mini" type="success" @click="handleModifyStatus(scope.row, 1)" style="font-size: 12px">{{$t('table.enable')}}</el-link>
|
||||
</div>
|
||||
<el-dropdown>
|
||||
<span class="el-dropdown-link" style="font-size: 12px">
|
||||
更多操作<i class="el-icon-arrow-down el-icon--right"></i>
|
||||
</span>
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item>
|
||||
<LinkPopover @handleCommitClick="handleDelete(scope.row)" style="width: 100%"/>
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item>
|
||||
<el-link :underline="false" type="primary" size="mini" @click="handlePortMapping(scope.row)" style="font-size: 12px">{{$t('table.securityGroupBindPortMapping')}}</el-link>
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<div class="pagination-container">
|
||||
<el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
|
||||
:current-pageInfo.sync="listQuery.current" :pageInfo-sizes="[10, 20, 30, 50]" :pageInfo-size="listQuery.size"
|
||||
layout="total, sizes, prev, pager, next, jumper" :total="total">
|
||||
</el-pagination>
|
||||
</div>
|
||||
|
||||
<el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible">
|
||||
<el-form :rules="rules" ref="dataForm" :model="temp" label-position="right" label-width="120px" style='width: 500px; margin-left:10px;'>
|
||||
<el-form-item :label="$t('table.name')" prop="name">
|
||||
<el-input :placeholder="$t('table.name')" v-model="temp.name"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item :label="$t('table.desc')" prop="desc">
|
||||
<el-input type="textarea" :autosize="{ minRows: 2, maxRows: 4}" :placeholder="$t('table.desc')" v-model="temp.description"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item :label="$t('table.defaultPassType')" prop="defaultPassType">
|
||||
<el-tooltip class="item" effect="dark" content="当IP地址不能匹配任何规则时,默认执行的放行类型" placement="bottom">
|
||||
<el-select style="width: 380px" class="filter-item" v-model="temp.defaultPassType" :disabled="dialogStatus === 'update'">
|
||||
<el-option v-for="item in passTypeList" :key="item.key" :label="item.key" :value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-tooltip>
|
||||
</el-form-item>
|
||||
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogFormVisible = false">{{$t('table.cancel')}}</el-button>
|
||||
<el-button v-if="dialogStatus=='create'" type="primary" @click="createData">{{$t('table.confirm')}}</el-button>
|
||||
<el-button v-else type="primary" @click="updateData">{{$t('table.confirm')}}</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog title="Reading statistics" :visible.sync="dialogPvVisible">
|
||||
<el-table :data="pvData" border fit highlight-current-row style="width: 100%">
|
||||
<el-table-column prop="key" label="Channel"> </el-table-column>
|
||||
<el-table-column prop="pv" label="Pv"> </el-table-column>
|
||||
</el-table>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="dialogPvVisible = false">{{$t('table.confirm')}}</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog :title="$t('table.securityGroupBindPortMapping')+'---'+forBindProtMappingSecurityGroup.name+'安全组'" :visible.sync="dialogBindPortMappingVisible" width="90%">
|
||||
<el-table :key='tableKey' :data="portMappingList" v-loading="listLoading" element-loading-text="给我一点时间" border width="100%"
|
||||
highlight-current-row style="width: 100%">
|
||||
<el-table-column align="center" :label="$t('table.id')" width="50">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ scope.row.id }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" :label="$t('table.licenseName')">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ scope.row.licenseName }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" :label="$t('table.protocalName')" width="120">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ scope.row.protocal }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" :label="$t('table.domainName')">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ scope.row.domain }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" :label="$t('table.serverPort')" width="100">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ scope.row.serverPort }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" :label="$t('table.proxyClient')" width="200">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ scope.row.clientIp }}:{{ scope.row.clientPort }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" :label="$t('table.desc')" width="120">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ scope.row.description }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column class-name="status-col" :label="$t('table.enableStatus')" width="120">
|
||||
<template slot-scope="scope">
|
||||
<el-tag :type="scope.row.enable | statusFilter">{{ scope.row.enable | statusName }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" :label="$t('table.actions')" width="150" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="primary" size="mini" v-if="!scope.row.securityGroupId" @click="handleBind(scope.row)">{{$t('table.bind')}}</el-button>
|
||||
<el-button type="danger" size="mini" v-if="scope.row.securityGroupId && scope.row.securityGroupId == forBindProtMappingSecurityGroup.id" @click="handleUnbind(scope.row)">{{$t('table.unbind')}}</el-button>
|
||||
<span v-if="scope.row.securityGroupId && scope.row.securityGroupId != forBindProtMappingSecurityGroup.id" style="font-size: 12px;">{{$t('table.bindOtherSecurityGroup')}}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<div class="pagination-container">
|
||||
<el-pagination background @size-change="handlePortMappingSizeChange" @current-change="handlePortMappingCurrentChange"
|
||||
:current-pageInfo.sync="portMappingListQuery.current" :pageInfo-sizes="[10, 20, 30, 50]" :pageInfo-size="portMappingListQuery.size"
|
||||
layout="total, sizes, prev, pager, next, jumper" :total="portMappingTotal">
|
||||
</el-pagination>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {fetchGroupPage, createGroup, updateGroup, deleteGroup, updateGroupEnableStatus} from '@/api/securityGroup'
|
||||
import { fetchList as fetchPortMappingList, portMappingBindSecurityGroup, portMappingUnbindSecurityGroup} from '@/api/portMapping'
|
||||
import waves from '@/directive/waves' // 水波纹指令
|
||||
import { parseTime } from '@/utils'
|
||||
import LinkPopover from '../../components/Link/linkPopover'
|
||||
|
||||
export default {
|
||||
name: 'complexTable',
|
||||
directives: {
|
||||
waves
|
||||
},
|
||||
components: {
|
||||
LinkPopover
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
tableKey: 0,
|
||||
list: [],
|
||||
total: null,
|
||||
listQuery: {
|
||||
current: 1,
|
||||
size: 10,
|
||||
name: undefined,
|
||||
description: undefined,
|
||||
defaultPassType: undefined,
|
||||
enable: undefined
|
||||
},
|
||||
listLoading: true,
|
||||
temp: {
|
||||
id: undefined,
|
||||
name: '',
|
||||
description: '',
|
||||
defaultPassType: undefined
|
||||
},
|
||||
selectObj: {
|
||||
statusOptions: [{ label: '启用', value: 1 }, { label: '禁用', value: 2 }],
|
||||
onlineOptions: [{ label: '在线', value: 1 }, { label: '离线', value: 2 }],
|
||||
passType: [{ label: '允许', value: 1 }, { label: '拒绝', value: 0 }]
|
||||
|
||||
},
|
||||
dialogFormVisible: false,
|
||||
dialogStatus: '',
|
||||
textMap: {
|
||||
update: '编辑',
|
||||
create: '新建'
|
||||
},
|
||||
passTypeList: [{key: '允许', value: 1}, {key: '拒绝', value: 0}],
|
||||
dialogPvVisible: false,
|
||||
pvData: [],
|
||||
rules: {
|
||||
name: [{ required: true, message: '安全组名称必填', trigger: 'blur' }],
|
||||
defaultPassType: [{ required: true, message: '默认放行类型必选', trigger: 'blur' }]
|
||||
},
|
||||
downloadLoading: false,
|
||||
checkBoxData:[], //表单勾选的行
|
||||
dialogBindPortMappingVisible: false,
|
||||
forBindProtMappingSecurityGroup: {},
|
||||
portMappingList: [],
|
||||
portMappingTotal: null,
|
||||
portMappingListLoading: false,
|
||||
portMappingListQuery: {
|
||||
current: 1,
|
||||
size: 10,
|
||||
importance: undefined,
|
||||
title: undefined,
|
||||
type: undefined,
|
||||
userId: undefined,
|
||||
license: undefined,
|
||||
port: undefined,
|
||||
isOnline: undefined,
|
||||
enable: undefined,
|
||||
description: undefined
|
||||
},
|
||||
}
|
||||
},
|
||||
filters: {
|
||||
passTypeName(type) {
|
||||
const statusMap = {
|
||||
1: '允许',
|
||||
0: '拒绝'
|
||||
}
|
||||
return statusMap[type]
|
||||
},
|
||||
passTypeFilter(type) {
|
||||
const statusMap = {
|
||||
1: 'success',
|
||||
0: 'danger'
|
||||
}
|
||||
return statusMap[type]
|
||||
},
|
||||
statusName(status) {
|
||||
const statusMap = {
|
||||
1: '启用',
|
||||
2: '禁用'
|
||||
}
|
||||
return statusMap[status]
|
||||
},
|
||||
statusFilter(status) {
|
||||
const statusMap = {
|
||||
1: 'success',
|
||||
2: 'danger'
|
||||
}
|
||||
return statusMap[status]
|
||||
},
|
||||
typeFilter(type) {
|
||||
return calendarTypeKeyValue[type]
|
||||
}
|
||||
},
|
||||
created() {
|
||||
// eslint-disable-next-line no-sequences
|
||||
this.getList()
|
||||
this.getPortMappingList()
|
||||
},
|
||||
methods: {
|
||||
getList() {
|
||||
this.listLoading = true
|
||||
fetchGroupPage(this.listQuery).then(response => {
|
||||
this.list = response.data.data.records
|
||||
this.total = response.data.data.total
|
||||
this.listLoading = false
|
||||
})
|
||||
},
|
||||
handleFilter() {
|
||||
this.listQuery.current = 1
|
||||
this.getList()
|
||||
},
|
||||
handleSizeChange(val) {
|
||||
this.listQuery.size = val
|
||||
this.getList()
|
||||
},
|
||||
handleCurrentChange(val) {
|
||||
this.listQuery.current = val
|
||||
this.getList()
|
||||
},
|
||||
getPortMappingList() {
|
||||
this.portMappingListLoading = true
|
||||
fetchPortMappingList(this.portMappingListQuery).then(response => {
|
||||
this.portMappingList = response.data.data.records
|
||||
this.portMappingTotal = response.data.data.total
|
||||
this.portMappingListQuery.current = response.data.data.current
|
||||
this.portMappingListLoading = false
|
||||
})
|
||||
},
|
||||
handleModifyStatus(row, enable) {
|
||||
updateGroupEnableStatus(row.id, enable).then(response => {
|
||||
if (response.data.data.code === 0) {
|
||||
this.$message({
|
||||
message: '操作成功',
|
||||
type: 'success'
|
||||
})
|
||||
}
|
||||
this.getList()
|
||||
})
|
||||
},
|
||||
resetTemp() {
|
||||
this.temp = {
|
||||
id: undefined,
|
||||
name: '',
|
||||
description: '',
|
||||
defaultPassType: undefined
|
||||
}
|
||||
},
|
||||
handleCreate() {
|
||||
this.resetTemp()
|
||||
this.dialogStatus = 'create'
|
||||
this.dialogFormVisible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs['dataForm'].clearValidate()
|
||||
})
|
||||
},
|
||||
createData() {
|
||||
this.$refs['dataForm'].validate((valid) => {
|
||||
if (valid) {
|
||||
createGroup(this.temp).then(response => {
|
||||
if (response.data.code === 0) {
|
||||
this.dialogFormVisible = false
|
||||
this.$notify({
|
||||
title: '成功',
|
||||
message: '创建成功',
|
||||
type: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
this.getList()
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
handleUpdate(row) {
|
||||
this.temp = Object.assign({}, row) // copy obj
|
||||
// this.temp.timestamp = new Date(this.temp.timestamp)
|
||||
this.dialogStatus = 'update'
|
||||
this.dialogFormVisible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs['dataForm'].clearValidate()
|
||||
})
|
||||
},
|
||||
updateData() {
|
||||
this.$refs['dataForm'].validate((valid) => {
|
||||
if (valid) {
|
||||
const tempData = Object.assign({}, this.temp)
|
||||
updateGroup(tempData).then(response => {
|
||||
if (response.data.code === 0) {
|
||||
this.$notify({
|
||||
title: '成功',
|
||||
message: '更新成功',
|
||||
type: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
this.dialogFormVisible = false
|
||||
this.getList()
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
handleDelete(row) {
|
||||
deleteGroup({groupId: row.id}).then(response => {
|
||||
if (response.data.code === 0) {
|
||||
this.$notify({
|
||||
title: '成功',
|
||||
message: '删除成功',
|
||||
type: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
this.getList()
|
||||
}
|
||||
})
|
||||
},
|
||||
handleGoRulePage (row) {
|
||||
this.$router.push({ path: '/system/securityRule', query: { groupId: row.id }})
|
||||
|
||||
// this.$router.push(`/system/securityRule?groupId=${row.id}`)
|
||||
},
|
||||
handlePortMapping(row) {
|
||||
this.dialogBindPortMappingVisible = true
|
||||
this.forBindProtMappingSecurityGroup = row
|
||||
},
|
||||
handlePortMappingSizeChange(val) {
|
||||
this.portMappingListQuery.size = val
|
||||
this.getPortMappingList()
|
||||
},
|
||||
handlePortMappingCurrentChange(val) {
|
||||
this.portMappingListQuery.current = val
|
||||
this.getPortMappingList()
|
||||
},
|
||||
handleBind(portMapping) {
|
||||
portMappingBindSecurityGroup(portMapping.id, this.forBindProtMappingSecurityGroup.id).then(response => {
|
||||
if (response.data.code === 0) {
|
||||
this.$notify({
|
||||
title: '成功',
|
||||
message: '绑定成功',
|
||||
type: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
this.getPortMappingList()
|
||||
}
|
||||
})
|
||||
},
|
||||
handleUnbind(portMapping) {
|
||||
portMappingUnbindSecurityGroup(portMapping.id).then(response => {
|
||||
if (response.data.code === 0) {
|
||||
this.$notify({
|
||||
title: '成功',
|
||||
message: '解绑成功',
|
||||
type: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
this.getPortMappingList()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,419 @@
|
||||
<template>
|
||||
<div class="app-container calendar-list-container">
|
||||
|
||||
<div>
|
||||
<div style="text-align: center;line-height:48px;font-size:24px">{{group.name}}安全组</div>
|
||||
<div style="text-align: center;font-size:14px; color: #606266">{{group.description}}</div>
|
||||
</div>
|
||||
|
||||
<div class="filter-container">
|
||||
<el-input v-model="listQuery.name" style="width:145px;margin-right:10px" placeholder="请输入名称" />
|
||||
<el-input v-model="listQuery.description" style="width:145px;margin-right:10px" placeholder="请输入描述" />
|
||||
<!-- <el-select v-model="listQuery.passType" placeholder="请选择默认放行类型" clearable style="width:145px;margin-right:10px">-->
|
||||
<!-- <el-option v-for="item in selectObj.passType" :key="item.value" :label="item.label" :value="item.value" />-->
|
||||
<!-- </el-select>-->
|
||||
<el-select v-model="listQuery.enable" placeholder="请选择启用状态" clearable style="width:145px;margin-right:10px">
|
||||
<el-option v-for="item in selectObj.statusOptions" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
<el-button class="filter-item" type="primary" v-waves icon="el-icon-search" @click="handleFilter">{{
|
||||
$t('table.search') }}
|
||||
</el-button>
|
||||
<el-button class="filter-item" @click="handleCreate" type="primary" icon="el-icon-edit">{{$t('table.add')}}</el-button>
|
||||
</div>
|
||||
|
||||
<el-table :key='tableKey' :data="list" v-loading="listLoading" element-loading-text="给我一点时间" border fit highlight-current-row
|
||||
style="width: 100%">
|
||||
<!-- <el-table-column align="center" width="40" type="selection" /> -->
|
||||
<el-table-column align="center" :label="$t('table.id')" width="60">
|
||||
<template slot-scope="scope">
|
||||
<span>{{scope.row.id}}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" :label="$t('table.ruleName')">
|
||||
<template slot-scope="scope">
|
||||
<span>{{scope.row.name}}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" :label="$t('table.desc')">
|
||||
<template slot-scope="scope">
|
||||
<span>{{scope.row.description}}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" :label="$t('table.rule')">
|
||||
<template slot-scope="scope">
|
||||
<span>{{scope.row.rule}}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" :label="$t('table.passType')">
|
||||
<template slot-scope="scope">
|
||||
<el-tag :type="scope.row.passType | passTypeFilter">{{ scope.row.passType | passTypeName }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- <el-table-column align="center" :label="$t('table.priority')">-->
|
||||
<!-- <template slot-scope="scope">-->
|
||||
<!-- <span>{{scope.row.priority}}</span>-->
|
||||
<!-- </template>-->
|
||||
<!-- </el-table-column>-->
|
||||
<el-table-column align="center" :label="$t('table.createTime')">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ scope.row.createTime | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" :label="$t('table.updateTime')">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ scope.row.updateTime | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column class-name="status-col" :label="$t('table.enableStatus')" width="150">
|
||||
<template slot-scope="scope">
|
||||
<el-tag :type="scope.row.enable | statusFilter">{{ scope.row.enable | statusName }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" :label="$t('table.actions')" width="250" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-link type="primary" :underline="false" size="mini" @click="handleUpdate(scope.row)" style="font-size:12px">{{$t('table.edit')}}</el-link>
|
||||
<el-link :underline="false" v-if="scope.row.enable =='1'" size="mini" type="warning" @click="handleModifyStatus(scope.row, 2)" style="font-size:12px">{{$t('table.disable')}}</el-link>
|
||||
<el-link :underline="false" v-if="scope.row.enable =='2'" size="mini" type="success" @click="handleModifyStatus(scope.row, 1)" style="font-size:12px">{{$t('table.enable')}}</el-link>
|
||||
<LinkPopover @handleCommitClick="handleDelete(scope.row)"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<div class="pagination-container">
|
||||
<el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
|
||||
:current-pageInfo.sync="listQuery.current" :pageInfo-sizes="[10, 20, 30, 50]" :pageInfo-size="listQuery.size"
|
||||
layout="total, sizes, prev, pager, next, jumper" :total="total">
|
||||
</el-pagination>
|
||||
</div>
|
||||
|
||||
<el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible" top="4vh">
|
||||
<el-form :rules="rules" ref="dataForm" :model="temp" label-position="right" label-width="100px" style='margin-left:50px;margin-right: 150px'>
|
||||
<el-form-item :label="$t('table.name')" prop="name">
|
||||
<el-input :placeholder="$t('table.name')" v-model="temp.name"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item :label="$t('table.desc')" prop="desc">
|
||||
<el-input type="textarea" :autosize="{ minRows: 2, maxRows: 4}" :placeholder="$t('table.desc')" v-model="temp.description"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item :label="$t('table.rule')" prop="rule">
|
||||
<el-input type="textarea" :autosize="{ minRows: 4, maxRows: 10}" :placeholder="$t('table.rule')" v-model="temp.rule"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<div style="line-height: 28px; color: cornflowerblue">
|
||||
<div>规则描述:</div>
|
||||
<div>单个ip:192.168.1.1, AA22:BB11:1122:CDEF:1234:AA99:7654:7410, ipv6只支持单个ip判断</div>
|
||||
<div>范围类型:192.168.1.0-192.168.1.255</div>
|
||||
<div>掩码类型:192.168.1.0/24</div>
|
||||
<div>泛型:0.0.0.0/ALL</div>
|
||||
<div>每个类型中间以英文逗号分隔,形如 192.168.1.1,192.168.3.0/24 是正确的 </div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
|
||||
|
||||
<el-form-item :label="$t('table.passType')" prop="passType">
|
||||
<el-tooltip class="item" effect="dark" :content="temp.passTypeTooltip" placement="right">
|
||||
<!-- <el-button>右边</el-button> -->
|
||||
<el-select class="filter-item" v-model="temp.passType" disabled>
|
||||
<el-option v-for="item in passTypeList" :key="item.key" :label="item.key" :value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-tooltip>
|
||||
|
||||
</el-form-item>
|
||||
|
||||
<!-- <el-form-item :label="$t('table.priority')" prop="priority">
|
||||
<el-input-number v-model="temp.priority" :min="1" :max="1000" :placeholder="$t('table.priority')"></el-input-number>
|
||||
</el-form-item> -->
|
||||
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogFormVisible = false">{{$t('table.cancel')}}</el-button>
|
||||
<el-button v-if="dialogStatus=='create'" type="primary" @click="createData">{{$t('table.confirm')}}</el-button>
|
||||
<el-button v-else type="primary" @click="updateData">{{$t('table.confirm')}}</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog title="Reading statistics" :visible.sync="dialogPvVisible">
|
||||
<el-table :data="pvData" border fit highlight-current-row style="width: 100%">
|
||||
<el-table-column prop="key" label="Channel"> </el-table-column>
|
||||
<el-table-column prop="pv" label="Pv"> </el-table-column>
|
||||
</el-table>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="dialogPvVisible = false">{{$t('table.confirm')}}</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {fetchGroupDetail, fetchRulePage, createRule, updateRule, deleteRule, updateRuleEnableStatus} from '@/api/securityGroup'
|
||||
import waves from '@/directive/waves' // 水波纹指令
|
||||
import { parseTime } from '@/utils'
|
||||
import LinkPopover from '../../components/Link/linkPopover'
|
||||
|
||||
export default {
|
||||
name: 'complexTable',
|
||||
directives: {
|
||||
waves
|
||||
},
|
||||
components: {
|
||||
LinkPopover
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
groupId: 1,
|
||||
group: {},
|
||||
tableKey: 0,
|
||||
list: [],
|
||||
total: null,
|
||||
listQuery: {
|
||||
current: 1,
|
||||
size: 10,
|
||||
groupId: undefined,
|
||||
name: undefined,
|
||||
description: undefined,
|
||||
passType: undefined,
|
||||
enable: undefined
|
||||
},
|
||||
listLoading: true,
|
||||
temp: {
|
||||
id: undefined,
|
||||
groupId: undefined,
|
||||
name: '',
|
||||
description: '',
|
||||
rule: '',
|
||||
passType: undefined,
|
||||
passTypeTooltip: '',
|
||||
priority: 1
|
||||
},
|
||||
selectObj: {
|
||||
statusOptions: [{ label: '启用', value: 1 }, { label: '禁用', value: 2 }],
|
||||
onlineOptions: [{ label: '在线', value: 1 }, { label: '离线', value: 2 }],
|
||||
passType: [{ label: '允许', value: 1 }, { label: '拒绝', value: 2 }]
|
||||
|
||||
},
|
||||
dialogFormVisible: false,
|
||||
dialogStatus: '',
|
||||
textMap: {
|
||||
update: '编辑',
|
||||
create: '新建'
|
||||
},
|
||||
passTypeList: [{key: '允许', value: 1}, {key: '拒绝', value: 0}],
|
||||
dialogPvVisible: false,
|
||||
pvData: [],
|
||||
rules: {
|
||||
name: [{ required: true, message: '安全组名称必填', trigger: 'blur' }],
|
||||
rule: [{ required: true, message: '规则内容必填', trigger: 'blur' }],
|
||||
// passType: [{ required: true, message: '放行类型必选', trigger: 'blur' }],
|
||||
// priority: [{ required: true, message: '优先级必填', trigger: 'blur' }]
|
||||
},
|
||||
downloadLoading: false,
|
||||
checkBoxData:[], //表单勾选的行
|
||||
}
|
||||
},
|
||||
filters: {
|
||||
passTypeName(type) {
|
||||
const statusMap = {
|
||||
1: '允许',
|
||||
0: '拒绝'
|
||||
}
|
||||
return statusMap[type]
|
||||
},
|
||||
passTypeFilter(type) {
|
||||
const statusMap = {
|
||||
1: 'success',
|
||||
0: 'danger'
|
||||
}
|
||||
return statusMap[type]
|
||||
},
|
||||
statusName(status) {
|
||||
const statusMap = {
|
||||
1: '启用',
|
||||
2: '禁用'
|
||||
}
|
||||
return statusMap[status]
|
||||
},
|
||||
statusFilter(status) {
|
||||
const statusMap = {
|
||||
1: 'success',
|
||||
2: 'danger'
|
||||
}
|
||||
return statusMap[status]
|
||||
},
|
||||
typeFilter(type) {
|
||||
return calendarTypeKeyValue[type]
|
||||
}
|
||||
},
|
||||
created() {
|
||||
// eslint-disable-next-line no-sequences
|
||||
if (this.$route.query.groupId) {
|
||||
this.listQuery.groupId = this.$route.query.groupId
|
||||
} else {
|
||||
this.$notify({
|
||||
title: '错误',
|
||||
message: '没有获取到安全组信息',
|
||||
type: 'error',
|
||||
duration: 3000
|
||||
})
|
||||
this.$router.push(`/system/securityGroup`)
|
||||
return
|
||||
}
|
||||
this.getGroupDetail()
|
||||
this.getList()
|
||||
},
|
||||
methods: {
|
||||
getGroupDetail () {
|
||||
fetchGroupDetail({id: this.listQuery.groupId}).then(response => {
|
||||
this.group = response.data.data
|
||||
})
|
||||
},
|
||||
getList() {
|
||||
if (!this.listQuery.groupId) {
|
||||
this.$notify({
|
||||
title: '错误',
|
||||
message: '没有获取到安全组信息',
|
||||
type: 'error',
|
||||
duration: 3000
|
||||
})
|
||||
return
|
||||
}
|
||||
this.listLoading = true
|
||||
fetchRulePage(this.listQuery).then(response => {
|
||||
this.list = response.data.data.records
|
||||
this.total = response.data.data.total
|
||||
this.listLoading = false
|
||||
})
|
||||
},
|
||||
handleFilter() {
|
||||
this.listQuery.current = 1
|
||||
this.getList()
|
||||
},
|
||||
handleSizeChange(val) {
|
||||
this.listQuery.size = val
|
||||
this.getList()
|
||||
},
|
||||
handleCurrentChange(val) {
|
||||
this.listQuery.current = val
|
||||
this.getList()
|
||||
},
|
||||
handleEnableStatus(row) {
|
||||
enableRule(row.id).then(response => {
|
||||
if (response.data.code === 0) {
|
||||
this.$message({
|
||||
message: '操作成功',
|
||||
type: 'success'
|
||||
})
|
||||
this.getList()
|
||||
}
|
||||
})
|
||||
},
|
||||
handleDisableStatus(row) {
|
||||
disableRule(row.id).then(response => {
|
||||
if (response.data.code === 0) {
|
||||
this.$message({
|
||||
message: '操作成功',
|
||||
type: 'success'
|
||||
})
|
||||
this.getList()
|
||||
}
|
||||
})
|
||||
},
|
||||
handleModifyStatus(row, enable) {
|
||||
updateRuleEnableStatus(row.id, enable).then(response => {
|
||||
if (response.data.data.code === 0) {
|
||||
this.$message({
|
||||
message: '操作成功',
|
||||
type: 'success'
|
||||
})
|
||||
}
|
||||
this.getList()
|
||||
})
|
||||
},
|
||||
resetTemp() {
|
||||
this.temp = {
|
||||
id: undefined,
|
||||
groupId: this.listQuery.groupId,
|
||||
name: '',
|
||||
description: '',
|
||||
rule: '',
|
||||
passType: this.group.defaultPassType == 1 ? 0 : 1,
|
||||
passTypeTooltip: `安全组已设置默认${(this.group.defaultPassType == 1 ? '允许' : '拒绝')}`,
|
||||
priority: 1
|
||||
}
|
||||
},
|
||||
handleCreate() {
|
||||
this.resetTemp()
|
||||
this.dialogStatus = 'create'
|
||||
this.dialogFormVisible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs['dataForm'].clearValidate()
|
||||
})
|
||||
},
|
||||
createData() {
|
||||
this.$refs['dataForm'].validate((valid) => {
|
||||
if (valid) {
|
||||
this.temp.groupId = this.listQuery.groupId
|
||||
createRule(this.temp).then(response => {
|
||||
if (response.data.code === 0) {
|
||||
this.dialogFormVisible = false
|
||||
this.$notify({
|
||||
title: '成功',
|
||||
message: '创建成功',
|
||||
type: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
this.getList()
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
handleUpdate(row) {
|
||||
this.temp = Object.assign({}, row) // copy obj
|
||||
this.temp.passType = row.passType
|
||||
this.temp.passTypeTooltip = `安全组已设置默认${(this.group.defaultPassType == 1 ? '允许' : '拒绝')}`,
|
||||
this.temp.timestamp = new Date(this.temp.timestamp)
|
||||
this.dialogStatus = 'update'
|
||||
this.dialogFormVisible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs['dataForm'].clearValidate()
|
||||
})
|
||||
},
|
||||
updateData() {
|
||||
this.$refs['dataForm'].validate((valid) => {
|
||||
if (valid) {
|
||||
const tempData = Object.assign({}, this.temp)
|
||||
tempData.groupId = this.listQuery.groupId
|
||||
updateRule(tempData).then(response => {
|
||||
if (response.data.code === 0) {
|
||||
this.$notify({
|
||||
title: '成功',
|
||||
message: '更新成功',
|
||||
type: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
this.dialogFormVisible = false
|
||||
this.getList()
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
handleDelete(row) {
|
||||
deleteRule({ruleId: row.id}).then(response => {
|
||||
if (response.data.code === 0) {
|
||||
this.$notify({
|
||||
title: '成功',
|
||||
message: '删除成功',
|
||||
type: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
this.getList()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -1,12 +1,15 @@
|
||||
FROM openjdk:17-jdk-alpine
|
||||
FROM openjdk:21-jdk-oracle
|
||||
#同步时间
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && \
|
||||
apk update && apk add wget unzip vim && apk add -U tzdata && \
|
||||
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone
|
||||
#RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && \
|
||||
# apk update && apk add wget unzip vim && apk add -U tzdata && \
|
||||
# ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone
|
||||
# 设置时区为北京时间
|
||||
ENV TZ=Asia/Shanghai
|
||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||
RUN mkdir -p /root/neutrino-proxy/config
|
||||
WORKDIR /root/neutrino-proxy
|
||||
COPY ./target/neutrino-proxy-client.jar /root/neutrino-proxy/neutrino-proxy-client.jar
|
||||
COPY ./src/main/resources/app.yml /root/neutrino-proxy/config
|
||||
COPY ./src/main/resources/app-copy.yml /root/neutrino-proxy/config/app.yml
|
||||
#VOLUME ["/root/neutrino-proxy"]
|
||||
ENTRYPOINT ["java","-jar","neutrino-proxy-client.jar","config=./config/app.yml"]
|
||||
|
||||
|
||||
@@ -28,6 +28,13 @@
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
<includes>
|
||||
<include>*.yml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>${project.basedir}/src/main/resources</directory>
|
||||
<filtering>false</filtering>
|
||||
|
||||
+3
-1
@@ -28,7 +28,9 @@ public class ProxyClient {
|
||||
setAlias("neutrino.proxy.tunnel.jks-path", "jksPath");
|
||||
setAlias("neutrino.proxy.tunnel.key-store-password", "keyStorePassword");
|
||||
setAlias("neutrino.proxy.tunnel.license-key", "licenseKey");
|
||||
});
|
||||
|
||||
log.info("NeutrinoProxy Client :{}", app.cfg().get("solon.app.version"));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
solon.logging.logger:
|
||||
"root":
|
||||
level: info
|
||||
|
||||
neutrino:
|
||||
proxy:
|
||||
tunnel:
|
||||
# 线程池相关配置,用于技术调优,可忽略
|
||||
thread-count: 50
|
||||
# 隧道SSL证书配置
|
||||
key-store-password: 123456
|
||||
jks-path: classpath:/test.jks
|
||||
# 服务端IP
|
||||
server-ip: localhost
|
||||
# 服务端端口(对应服务端app.yml中的tunnel.port、tunnel.ssl-port)
|
||||
server-port: 9002
|
||||
# 是否启用SSL(注意:该配置必须和server-port对应上)
|
||||
ssl-enable: true
|
||||
# 客户端连接唯一凭证
|
||||
license-key:
|
||||
# 客户端唯一身份标识(可忽略,若不设置首次启动会自动生成)
|
||||
client-id:
|
||||
# 是否开启隧道传输报文日志(日志级别为debug时开启才有效)
|
||||
transfer-log-enable: false
|
||||
# 是否开启心跳日志
|
||||
heartbeat-log-enable: false
|
||||
# 重连设置
|
||||
reconnection:
|
||||
# 重连间隔(秒)
|
||||
interval-seconds: 10
|
||||
# 是否开启无限重连(未开启时,客户端license不合法会自动停止应用,开启了则不会,请谨慎开启)
|
||||
unlimited: false
|
||||
client:
|
||||
udp:
|
||||
# 线程池相关配置,用于技术调优,可忽略
|
||||
boss-thread-count: 5
|
||||
work-thread-count: 20
|
||||
# udp傀儡端口范围
|
||||
puppet-port-range: 10000-10500
|
||||
# 是否开启隧道传输报文日志(日志级别为debug时开启才有效)
|
||||
transfer-log-enable: false
|
||||
@@ -1,6 +1,9 @@
|
||||
solon:
|
||||
config:
|
||||
add: ./app.yml
|
||||
app:
|
||||
name: neutrino-proxy-client
|
||||
version: 2.0.1
|
||||
# 日志级别
|
||||
solon.logging.appender:
|
||||
console:
|
||||
@@ -13,6 +16,7 @@ solon.logging.appender:
|
||||
solon.logging.logger:
|
||||
"root":
|
||||
level: info
|
||||
|
||||
neutrino:
|
||||
application:
|
||||
name: neutrino-proxy-client
|
||||
|
||||
@@ -30,10 +30,10 @@
|
||||
<artifactId>hutool-core</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
<!--lombok-->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-cache</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
@@ -49,6 +49,10 @@ public interface Constants {
|
||||
AttributeKey<Boolean> IS_UDP_KEY = AttributeKey.newInstance("isUdp");
|
||||
AttributeKey<InetSocketAddress> SENDER = AttributeKey.newInstance("sender");
|
||||
|
||||
AttributeKey<Integer> SERVER_PORT = AttributeKey.newInstance("serverPort");
|
||||
|
||||
AttributeKey<Boolean> FLOW_LIMITER_FLAG = AttributeKey.newInstance("flowLimiterFlag");
|
||||
|
||||
|
||||
int HEADER_SIZE = 4;
|
||||
int TYPE_SIZE = 1;
|
||||
|
||||
+11
-1
@@ -8,6 +8,7 @@ import org.noear.solon.aot.RuntimeNativeRegistrar;
|
||||
import org.noear.solon.aot.hint.MemberCategory;
|
||||
import org.noear.solon.core.AppContext;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@@ -22,9 +23,18 @@ public class NeutrinoCoreRuntimeNativeRegistrar implements RuntimeNativeRegistra
|
||||
metadata.registerReflection(clazz, MemberCategory.INVOKE_DECLARED_METHODS);
|
||||
}
|
||||
|
||||
Set<Class<?>> byteBufferClasses = ClassUtil.scanPackageBySuper("java", ByteBuffer.class);
|
||||
for (Class<?> clazz : byteBufferClasses) {
|
||||
metadata.registerReflection(clazz, MemberCategory.INVOKE_DECLARED_METHODS);
|
||||
}
|
||||
|
||||
metadata.registerReflection(ProxyMessage.class, MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_DECLARED_METHODS, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
|
||||
metadata.registerReflection(ProxyMessage.UdpBaseInfo.class, MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_DECLARED_METHODS, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
|
||||
|
||||
metadata.registerArg("--add-opens java.base/java.lang.invoke=ALL-UNNAMED --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED -march=compatibility");
|
||||
metadata.registerArg("-J--add-opens=java.base/java.lang.invoke=ALL-UNNAMED");
|
||||
metadata.registerArg("-J--add-opens=java.base/java.nio=ALL-UNNAMED");
|
||||
metadata.registerArg("-J--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED");
|
||||
|
||||
metadata.registerArg("-march=compatibility");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package org.dromara.neutrinoproxy.core.util;
|
||||
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* @author: wen.y
|
||||
* @date: 2023/12/9
|
||||
*/
|
||||
public class HttpUtil {
|
||||
|
||||
/**
|
||||
* 获取请求头 Host 忽略端口号
|
||||
* @param httpContent
|
||||
* @return
|
||||
*/
|
||||
public static String getHostIgnorePort(String httpContent) {
|
||||
String host = getHost(httpContent);
|
||||
if (StringUtils.isEmpty(host) || !host.contains(":")) {
|
||||
return host;
|
||||
}
|
||||
return host.replaceAll(":.*", "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取请求头 Host
|
||||
* @param httpContent
|
||||
* @return
|
||||
*/
|
||||
public static String getHost(String httpContent) {
|
||||
return getHeaderValue(httpContent, "Host");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取请求头
|
||||
* @param httpContent
|
||||
* @return
|
||||
*/
|
||||
public static String getHeaderValue(String httpContent, String header) {
|
||||
String headerContent = httpContent.split("\r\n\r\n")[0];
|
||||
String[] lines = headerContent.split("\r\n");
|
||||
String firstLine = lines[0];
|
||||
if (!(firstLine.endsWith("HTTP/1.1") || firstLine.endsWith("HTTP/1.0"))) {
|
||||
return null;
|
||||
}
|
||||
for (int i = 1; i < lines.length; i++) {
|
||||
String line = lines[i];
|
||||
if (!line.startsWith(header + ":")) {
|
||||
continue;
|
||||
}
|
||||
if (line.length() > header.length() + 1) {
|
||||
return line.substring(header.length() + 1).trim();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package org.dromara.neutrinoproxy.core.util;
|
||||
|
||||
import cn.hutool.core.net.Ipv4Util;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
public class IpUtil extends org.noear.solon.core.util.IpUtil {
|
||||
|
||||
public static String getRemoteIp(ChannelHandlerContext ctx) {
|
||||
String remoteAddress = "";
|
||||
InetSocketAddress socketAddress = (InetSocketAddress) ctx.channel().remoteAddress();
|
||||
if (socketAddress != null) {
|
||||
remoteAddress = socketAddress.getAddress().getHostAddress();
|
||||
}
|
||||
return remoteAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* 工作原理为从http协议的header中找公网地址,此主要用于处理nginx转发时塞进去的真实IP的header,找不到返回null
|
||||
* @param httpContent http协议文档内容
|
||||
* @return 返回找到的第一个公网地址
|
||||
*/
|
||||
public static String getRealRemoteIp(String httpContent) {
|
||||
String ip = HttpUtil.getHeaderValue(httpContent, "X-Forwarded-For");
|
||||
if (StringUtils.isEmpty(ip)) {
|
||||
ip = HttpUtil.getHeaderValue(httpContent, "X-Real-IP");
|
||||
}
|
||||
if (StringUtils.isNotEmpty(ip) && !Ipv4Util.isInnerIP(ip)) {
|
||||
return ip;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package org.dromara.neutrinoproxy.core.util;
|
||||
|
||||
import org.noear.solon.Solon;
|
||||
|
||||
/**
|
||||
* @author songyinyin
|
||||
* @since 2023/10/31 11:48
|
||||
*/
|
||||
public class NeutrinoProxyVersion {
|
||||
|
||||
/**
|
||||
* 获取 NeutrinoProxy 版本号
|
||||
*/
|
||||
public static String getVersion() {
|
||||
return Solon.cfg().get("solon.app.version");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,12 +1,15 @@
|
||||
FROM openjdk:17-jdk-alpine
|
||||
FROM openjdk:21-jdk-oracle
|
||||
#同步时间
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && \
|
||||
apk update && apk add wget unzip vim && apk add -U tzdata && \
|
||||
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone
|
||||
#RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && \
|
||||
# apk update && apk add wget unzip vim && apk add -U tzdata && \
|
||||
# ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone
|
||||
# 设置时区为北京时间
|
||||
ENV TZ=Asia/Shanghai
|
||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||
RUN mkdir -p /root/neutrino-proxy/config
|
||||
WORKDIR /root/neutrino-proxy
|
||||
COPY ./target/neutrino-proxy-server.jar /root/neutrino-proxy/neutrino-proxy-server.jar
|
||||
COPY ./src/main/resources/app.yml /root/neutrino-proxy/config
|
||||
COPY ./src/main/resources/app-copy.yml /root/neutrino-proxy/config/app.yml
|
||||
#VOLUME ["/root/neutrino-proxy"]
|
||||
ENTRYPOINT ["java","-jar","neutrino-proxy-server.jar","config=./config/app.yml"]
|
||||
|
||||
|
||||
@@ -61,6 +61,13 @@
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
<includes>
|
||||
<include>*.yml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>${project.basedir}/src/main/resources</directory>
|
||||
<filtering>false</filtering>
|
||||
|
||||
+1
-1
@@ -2,7 +2,6 @@ package org.dromara.neutrinoproxy.server;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.solonplugins.job.annotation.EnableJob;
|
||||
import org.noear.snack.core.utils.StringUtil;
|
||||
import org.noear.solon.Solon;
|
||||
import org.noear.solon.Utils;
|
||||
import org.noear.solon.annotation.SolonMain;
|
||||
@@ -26,6 +25,7 @@ public class ProxyServer {
|
||||
if (Utils.isNotEmpty(loglevel)) {
|
||||
app.cfg().put("solon.logging.logger.root.level", loglevel);
|
||||
}
|
||||
log.info("NeutrinoProxy Server :{}", app.cfg().get("solon.app.version"));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
+7
-22
@@ -3,28 +3,8 @@ package org.dromara.neutrinoproxy.server.base;
|
||||
import org.dromara.neutrinoproxy.server.base.proxy.ProxyConfig;
|
||||
import org.dromara.neutrinoproxy.server.base.rest.ResponseBody;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.report.HomeDataView;
|
||||
import org.dromara.neutrinoproxy.server.dal.ClientConnectRecordMapper;
|
||||
import org.dromara.neutrinoproxy.server.dal.FlowReportDayMapper;
|
||||
import org.dromara.neutrinoproxy.server.dal.FlowReportHourMapper;
|
||||
import org.dromara.neutrinoproxy.server.dal.FlowReportMinuteMapper;
|
||||
import org.dromara.neutrinoproxy.server.dal.FlowReportMonthMapper;
|
||||
import org.dromara.neutrinoproxy.server.dal.JobInfoMapper;
|
||||
import org.dromara.neutrinoproxy.server.dal.LicenseMapper;
|
||||
import org.dromara.neutrinoproxy.server.dal.PortMappingMapper;
|
||||
import org.dromara.neutrinoproxy.server.dal.PortPoolMapper;
|
||||
import org.dromara.neutrinoproxy.server.dal.UserLoginRecordMapper;
|
||||
import org.dromara.neutrinoproxy.server.dal.UserMapper;
|
||||
import org.dromara.neutrinoproxy.server.dal.UserTokenMapper;
|
||||
import org.dromara.neutrinoproxy.server.service.ClientConnectRecordService;
|
||||
import org.dromara.neutrinoproxy.server.service.JobInfoService;
|
||||
import org.dromara.neutrinoproxy.server.service.JobLogService;
|
||||
import org.dromara.neutrinoproxy.server.service.LicenseService;
|
||||
import org.dromara.neutrinoproxy.server.service.PortGroupService;
|
||||
import org.dromara.neutrinoproxy.server.service.PortMappingService;
|
||||
import org.dromara.neutrinoproxy.server.service.PortPoolService;
|
||||
import org.dromara.neutrinoproxy.server.service.ReportService;
|
||||
import org.dromara.neutrinoproxy.server.service.UserLoginRecordService;
|
||||
import org.dromara.neutrinoproxy.server.service.UserService;
|
||||
import org.dromara.neutrinoproxy.server.dal.*;
|
||||
import org.dromara.neutrinoproxy.server.service.*;
|
||||
import org.dromara.solonplugins.job.JobBean;
|
||||
import org.noear.solon.annotation.Component;
|
||||
import org.noear.solon.aot.RuntimeNativeMetadata;
|
||||
@@ -56,6 +36,8 @@ public class NeutrinoServerRuntimeNativeRegistrar implements RuntimeNativeRegist
|
||||
metadata.registerLambdaSerialization(ReportService.class);
|
||||
metadata.registerLambdaSerialization(UserLoginRecordService.class);
|
||||
metadata.registerLambdaSerialization(UserService.class);
|
||||
metadata.registerLambdaSerialization(SecurityGroupService.class);
|
||||
|
||||
|
||||
metadata.registerLambdaSerialization(LicenseMapper.class);
|
||||
metadata.registerLambdaSerialization(ClientConnectRecordMapper.class);
|
||||
@@ -69,6 +51,9 @@ public class NeutrinoServerRuntimeNativeRegistrar implements RuntimeNativeRegist
|
||||
metadata.registerLambdaSerialization(UserLoginRecordMapper.class);
|
||||
metadata.registerLambdaSerialization(UserMapper.class);
|
||||
metadata.registerLambdaSerialization(UserTokenMapper.class);
|
||||
metadata.registerLambdaSerialization(SecurityGroupMapper.class);
|
||||
metadata.registerLambdaSerialization(SecurityRuleMapper.class);
|
||||
|
||||
|
||||
metadata.registerReflection(HomeDataView.class, MemberCategory.DECLARED_FIELDS);
|
||||
metadata.registerReflection(HomeDataView.Last7dFlow.class, MemberCategory.DECLARED_FIELDS);
|
||||
|
||||
+4
-4
@@ -58,10 +58,10 @@ public class DBInitialize implements EventListener<AppLoadEndEvent> {
|
||||
|
||||
@Init
|
||||
public void init() throws Throwable {
|
||||
// // aot 阶段,不初始化数据库
|
||||
// if (NativeDetector.isAotRuntime()) {
|
||||
// return;
|
||||
// }
|
||||
// aot 阶段,不初始化数据库
|
||||
if (NativeDetector.isAotRuntime()) {
|
||||
return;
|
||||
}
|
||||
Assert.notNull(dbConfig.getType(), "neutrino.data.db.type不能为空!");
|
||||
dbTypeEnum = DbTypeEnum.of(dbConfig.getType());
|
||||
Assert.notNull(dbTypeEnum, "neutrino.data.db.type取值异常!");
|
||||
|
||||
+7
@@ -20,6 +20,9 @@ import io.netty.channel.nio.NioEventLoopGroup;
|
||||
import org.dromara.neutrinoproxy.server.proxy.core.BytesMetricsHandler;
|
||||
import org.dromara.neutrinoproxy.server.proxy.core.TcpVisitorChannelHandler;
|
||||
import org.dromara.neutrinoproxy.server.proxy.core.UdpVisitorChannelHandler;
|
||||
import org.dromara.neutrinoproxy.server.proxy.security.TcpVisitorSecurityChannelHandler;
|
||||
import org.dromara.neutrinoproxy.server.proxy.security.UdpVisitorSecurityChannelHandler;
|
||||
import org.dromara.neutrinoproxy.server.proxy.security.VisitorFlowLimiterChannelHandler;
|
||||
import org.noear.solon.Solon;
|
||||
import org.noear.solon.annotation.Bean;
|
||||
import org.noear.solon.annotation.Configuration;
|
||||
@@ -74,6 +77,8 @@ public class ProxyConfiguration implements LifecycleBean {
|
||||
}
|
||||
ch.pipeline().addFirst(new BytesMetricsHandler());
|
||||
// ch.pipeline().addLast(new ChannelTrafficShapingHandler(1024 * 1024 * 20, 1024 * 1024 * 20, 100, 20000));
|
||||
ch.pipeline().addLast(new TcpVisitorSecurityChannelHandler());
|
||||
ch.pipeline().addLast("flowLimiter", new VisitorFlowLimiterChannelHandler());
|
||||
ch.pipeline().addLast(new TcpVisitorChannelHandler());
|
||||
}
|
||||
});
|
||||
@@ -111,6 +116,8 @@ public class ProxyConfiguration implements LifecycleBean {
|
||||
if (null != proxyConfig.getServer().getUdp().getTransferLogEnable() && proxyConfig.getServer().getUdp().getTransferLogEnable()) {
|
||||
ch.pipeline().addFirst(new LoggingHandler(UdpVisitorChannelHandler.class));
|
||||
}
|
||||
pipeline.addLast(udpServerWorkerGroup, new UdpVisitorSecurityChannelHandler());
|
||||
ch.pipeline().addLast("flowLimiter", new VisitorFlowLimiterChannelHandler());
|
||||
pipeline.addLast(udpServerWorkerGroup, new UdpVisitorChannelHandler());
|
||||
}
|
||||
});
|
||||
|
||||
+7
-2
@@ -40,8 +40,8 @@ public enum ExceptionConstant {
|
||||
NO_PERMISSION_VISIT(5, "当前用户无权访问该资源"),
|
||||
PARAMS_NOT_NULL(10, "参数[{}]不能为空"),
|
||||
PARAMS_NOT_EMPTY(11, "参数[{}]不能为空"),
|
||||
|
||||
FILED_LENGTH_OUT(12 ,"{}不能超出长度{}"),
|
||||
BYTES_DESC_INVALID(13, "参数[{}]字节描述不合法"),
|
||||
|
||||
// 用户管理(11000)
|
||||
// license管理(12000)
|
||||
@@ -67,7 +67,12 @@ public enum ExceptionConstant {
|
||||
|
||||
PORT_GROUP_NAME_ALREADY_EXIST(16000,"端口分组名称[{}]已经存在"),
|
||||
PORT_GROUP_NAME_DOES_NOT_EXIST(16001,"端口分组不存在"),
|
||||
DEFAULT_GROUP_FORBID_DELETE(16002,"默认分组禁止删除")
|
||||
DEFAULT_GROUP_FORBID_DELETE(16002,"默认分组禁止删除"),
|
||||
|
||||
// 安全组管理(17000)
|
||||
SECURITY_GROUP_NOT_EXIST(17000, "安全组不存在"),
|
||||
SECURITY_RULE_NOT_EXIST(17001, "安全规则不存在"),
|
||||
|
||||
;
|
||||
|
||||
private int code;
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package org.dromara.neutrinoproxy.server.constant;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum SecurityRulePassTypeEnum {
|
||||
DENY(0, "deny"),
|
||||
ALLOW(1, "allow"),
|
||||
NONE(-1, "none")
|
||||
;
|
||||
|
||||
private final Integer type;
|
||||
private final String desc;
|
||||
}
|
||||
+4
@@ -70,6 +70,8 @@ public class LicenseController {
|
||||
ParamCheckUtil.checkNotNull(req, "req");
|
||||
ParamCheckUtil.checkNotEmpty(req.getName(), "name");
|
||||
ParamCheckUtil.checkNotNull(req.getUserId(), "userId");
|
||||
ParamCheckUtil.checkBytesDesc(req.getUpLimitRate(), "upLimitRate");
|
||||
ParamCheckUtil.checkBytesDesc(req.getDownLimitRate(), "downLimitRate");
|
||||
|
||||
return licenseService.create(req);
|
||||
}
|
||||
@@ -81,6 +83,8 @@ public class LicenseController {
|
||||
ParamCheckUtil.checkNotNull(req, "req");
|
||||
ParamCheckUtil.checkNotNull(req.getId(), "id");
|
||||
ParamCheckUtil.checkNotEmpty(req.getName(), "name");
|
||||
ParamCheckUtil.checkBytesDesc(req.getUpLimitRate(), "upLimitRate");
|
||||
ParamCheckUtil.checkBytesDesc(req.getDownLimitRate(), "downLimitRate");
|
||||
|
||||
return licenseService.update(req);
|
||||
}
|
||||
|
||||
+36
-2
@@ -13,6 +13,8 @@ import org.dromara.neutrinoproxy.server.util.ParamCheckUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.noear.solon.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 端口映射
|
||||
* @author: aoshiguchen
|
||||
@@ -41,6 +43,8 @@ public class PortMappingController {
|
||||
ParamCheckUtil.checkNotNull(req.getClientPort(), "clientPort");
|
||||
ParamCheckUtil.checkNotEmpty(req.getProtocal(), "protocal");
|
||||
ParamCheckUtil.checkMaxLength(req.getDescription(), 50, "描述", "50");
|
||||
ParamCheckUtil.checkBytesDesc(req.getUpLimitRate(), "upLimitRate");
|
||||
ParamCheckUtil.checkBytesDesc(req.getDownLimitRate(), "downLimitRate");
|
||||
if (StringUtils.isBlank(req.getClientIp())) {
|
||||
// 没传客户端ip,默认为127.0.0.1
|
||||
req.setClientIp("127.0.0.1");
|
||||
@@ -58,19 +62,24 @@ public class PortMappingController {
|
||||
if (null == req.getProxyTimeoutMs()) {
|
||||
req.setProxyTimeoutMs(0L);
|
||||
}
|
||||
if (null == req.getSecurityGroupId()) {
|
||||
req.setSecurityGroupId(0);
|
||||
}
|
||||
|
||||
return portMappingService.create(req);
|
||||
}
|
||||
|
||||
@Post
|
||||
@Mapping("/update")
|
||||
public PortMappingUpdateRes update(PortMappingUpdateReq req) {
|
||||
public void update(PortMappingUpdateReq req) {
|
||||
ParamCheckUtil.checkNotNull(req, "req");
|
||||
ParamCheckUtil.checkNotNull(req.getLicenseId(), "licenseId");
|
||||
ParamCheckUtil.checkNotNull(req.getServerPort(), "serverPort");
|
||||
ParamCheckUtil.checkNotNull(req.getClientPort(), "clientPort");
|
||||
ParamCheckUtil.checkNotEmpty(req.getProtocal(), "protocal");
|
||||
ParamCheckUtil.checkMaxLength(req.getDescription(), 50, "描述", "50");
|
||||
ParamCheckUtil.checkBytesDesc(req.getUpLimitRate(), "upLimitRate");
|
||||
ParamCheckUtil.checkBytesDesc(req.getDownLimitRate(), "downLimitRate");
|
||||
if (StringUtils.isBlank(req.getClientIp())) {
|
||||
// 没传客户端ip,默认为127.0.0.1
|
||||
req.setClientIp("127.0.0.1");
|
||||
@@ -88,8 +97,11 @@ public class PortMappingController {
|
||||
if (null == req.getProxyTimeoutMs()) {
|
||||
req.setProxyTimeoutMs(0L);
|
||||
}
|
||||
if (null == req.getSecurityGroupId()) {
|
||||
req.setSecurityGroupId(0);
|
||||
}
|
||||
|
||||
return portMappingService.update(req);
|
||||
portMappingService.update(req);
|
||||
}
|
||||
|
||||
@Get
|
||||
@@ -119,4 +131,26 @@ public class PortMappingController {
|
||||
|
||||
portMappingService.delete(req.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定安全组
|
||||
* @param req portMappingId和securityGroupId
|
||||
*/
|
||||
@Post
|
||||
@Mapping("/bind/security-group")
|
||||
public void bindSecurityGroup(PortMappingBindSecurityGroupReq req) {
|
||||
portMappingService.portBindSecurityGroup(req.getId(), req.getSecurityGroupId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 安全组解绑
|
||||
* @param id 端口映射Id
|
||||
*/
|
||||
@Post
|
||||
@Mapping("/unbind/security-group")
|
||||
public void unbindSecurityGroup(Integer id) {
|
||||
portMappingService.portUnbindSecurityGroup(id);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
package org.dromara.neutrinoproxy.server.controller;
|
||||
|
||||
import org.dromara.neutrinoproxy.server.base.page.PageInfo;
|
||||
import org.dromara.neutrinoproxy.server.base.page.PageQuery;
|
||||
import org.dromara.neutrinoproxy.server.controller.req.system.*;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.system.*;
|
||||
import org.dromara.neutrinoproxy.server.service.PortMappingService;
|
||||
import org.dromara.neutrinoproxy.server.service.SecurityGroupService;
|
||||
import org.dromara.neutrinoproxy.server.util.ParamCheckUtil;
|
||||
import org.noear.solon.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
@Mapping("/security")
|
||||
public class SecurityController {
|
||||
|
||||
@Inject
|
||||
private SecurityGroupService groupService;
|
||||
|
||||
@Inject
|
||||
private PortMappingService portMappingService;
|
||||
|
||||
/**
|
||||
* 获取当前用户权限下的安全组
|
||||
*/
|
||||
@Get
|
||||
@Mapping("/group/page")
|
||||
public PageInfo<SecurityGroupListRes> groupPage(PageQuery pageQuery, SecurityGroupListReq req) {
|
||||
ParamCheckUtil.checkNotNull(pageQuery, "pageQuery");
|
||||
|
||||
return groupService.groupPage(pageQuery, req);
|
||||
}
|
||||
|
||||
@Get
|
||||
@Mapping("/group/list")
|
||||
public List<SecurityGroupListRes> groupList() {
|
||||
return groupService.groupList();
|
||||
}
|
||||
|
||||
@Get
|
||||
@Mapping("/group/detail")
|
||||
public SecurityGroupDetailRes groupDetail(SecurityGroupDetailReq req) {
|
||||
ParamCheckUtil.checkNotNull(req, "req");
|
||||
ParamCheckUtil.checkNotNull(req.getId(), "id");
|
||||
|
||||
return groupService.groupDetail(req);
|
||||
}
|
||||
|
||||
@Post
|
||||
@Mapping("/group/create")
|
||||
public void createGroup(SecurityGroupCreateReq req) {
|
||||
groupService.createGroup(req);
|
||||
}
|
||||
|
||||
@Post
|
||||
@Mapping("/group/update")
|
||||
public void updateGroup(SecurityGroupUpdateReq req) {
|
||||
groupService.updateGroup(req);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将级联删除对应规则,并更新缓存
|
||||
* @param groupId 安全组Id
|
||||
*/
|
||||
@Post
|
||||
@Mapping("/group/delete")
|
||||
public void deleteGroup(Integer groupId) {
|
||||
ParamCheckUtil.checkNotNull(groupId, "groupId");
|
||||
|
||||
groupService.deleteGroup(groupId);
|
||||
}
|
||||
|
||||
@Post
|
||||
@Mapping("/group/update/enable-status")
|
||||
public SecurityGroupUpdateEnableStatueRes updateGroupEnableStatueReq(SecurityGroupUpdateEnableStatueReq req) {
|
||||
ParamCheckUtil.checkNotNull(req, "req");
|
||||
ParamCheckUtil.checkNotNull(req.getId(), "id");
|
||||
ParamCheckUtil.checkNotNull(req.getEnable(), "enable");
|
||||
|
||||
return groupService.updateGroupEnableStatueReq(req);
|
||||
}
|
||||
|
||||
@Get
|
||||
@Mapping("/rule/page")
|
||||
public PageInfo<SecurityRuleListRes> rulePage(PageQuery pageQuery, SecurityRuleListReq req) {
|
||||
ParamCheckUtil.checkNotNull(pageQuery, "pageQuery");
|
||||
|
||||
return groupService.rulePage(pageQuery, req);
|
||||
}
|
||||
|
||||
@Get
|
||||
@Mapping("/rule/list")
|
||||
public List<SecurityRuleListRes> getRuleListByGroupId(SecurityRuleListReq req) {
|
||||
return groupService.ruleList(req);
|
||||
}
|
||||
|
||||
@Post
|
||||
@Mapping("/rule/create")
|
||||
public void createRule(SecurityRuleCreateReq req) {
|
||||
groupService.createRule(req);
|
||||
}
|
||||
|
||||
@Post
|
||||
@Mapping("/rule/update")
|
||||
public void updateRule(SecurityRuleUpdateReq req) {
|
||||
groupService.updateRule(req);
|
||||
}
|
||||
|
||||
@Post
|
||||
@Mapping("/rule/delete")
|
||||
public void deleteRule(Integer ruleId) {
|
||||
groupService.deleteRule(ruleId);
|
||||
}
|
||||
|
||||
|
||||
@Post
|
||||
@Mapping("/rule/update/enable-status")
|
||||
public SecurityRuleUpdateEnableStatueRes updateRuleEnableStatueReq(SecurityRuleUpdateEnableStatueReq req) {
|
||||
ParamCheckUtil.checkNotNull(req, "req");
|
||||
ParamCheckUtil.checkNotNull(req.getId(), "id");
|
||||
ParamCheckUtil.checkNotNull(req.getEnable(), "enable");
|
||||
|
||||
return groupService.updateRuleEnableStatueReq(req);
|
||||
}
|
||||
|
||||
}
|
||||
+8
@@ -38,4 +38,12 @@ public class LicenseCreateReq {
|
||||
* 用户ID
|
||||
*/
|
||||
private Integer userId;
|
||||
/**
|
||||
* 上传限速
|
||||
*/
|
||||
private String upLimitRate;
|
||||
/**
|
||||
* 下载限速
|
||||
*/
|
||||
private String downLimitRate;
|
||||
}
|
||||
|
||||
+8
@@ -38,4 +38,12 @@ public class LicenseUpdateReq {
|
||||
* license名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 上传限速
|
||||
*/
|
||||
private String upLimitRate;
|
||||
/**
|
||||
* 下载限速
|
||||
*/
|
||||
private String downLimitRate;
|
||||
}
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package org.dromara.neutrinoproxy.server.controller.req.proxy;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PortMappingBindSecurityGroupReq {
|
||||
|
||||
private Integer id;
|
||||
|
||||
private Integer securityGroupId;
|
||||
|
||||
}
|
||||
+14
@@ -54,6 +54,14 @@ public class PortMappingCreateReq {
|
||||
* 客户端端口
|
||||
*/
|
||||
private Integer clientPort;
|
||||
/**
|
||||
* 上传限速
|
||||
*/
|
||||
private String upLimitRate;
|
||||
/**
|
||||
* 下载限速
|
||||
*/
|
||||
private String downLimitRate;
|
||||
/**
|
||||
* 代理响应数量(响应数据包数量,如果没有拆包则等于数据条数)
|
||||
*/
|
||||
@@ -62,6 +70,12 @@ public class PortMappingCreateReq {
|
||||
* 代理超时时间
|
||||
*/
|
||||
private Long proxyTimeoutMs;
|
||||
|
||||
/**
|
||||
* 安全组Id
|
||||
*/
|
||||
private Integer securityGroupId;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
|
||||
+14
@@ -58,6 +58,14 @@ public class PortMappingUpdateReq {
|
||||
* 客户端端口
|
||||
*/
|
||||
private Integer clientPort;
|
||||
/**
|
||||
* 上传限速
|
||||
*/
|
||||
private String upLimitRate;
|
||||
/**
|
||||
* 下载限速
|
||||
*/
|
||||
private String downLimitRate;
|
||||
/**
|
||||
* 代理响应数量(响应数据包数量,如果没有拆包则等于数据条数)
|
||||
*/
|
||||
@@ -66,6 +74,12 @@ public class PortMappingUpdateReq {
|
||||
* 代理超时时间
|
||||
*/
|
||||
private Long proxyTimeoutMs;
|
||||
|
||||
/**
|
||||
* 安全组Id
|
||||
*/
|
||||
private Integer securityGroupId;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package org.dromara.neutrinoproxy.server.controller.req.system;
|
||||
|
||||
import lombok.Data;
|
||||
import org.dromara.neutrinoproxy.server.constant.SecurityRulePassTypeEnum;
|
||||
|
||||
@Data
|
||||
public class SecurityGroupCreateReq {
|
||||
/**
|
||||
* 组名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 通过类型
|
||||
*/
|
||||
private Integer defaultPassType;
|
||||
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package org.dromara.neutrinoproxy.server.controller.req.system;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author: aoshiguchen
|
||||
* @date: 2023/12/10
|
||||
*/
|
||||
@Data
|
||||
public class SecurityGroupDetailReq {
|
||||
private Integer id;
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package org.dromara.neutrinoproxy.server.controller.req.system;
|
||||
|
||||
import lombok.Data;
|
||||
import org.dromara.neutrinoproxy.server.constant.SecurityRulePassTypeEnum;
|
||||
|
||||
/**
|
||||
* @author: wen.y
|
||||
* @date: 2023/12/10
|
||||
*/
|
||||
@Data
|
||||
public class SecurityGroupListReq {
|
||||
private String name;
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
/**
|
||||
* 通过类型
|
||||
*/
|
||||
private Integer defaultPassType;
|
||||
private Integer enable;
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package org.dromara.neutrinoproxy.server.controller.req.system;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author: aoshiguchen
|
||||
* @date: 2023/12/10
|
||||
*/
|
||||
@Data
|
||||
public class SecurityGroupUpdateEnableStatueReq {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 启用状态
|
||||
*/
|
||||
private Integer enable;
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package org.dromara.neutrinoproxy.server.controller.req.system;
|
||||
|
||||
import lombok.Data;
|
||||
import org.dromara.neutrinoproxy.server.constant.SecurityRulePassTypeEnum;
|
||||
|
||||
@Data
|
||||
public class SecurityGroupUpdateReq {
|
||||
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 组名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
package org.dromara.neutrinoproxy.server.controller.req.system;
|
||||
|
||||
import cn.hutool.core.net.Ipv4Util;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.dromara.neutrinoproxy.server.constant.EnableStatusEnum;
|
||||
import org.dromara.neutrinoproxy.server.constant.SecurityRulePassTypeEnum;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
@Accessors(chain = true)
|
||||
public class SecurityRuleCreateReq {
|
||||
|
||||
/**
|
||||
* 所属安全组
|
||||
*/
|
||||
private Integer groupId;
|
||||
|
||||
/**
|
||||
* 规则名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 规则描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 规则,ipv6只支持单个ip判断
|
||||
* 单个ip:192.168.1.1,0:0:0:0:0:0:10.0.0.1
|
||||
* 范围类型:192.168.1.0-192.168.1.255
|
||||
* 掩码类型:192.168.1.0/24
|
||||
* 泛型:0.0.0.0/ALL
|
||||
* 每个类型中间以英文逗号分隔
|
||||
*/
|
||||
private String rule;
|
||||
|
||||
/**
|
||||
* 放行类型,reject 或 allow
|
||||
* {@link SecurityRulePassTypeEnum}
|
||||
*/
|
||||
private Integer passType;
|
||||
|
||||
/**
|
||||
* 优先级,数字越小,优先级越高
|
||||
*/
|
||||
private Integer priority = 1;
|
||||
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package org.dromara.neutrinoproxy.server.controller.req.system;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author: aoshiguchen
|
||||
* @date: 2023/12/10
|
||||
*/
|
||||
@Data
|
||||
public class SecurityRuleListReq {
|
||||
private String groupId;
|
||||
private String name;
|
||||
private String description;
|
||||
private Integer passType;
|
||||
private Integer enable;
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package org.dromara.neutrinoproxy.server.controller.req.system;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author: aoshiguchen
|
||||
* @date: 2023/12/10
|
||||
*/
|
||||
@Data
|
||||
public class SecurityRuleUpdateEnableStatueReq {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 启用状态
|
||||
*/
|
||||
private Integer enable;
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
package org.dromara.neutrinoproxy.server.controller.req.system;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.dromara.neutrinoproxy.server.constant.SecurityRulePassTypeEnum;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
@Accessors(chain = true)
|
||||
public class SecurityRuleUpdateReq {
|
||||
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 所属安全组
|
||||
*/
|
||||
private Integer groupId;
|
||||
|
||||
/**
|
||||
* 规则名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 规则描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 规则,ipv6只支持单个ip判断
|
||||
* 单个ip:192.168.1.1,0:0:0:0:0:0:10.0.0.1
|
||||
* 范围类型:192.168.1.0-192.168.1.255
|
||||
* 掩码类型:192.168.1.0/24
|
||||
* 泛型:0.0.0.0/ALL
|
||||
* 每个类型中间以英文逗号分隔
|
||||
*/
|
||||
private String rule;
|
||||
|
||||
/**
|
||||
* 放行类型,reject 或 allow
|
||||
* {@link SecurityRulePassTypeEnum}
|
||||
*/
|
||||
private Integer passType;
|
||||
|
||||
/**
|
||||
* 优先级,数字越小,优先级越高
|
||||
*/
|
||||
private Integer priority;
|
||||
|
||||
}
|
||||
+8
@@ -32,6 +32,14 @@ public class LicenseListRes {
|
||||
* 用户名
|
||||
*/
|
||||
private String userName;
|
||||
/**
|
||||
* 上传限速
|
||||
*/
|
||||
private String upLimitRate;
|
||||
/**
|
||||
* 下载限速
|
||||
*/
|
||||
private String downLimitRate;
|
||||
/**
|
||||
* 是否在线
|
||||
* {@link OnlineStatusEnum}
|
||||
|
||||
+14
@@ -75,6 +75,14 @@ public class PortMappingListRes {
|
||||
* 客户端端口
|
||||
*/
|
||||
private Integer clientPort;
|
||||
/**
|
||||
* 上传限速
|
||||
*/
|
||||
private String upLimitRate;
|
||||
/**
|
||||
* 下载限速
|
||||
*/
|
||||
private String downLimitRate;
|
||||
/**
|
||||
* 客户端端口
|
||||
*/
|
||||
@@ -101,6 +109,12 @@ public class PortMappingListRes {
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 安全组Id
|
||||
*/
|
||||
private Integer securityGroupId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
package org.dromara.neutrinoproxy.server.controller.res.system;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.dromara.neutrinoproxy.server.constant.EnableStatusEnum;
|
||||
import org.dromara.neutrinoproxy.server.constant.SecurityRulePassTypeEnum;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class SecurityGroupDetailRes {
|
||||
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 组名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 启用状态
|
||||
* {@link EnableStatusEnum}
|
||||
*/
|
||||
private Integer enable;
|
||||
|
||||
/**
|
||||
* 默认放行类型
|
||||
* {@link SecurityRulePassTypeEnum}
|
||||
*/
|
||||
private Integer defaultPassType;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private String createTime;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private String updateTime;
|
||||
|
||||
|
||||
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
package org.dromara.neutrinoproxy.server.controller.res.system;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.dromara.neutrinoproxy.server.constant.EnableStatusEnum;
|
||||
import org.dromara.neutrinoproxy.server.constant.SecurityRulePassTypeEnum;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class SecurityGroupListRes {
|
||||
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 组名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 启用状态
|
||||
* {@link EnableStatusEnum}
|
||||
*/
|
||||
private Integer enable;
|
||||
|
||||
/**
|
||||
* 默认放行类型
|
||||
* {@link SecurityRulePassTypeEnum}
|
||||
*/
|
||||
private Integer defaultPassType;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package org.dromara.neutrinoproxy.server.controller.res.system;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author: aoshiguchen
|
||||
* @date: 2023/12/10
|
||||
*/
|
||||
@Data
|
||||
public class SecurityGroupUpdateEnableStatueRes {
|
||||
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
package org.dromara.neutrinoproxy.server.controller.res.system;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.dromara.neutrinoproxy.server.constant.SecurityRulePassTypeEnum;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
@Accessors(chain = true)
|
||||
public class SecurityRuleListRes {
|
||||
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 所属安全组
|
||||
*/
|
||||
private Integer groupId;
|
||||
|
||||
/**
|
||||
* 规则名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 规则描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 规则,ipv6只支持单个ip判断
|
||||
* 单个ip:192.168.1.1,0:0:0:0:0:0:10.0.0.1
|
||||
* 范围类型:192.168.1.0-192.168.1.255
|
||||
* 掩码类型:192.168.1.0/24
|
||||
* 泛型:0.0.0.0/ALL
|
||||
* 每个类型中间以英文逗号分隔
|
||||
*/
|
||||
private String rule;
|
||||
|
||||
/**
|
||||
* 放行类型,reject 或 allow
|
||||
* {@link SecurityRulePassTypeEnum}
|
||||
*/
|
||||
private Integer passType;
|
||||
|
||||
/**
|
||||
* 优先级,数字越小,优先级越高
|
||||
*/
|
||||
private Integer priority;
|
||||
|
||||
/**
|
||||
* 启用状态
|
||||
*/
|
||||
private Integer enable;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package org.dromara.neutrinoproxy.server.controller.res.system;
|
||||
|
||||
/**
|
||||
* @author: aoshiguchen
|
||||
* @date: 2023/12/10
|
||||
*/
|
||||
public class SecurityRuleUpdateEnableStatueRes {
|
||||
}
|
||||
+2
-2
@@ -45,8 +45,8 @@ public interface FlowReportHourMapper extends BaseMapper<FlowReportHourDO> {
|
||||
|
||||
default List<FlowReportHourDO> findListByDateRange(Date startDate, Date endDate) {
|
||||
return this.selectList(new LambdaQueryWrapper<FlowReportHourDO>()
|
||||
.ge(FlowReportHourDO::getDateStr, startDate)
|
||||
.le(FlowReportHourDO::getDateStr, endDate)
|
||||
.ge(FlowReportHourDO::getDate, startDate)
|
||||
.le(FlowReportHourDO::getDate, endDate)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
-8
@@ -89,14 +89,6 @@ public interface LicenseMapper extends BaseMapper<LicenseDO> {
|
||||
return this.selectById(id);
|
||||
}
|
||||
|
||||
default void update(Integer id, String name, Date updateTime) {
|
||||
this.update(null, new LambdaUpdateWrapper<LicenseDO>()
|
||||
.eq(LicenseDO::getId, id)
|
||||
.set(LicenseDO::getName, name)
|
||||
.set(LicenseDO::getUpdateTime, updateTime)
|
||||
);
|
||||
}
|
||||
|
||||
default List<LicenseDO> findByIds(Set<Integer> ids) {
|
||||
return selectBatchIds(ids);
|
||||
}
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package org.dromara.neutrinoproxy.server.dal;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.dromara.neutrinoproxy.server.controller.req.proxy.PortMappingListReq;
|
||||
import org.dromara.neutrinoproxy.server.controller.req.system.SecurityGroupListReq;
|
||||
import org.dromara.neutrinoproxy.server.dal.entity.PortMappingDO;
|
||||
import org.dromara.neutrinoproxy.server.dal.entity.SecurityGroupDO;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public interface SecurityGroupMapper extends BaseMapper<SecurityGroupDO> {
|
||||
List<SecurityGroupDO> selectByCondition(IPage<SecurityGroupDO> page, @Param("req") SecurityGroupListReq req);
|
||||
|
||||
default void updateEnableStatus(Integer id, Integer enable, Date updateTime) {
|
||||
this.update(null, new LambdaUpdateWrapper<SecurityGroupDO>()
|
||||
.eq(SecurityGroupDO::getId, id)
|
||||
.set(SecurityGroupDO::getEnable, enable)
|
||||
.set(SecurityGroupDO::getUpdateTime, updateTime)
|
||||
);
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package org.dromara.neutrinoproxy.server.dal;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.dromara.neutrinoproxy.server.controller.req.system.SecurityGroupListReq;
|
||||
import org.dromara.neutrinoproxy.server.controller.req.system.SecurityRuleListReq;
|
||||
import org.dromara.neutrinoproxy.server.dal.entity.SecurityGroupDO;
|
||||
import org.dromara.neutrinoproxy.server.dal.entity.SecurityRuleDO;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public interface SecurityRuleMapper extends BaseMapper<SecurityRuleDO> {
|
||||
List<SecurityRuleDO> selectByCondition(IPage<SecurityRuleDO> page, @Param("req") SecurityRuleListReq req);
|
||||
|
||||
default void updateEnableStatus(Integer id, Integer enable, Date updateTime) {
|
||||
this.update(null, new LambdaUpdateWrapper<SecurityRuleDO>()
|
||||
.eq(SecurityRuleDO::getId, id)
|
||||
.set(SecurityRuleDO::getEnable, enable)
|
||||
.set(SecurityRuleDO::getUpdateTime, updateTime)
|
||||
);
|
||||
}
|
||||
}
|
||||
+10
-8
@@ -21,6 +21,7 @@
|
||||
*/
|
||||
package org.dromara.neutrinoproxy.server.dal.entity;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
@@ -59,6 +60,14 @@ public class LicenseDO {
|
||||
* 用户ID
|
||||
*/
|
||||
private Integer userId;
|
||||
/**
|
||||
* 上传限速
|
||||
*/
|
||||
private String upLimitRate;
|
||||
/**
|
||||
* 下载限速
|
||||
*/
|
||||
private String downLimitRate;
|
||||
/**
|
||||
* 是否在线
|
||||
* {@link OnlineStatusEnum}
|
||||
@@ -80,14 +89,7 @@ public class LicenseDO {
|
||||
|
||||
public LicenseListRes toRes() {
|
||||
LicenseListRes res = new LicenseListRes();
|
||||
res.setId(id);
|
||||
res.setName(name);
|
||||
res.setKey(key);
|
||||
res.setUserId(userId);
|
||||
res.setIsOnline(isOnline);
|
||||
res.setEnable(enable);
|
||||
res.setCreateTime(createTime);
|
||||
res.setUpdateTime(updateTime);
|
||||
BeanUtil.copyProperties(this, res);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
+16
-15
@@ -21,6 +21,7 @@
|
||||
*/
|
||||
package org.dromara.neutrinoproxy.server.dal.entity;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
@@ -69,6 +70,14 @@ public class PortMappingDO {
|
||||
* 客户端端口
|
||||
*/
|
||||
private Integer clientPort;
|
||||
/**
|
||||
* 上传限速
|
||||
*/
|
||||
private String upLimitRate;
|
||||
/**
|
||||
* 下载限速
|
||||
*/
|
||||
private String downLimitRate;
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@@ -92,6 +101,12 @@ public class PortMappingDO {
|
||||
* {@link EnableStatusEnum}
|
||||
*/
|
||||
private Integer enable;
|
||||
|
||||
/**
|
||||
* 安全组Id
|
||||
*/
|
||||
private Integer securityGroupId = 0; // 设置为null不生效,不知道为啥
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@@ -101,23 +116,9 @@ public class PortMappingDO {
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
public PortMappingListRes toRes() {
|
||||
PortMappingListRes res = new PortMappingListRes();
|
||||
res.setId(id);
|
||||
res.setLicenseId(licenseId);
|
||||
res.setProtocal(protocal);
|
||||
res.setSubdomain(subdomain);
|
||||
res.setServerPort(serverPort);
|
||||
res.setClientIp(clientIp);
|
||||
res.setClientPort(clientPort);
|
||||
res.setDescription(description);
|
||||
res.setIsOnline(isOnline);
|
||||
res.setProxyResponses(proxyResponses);
|
||||
res.setProxyTimeoutMs(proxyTimeoutMs);
|
||||
res.setEnable(enable);
|
||||
res.setCreateTime(createTime);
|
||||
res.setUpdateTime(updateTime);
|
||||
BeanUtil.copyProperties(this, res);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
package org.dromara.neutrinoproxy.server.dal.entity;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.dromara.neutrinoproxy.server.constant.EnableStatusEnum;
|
||||
import org.dromara.neutrinoproxy.server.constant.SecurityRulePassTypeEnum;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.system.SecurityGroupDetailRes;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.system.SecurityGroupListRes;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
@Accessors(chain = true)
|
||||
@TableName("security_group")
|
||||
public class SecurityGroupDO {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 组名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Integer userId;
|
||||
/**
|
||||
* 启用状态
|
||||
* {@link EnableStatusEnum}
|
||||
*/
|
||||
private Integer enable;
|
||||
|
||||
/**
|
||||
* 默认放行类型
|
||||
* {@link SecurityRulePassTypeEnum}
|
||||
*/
|
||||
private Integer defaultPassType;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
public SecurityGroupListRes toListRes() {
|
||||
SecurityGroupListRes res = new SecurityGroupListRes();
|
||||
BeanUtil.copyProperties(this, res);
|
||||
return res;
|
||||
}
|
||||
|
||||
public SecurityGroupDetailRes toDetailRes() {
|
||||
SecurityGroupDetailRes res = new SecurityGroupDetailRes();
|
||||
BeanUtil.copyProperties(this, res);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
+152
@@ -0,0 +1,152 @@
|
||||
package org.dromara.neutrinoproxy.server.dal.entity;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.net.Ipv4Util;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.dromara.neutrinoproxy.server.constant.EnableStatusEnum;
|
||||
import org.dromara.neutrinoproxy.server.constant.SecurityRulePassTypeEnum;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.system.SecurityRuleListRes;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
@Accessors(chain = true)
|
||||
@TableName("security_rule")
|
||||
public class SecurityRuleDO {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 所属安全组
|
||||
*/
|
||||
private Integer groupId;
|
||||
|
||||
/**
|
||||
* 规则名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 规则描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 规则,ipv6只支持单个ip判断
|
||||
* 单个ip:192.168.1.1,0:0:0:0:0:0:10.0.0.1
|
||||
* 范围类型:192.168.1.0-192.168.1.255
|
||||
* 掩码类型:192.168.1.0/24
|
||||
* 泛型:0.0.0.0/ALL
|
||||
* 每个类型中间以英文逗号分隔
|
||||
*/
|
||||
private String rule;
|
||||
|
||||
/**
|
||||
* 放行类型,reject 或 allow
|
||||
* {@link SecurityRulePassTypeEnum}
|
||||
*/
|
||||
private Integer passType;
|
||||
|
||||
/**
|
||||
* 优先级,数字越小,优先级越高
|
||||
*/
|
||||
private Integer priority = 1;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Integer userId;
|
||||
|
||||
/**
|
||||
* 启用状态
|
||||
* {@link EnableStatusEnum}
|
||||
*/
|
||||
private Integer enable;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 判断当前规则是否允许指定ip放行
|
||||
* @param ip 指定的IP
|
||||
* @return 放行状态
|
||||
*/
|
||||
public SecurityRulePassTypeEnum judge(String ip) {
|
||||
|
||||
// 被判断的IP地址为空,不做判断
|
||||
if (StrUtil.isEmpty(ip)) {
|
||||
return SecurityRulePassTypeEnum.NONE;
|
||||
}
|
||||
|
||||
// 没有规则,默认允许访问
|
||||
if (StrUtil.isEmpty(rule)) {
|
||||
return SecurityRulePassTypeEnum.ALLOW;
|
||||
}
|
||||
|
||||
// ipv6只适配单ip形式
|
||||
boolean isIpv6 = ip.contains(":");
|
||||
long ipLong = -1L;
|
||||
if (!isIpv6) {
|
||||
ipLong = Ipv4Util.ipv4ToLong(ip);
|
||||
}
|
||||
|
||||
String[] rules = this.rule.split(",");
|
||||
for (String rule : rules) {
|
||||
|
||||
rule = rule.trim();
|
||||
|
||||
// 单个ip,ipv6在此步已处理,后面不需要额外判断ipv6的情况
|
||||
if (rule.matches("(\\d+\\.){3}\\d+") || isIpv6) {
|
||||
if (rule.equalsIgnoreCase(ip)) {
|
||||
return SecurityRulePassTypeEnum.ALLOW.getType().equals(passType) ? SecurityRulePassTypeEnum.ALLOW : SecurityRulePassTypeEnum.DENY;
|
||||
}
|
||||
}
|
||||
|
||||
// 范围类型
|
||||
if (rule.matches("(\\d+\\.){3}\\d+-(\\d+\\.){3}\\d+")) {
|
||||
String[] ipRange = rule.split("-");
|
||||
if (ipRange[0].compareTo(ip) <= 0 && ip.compareTo(ipRange[1]) <= 0) {
|
||||
return SecurityRulePassTypeEnum.ALLOW.getType().equals(passType) ? SecurityRulePassTypeEnum.ALLOW : SecurityRulePassTypeEnum.DENY;
|
||||
}
|
||||
}
|
||||
|
||||
// 掩码类型
|
||||
if (rule.matches("(\\d+\\.){3}\\d+/\\d+")) {
|
||||
String[] netIp = rule.split("/");
|
||||
Long beginIp = Ipv4Util.getBeginIpLong(netIp[0], Integer.parseInt(netIp[1]));
|
||||
Long endIp = Ipv4Util.getEndIpLong(netIp[0], Integer.parseInt(netIp[1]));
|
||||
if (beginIp <= ipLong && ipLong <= endIp) {
|
||||
return SecurityRulePassTypeEnum.ALLOW.getType().equals(passType) ? SecurityRulePassTypeEnum.ALLOW : SecurityRulePassTypeEnum.DENY;
|
||||
}
|
||||
}
|
||||
|
||||
if (rule.equalsIgnoreCase("ALL") || rule.equals("0.0.0.0") || rule.equals("0.0.0.0/0")) {
|
||||
return SecurityRulePassTypeEnum.ALLOW.getType().equals(passType) ? SecurityRulePassTypeEnum.ALLOW : SecurityRulePassTypeEnum.DENY;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 都没有匹配到
|
||||
return SecurityRulePassTypeEnum.NONE;
|
||||
}
|
||||
|
||||
public SecurityRuleListRes toListRes() {
|
||||
SecurityRuleListRes res = new SecurityRuleListRes();
|
||||
BeanUtil.copyProperties(this, res);
|
||||
return res;
|
||||
}
|
||||
|
||||
}
|
||||
+8
-8
@@ -1,6 +1,11 @@
|
||||
package org.dromara.neutrinoproxy.server.proxy.core;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.neutrinoproxy.core.Constants;
|
||||
import org.dromara.neutrinoproxy.core.ProxyMessage;
|
||||
@@ -8,11 +13,6 @@ import org.dromara.neutrinoproxy.server.constant.NetworkProtocolEnum;
|
||||
import org.dromara.neutrinoproxy.server.proxy.domain.VisitorChannelAttachInfo;
|
||||
import org.dromara.neutrinoproxy.server.service.FlowReportService;
|
||||
import org.dromara.neutrinoproxy.server.util.ProxyUtil;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
import org.noear.solon.Solon;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
@@ -43,13 +43,13 @@ public class TcpVisitorChannelHandler extends SimpleChannelInboundHandler<ByteBu
|
||||
ctx.channel().close();
|
||||
return;
|
||||
}
|
||||
byte[] bytes = new byte[buf.readableBytes()];
|
||||
buf.readBytes(bytes);
|
||||
|
||||
// 代理通道可写,则设置访问通道可读。代理通道不可写,则设置访问通道不可读
|
||||
visitorChannel.config().setAutoRead(proxyChannel.isWritable());
|
||||
|
||||
// 转发代理数据
|
||||
byte[] bytes = new byte[buf.readableBytes()];
|
||||
buf.readBytes(bytes);
|
||||
String visitorId = ProxyUtil.getVisitorIdByChannel(visitorChannel);
|
||||
proxyChannel.writeAndFlush(ProxyMessage.buildTransferMessage(visitorId, bytes));
|
||||
|
||||
@@ -62,8 +62,8 @@ public class TcpVisitorChannelHandler extends SimpleChannelInboundHandler<ByteBu
|
||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||
Channel visitorChannel = ctx.channel();
|
||||
InetSocketAddress sa = (InetSocketAddress) visitorChannel.localAddress();
|
||||
Channel cmdChannel = ProxyUtil.getCmdChannelByServerPort(sa.getPort());
|
||||
|
||||
Channel cmdChannel = ProxyUtil.getCmdChannelByServerPort(sa.getPort());
|
||||
if (null == cmdChannel) {
|
||||
// 该端口还没有代理客户端
|
||||
ctx.channel().close();
|
||||
|
||||
+3
-11
@@ -7,7 +7,6 @@ import io.netty.channel.ChannelOption;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
import io.netty.channel.socket.DatagramPacket;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dromara.neutrinoproxy.core.Constants;
|
||||
import org.dromara.neutrinoproxy.core.ProxyMessage;
|
||||
import org.dromara.neutrinoproxy.server.constant.NetworkProtocolEnum;
|
||||
@@ -18,7 +17,6 @@ import org.dromara.neutrinoproxy.server.util.ProxyUtil;
|
||||
import org.noear.solon.Solon;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* @author: aoshiguchen
|
||||
@@ -29,7 +27,9 @@ public class UdpVisitorChannelHandler extends SimpleChannelInboundHandler<Datagr
|
||||
|
||||
@Override
|
||||
protected void channelRead0(ChannelHandlerContext ctx, DatagramPacket datagramPacket) throws Exception {
|
||||
log.debug("chid>>>{}", ctx.channel().id().asLongText());
|
||||
Channel visitorChannel = ctx.channel();
|
||||
InetSocketAddress sa = (InetSocketAddress) visitorChannel.localAddress();
|
||||
|
||||
byte[] bytes = new byte[datagramPacket.content().readableBytes()];
|
||||
datagramPacket.content().readBytes(bytes);
|
||||
datagramPacket.content().resetReaderIndex();
|
||||
@@ -65,12 +65,6 @@ public class UdpVisitorChannelHandler extends SimpleChannelInboundHandler<Datagr
|
||||
Solon.context().getBean(FlowReportService.class).addWriteByte(visitorChannelAttachInfo.getLicenseId(), bytes.length);
|
||||
});
|
||||
|
||||
// String visitorId = ProxyUtil.getVisitorIdByChannel(ctx.channel());
|
||||
// if (StringUtils.isNotBlank(visitorId)) {
|
||||
// // UDP代理隧道已就绪,直接转发
|
||||
// proxyAttachment.execute();
|
||||
// return;
|
||||
// }
|
||||
Channel proxyChannel = ctx.channel().attr(Constants.NEXT_CHANNEL).get();
|
||||
if (null != proxyChannel && proxyChannel.isActive()) {
|
||||
// UDP代理隧道已就绪,直接转发
|
||||
@@ -78,8 +72,6 @@ public class UdpVisitorChannelHandler extends SimpleChannelInboundHandler<Datagr
|
||||
return;
|
||||
}
|
||||
|
||||
Channel visitorChannel = ctx.channel();
|
||||
InetSocketAddress sa = (InetSocketAddress) visitorChannel.localAddress();
|
||||
Channel cmdChannel = ProxyUtil.getCmdChannelByServerPort(sa.getPort());
|
||||
|
||||
// 没有指令通道,直接结束
|
||||
|
||||
+5
-1
@@ -11,6 +11,8 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.neutrinoproxy.server.base.proxy.ProxyConfig;
|
||||
import org.dromara.neutrinoproxy.server.proxy.core.BytesMetricsHandler;
|
||||
import org.dromara.neutrinoproxy.server.proxy.core.ProxyTunnelServer;
|
||||
import org.dromara.neutrinoproxy.server.proxy.security.HttpVisitorSecurityChannelHandler;
|
||||
import org.dromara.neutrinoproxy.server.proxy.security.VisitorFlowLimiterChannelHandler;
|
||||
import org.noear.solon.annotation.Component;
|
||||
import org.noear.solon.annotation.Inject;
|
||||
import org.noear.solon.core.event.AppLoadEndEvent;
|
||||
@@ -46,7 +48,9 @@ public class HttpProxy implements EventListener<AppLoadEndEvent> {
|
||||
ch.pipeline().addFirst(new LoggingHandler(HttpProxy.class));
|
||||
}
|
||||
ch.pipeline().addFirst(new BytesMetricsHandler());
|
||||
ch.pipeline().addLast(new HttpVisitorChannelHandler(proxyConfig.getServer().getTcp().getDomainName()));
|
||||
ch.pipeline().addLast(new HttpVisitorSecurityChannelHandler(proxyConfig.getServer().getTcp().getDomainName()));
|
||||
ch.pipeline().addLast("flowLimiter",new VisitorFlowLimiterChannelHandler());
|
||||
ch.pipeline().addLast(new HttpVisitorChannelHandler());
|
||||
}
|
||||
});
|
||||
bootstrap.bind("0.0.0.0", proxyConfig.getServer().getTcp().getHttpProxyPort()).sync();
|
||||
|
||||
+10
-48
@@ -1,6 +1,5 @@
|
||||
package org.dromara.neutrinoproxy.server.proxy.enhance;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
@@ -25,22 +24,9 @@ import java.net.InetSocketAddress;
|
||||
*/
|
||||
@Slf4j
|
||||
public class HttpVisitorChannelHandler extends SimpleChannelInboundHandler<ByteBuf> {
|
||||
/**
|
||||
* 域名
|
||||
*/
|
||||
private String domainName;
|
||||
|
||||
public HttpVisitorChannelHandler(String domainName) {
|
||||
this.domainName = domainName;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void channelRead0(ChannelHandlerContext ctx, ByteBuf byteBuf) throws Exception {
|
||||
if (StrUtil.isBlank(domainName)) {
|
||||
ctx.channel().close();
|
||||
return;
|
||||
}
|
||||
|
||||
byte[] bytes = new byte[byteBuf.readableBytes()];
|
||||
byteBuf.readBytes(bytes);
|
||||
byteBuf.resetReaderIndex();
|
||||
@@ -68,25 +54,9 @@ public class HttpVisitorChannelHandler extends SimpleChannelInboundHandler<ByteB
|
||||
// 用户连接到代理服务器时,设置用户连接不可读,等待代理后端服务器连接成功后再改变为可读状态
|
||||
ctx.channel().config().setOption(ChannelOption.AUTO_READ, false);
|
||||
|
||||
String host = getHost(bytes);
|
||||
log.debug("HttpProxy host: {}", host);
|
||||
if (StringUtils.isBlank(host)) {
|
||||
ctx.channel().close();
|
||||
return;
|
||||
}
|
||||
if (!host.endsWith(domainName)) {
|
||||
ctx.channel().close();
|
||||
return;
|
||||
}
|
||||
int index = host.lastIndexOf("." + domainName);
|
||||
String subdomain = host.substring(0, index);
|
||||
|
||||
// 根据域名拿到绑定的映射对应的cmdChannel
|
||||
Integer serverPort = ProxyUtil.getServerPortBySubdomain(subdomain);
|
||||
if (null == serverPort) {
|
||||
ctx.channel().close();
|
||||
return;
|
||||
}
|
||||
Integer serverPort = ctx.channel().attr(Constants.SERVER_PORT).get();
|
||||
Channel cmdChannel = ProxyUtil.getCmdChannelByServerPort(serverPort);
|
||||
if (null == cmdChannel) {
|
||||
ctx.channel().close();
|
||||
@@ -150,23 +120,15 @@ public class HttpVisitorChannelHandler extends SimpleChannelInboundHandler<ByteB
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
private String getHost(byte[] buf) {
|
||||
String req = new String(buf);
|
||||
String[] lines = req.split("\r\n");
|
||||
String firstLine = lines[0];
|
||||
if (!(firstLine.endsWith("HTTP/1.1") || firstLine.endsWith("HTTP/1.0"))) {
|
||||
return null;
|
||||
@Override
|
||||
public void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception {
|
||||
|
||||
// 通知代理客户端
|
||||
Channel visitorChannel = ctx.channel();
|
||||
Channel proxyChannel = visitorChannel.attr(Constants.NEXT_CHANNEL).get();
|
||||
if (null != proxyChannel) {
|
||||
proxyChannel.config().setOption(ChannelOption.AUTO_READ, visitorChannel.isWritable());
|
||||
}
|
||||
for (int i = 1; i < lines.length; i++) {
|
||||
String line = lines[i];
|
||||
if (!line.startsWith("Host: ")) {
|
||||
continue;
|
||||
}
|
||||
// 域名
|
||||
String domain = line.substring(6);
|
||||
// 去掉域名后面的端口号
|
||||
return domain.replaceAll(":.*", "");
|
||||
}
|
||||
return null;
|
||||
super.channelWritabilityChanged(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
+5
-1
@@ -14,6 +14,8 @@ import org.dromara.neutrinoproxy.core.util.FileUtil;
|
||||
import org.dromara.neutrinoproxy.server.base.proxy.ProxyConfig;
|
||||
import org.dromara.neutrinoproxy.server.proxy.core.BytesMetricsHandler;
|
||||
import org.dromara.neutrinoproxy.server.proxy.core.ProxyTunnelServer;
|
||||
import org.dromara.neutrinoproxy.server.proxy.security.HttpVisitorSecurityChannelHandler;
|
||||
import org.dromara.neutrinoproxy.server.proxy.security.VisitorFlowLimiterChannelHandler;
|
||||
import org.noear.solon.annotation.Component;
|
||||
import org.noear.solon.annotation.Inject;
|
||||
import org.noear.solon.core.event.AppLoadEndEvent;
|
||||
@@ -55,7 +57,9 @@ public class HttpsProxy implements EventListener<AppLoadEndEvent> {
|
||||
}
|
||||
ch.pipeline().addLast(createSslHandler());
|
||||
ch.pipeline().addFirst(new BytesMetricsHandler());
|
||||
ch.pipeline().addLast(new HttpVisitorChannelHandler(proxyConfig.getServer().getTcp().getDomainName()));
|
||||
ch.pipeline().addLast(new HttpVisitorSecurityChannelHandler(proxyConfig.getServer().getTcp().getDomainName()));
|
||||
ch.pipeline().addLast("flowLimiter",new VisitorFlowLimiterChannelHandler());
|
||||
ch.pipeline().addLast(new HttpVisitorChannelHandler());
|
||||
}
|
||||
});
|
||||
bootstrap.bind("0.0.0.0", proxyConfig.getServer().getTcp().getHttpsProxyPort()).sync();
|
||||
|
||||
+2
-2
@@ -90,7 +90,7 @@ public class ProxyMessageAuthHandler implements ProxyMessageHandler {
|
||||
|
||||
if (StrUtil.isEmpty(licenseKey)) {
|
||||
log.warn("[client connection] license cannot empty info:{} ", info);
|
||||
ctx.channel().writeAndFlush(ProxyMessage.buildAuthResultMessage(ExceptionEnum.AUTH_FAILED.getCode(), "license不能为空!", licenseKey));
|
||||
ctx.channel().writeAndFlush(ProxyMessage.buildAuthResultMessage(ExceptionEnum.AUTH_FAILED.getCode(), "license cannot be empty!", licenseKey));
|
||||
ctx.channel().close();
|
||||
clientConnectRecordService.add(new ClientConnectRecordDO()
|
||||
.setIp(ip)
|
||||
@@ -105,7 +105,7 @@ public class ProxyMessageAuthHandler implements ProxyMessageHandler {
|
||||
LicenseDO licenseDO = licenseService.findByKey(licenseKey);
|
||||
if (null == licenseDO) {
|
||||
log.warn("[client connection] license notfound info:{} ", info);
|
||||
ctx.channel().writeAndFlush(ProxyMessage.buildAuthResultMessage(ExceptionEnum.AUTH_FAILED.getCode(), "license不存在!", licenseKey));
|
||||
ctx.channel().writeAndFlush(ProxyMessage.buildAuthResultMessage(ExceptionEnum.AUTH_FAILED.getCode(), "license not found!", licenseKey));
|
||||
ctx.channel().close();
|
||||
clientConnectRecordService.add(new ClientConnectRecordDO()
|
||||
.setIp(ip)
|
||||
|
||||
+4
-3
@@ -50,7 +50,7 @@ public class ProxyMessageConnectHandler implements ProxyMessageHandler {
|
||||
|
||||
LicenseDO licenseDO = licenseService.findByKey(licenseKey);
|
||||
if (null == licenseDO) {
|
||||
ctx.channel().writeAndFlush(ProxyMessage.buildErrMessage(ExceptionEnum.CONNECT_FAILED, "the license notfound!"));
|
||||
ctx.channel().writeAndFlush(ProxyMessage.buildErrMessage(ExceptionEnum.CONNECT_FAILED, "the license not found!"));
|
||||
ctx.channel().close();
|
||||
return;
|
||||
}
|
||||
@@ -69,7 +69,7 @@ public class ProxyMessageConnectHandler implements ProxyMessageHandler {
|
||||
Channel cmdChannel = ProxyUtil.getCmdChannelByLicenseId(licenseDO.getId());
|
||||
|
||||
if (null == cmdChannel) {
|
||||
ctx.channel().writeAndFlush(ProxyMessage.buildErrMessage(ExceptionEnum.CONNECT_FAILED, "server error,cmd channel notfound!"));
|
||||
ctx.channel().writeAndFlush(ProxyMessage.buildErrMessage(ExceptionEnum.CONNECT_FAILED, "server error,cmd channel not found!"));
|
||||
ctx.channel().close();
|
||||
return;
|
||||
}
|
||||
@@ -82,7 +82,8 @@ public class ProxyMessageConnectHandler implements ProxyMessageHandler {
|
||||
ctx.channel().attr(Constants.LICENSE_ID).set(licenseDO.getId());
|
||||
ctx.channel().attr(Constants.NEXT_CHANNEL).set(visitorChannel);
|
||||
visitorChannel.attr(Constants.NEXT_CHANNEL).set(ctx.channel());
|
||||
// 代理客户端与后端服务器连接成功,修改用户连接为可读状态
|
||||
visitorChannel.attr(Constants.LICENSE_ID).set(licenseDO.getId());
|
||||
// 代理客户端与后端服务器连接成功,修改用户连接为可读状态
|
||||
visitorChannel.config().setOption(ChannelOption.AUTO_READ, true);
|
||||
|
||||
// 获取代理附加对象
|
||||
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
package org.dromara.neutrinoproxy.server.proxy.security;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dromara.neutrinoproxy.core.Constants;
|
||||
import org.dromara.neutrinoproxy.core.util.HttpUtil;
|
||||
import org.dromara.neutrinoproxy.core.util.IpUtil;
|
||||
import org.dromara.neutrinoproxy.server.service.PortMappingService;
|
||||
import org.dromara.neutrinoproxy.server.service.SecurityGroupService;
|
||||
import org.dromara.neutrinoproxy.server.util.ProxyUtil;
|
||||
import org.noear.solon.Solon;
|
||||
|
||||
/**
|
||||
* @author: aoshiguchen
|
||||
* @date: 2023/12/14
|
||||
*/
|
||||
@Slf4j
|
||||
public class HttpVisitorSecurityChannelHandler extends ChannelInboundHandlerAdapter {
|
||||
private final SecurityGroupService securityGroupService = Solon.context().getBean(SecurityGroupService.class);
|
||||
private final PortMappingService portMappingService = Solon.context().getBean(PortMappingService.class);
|
||||
/**
|
||||
* 域名
|
||||
*/
|
||||
private String domainName;
|
||||
|
||||
public HttpVisitorSecurityChannelHandler(String domainName) {
|
||||
this.domainName = domainName;
|
||||
}
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
// 未配置域名则不支持通过域名访问
|
||||
if (StrUtil.isBlank(domainName)) {
|
||||
ctx.channel().close();
|
||||
return;
|
||||
}
|
||||
|
||||
ByteBuf buf = (ByteBuf) msg;
|
||||
byte[] bytes = new byte[buf.readableBytes()];
|
||||
buf.readBytes(bytes);
|
||||
|
||||
// 获取Host请求头
|
||||
String httpContent = new String(bytes);
|
||||
String host = HttpUtil.getHostIgnorePort(httpContent);
|
||||
|
||||
log.debug("HttpProxy host: {}", host);
|
||||
if (StringUtils.isBlank(host)) {
|
||||
ctx.channel().close();
|
||||
return;
|
||||
}
|
||||
|
||||
// 根据Host匹配端口映射
|
||||
if (!host.endsWith(domainName)) {
|
||||
ctx.channel().close();
|
||||
return;
|
||||
}
|
||||
int index = host.lastIndexOf("." + domainName);
|
||||
String subdomain = host.substring(0, index);
|
||||
|
||||
// 根据域名拿到绑定的映射对应的cmdChannel
|
||||
Integer serverPort = ProxyUtil.getServerPortBySubdomain(subdomain);
|
||||
if (null == serverPort) {
|
||||
ctx.channel().close();
|
||||
return;
|
||||
}
|
||||
|
||||
// 判断IP是否在该端口绑定的安全组允许的规则内
|
||||
String ip = IpUtil.getRealRemoteIp(httpContent);
|
||||
if (ip == null) {
|
||||
ip = IpUtil.getRemoteIp(ctx);
|
||||
}
|
||||
if (!securityGroupService.judgeAllow(ip, portMappingService.getSecurityGroupIdByMappingPort(serverPort))) {
|
||||
// 不在安全组规则放行范围内
|
||||
ctx.channel().close();
|
||||
return;
|
||||
}
|
||||
|
||||
// 继续传播
|
||||
ctx.channel().attr(Constants.SERVER_PORT).set(serverPort);
|
||||
buf.resetReaderIndex();
|
||||
ctx.fireChannelRead(buf);
|
||||
}
|
||||
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
package org.dromara.neutrinoproxy.server.proxy.security;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dromara.neutrinoproxy.core.Constants;
|
||||
import org.dromara.neutrinoproxy.core.util.IpUtil;
|
||||
import org.dromara.neutrinoproxy.server.service.PortMappingService;
|
||||
import org.dromara.neutrinoproxy.server.service.SecurityGroupService;
|
||||
import org.noear.solon.Solon;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
/**
|
||||
* @author: aoshiguchen
|
||||
* @date: 2023/12/14
|
||||
*/
|
||||
@Slf4j
|
||||
public class TcpVisitorSecurityChannelHandler extends ChannelInboundHandlerAdapter {
|
||||
private final SecurityGroupService securityGroupService = Solon.context().getBean(SecurityGroupService.class);
|
||||
private final PortMappingService portMappingService = Solon.context().getBean(PortMappingService.class);
|
||||
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
Channel visitorChannel = ctx.channel();
|
||||
|
||||
ByteBuf buf = (ByteBuf) msg;
|
||||
byte[] bytes = new byte[buf.readableBytes()];
|
||||
buf.readBytes(bytes);
|
||||
|
||||
// 判断IP是否在该端口绑定的安全组允许的规则内
|
||||
String ip = IpUtil.getRealRemoteIp(new String(bytes));
|
||||
if (StringUtils.isEmpty(ip)) {
|
||||
ip = IpUtil.getRemoteIp(ctx);
|
||||
}
|
||||
InetSocketAddress sa = (InetSocketAddress) visitorChannel.localAddress();
|
||||
if (!securityGroupService.judgeAllow(ip, portMappingService.getSecurityGroupIdByMappingPort(sa.getPort()))) {
|
||||
// 不在安全组规则放行范围内
|
||||
ctx.channel().close();
|
||||
return;
|
||||
}
|
||||
|
||||
// 继续传播
|
||||
ctx.channel().attr(Constants.SERVER_PORT).set(sa.getPort());
|
||||
buf.resetReaderIndex();
|
||||
ctx.fireChannelRead(buf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||
Channel visitorChannel = ctx.channel();
|
||||
InetSocketAddress sa = (InetSocketAddress) visitorChannel.localAddress();
|
||||
|
||||
// 判断IP是否在该端口绑定的安全组允许的规则内
|
||||
if (!securityGroupService.judgeAllow(IpUtil.getRemoteIp(ctx), portMappingService.getSecurityGroupIdByMappingPort(sa.getPort()))) {
|
||||
// 不在安全组规则放行范围内
|
||||
ctx.channel().close();
|
||||
return;
|
||||
}
|
||||
|
||||
// 继续传播
|
||||
ctx.fireChannelActive();
|
||||
}
|
||||
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
package org.dromara.neutrinoproxy.server.proxy.security;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||
import io.netty.channel.socket.DatagramPacket;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.neutrinoproxy.core.Constants;
|
||||
import org.dromara.neutrinoproxy.server.service.PortMappingService;
|
||||
import org.dromara.neutrinoproxy.server.service.SecurityGroupService;
|
||||
import org.noear.solon.Solon;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
/**
|
||||
* @author: aoshiguchen
|
||||
* @date: 2023/12/14
|
||||
*/
|
||||
@Slf4j
|
||||
public class UdpVisitorSecurityChannelHandler extends ChannelInboundHandlerAdapter {
|
||||
private final SecurityGroupService securityGroupService = Solon.context().getBean(SecurityGroupService.class);
|
||||
private final PortMappingService portMappingService = Solon.context().getBean(PortMappingService.class);
|
||||
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
Channel visitorChannel = ctx.channel();
|
||||
InetSocketAddress sa = (InetSocketAddress) visitorChannel.localAddress();
|
||||
DatagramPacket datagramPacket = (DatagramPacket) msg;
|
||||
|
||||
// 判断IP是否在该端口绑定的安全组允许的规则内
|
||||
if (!securityGroupService.judgeAllow(datagramPacket.sender().getAddress().getHostAddress(), portMappingService.getSecurityGroupIdByMappingPort(sa.getPort()))) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 继续传播
|
||||
ctx.channel().attr(Constants.SERVER_PORT).set(sa.getPort());
|
||||
ctx.fireChannelRead(msg);
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
package org.dromara.neutrinoproxy.server.proxy.security;
|
||||
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||
import io.netty.handler.traffic.ChannelTrafficShapingHandler;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.neutrinoproxy.core.Constants;
|
||||
import org.dromara.neutrinoproxy.server.service.LicenseService;
|
||||
import org.dromara.neutrinoproxy.server.service.PortMappingService;
|
||||
import org.dromara.neutrinoproxy.server.service.SecurityGroupService;
|
||||
import org.dromara.neutrinoproxy.server.service.bo.FlowLimitBO;
|
||||
import org.noear.solon.Solon;
|
||||
|
||||
/**
|
||||
* 访问者流量限制器
|
||||
* @author: aoshiguchen
|
||||
* @date: 2023/12/15
|
||||
*/
|
||||
@Slf4j
|
||||
public class VisitorFlowLimiterChannelHandler extends ChannelInboundHandlerAdapter {
|
||||
private final PortMappingService portMappingService = Solon.context().getBean(PortMappingService.class);
|
||||
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
Boolean flowLimiterFlag = ctx.channel().attr(Constants.FLOW_LIMITER_FLAG).get();
|
||||
|
||||
if (null == flowLimiterFlag || !flowLimiterFlag) {
|
||||
Integer serverPort = ctx.channel().attr(Constants.SERVER_PORT).get();
|
||||
Long upLimitRate = null;
|
||||
Long downLimitRate = null;
|
||||
// 先获取端口映射上的限速设置
|
||||
FlowLimitBO flowLimitBO = portMappingService.getFlowLimitByServerPort(serverPort);
|
||||
if (null != flowLimitBO) {
|
||||
upLimitRate = flowLimitBO.getUpLimitRate();
|
||||
downLimitRate = flowLimitBO.getDownLimitRate();
|
||||
}
|
||||
if (null != upLimitRate || null != downLimitRate) {
|
||||
// 如果不全为空,则需要做限速
|
||||
ctx.pipeline().addAfter("flowLimiter", "trafficShaping", new ChannelTrafficShapingHandler(downLimitRate == null ? 0 : downLimitRate, upLimitRate == null ? 0 : upLimitRate, 100, 600000));
|
||||
}
|
||||
|
||||
// 每个连接第一次处理之后。无论是否限速,该连接后续都不在处理,避免频繁执行影响性能
|
||||
ctx.channel().attr(Constants.FLOW_LIMITER_FLAG).set(Boolean.TRUE);
|
||||
}
|
||||
|
||||
// 继续传播
|
||||
ctx.fireChannelRead(msg);
|
||||
}
|
||||
|
||||
}
|
||||
+10
-4
@@ -35,11 +35,9 @@ import org.noear.solon.Solon;
|
||||
import org.noear.solon.annotation.Component;
|
||||
import org.noear.solon.annotation.Init;
|
||||
import org.noear.solon.annotation.Inject;
|
||||
import org.noear.solon.core.runtime.NativeDetector;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -67,6 +65,10 @@ public class JobInfoService implements IJobSource {
|
||||
|
||||
@Init
|
||||
public void init() {
|
||||
// aot 阶段,不初始化
|
||||
if (NativeDetector.isAotRuntime()) {
|
||||
return;
|
||||
}
|
||||
jobHandlerMap.put("DataCleanJob", dataCleanJob);
|
||||
jobHandlerMap.put("DemoJob", demoJob);
|
||||
jobHandlerMap.put("FlowReportForDayJob", flowReportForDayJob);
|
||||
@@ -107,6 +109,10 @@ public class JobInfoService implements IJobSource {
|
||||
|
||||
@Override
|
||||
public List<JobInfo> sourceList() {
|
||||
// aot 阶段,不查数据库
|
||||
if (NativeDetector.isAotRuntime()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<JobInfo> jobInfoList = Lists.newArrayList();
|
||||
List<JobInfoDO> jobInfoDOList = jobInfoMapper.findList();
|
||||
if (CollectionUtil.isEmpty(jobInfoDOList)) {
|
||||
|
||||
+6
@@ -35,7 +35,9 @@ import org.dromara.neutrinoproxy.server.dal.entity.JobLogDO;
|
||||
import org.dromara.solonplugins.job.IJobCallback;
|
||||
import org.dromara.solonplugins.job.JobInfo;
|
||||
import org.noear.solon.annotation.Component;
|
||||
import org.noear.solon.core.runtime.NativeDetector;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -53,6 +55,10 @@ public class JobLogService implements IJobCallback {
|
||||
|
||||
@Override
|
||||
public void executeLog(JobInfo jobInfo, String param, Throwable throwable) {
|
||||
// aot 阶段,不查数据库
|
||||
if (NativeDetector.isAotRuntime()) {
|
||||
return;
|
||||
}
|
||||
Integer code = 0;
|
||||
String msg = "";
|
||||
if (null == throwable) {
|
||||
|
||||
+81
-10
@@ -1,7 +1,10 @@
|
||||
package org.dromara.neutrinoproxy.server.service;
|
||||
|
||||
import cn.hutool.cache.Cache;
|
||||
import cn.hutool.cache.CacheUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.solon.plugins.pagination.Page;
|
||||
import com.google.common.collect.Sets;
|
||||
@@ -29,11 +32,14 @@ import org.dromara.neutrinoproxy.server.dal.UserMapper;
|
||||
import org.dromara.neutrinoproxy.server.dal.entity.LicenseDO;
|
||||
import org.dromara.neutrinoproxy.server.dal.entity.PortMappingDO;
|
||||
import org.dromara.neutrinoproxy.server.dal.entity.UserDO;
|
||||
import org.dromara.neutrinoproxy.server.service.bo.FlowLimitBO;
|
||||
import org.dromara.neutrinoproxy.server.util.ParamCheckUtil;
|
||||
import org.dromara.neutrinoproxy.server.util.StringUtil;
|
||||
import org.noear.solon.annotation.Component;
|
||||
import org.noear.solon.annotation.Init;
|
||||
import org.noear.solon.annotation.Inject;
|
||||
import org.noear.solon.core.bean.LifecycleBean;
|
||||
import org.noear.solon.core.runtime.NativeDetector;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
@@ -62,6 +68,8 @@ public class LicenseService implements LifecycleBean {
|
||||
private VisitorChannelService visitorChannelService;
|
||||
@Inject
|
||||
private DBInitialize dbInitialize;
|
||||
// 流量限制缓存
|
||||
private final Cache<Integer, FlowLimitBO> flowLimitCache = CacheUtil.newLRUCache(200, 1000 * 60 * 5);
|
||||
|
||||
public PageInfo<LicenseListRes> page(PageQuery pageQuery, LicenseListReq req) {
|
||||
Page<LicenseDO> page = licenseMapper.selectPage(new Page<>(pageQuery.getCurrent(), pageQuery.getSize()), new LambdaQueryWrapper<LicenseDO>()
|
||||
@@ -127,15 +135,21 @@ public class LicenseService implements LifecycleBean {
|
||||
String key = UUID.randomUUID().toString().replaceAll("-", "");
|
||||
Date now = new Date();
|
||||
|
||||
licenseMapper.insert(new LicenseDO()
|
||||
.setName(req.getName())
|
||||
.setKey(key)
|
||||
.setUserId(req.getUserId())
|
||||
.setIsOnline(OnlineStatusEnum.OFFLINE.getStatus())
|
||||
.setEnable(EnableStatusEnum.ENABLE.getStatus())
|
||||
.setCreateTime(now)
|
||||
.setUpdateTime(now)
|
||||
);
|
||||
licenseDO = new LicenseDO()
|
||||
.setName(req.getName())
|
||||
.setKey(key)
|
||||
.setUserId(req.getUserId())
|
||||
.setUpLimitRate(req.getUpLimitRate())
|
||||
.setDownLimitRate(req.getDownLimitRate())
|
||||
.setIsOnline(OnlineStatusEnum.OFFLINE.getStatus())
|
||||
.setEnable(EnableStatusEnum.ENABLE.getStatus())
|
||||
.setCreateTime(now)
|
||||
.setUpdateTime(now);
|
||||
|
||||
licenseMapper.insert(licenseDO);
|
||||
|
||||
// 刷新流量限制缓存
|
||||
refreshFlowLimitCache(licenseDO.getId(), licenseDO.getUpLimitRate(), licenseDO.getDownLimitRate());
|
||||
return new LicenseCreateRes();
|
||||
}
|
||||
|
||||
@@ -146,7 +160,17 @@ public class LicenseService implements LifecycleBean {
|
||||
LicenseDO licenseCheck = licenseMapper.checkRepeat(oldLicenseDO.getUserId(), req.getName(), Sets.newHashSet(oldLicenseDO.getId()));
|
||||
ParamCheckUtil.checkMustNull(licenseCheck, ExceptionConstant.LICENSE_NAME_CANNOT_REPEAT);
|
||||
|
||||
licenseMapper.update(req.getId(), req.getName(), new Date());
|
||||
licenseMapper.update(null, new LambdaUpdateWrapper<LicenseDO>()
|
||||
.eq(LicenseDO::getId, req.getId())
|
||||
.set(LicenseDO::getName, req.getName())
|
||||
.set(LicenseDO::getUpLimitRate, req.getUpLimitRate())
|
||||
.set(LicenseDO::getDownLimitRate, req.getDownLimitRate())
|
||||
.set(LicenseDO::getUpdateTime, new Date())
|
||||
);
|
||||
|
||||
// 刷新流量限制缓存
|
||||
refreshFlowLimitCache(req.getId(), req.getUpLimitRate(), req.getDownLimitRate());
|
||||
|
||||
return new LicenseUpdateRes();
|
||||
}
|
||||
|
||||
@@ -199,6 +223,8 @@ public class LicenseService implements LifecycleBean {
|
||||
licenseMapper.deleteById(id);
|
||||
// 更新VisitorChannel
|
||||
visitorChannelService.updateVisitorChannelByLicenseId(id, EnableStatusEnum.DISABLE.getStatus());
|
||||
// 删除流量限制缓存
|
||||
flowLimitCache.remove(id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -238,10 +264,55 @@ public class LicenseService implements LifecycleBean {
|
||||
*/
|
||||
@Init
|
||||
public void init() {
|
||||
// aot 阶段,不初始化
|
||||
if (NativeDetector.isAotRuntime()) {
|
||||
return;
|
||||
}
|
||||
// 服务刚启动,所以默认所有license都是离线状态。解决服务突然关闭,在线状态来不及更新的问题
|
||||
licenseMapper.updateOnlineStatus(OnlineStatusEnum.OFFLINE.getStatus(), new Date());
|
||||
// 刷新流量限制缓存
|
||||
List<LicenseDO> licenseDOList = licenseMapper.listAll();
|
||||
if (CollectionUtils.isEmpty(licenseDOList)) {
|
||||
for (LicenseDO licenseDO : licenseDOList) {
|
||||
refreshFlowLimitCache(licenseDO.getId(), licenseDO.getUpLimitRate(), licenseDO.getDownLimitRate());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 刷新流量限制缓存
|
||||
* @param id
|
||||
* @param upLimitRate
|
||||
* @param downLimitRate
|
||||
*/
|
||||
private void refreshFlowLimitCache(Integer id, String upLimitRate, String downLimitRate) {
|
||||
if (null == id) {
|
||||
return;
|
||||
}
|
||||
flowLimitCache.put(id, new FlowLimitBO()
|
||||
.setUpLimitRate(StringUtil.parseBytes(upLimitRate))
|
||||
.setDownLimitRate(StringUtil.parseBytes(downLimitRate))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取license的流量限制
|
||||
* @param licenseId
|
||||
* @return
|
||||
*/
|
||||
public FlowLimitBO getFlowLimit(Integer licenseId) {
|
||||
FlowLimitBO res = flowLimitCache.get(licenseId);
|
||||
if (null == res) {
|
||||
LicenseDO licenseDO = licenseMapper.queryById(licenseId);
|
||||
if (null != licenseDO) {
|
||||
refreshFlowLimitCache(licenseId, licenseDO.getUpLimitRate(), licenseDO.getDownLimitRate());
|
||||
res = flowLimitCache.get(licenseId);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() throws Throwable {
|
||||
|
||||
|
||||
+207
-23
@@ -1,10 +1,15 @@
|
||||
package org.dromara.neutrinoproxy.server.service;
|
||||
|
||||
import cn.hutool.cache.Cache;
|
||||
import cn.hutool.cache.CacheUtil;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.solon.plugins.pagination.Page;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.apache.ibatis.solon.annotation.Db;
|
||||
@@ -34,18 +39,18 @@ import org.dromara.neutrinoproxy.server.dal.entity.LicenseDO;
|
||||
import org.dromara.neutrinoproxy.server.dal.entity.PortMappingDO;
|
||||
import org.dromara.neutrinoproxy.server.dal.entity.PortPoolDO;
|
||||
import org.dromara.neutrinoproxy.server.dal.entity.UserDO;
|
||||
import org.dromara.neutrinoproxy.server.service.bo.FlowLimitBO;
|
||||
import org.dromara.neutrinoproxy.server.util.ParamCheckUtil;
|
||||
import org.dromara.neutrinoproxy.server.util.ProxyUtil;
|
||||
import org.dromara.neutrinoproxy.server.util.StringUtil;
|
||||
import org.noear.solon.annotation.Component;
|
||||
import org.noear.solon.annotation.Init;
|
||||
import org.noear.solon.annotation.Inject;
|
||||
import org.noear.solon.core.bean.LifecycleBean;
|
||||
import org.noear.solon.core.runtime.NativeDetector;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -72,6 +77,17 @@ public class PortMappingService implements LifecycleBean {
|
||||
private ProxyConfig proxyConfig;
|
||||
@Inject
|
||||
private DBInitialize dbInitialize;
|
||||
@Inject
|
||||
private LicenseService licenseService;
|
||||
|
||||
/** 端口到安全组Id的映射 */
|
||||
private final Map<Integer, Integer> mappingPortToSecurityGroupMap = new ConcurrentHashMap<>();
|
||||
// 服务端端口到端口映射id的映射
|
||||
private final Cache<Integer, Integer> serverPortToPortMappingIdCache = CacheUtil.newLRUCache(500, 1000 * 60 * 10);
|
||||
// 端口映射id到licenseId
|
||||
private final Cache<Integer, Integer> idToLicenseIdCache = CacheUtil.newLRUCache(500, 1000 * 60 * 10);
|
||||
// 流量限制缓存
|
||||
private final Cache<Integer, FlowLimitBO> flowLimitCache = CacheUtil.newLRUCache(500, 1000 * 60 * 5);
|
||||
|
||||
public PageInfo<PortMappingListRes> page(PageQuery pageQuery, PortMappingListReq req) {
|
||||
if (StringUtils.isNotEmpty(req.getDescription())) {
|
||||
@@ -122,7 +138,9 @@ public class PortMappingService implements LifecycleBean {
|
||||
}
|
||||
});
|
||||
//sorted [userId asc] [licenseId asc] [createTime asc]
|
||||
respList = respList.stream().sorted(Comparator.comparing(PortMappingListRes::getUserId).thenComparing(PortMappingListRes::getLicenseId).thenComparing(PortMappingListRes::getCreateTime)).collect(Collectors.toList());
|
||||
respList = respList.stream()
|
||||
.filter(e -> null != e.getUserId())
|
||||
.sorted(Comparator.comparing(PortMappingListRes::getUserId).thenComparing(PortMappingListRes::getLicenseId).thenComparing(PortMappingListRes::getCreateTime)).collect(Collectors.toList());
|
||||
return PageInfo.of(respList, page.getTotal(), pageQuery.getCurrent(), pageQuery.getSize());
|
||||
}
|
||||
|
||||
@@ -146,6 +164,8 @@ public class PortMappingService implements LifecycleBean {
|
||||
portMappingDO.setServerPort(req.getServerPort());
|
||||
portMappingDO.setClientIp(req.getClientIp());
|
||||
portMappingDO.setClientPort(req.getClientPort());
|
||||
portMappingDO.setUpLimitRate(req.getUpLimitRate());
|
||||
portMappingDO.setDownLimitRate(req.getDownLimitRate());
|
||||
portMappingDO.setProxyResponses(req.getProxyResponses());
|
||||
portMappingDO.setProxyTimeoutMs(req.getProxyTimeoutMs());
|
||||
portMappingDO.setDescription(req.getDescription());
|
||||
@@ -160,10 +180,20 @@ public class PortMappingService implements LifecycleBean {
|
||||
if (NetworkProtocolEnum.isHttp(portMappingDO.getProtocal()) && StrUtil.isNotBlank(proxyConfig.getServer().getTcp().getDomainName()) && StrUtil.isNotBlank(portMappingDO.getSubdomain())) {
|
||||
ProxyUtil.setSubdomainToServerPort(portMappingDO.getSubdomain(), portMappingDO.getServerPort());
|
||||
}
|
||||
|
||||
updateMappingPortToSecurityGroupMap(portMappingDO.getServerPort(), req.getSecurityGroupId());
|
||||
|
||||
// 更新端口到映射的缓存
|
||||
serverPortToPortMappingIdCache.put(req.getServerPort(), portMappingDO.getId());
|
||||
// 更新端口映射到licenseId的缓存
|
||||
idToLicenseIdCache.put(portMappingDO.getId(), portMappingDO.getLicenseId());
|
||||
// 刷新流量限制缓存
|
||||
refreshFlowLimitCache(portMappingDO.getId(), portMappingDO.getUpLimitRate(), portMappingDO.getDownLimitRate());
|
||||
|
||||
return new PortMappingCreateRes();
|
||||
}
|
||||
|
||||
public PortMappingUpdateRes update(PortMappingUpdateReq req) {
|
||||
public void update(PortMappingUpdateReq req) {
|
||||
LicenseDO licenseDO = licenseMapper.findById(req.getLicenseId());
|
||||
ParamCheckUtil.checkNotNull(licenseDO, ExceptionConstant.LICENSE_NOT_EXIST);
|
||||
if (!SystemContextHolder.isAdmin()) {
|
||||
@@ -179,21 +209,25 @@ public class PortMappingService implements LifecycleBean {
|
||||
PortMappingDO oldPortMappingDO = portMappingMapper.findById(req.getId());
|
||||
ParamCheckUtil.checkNotNull(oldPortMappingDO, ExceptionConstant.PORT_MAPPING_NOT_EXIST);
|
||||
|
||||
PortMappingDO portMappingDO = new PortMappingDO();
|
||||
portMappingDO.setId(req.getId());
|
||||
portMappingDO.setProtocal(req.getProtocal());
|
||||
portMappingDO.setSubdomain(req.getSubdomain());
|
||||
portMappingDO.setLicenseId(req.getLicenseId());
|
||||
portMappingDO.setServerPort(req.getServerPort());
|
||||
portMappingDO.setClientIp(req.getClientIp());
|
||||
portMappingDO.setClientPort(req.getClientPort());
|
||||
portMappingDO.setProxyResponses(req.getProxyResponses());
|
||||
portMappingDO.setProxyTimeoutMs(req.getProxyTimeoutMs());
|
||||
portMappingDO.setDescription(req.getDescription());
|
||||
portMappingDO.setUpdateTime(new Date());
|
||||
portMappingDO.setEnable(EnableStatusEnum.ENABLE.getStatus());
|
||||
portMappingMapper.updateById(portMappingDO);
|
||||
// 更新端口映射
|
||||
portMappingMapper.update(null, new LambdaUpdateWrapper<PortMappingDO>()
|
||||
.eq(PortMappingDO::getId, req.getId())
|
||||
.set(PortMappingDO::getProtocal, req.getProtocal())
|
||||
.set(PortMappingDO::getSubdomain, req.getSubdomain())
|
||||
.set(PortMappingDO::getServerPort, req.getServerPort())
|
||||
.set(PortMappingDO::getClientIp, req.getClientIp())
|
||||
.set(PortMappingDO::getClientPort, req.getClientPort())
|
||||
.set(PortMappingDO::getUpLimitRate, req.getUpLimitRate())
|
||||
.set(PortMappingDO::getDownLimitRate, req.getDownLimitRate())
|
||||
.set(PortMappingDO::getProxyTimeoutMs, req.getProxyTimeoutMs())
|
||||
.set(PortMappingDO::getProxyResponses, req.getProxyResponses())
|
||||
.set(PortMappingDO::getSecurityGroupId, req.getSecurityGroupId())
|
||||
.set(PortMappingDO::getDescription, req.getDescription())
|
||||
.set(PortMappingDO::getUpdateTime, new Date())
|
||||
);
|
||||
|
||||
// 更新VisitorChannel
|
||||
PortMappingDO portMappingDO = portMappingMapper.findById(req.getId());
|
||||
visitorChannelService.updateVisitorChannelByPortMapping(oldPortMappingDO, portMappingDO);
|
||||
// 删除老的域名映射
|
||||
if (NetworkProtocolEnum.isHttp(oldPortMappingDO.getProtocal()) && StrUtil.isNotBlank(oldPortMappingDO.getSubdomain())) {
|
||||
@@ -203,7 +237,15 @@ public class PortMappingService implements LifecycleBean {
|
||||
if (NetworkProtocolEnum.isHttp(portMappingDO.getProtocal()) && StrUtil.isNotBlank(proxyConfig.getServer().getTcp().getDomainName()) && StrUtil.isNotBlank(portMappingDO.getSubdomain())) {
|
||||
ProxyUtil.setSubdomainToServerPort(portMappingDO.getSubdomain(), portMappingDO.getServerPort());
|
||||
}
|
||||
return new PortMappingUpdateRes();
|
||||
|
||||
updateMappingPortToSecurityGroupMap(portMappingDO.getServerPort(), req.getSecurityGroupId());
|
||||
|
||||
// 更新端口到映射的缓存
|
||||
serverPortToPortMappingIdCache.put(req.getServerPort(), req.getId());
|
||||
// 更新端口映射到licenseId的缓存
|
||||
idToLicenseIdCache.put(portMappingDO.getId(), portMappingDO.getLicenseId());
|
||||
// 刷新流量限制缓存
|
||||
refreshFlowLimitCache(req.getId(), req.getUpLimitRate(), req.getDownLimitRate());
|
||||
}
|
||||
|
||||
public PortMappingDetailRes detail(Integer id) {
|
||||
@@ -278,6 +320,35 @@ public class PortMappingService implements LifecycleBean {
|
||||
if (NetworkProtocolEnum.isHttp(portMappingDO.getProtocal()) && StrUtil.isNotBlank(portMappingDO.getSubdomain())) {
|
||||
ProxyUtil.removeSubdomainToServerPort(portMappingDO.getSubdomain());
|
||||
}
|
||||
|
||||
updateMappingPortToSecurityGroupMap(portMappingDO.getServerPort(), null);
|
||||
|
||||
// 删除id到licenseId的映射
|
||||
idToLicenseIdCache.remove(id);
|
||||
// 删除流量限制缓存
|
||||
flowLimitCache.remove(id);
|
||||
}
|
||||
|
||||
public void portBindSecurityGroup(Integer portMappingId, Integer groupId) {
|
||||
PortMappingDO mappingDO = portMappingMapper.findById(portMappingId);
|
||||
if (mappingDO == null) {
|
||||
throw new RuntimeException("指定的端口映射不存在");
|
||||
}
|
||||
mappingDO.setSecurityGroupId(groupId);
|
||||
mappingDO.setUpdateTime(new Date());
|
||||
portMappingMapper.updateById(mappingDO);
|
||||
updateMappingPortToSecurityGroupMap(mappingDO.getServerPort(), groupId);
|
||||
}
|
||||
|
||||
public void portUnbindSecurityGroup(Integer portMappingId) {
|
||||
PortMappingDO mappingDO = portMappingMapper.findById(portMappingId);
|
||||
if (mappingDO == null) {
|
||||
throw new RuntimeException("指定的端口映射不存在");
|
||||
}
|
||||
mappingDO.setSecurityGroupId(0);
|
||||
mappingDO.setUpdateTime(new Date());
|
||||
portMappingMapper.updateById(mappingDO);
|
||||
updateMappingPortToSecurityGroupMap(mappingDO.getServerPort(), null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -290,18 +361,44 @@ public class PortMappingService implements LifecycleBean {
|
||||
return portMappingMapper.findEnableListByLicenseId(licenseId);
|
||||
}
|
||||
|
||||
public Integer getSecurityGroupIdByMappingPort(Integer port) {
|
||||
return mappingPortToSecurityGroupMap.get(port);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 服务端项目停止、启动时,更新在线状态为离线
|
||||
*/
|
||||
@Init
|
||||
public void init() {
|
||||
// aot 阶段,不初始化
|
||||
if (NativeDetector.isAotRuntime()) {
|
||||
return;
|
||||
}
|
||||
// 服务刚启动,所以默认所有license都是离线状态。解决服务突然关闭,在线状态来不及更新的问题
|
||||
portMappingMapper.updateOnlineStatus(OnlineStatusEnum.OFFLINE.getStatus(), new Date());
|
||||
|
||||
List<PortMappingDO> allMappingDOList = portMappingMapper.selectList(Wrappers.lambdaQuery(PortMappingDO.class));
|
||||
allMappingDOList.forEach(item -> {
|
||||
Integer securityGroupId = item.getSecurityGroupId();
|
||||
if (securityGroupId != null && securityGroupId > 0) {
|
||||
updateMappingPortToSecurityGroupMap(item.getServerPort(), item.getSecurityGroupId());
|
||||
}
|
||||
// 更新端口到映射的缓存
|
||||
serverPortToPortMappingIdCache.put(item.getServerPort(), item.getId());
|
||||
// 更新端口映射到licenseId的缓存
|
||||
idToLicenseIdCache.put(item.getId(), item.getLicenseId());
|
||||
// 刷新流量限制缓存
|
||||
refreshFlowLimitCache(item.getId(), item.getUpLimitRate(), item.getDownLimitRate());
|
||||
});
|
||||
|
||||
// 未配置域名,则不需要处理域名映射逻辑
|
||||
if (StrUtil.isBlank(proxyConfig.getServer().getTcp().getDomainName())) {
|
||||
return;
|
||||
}
|
||||
List<PortMappingDO> portMappingDOList = portMappingMapper.selectList(new LambdaQueryWrapper<PortMappingDO>().eq(PortMappingDO::getProtocal, NetworkProtocolEnum.HTTP.getDesc()).isNotNull(PortMappingDO::getSubdomain));
|
||||
List<PortMappingDO> portMappingDOList = allMappingDOList.stream()
|
||||
.filter(item -> NetworkProtocolEnum.HTTP.getDesc().equals(item.getProtocal()) && item.getSubdomain() != null)
|
||||
.collect(Collectors.toList());
|
||||
if (CollectionUtil.isEmpty(portMappingDOList)) {
|
||||
return;
|
||||
}
|
||||
@@ -310,9 +407,96 @@ public class PortMappingService implements LifecycleBean {
|
||||
return;
|
||||
}
|
||||
ProxyUtil.setSubdomainToServerPort(item.getSubdomain(), item.getServerPort());
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新流量限制缓存
|
||||
* @param id
|
||||
* @param upLimitRate
|
||||
* @param downLimitRate
|
||||
*/
|
||||
private void refreshFlowLimitCache(Integer id, String upLimitRate, String downLimitRate) {
|
||||
if (null == id) {
|
||||
return;
|
||||
}
|
||||
flowLimitCache.put(id, new FlowLimitBO()
|
||||
.setUpLimitRate(StringUtil.parseBytes(upLimitRate))
|
||||
.setDownLimitRate(StringUtil.parseBytes(downLimitRate))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取license的流量限制
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public FlowLimitBO getFlowLimit(Integer id) {
|
||||
FlowLimitBO res = flowLimitCache.get(id);
|
||||
if (null == res) {
|
||||
PortMappingDO portMappingDO = portMappingMapper.findById(id);
|
||||
if (null != portMappingDO) {
|
||||
refreshFlowLimitCache(id, portMappingDO.getUpLimitRate(), portMappingDO.getDownLimitRate());
|
||||
res = flowLimitCache.get(id);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public Integer getPortMappingIdByServerPort(Integer serverPort) {
|
||||
if (null == serverPort) {
|
||||
return null;
|
||||
}
|
||||
Integer id = serverPortToPortMappingIdCache.get(serverPort);
|
||||
if (null != id) {
|
||||
return id;
|
||||
}
|
||||
List<PortMappingDO> portMappingDOList = portMappingMapper.findListByServerPort(serverPort);
|
||||
// 不存在 或者 有多条记录,都不处理
|
||||
if (CollectionUtils.isEmpty(portMappingDOList) || portMappingDOList.size() > 1) {
|
||||
return null;
|
||||
}
|
||||
id = portMappingDOList.get(0).getId();
|
||||
serverPortToPortMappingIdCache.put(serverPort, id);
|
||||
return id;
|
||||
}
|
||||
|
||||
public Integer getLicenseIdById(Integer id) {
|
||||
Integer licenseId = idToLicenseIdCache.get(id);
|
||||
if (null == licenseId) {
|
||||
PortMappingDO portMappingDO = portMappingMapper.findById(id);
|
||||
if (null != portMappingDO) {
|
||||
licenseId = portMappingDO.getLicenseId();
|
||||
idToLicenseIdCache.put(id, licenseId);
|
||||
}
|
||||
}
|
||||
return licenseId;
|
||||
}
|
||||
|
||||
public FlowLimitBO getFlowLimitByServerPort(Integer serverPort) {
|
||||
Integer id = getPortMappingIdByServerPort(serverPort);
|
||||
if (null == id) {
|
||||
return null;
|
||||
}
|
||||
FlowLimitBO res = getFlowLimit(id);
|
||||
if (null == res || (null == res.getUpLimitRate() && null == res.getDownLimitRate())) {
|
||||
Integer licenseId = getLicenseIdById(id);
|
||||
if (null != licenseId) {
|
||||
res = licenseService.getFlowLimit(licenseId);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
private void updateMappingPortToSecurityGroupMap(Integer serverPort, Integer securityGroupId) {
|
||||
if (securityGroupId == null || securityGroupId == 0) {
|
||||
mappingPortToSecurityGroupMap.remove(serverPort);
|
||||
return;
|
||||
}
|
||||
mappingPortToSecurityGroupMap.put(serverPort, securityGroupId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() throws Throwable {
|
||||
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ public class ProtocalService {
|
||||
public List<ProtocalListRes> list() {
|
||||
return Lists.newArrayList(
|
||||
new ProtocalListRes().setName("TCP").setEnable(Boolean.TRUE).setRemark("支持一切TCP之上的协议"),
|
||||
new ProtocalListRes().setName("HTTP(S)").setEnable(Boolean.TRUE).setRemark("支持绑定子域名,未绑定时等价于时使用TCP。 若配置了证书,则同时支持HTTPS。"),
|
||||
new ProtocalListRes().setName("HTTP(S)").setEnable(Boolean.TRUE).setRemark("支持绑定子域名,未绑定时等价于使用TCP。 若配置了证书,则同时支持HTTPS。"),
|
||||
new ProtocalListRes().setName("UDP").setEnable(Boolean.TRUE).setRemark("支持UDP转发、响应。需要配合响应数、超时时间使用")
|
||||
);
|
||||
}
|
||||
|
||||
+267
@@ -0,0 +1,267 @@
|
||||
package org.dromara.neutrinoproxy.server.service;
|
||||
|
||||
import cn.hutool.cache.Cache;
|
||||
import cn.hutool.cache.CacheUtil;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.solon.plugins.pagination.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.ibatis.solon.annotation.Db;
|
||||
import org.dromara.neutrinoproxy.server.base.page.PageInfo;
|
||||
import org.dromara.neutrinoproxy.server.base.page.PageQuery;
|
||||
import org.dromara.neutrinoproxy.server.base.rest.SystemContextHolder;
|
||||
import org.dromara.neutrinoproxy.server.constant.EnableStatusEnum;
|
||||
import org.dromara.neutrinoproxy.server.constant.ExceptionConstant;
|
||||
import org.dromara.neutrinoproxy.server.constant.SecurityRulePassTypeEnum;
|
||||
import org.dromara.neutrinoproxy.server.controller.req.system.*;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.system.*;
|
||||
import org.dromara.neutrinoproxy.server.dal.SecurityGroupMapper;
|
||||
import org.dromara.neutrinoproxy.server.dal.SecurityRuleMapper;
|
||||
import org.dromara.neutrinoproxy.server.dal.entity.SecurityGroupDO;
|
||||
import org.dromara.neutrinoproxy.server.dal.entity.SecurityRuleDO;
|
||||
import org.dromara.neutrinoproxy.server.util.ParamCheckUtil;
|
||||
import org.noear.solon.annotation.Component;
|
||||
import org.noear.solon.annotation.Init;
|
||||
import org.noear.solon.core.runtime.NativeDetector;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class SecurityGroupService {
|
||||
|
||||
@Db
|
||||
private SecurityGroupMapper securityGroupMapper;
|
||||
|
||||
@Db
|
||||
private SecurityRuleMapper securityRuleMapper;
|
||||
|
||||
private final Map<Integer, SecurityGroupDO> securityGroupMap = new ConcurrentHashMap<>();
|
||||
|
||||
// 允许通过控制的缓存,缓存类型最近最久未使用缓存,容量100,超时时间5分钟
|
||||
private final Cache<String, Boolean> ipAllowControlCache = CacheUtil.newLRUCache(100, 1000 * 60 * 5);
|
||||
|
||||
@Init(index = 100)
|
||||
public synchronized void init() {
|
||||
// aot 阶段,不初始化
|
||||
if (NativeDetector.isAotRuntime()) {
|
||||
return;
|
||||
}
|
||||
securityGroupMap.clear();
|
||||
List<SecurityGroupDO> groupDOList = securityGroupMapper.selectList(Wrappers.lambdaQuery(SecurityGroupDO.class)
|
||||
.eq(SecurityGroupDO::getEnable, EnableStatusEnum.ENABLE.getStatus()));
|
||||
groupDOList.forEach(securityGroupDO -> securityGroupMap.put(securityGroupDO.getId(), securityGroupDO));
|
||||
ipAllowControlCache.clear();
|
||||
}
|
||||
|
||||
public void clearCache() {
|
||||
ipAllowControlCache.clear();
|
||||
}
|
||||
|
||||
public PageInfo<SecurityGroupListRes> groupPage(PageQuery pageQuery, SecurityGroupListReq req) {
|
||||
if (StringUtils.isNotEmpty(req.getName())) {
|
||||
//在应用层处理,否则sqlite不支持
|
||||
req.setName("%" + req.getName() + "%");
|
||||
}
|
||||
if (StringUtils.isNotEmpty(req.getDescription())) {
|
||||
//在应用层处理,否则sqlite不支持
|
||||
req.setDescription("%" + req.getDescription() + "%");
|
||||
}
|
||||
Page<SecurityGroupDO> page = new Page<>(pageQuery.getCurrent(), pageQuery.getSize());
|
||||
List<SecurityGroupDO> list = securityGroupMapper.selectByCondition(page, req);
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return PageInfo.of(null, page.getTotal(), pageQuery.getCurrent(), pageQuery.getSize());
|
||||
}
|
||||
List<SecurityGroupListRes> respList = list.stream().map(SecurityGroupDO::toListRes).collect(Collectors.toList());
|
||||
return PageInfo.of(respList, page.getTotal(), pageQuery.getCurrent(), pageQuery.getSize());
|
||||
}
|
||||
|
||||
public List<SecurityGroupListRes> groupList() {
|
||||
List<SecurityGroupDO> list = securityGroupMapper.selectList(Wrappers.lambdaQuery(SecurityGroupDO.class)
|
||||
.eq(SecurityGroupDO::getUserId, SystemContextHolder.getUserId()));
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return list.stream().map(SecurityGroupDO::toListRes).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public SecurityGroupDetailRes groupDetail(SecurityGroupDetailReq req) {
|
||||
SecurityGroupDO securityGroupDO = securityGroupMapper.selectById(req.getId());
|
||||
if (null != securityGroupDO) {
|
||||
return securityGroupDO.toDetailRes();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void createGroup(SecurityGroupCreateReq req) {
|
||||
SecurityGroupDO groupDO = new SecurityGroupDO();
|
||||
BeanUtil.copyProperties(req, groupDO);
|
||||
groupDO.setEnable(EnableStatusEnum.ENABLE.getStatus())
|
||||
.setUserId(SystemContextHolder.getUserId())
|
||||
.setCreateTime(new Date())
|
||||
.setUpdateTime(new Date());
|
||||
securityGroupMapper.insert(groupDO);
|
||||
init();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新时不允许更新默认放行类型
|
||||
* @param req 安全组更新参数
|
||||
*/
|
||||
public void updateGroup(SecurityGroupUpdateReq req) {
|
||||
SecurityGroupDO groupDO = securityGroupMapper.selectById(req.getId());
|
||||
BeanUtil.copyProperties(req, groupDO, "defaultPassType");
|
||||
securityGroupMapper.updateById(groupDO);
|
||||
init();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除安全组,并级联删除安全组下的规则,删除后,需缓存
|
||||
* @param groupId 安全组Id
|
||||
*/
|
||||
public void deleteGroup(Integer groupId) {
|
||||
securityGroupMapper.deleteById(groupId);
|
||||
securityRuleMapper.delete(Wrappers.lambdaQuery(SecurityRuleDO.class)
|
||||
.eq(SecurityRuleDO::getGroupId, groupId));
|
||||
init();
|
||||
}
|
||||
|
||||
public SecurityGroupUpdateEnableStatueRes updateGroupEnableStatueReq(SecurityGroupUpdateEnableStatueReq req) {
|
||||
SecurityGroupDO groupDO = securityGroupMapper.selectById(req.getId());
|
||||
ParamCheckUtil.checkNotNull(groupDO, ExceptionConstant.SECURITY_GROUP_NOT_EXIST);
|
||||
|
||||
securityGroupMapper.updateEnableStatus(req.getId(), req.getEnable(), new Date());
|
||||
init();
|
||||
return new SecurityGroupUpdateEnableStatueRes();
|
||||
}
|
||||
|
||||
public PageInfo<SecurityRuleListRes> rulePage(PageQuery pageQuery, SecurityRuleListReq req) {
|
||||
if (StringUtils.isNotEmpty(req.getName())) {
|
||||
//在应用层处理,否则sqlite不支持
|
||||
req.setName("%" + req.getName() + "%");
|
||||
}
|
||||
if (StringUtils.isNotEmpty(req.getDescription())) {
|
||||
//在应用层处理,否则sqlite不支持
|
||||
req.setDescription("%" + req.getDescription() + "%");
|
||||
}
|
||||
Page<SecurityRuleDO> page = new Page<>(pageQuery.getCurrent(), pageQuery.getSize());
|
||||
List<SecurityRuleDO> list = securityRuleMapper.selectByCondition(page, req);
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return PageInfo.of(null, page.getTotal(), pageQuery.getCurrent(), pageQuery.getSize());
|
||||
}
|
||||
List<SecurityRuleListRes> respList = list.stream().map(SecurityRuleDO::toListRes).collect(Collectors.toList());
|
||||
return PageInfo.of(respList, page.getTotal(), pageQuery.getCurrent(), pageQuery.getSize());
|
||||
}
|
||||
|
||||
public List<SecurityRuleListRes> ruleList(SecurityRuleListReq req) {
|
||||
List<SecurityRuleDO> list = securityRuleMapper.selectList(new LambdaQueryWrapper<SecurityRuleDO>()
|
||||
.eq(null != req.getGroupId(), SecurityRuleDO::getGroupId, req.getGroupId())
|
||||
);
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return list.stream().map(SecurityRuleDO::toListRes).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public void createRule(SecurityRuleCreateReq req) {
|
||||
SecurityRuleDO ruleDO = new SecurityRuleDO();
|
||||
BeanUtil.copyProperties(req, ruleDO);
|
||||
ruleDO.setUserId(SystemContextHolder.getUserId())
|
||||
.setCreateTime(new Date())
|
||||
.setEnable(EnableStatusEnum.ENABLE.getStatus())
|
||||
.setUpdateTime(new Date());
|
||||
securityRuleMapper.insert(ruleDO);
|
||||
clearCache();
|
||||
}
|
||||
|
||||
public void updateRule(SecurityRuleUpdateReq req) {
|
||||
SecurityRuleDO ruleDO = securityRuleMapper.selectById(req.getId());
|
||||
BeanUtil.copyProperties(req, ruleDO);
|
||||
securityRuleMapper.updateById(ruleDO);
|
||||
clearCache();
|
||||
}
|
||||
|
||||
public void deleteRule(Integer ruleId) {
|
||||
securityRuleMapper.deleteById(ruleId);
|
||||
clearCache();
|
||||
}
|
||||
|
||||
public SecurityRuleUpdateEnableStatueRes updateRuleEnableStatueReq(SecurityRuleUpdateEnableStatueReq req) {
|
||||
SecurityRuleDO ruleDO = securityRuleMapper.selectById(req.getId());
|
||||
ParamCheckUtil.checkNotNull(ruleDO, ExceptionConstant.SECURITY_RULE_NOT_EXIST);
|
||||
|
||||
securityRuleMapper.updateEnableStatus(req.getId(), req.getEnable(), new Date());
|
||||
clearCache();
|
||||
return new SecurityRuleUpdateEnableStatueRes();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断ip在该安全组下是否允许,如果安全组没有创建,则放行,默认黑名单规则
|
||||
* @param ip 被判断的IP地址
|
||||
* @param groupId 安全组Id
|
||||
* @return 是否放行
|
||||
*/
|
||||
public boolean judgeAllow(String ip, Integer groupId) {
|
||||
ip = ip.toLowerCase();
|
||||
// 不能判断当前连接的IP,保守处理,拒绝放行
|
||||
if (StrUtil.isEmpty(ip)) {
|
||||
log.debug("[SecurityGroup] cannot get remote ip,this pack be reject");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 黑名单规则,没有该安全组,则放行
|
||||
if (groupId == null) {
|
||||
return true;
|
||||
}
|
||||
SecurityGroupDO groupDO = securityGroupMap.get(groupId);
|
||||
if (groupDO == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Boolean allow = null;
|
||||
String judgeAllowMapKey = ip + groupId;
|
||||
if (ipAllowControlCache.containsKey(judgeAllowMapKey)) {
|
||||
allow = ipAllowControlCache.get(judgeAllowMapKey);
|
||||
log.debug("[SecurityGroup] ip:{} groupId:{} cached security strategy:{}", ip, groupId, allow ? "allow" : "reject");
|
||||
return allow;
|
||||
}
|
||||
|
||||
List<SecurityRuleDO> ruleDOList = securityRuleMapper.selectList(Wrappers.lambdaQuery(SecurityRuleDO.class)
|
||||
.eq(SecurityRuleDO::getGroupId, groupId)
|
||||
.eq(SecurityRuleDO::getEnable, EnableStatusEnum.ENABLE.getStatus())
|
||||
.orderByAsc(SecurityRuleDO::getPriority)
|
||||
);
|
||||
for (SecurityRuleDO ruleDO : ruleDOList) {
|
||||
SecurityRulePassTypeEnum passType = ruleDO.judge(ip);
|
||||
if (passType == SecurityRulePassTypeEnum.ALLOW) {
|
||||
allow = true;
|
||||
log.debug("[SecurityGroup] ip:{} groupId:{} ruleId:{} security strategy:{}", ip, groupId, ruleDO.getId(), "allow");
|
||||
break;
|
||||
}
|
||||
if (passType == SecurityRulePassTypeEnum.DENY) {
|
||||
allow = false;
|
||||
log.info("[SecurityGroup] ip:{} groupId:{} ruleId:{} security strategy:{}", ip, groupId, ruleDO.getId(), "reject");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 当前IP没有匹配到任何一条规则,则使用安全组默认规则
|
||||
if (allow == null) {
|
||||
allow = SecurityRulePassTypeEnum.ALLOW.getType().equals(groupDO.getDefaultPassType());
|
||||
log.debug("[SecurityGroup] ip:{} groupId{} use security group default strategy:{}", ip, groupId, allow ? "allow" : "reject");
|
||||
}
|
||||
|
||||
ipAllowControlCache.put(judgeAllowMapKey, allow);
|
||||
|
||||
return allow;
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package org.dromara.neutrinoproxy.server.service.bo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @author: aoshiguchen
|
||||
* @date: 2023/12/15
|
||||
*/
|
||||
@Accessors(chain = true)
|
||||
@Data
|
||||
public class FlowLimitBO {
|
||||
private Long upLimitRate;
|
||||
private Long downLimitRate;
|
||||
}
|
||||
+16
@@ -103,4 +103,20 @@ public class ParamCheckUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验字节描述
|
||||
* @param str
|
||||
* @param params
|
||||
*/
|
||||
public static void checkBytesDesc(String str, Object... params) {
|
||||
// 允许为空
|
||||
if (StrUtil.isEmpty(str)) {
|
||||
return;
|
||||
}
|
||||
Long bytes = StringUtil.parseBytes(str);
|
||||
if (null == bytes || bytes <= 0) {
|
||||
throw ServiceException.create(ExceptionConstant.BYTES_DESC_INVALID, params);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
package org.dromara.neutrinoproxy.server.util;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @author: aoshiguchen
|
||||
* @date: 2023/12/15
|
||||
*/
|
||||
public class StringUtil {
|
||||
private static final Integer BYTES_MUL_KB = 1024;
|
||||
private static final Integer BYTES_MUL_MB = BYTES_MUL_KB * 1024;
|
||||
private static final Integer BYTES_MUL_GB = BYTES_MUL_MB * 1024;
|
||||
private static final String[] BYTES_UNIT_STR = {"B", "K", "KB", "M", "MB", "G", "GB"};
|
||||
private static final Integer[] BYTES_UNIT_MUL = {1, BYTES_MUL_KB, BYTES_MUL_KB, BYTES_MUL_MB, BYTES_MUL_MB, BYTES_MUL_GB, BYTES_MUL_GB};
|
||||
private static final String BYTES_DESC_REGEX = "\\s*(\\d+\\.*\\d*)\\s*(B|K|KB|M|MB|G|GB)\\s*";
|
||||
private static final Pattern BYTES_DESC_PATTERN = Pattern.compile(BYTES_DESC_REGEX);
|
||||
|
||||
/**
|
||||
* 校验是否符合字节描述
|
||||
* @param desc
|
||||
* @return
|
||||
*/
|
||||
public static boolean isBytesDesc(String desc) {
|
||||
if (StrUtil.isBlank(desc)) {
|
||||
return false;
|
||||
}
|
||||
return desc.toUpperCase().matches(BYTES_DESC_REGEX);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析字节数
|
||||
* 支持B、K、KB、M、MB、G、GB 忽略大小写、忽略首尾空格、忽略数字与单位之间的空格
|
||||
* @param desc
|
||||
* @return
|
||||
*/
|
||||
public static Long parseBytes(String desc) {
|
||||
try {
|
||||
if (!isBytesDesc(desc)) {
|
||||
return null;
|
||||
}
|
||||
Matcher matcher = BYTES_DESC_PATTERN.matcher(desc.toUpperCase());
|
||||
boolean found = matcher.find();
|
||||
if (!found) {
|
||||
return null;
|
||||
}
|
||||
Double n = Double.parseDouble(matcher.group(1));
|
||||
String unit = matcher.group(2);
|
||||
Integer unitIndex = getBytesUnitIndex(unit);
|
||||
if (null == unitIndex) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (long)(n * BYTES_UNIT_MUL[unitIndex]);
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Integer getBytesUnitIndex(String unit) {
|
||||
if (StrUtil.isBlank(unit)) {
|
||||
return null;
|
||||
}
|
||||
for (int i = 0; i < BYTES_UNIT_STR.length; i++) {
|
||||
if (unit.equals(BYTES_UNIT_STR[i])) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
server:
|
||||
# 服务端web端口,用于支持HTTP接口,管理后台页面访问
|
||||
port: 8888
|
||||
# 日志级别
|
||||
solon.logging:
|
||||
logger:
|
||||
"root":
|
||||
level: info
|
||||
appender:
|
||||
file:
|
||||
level: info
|
||||
|
||||
neutrino:
|
||||
proxy:
|
||||
# 隧道相关配置-用于维持服务端与客户端的通信
|
||||
tunnel:
|
||||
# 线程池相关配置,用于技术调优,可忽略
|
||||
boss-thread-count: 2
|
||||
work-thread-count: 10
|
||||
# 隧道非SSL端口
|
||||
port: 9000
|
||||
# 隧道SSL端口
|
||||
ssl-port: 9002
|
||||
# 隧道SSL证书配置
|
||||
key-store-password: 123456
|
||||
key-manager-password: 123456
|
||||
jks-path: classpath:/test.jks
|
||||
# 是否开启隧道传输报文日志(日志级别为debug时开启才有效)
|
||||
transfer-log-enable: false
|
||||
# 是否开启心跳日志
|
||||
heartbeat-log-enable: false
|
||||
server:
|
||||
tcp:
|
||||
# 线程池相关配置,用于技术调优,可忽略
|
||||
boss-thread-count: 5
|
||||
work-thread-count: 20
|
||||
# http代理端口,默认80
|
||||
http-proxy-port: 80
|
||||
# https代理端口,默认443 (需要配置域名、证书)
|
||||
https-proxy-port: 443
|
||||
# 如果不配置,则不支持域名映射
|
||||
domain-name:
|
||||
# https证书配置
|
||||
key-store-password:
|
||||
jks-path:
|
||||
# 是否开启代理服务报文日志(日志级别为debug时开启才有效)
|
||||
transfer-log-enable: false
|
||||
udp:
|
||||
# 线程池相关配置,用于技术调优,可忽略
|
||||
boss-thread-count: 5
|
||||
work-thread-count: 20
|
||||
# 是否开启代理服务报文日志(日志级别为debug时开启才有效)
|
||||
transfer-log-enable: false
|
||||
data:
|
||||
db:
|
||||
# 数据库类型,目前支持h2、mysql、mariadb
|
||||
type: h2
|
||||
# 数据库连接URL
|
||||
url: jdbc:h2:file:./data/db;MODE=MySQL;AUTO_SERVER=TRUE
|
||||
# 数据库用户名
|
||||
username:
|
||||
# 数据库密码
|
||||
password:
|
||||
@@ -5,10 +5,9 @@ server:
|
||||
solon:
|
||||
app:
|
||||
name: neutrino-proxy-server
|
||||
version: 2.0.1
|
||||
config:
|
||||
add: ./app.yml
|
||||
# aot:
|
||||
# jvmArguments: --add-opens java.base/java.lang=ALL-UNNAMED
|
||||
# 日志级别
|
||||
solon.logging.appender:
|
||||
console:
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.dromara.neutrinoproxy.server.dal.SecurityGroupMapper">
|
||||
|
||||
<select id="selectByCondition" resultType="org.dromara.neutrinoproxy.server.dal.entity.SecurityGroupDO">
|
||||
SELECT sg.* from security_group sg
|
||||
<where>
|
||||
<if test="req.name != null and req.name != '' ">
|
||||
AND sg.name like #{req.name}
|
||||
</if>
|
||||
<if test="req.description != null and req.description != '' ">
|
||||
AND sg.description like #{req.description}
|
||||
</if>
|
||||
<if test="req.defaultPassType != null">
|
||||
AND sg.default_pass_type like #{req.defaultPassType}
|
||||
</if>
|
||||
<if test="req.enable != null">
|
||||
AND sg.enable like #{req.enable}
|
||||
</if>
|
||||
</where>
|
||||
order by sg.id DESC
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.dromara.neutrinoproxy.server.dal.SecurityRuleMapper">
|
||||
|
||||
<select id="selectByCondition" resultType="org.dromara.neutrinoproxy.server.dal.entity.SecurityRuleDO">
|
||||
SELECT sr.* from security_rule sr
|
||||
<where>
|
||||
<if test="req.groupId != null">
|
||||
AND sr.group_id = ${req.groupId}
|
||||
</if>
|
||||
<if test="req.name != null and req.name != '' ">
|
||||
AND sr.name like #{req.name}
|
||||
</if>
|
||||
<if test="req.description != null and req.description != '' ">
|
||||
AND sr.description like #{req.description}
|
||||
</if>
|
||||
<if test="req.passType != null">
|
||||
AND sr.pass_type like #{req.passType}
|
||||
</if>
|
||||
<if test="req.enable != null">
|
||||
AND sr.enable like #{req.enable}
|
||||
</if>
|
||||
</where>
|
||||
order by sr.id DESC
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -45,6 +45,37 @@ CREATE TABLE IF NOT EXISTS `port_group` (
|
||||
`create_time` TIMESTAMP NOT NULL,
|
||||
`update_time` TIMESTAMP NOT NULL
|
||||
);
|
||||
|
||||
#安全组
|
||||
CREATE TABLE IF NOT EXISTS `security_group` (
|
||||
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||
`name` VARCHAR(20) NOT NULL,
|
||||
`description` VARCHAR(255),
|
||||
`user_id` INTEGER NOT NULL,
|
||||
`enable` INTEGER NOT NULL,
|
||||
`default_pass_type` INTEGER NOT NULL,
|
||||
`create_time` TIMESTAMP NOT NULL,
|
||||
`update_time` TIMESTAMP NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
|
||||
#安全组规则
|
||||
CREATE TABLE IF NOT EXISTS `security_rule` (
|
||||
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||
`group_id` INTEGER NOT NULL,
|
||||
`name` VARCHAR(20) NOT NULL,
|
||||
`description` VARCHAR(255) NOT NULL,
|
||||
`rule` text NOT NULL,
|
||||
`pass_type` INTEGER NOT NULL,
|
||||
`priority` INTEGER NOT NULL,
|
||||
`user_id` INTEGER NOT NULL,
|
||||
`enable` INTEGER NOT NULL,
|
||||
`create_time` TIMESTAMP NOT NULL,
|
||||
`update_time` TIMESTAMP NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS I_security_rule_group_id ON security_rule(group_id);
|
||||
|
||||
#############################代理配置相关表#############################
|
||||
#license表
|
||||
CREATE TABLE IF NOT EXISTS `license` (
|
||||
@@ -52,6 +83,8 @@ CREATE TABLE IF NOT EXISTS `license` (
|
||||
`name` VARCHAR(50) NOT NULL,
|
||||
`key` VARCHAR(100) NOT NULL,
|
||||
`user_id` INTEGER NOT NULL,
|
||||
`up_limit_rate` VARCHAR(20) DEFAULT NULL,
|
||||
`down_limit_rate` VARCHAR(20) DEFAULT NULL,
|
||||
`is_online` INTEGER(2) NOT NULL,
|
||||
`enable` INTEGER(2) NOT NULL,
|
||||
`create_time` TIMESTAMP NOT NULL,
|
||||
@@ -68,11 +101,14 @@ CREATE TABLE IF NOT EXISTS `port_mapping` (
|
||||
`server_port` INTEGER NOT NULL,
|
||||
`client_ip` VARCHAR(20) NOT NULL,
|
||||
`client_port` INTEGER NOT NULL,
|
||||
`up_limit_rate` VARCHAR(20) DEFAULT NULL,
|
||||
`down_limit_rate` VARCHAR(20) DEFAULT NULL,
|
||||
`is_online` INTEGER(2) NOT NULL,
|
||||
`description` VARCHAR(100) DEFAULT NULL,
|
||||
`proxy_responses` INTEGER(20) NOT NULL DEFAULT 0,
|
||||
`proxy_timeout_ms` INTEGER(20) NOT NULL DEFAULT 0,
|
||||
`enable` INTEGER(2) NOT NULL,
|
||||
`security_group_id` INTEGER(20) NOT NULL DEFAULT 0,
|
||||
`create_time` TIMESTAMP NOT NULL,
|
||||
`update_time` TIMESTAMP NOT NULL
|
||||
);
|
||||
@@ -135,8 +171,8 @@ CREATE TABLE IF NOT EXISTS `flow_report_minute` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
`user_id` INTEGER(20) NOT NULL,
|
||||
`license_id` INTEGER(20) NOT NULL,
|
||||
`write_bytes` INTEGER(20) NOT NULL,
|
||||
`read_bytes` INTEGER(20) NOT NULL,
|
||||
`write_bytes` bigint NOT NULL,
|
||||
`read_bytes` bigint NOT NULL,
|
||||
`date` TIMESTAMP NOT NULL,
|
||||
`date_str` VARCHAR(20) NOT NULL,
|
||||
`create_time` TIMESTAMP NOT NULL
|
||||
@@ -151,8 +187,8 @@ CREATE TABLE IF NOT EXISTS `flow_report_hour` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
`user_id` INTEGER(20) NOT NULL,
|
||||
`license_id` INTEGER(20) NOT NULL,
|
||||
`write_bytes` INTEGER(20) NOT NULL,
|
||||
`read_bytes` INTEGER(20) NOT NULL,
|
||||
`write_bytes` bigint NOT NULL,
|
||||
`read_bytes` bigint NOT NULL,
|
||||
`date` TIMESTAMP NOT NULL,
|
||||
`date_str` VARCHAR(20) NOT NULL,
|
||||
`create_time` TIMESTAMP NOT NULL
|
||||
@@ -167,8 +203,8 @@ CREATE TABLE IF NOT EXISTS `flow_report_day` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
`user_id` INTEGER(20) NOT NULL,
|
||||
`license_id` INTEGER(20) NOT NULL,
|
||||
`write_bytes` INTEGER(20) NOT NULL,
|
||||
`read_bytes` INTEGER(20) NOT NULL,
|
||||
`write_bytes` bigint NOT NULL,
|
||||
`read_bytes` bigint NOT NULL,
|
||||
`date` TIMESTAMP NOT NULL,
|
||||
`date_str` VARCHAR(20) NOT NULL,
|
||||
`create_time` TIMESTAMP NOT NULL
|
||||
@@ -183,8 +219,8 @@ CREATE TABLE IF NOT EXISTS `flow_report_month` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
`user_id` INTEGER(20) NOT NULL,
|
||||
`license_id` INTEGER(20) NOT NULL,
|
||||
`write_bytes` INTEGER(20) NOT NULL,
|
||||
`read_bytes` INTEGER(20) NOT NULL,
|
||||
`write_bytes` bigint NOT NULL,
|
||||
`read_bytes` bigint NOT NULL,
|
||||
`date` TIMESTAMP NOT NULL,
|
||||
`date_str` VARCHAR(20) NOT NULL,
|
||||
`create_time` TIMESTAMP NOT NULL
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
#安全组
|
||||
CREATE TABLE IF NOT EXISTS `security_group` (
|
||||
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||
`name` VARCHAR(20) NOT NULL,
|
||||
`description` VARCHAR(255),
|
||||
`user_id` INTEGER NOT NULL,
|
||||
`enable` INTEGER NOT NULL,
|
||||
`default_pass_type` INTEGER NOT NULL,
|
||||
`create_time` TIMESTAMP NOT NULL,
|
||||
`update_time` TIMESTAMP NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
|
||||
#安全组规则
|
||||
CREATE TABLE IF NOT EXISTS `security_rule` (
|
||||
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||
`group_id` INTEGER NOT NULL,
|
||||
`name` VARCHAR(20) NOT NULL,
|
||||
`description` VARCHAR(255) NOT NULL,
|
||||
`rule` text NOT NULL,
|
||||
`pass_type` INTEGER NOT NULL,
|
||||
`priority` INTEGER NOT NULL,
|
||||
`user_id` INTEGER NOT NULL,
|
||||
`enable` INTEGER NOT NULL,
|
||||
`create_time` TIMESTAMP NOT NULL,
|
||||
`update_time` TIMESTAMP NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS I_security_rule_group_id ON security_rule(group_id);
|
||||
|
||||
# port_mapping表增加字段
|
||||
ALTER TABLE `port_mapping` ADD COLUMN `security_group_id` INTEGER DEFAULT 0;
|
||||
ALTER TABLE `port_mapping` ADD COLUMN `up_limit_rate` varchar(20) DEFAULT NULL;
|
||||
ALTER TABLE `port_mapping` ADD COLUMN `down_limit_rate` varchar(20) DEFAULT NULL;
|
||||
|
||||
# license表增加字段
|
||||
ALTER TABLE `license` ADD COLUMN `up_limit_rate` varchar(20) DEFAULT NULL;
|
||||
ALTER TABLE `license` ADD COLUMN `down_limit_rate` varchar(20) DEFAULT NULL;
|
||||
@@ -50,6 +50,36 @@ CREATE TABLE IF NOT EXISTS `port_group` (
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
#安全组
|
||||
CREATE TABLE IF NOT EXISTS `security_group` (
|
||||
`id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`name` varchar(20) NOT NULL COMMENT '安全组名称',
|
||||
`description` varchar(255) COMMENT '安全组描述',
|
||||
`user_id` int NOT NULL COMMENT '用户ID',
|
||||
`enable` int NOT NULL COMMENT '是否启用(1、启用 2、禁用)',
|
||||
`default_pass_type` int NOT NULL COMMENT '默认放行类型',
|
||||
`create_time` datetime(3) NOT NULL COMMENT '创建时间',
|
||||
`update_time` datetime(3) NOT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
#安全组规则
|
||||
CREATE TABLE IF NOT EXISTS `security_rule` (
|
||||
`id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`group_id` int NOT NULL COMMENT '关联安全组',
|
||||
`name` varchar(20) NOT NULL COMMENT '规则名称',
|
||||
`description` varchar(255) NOT NULL COMMENT '规则描述',
|
||||
`rule` text NOT NULL COMMENT '规则内容',
|
||||
`pass_type` int NOT NULL COMMENT '放行类型',
|
||||
`priority` int(1) NOT NULL COMMENT '优先级',
|
||||
`user_id` int NOT NULL COMMENT '用户ID',
|
||||
`enable` int NOT NULL COMMENT '是否启用(1、启用 2、禁用)',
|
||||
`create_time` datetime(3) NOT NULL COMMENT '创建时间',
|
||||
`update_time` datetime(3) NOT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `I_security_rule_group_id_priority` (`group_id`, `priority`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
#############################代理配置相关表#############################
|
||||
#license表
|
||||
CREATE TABLE IF NOT EXISTS `license` (
|
||||
@@ -57,6 +87,8 @@ CREATE TABLE IF NOT EXISTS `license` (
|
||||
`name` varchar(50) NOT NULL COMMENT 'license名称',
|
||||
`key` varchar(100) NOT NULL COMMENT 'license key',
|
||||
`user_id` int NOT NULL COMMENT '用户ID',
|
||||
`up_limit_rate` varchar(20) DEFAULT NULL COMMENT '上传限速',
|
||||
`down_limit_rate` varchar(20) DEFAULT NULL COMMENT '下载限速',
|
||||
`is_online` int NOT NULL COMMENT '是否在线(1、在线 2、离线)',
|
||||
`enable` int NOT NULL COMMENT '是否启用(1、启用 2、禁用)',
|
||||
`create_time` datetime(3) NOT NULL COMMENT '创建时间',
|
||||
@@ -74,11 +106,14 @@ CREATE TABLE IF NOT EXISTS `port_mapping` (
|
||||
`server_port` int NOT NULL COMMENT '服务端端口',
|
||||
`client_ip` varchar(20) NOT NULL COMMENT '客户端IP',
|
||||
`client_port` int NOT NULL COMMENT '客户端端口',
|
||||
`up_limit_rate` varchar(20) DEFAULT NULL COMMENT '上传限速',
|
||||
`down_limit_rate` varchar(20) DEFAULT NULL COMMENT '下载限速',
|
||||
`is_online` int NOT NULL COMMENT '是否在线(1、在线 2、离线)',
|
||||
`description` varchar(100) DEFAULT NULL COMMENT '描述',
|
||||
`proxy_responses` int NOT NULL DEFAULT 0 COMMENT '代理响应数据包数量',
|
||||
`proxy_timeout_ms` int NOT NULL DEFAULT 0 COMMENT '代理超时毫秒数',
|
||||
`enable` int NOT NULL COMMENT '是否启用(1、启用 2、禁用)',
|
||||
`security_group_id` int DEFAULT 0 COMMENT '安全组Id',
|
||||
`create_time` datetime(3) NOT NULL COMMENT '创建时间',
|
||||
`update_time` datetime(3) NOT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
@@ -145,8 +180,8 @@ CREATE TABLE IF NOT EXISTS `flow_report_minute` (
|
||||
`id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`user_id` int NOT NULL COMMENT '用户ID',
|
||||
`license_id` int NOT NULL COMMENT 'licenseId',
|
||||
`write_bytes` int NOT NULL COMMENT '写入流量',
|
||||
`read_bytes` int NOT NULL COMMENT '读取流量',
|
||||
`write_bytes` bigint NOT NULL COMMENT '写入流量',
|
||||
`read_bytes` bigint NOT NULL COMMENT '读取流量',
|
||||
`date` datetime(3) NOT NULL COMMENT '时间',
|
||||
`date_str` varchar(20) NOT NULL COMMENT '时间 yyyy-MM-dd HH:mm',
|
||||
`create_time` datetime(3) NOT NULL COMMENT '创建时间',
|
||||
@@ -162,8 +197,8 @@ CREATE TABLE IF NOT EXISTS `flow_report_hour` (
|
||||
`id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`user_id` int NOT NULL COMMENT '用户ID',
|
||||
`license_id` int NOT NULL COMMENT 'licenseId',
|
||||
`write_bytes` int NOT NULL COMMENT '写入流量',
|
||||
`read_bytes` int NOT NULL COMMENT '读取流量',
|
||||
`write_bytes` bigint NOT NULL COMMENT '写入流量',
|
||||
`read_bytes` bigint NOT NULL COMMENT '读取流量',
|
||||
`date` datetime(3) NOT NULL COMMENT '时间',
|
||||
`date_str` varchar(20) NOT NULL COMMENT '时间 yyyy-MM-dd HH',
|
||||
`create_time` datetime(3) NOT NULL COMMENT '创建时间',
|
||||
@@ -179,8 +214,8 @@ CREATE TABLE IF NOT EXISTS `flow_report_day` (
|
||||
`id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`user_id` int NOT NULL COMMENT '用户ID',
|
||||
`license_id` int NOT NULL COMMENT 'licenseId',
|
||||
`write_bytes` int NOT NULL COMMENT '写入流量',
|
||||
`read_bytes` int NOT NULL COMMENT '读取流量',
|
||||
`write_bytes` bigint NOT NULL COMMENT '写入流量',
|
||||
`read_bytes` bigint NOT NULL COMMENT '读取流量',
|
||||
`date` datetime(3) NOT NULL COMMENT '时间',
|
||||
`date_str` varchar(20) NOT NULL COMMENT '时间 yyyy-MM-dd',
|
||||
`create_time` datetime(3) NOT NULL COMMENT '创建时间',
|
||||
@@ -196,8 +231,8 @@ CREATE TABLE IF NOT EXISTS `flow_report_month` (
|
||||
`id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`user_id` int NOT NULL COMMENT '用户ID',
|
||||
`license_id` int NOT NULL COMMENT 'licenseId',
|
||||
`write_bytes` int NOT NULL COMMENT '写入流量',
|
||||
`read_bytes` int NOT NULL COMMENT '读取流量',
|
||||
`write_bytes` bigint NOT NULL COMMENT '写入流量',
|
||||
`read_bytes` bigint NOT NULL COMMENT '读取流量',
|
||||
`date` datetime(3) NOT NULL COMMENT '时间',
|
||||
`date_str` varchar(20) NOT NULL COMMENT '时间 yyyy-MM',
|
||||
`create_time` datetime(3) NOT NULL COMMENT '创建时间',
|
||||
|
||||
@@ -50,6 +50,36 @@ CREATE TABLE IF NOT EXISTS `port_group` (
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
#安全组
|
||||
CREATE TABLE IF NOT EXISTS `security_group` (
|
||||
`id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`name` varchar(20) NOT NULL COMMENT '安全组名称',
|
||||
`description` varchar(255) COMMENT '安全组描述',
|
||||
`user_id` int NOT NULL COMMENT '用户ID',
|
||||
`enable` int NOT NULL COMMENT '是否启用(1、启用 2、禁用)',
|
||||
`default_pass_type` int NOT NULL COMMENT '默认放行类型',
|
||||
`create_time` datetime(3) NOT NULL COMMENT '创建时间',
|
||||
`update_time` datetime(3) NOT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
#安全组规则
|
||||
CREATE TABLE IF NOT EXISTS `security_rule` (
|
||||
`id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`group_id` int NOT NULL COMMENT '关联安全组',
|
||||
`name` varchar(20) NOT NULL COMMENT '规则名称',
|
||||
`description` varchar(255) NOT NULL COMMENT '规则描述',
|
||||
`rule` text NOT NULL COMMENT '规则内容',
|
||||
`pass_type` int NOT NULL COMMENT '放行类型',
|
||||
`priority` int(1) NOT NULL COMMENT '优先级',
|
||||
`user_id` int NOT NULL COMMENT '用户ID',
|
||||
`enable` int NOT NULL COMMENT '是否启用(1、启用 2、禁用)',
|
||||
`create_time` datetime(3) NOT NULL COMMENT '创建时间',
|
||||
`update_time` datetime(3) NOT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `I_security_rule_group_id_priority` (`group_id`, `priority`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
#############################代理配置相关表#############################
|
||||
#license表
|
||||
CREATE TABLE IF NOT EXISTS `license` (
|
||||
@@ -57,6 +87,8 @@ CREATE TABLE IF NOT EXISTS `license` (
|
||||
`name` varchar(50) NOT NULL COMMENT 'license名称',
|
||||
`key` varchar(100) NOT NULL COMMENT 'license key',
|
||||
`user_id` int NOT NULL COMMENT '用户ID',
|
||||
`up_limit_rate` varchar(20) DEFAULT NULL COMMENT '上传限速',
|
||||
`down_limit_rate` varchar(20) DEFAULT NULL COMMENT '下载限速',
|
||||
`is_online` int NOT NULL COMMENT '是否在线(1、在线 2、离线)',
|
||||
`enable` int NOT NULL COMMENT '是否启用(1、启用 2、禁用)',
|
||||
`create_time` datetime(3) NOT NULL COMMENT '创建时间',
|
||||
@@ -74,11 +106,14 @@ CREATE TABLE IF NOT EXISTS `port_mapping` (
|
||||
`server_port` int NOT NULL COMMENT '服务端端口',
|
||||
`client_ip` varchar(20) NOT NULL COMMENT '客户端IP',
|
||||
`client_port` int NOT NULL COMMENT '客户端端口',
|
||||
`up_limit_rate` varchar(20) DEFAULT NULL COMMENT '上传限速',
|
||||
`down_limit_rate` varchar(20) DEFAULT NULL COMMENT '下载限速',
|
||||
`is_online` int NOT NULL COMMENT '是否在线(1、在线 2、离线)',
|
||||
`description` varchar(100) DEFAULT NULL COMMENT '描述',
|
||||
`proxy_responses` int NOT NULL DEFAULT 0 COMMENT '代理响应数据包数量',
|
||||
`proxy_timeout_ms` int NOT NULL DEFAULT 0 COMMENT '代理超时毫秒数',
|
||||
`enable` int NOT NULL COMMENT '是否启用(1、启用 2、禁用)',
|
||||
`security_group_id` int DEFAULT 0 COMMENT '安全组Id',
|
||||
`create_time` datetime(3) NOT NULL COMMENT '创建时间',
|
||||
`update_time` datetime(3) NOT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
@@ -145,8 +180,8 @@ CREATE TABLE IF NOT EXISTS `flow_report_minute` (
|
||||
`id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`user_id` int NOT NULL COMMENT '用户ID',
|
||||
`license_id` int NOT NULL COMMENT 'licenseId',
|
||||
`write_bytes` int NOT NULL COMMENT '写入流量',
|
||||
`read_bytes` int NOT NULL COMMENT '读取流量',
|
||||
`write_bytes` bigint NOT NULL COMMENT '写入流量',
|
||||
`read_bytes` bigint NOT NULL COMMENT '读取流量',
|
||||
`date` datetime(3) NOT NULL COMMENT '时间',
|
||||
`date_str` varchar(20) NOT NULL COMMENT '时间 yyyy-MM-dd HH:mm',
|
||||
`create_time` datetime(3) NOT NULL COMMENT '创建时间',
|
||||
@@ -162,8 +197,8 @@ CREATE TABLE IF NOT EXISTS `flow_report_hour` (
|
||||
`id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`user_id` int NOT NULL COMMENT '用户ID',
|
||||
`license_id` int NOT NULL COMMENT 'licenseId',
|
||||
`write_bytes` int NOT NULL COMMENT '写入流量',
|
||||
`read_bytes` int NOT NULL COMMENT '读取流量',
|
||||
`write_bytes` bigint NOT NULL COMMENT '写入流量',
|
||||
`read_bytes` bigint NOT NULL COMMENT '读取流量',
|
||||
`date` datetime(3) NOT NULL COMMENT '时间',
|
||||
`date_str` varchar(20) NOT NULL COMMENT '时间 yyyy-MM-dd HH',
|
||||
`create_time` datetime(3) NOT NULL COMMENT '创建时间',
|
||||
@@ -179,8 +214,8 @@ CREATE TABLE IF NOT EXISTS `flow_report_day` (
|
||||
`id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`user_id` int NOT NULL COMMENT '用户ID',
|
||||
`license_id` int NOT NULL COMMENT 'licenseId',
|
||||
`write_bytes` int NOT NULL COMMENT '写入流量',
|
||||
`read_bytes` int NOT NULL COMMENT '读取流量',
|
||||
`write_bytes` bigint NOT NULL COMMENT '写入流量',
|
||||
`read_bytes` bigint NOT NULL COMMENT '读取流量',
|
||||
`date` datetime(3) NOT NULL COMMENT '时间',
|
||||
`date_str` varchar(20) NOT NULL COMMENT '时间 yyyy-MM-dd',
|
||||
`create_time` datetime(3) NOT NULL COMMENT '创建时间',
|
||||
@@ -196,8 +231,8 @@ CREATE TABLE IF NOT EXISTS `flow_report_month` (
|
||||
`id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`user_id` int NOT NULL COMMENT '用户ID',
|
||||
`license_id` int NOT NULL COMMENT 'licenseId',
|
||||
`write_bytes` int NOT NULL COMMENT '写入流量',
|
||||
`read_bytes` int NOT NULL COMMENT '读取流量',
|
||||
`write_bytes` bigint NOT NULL COMMENT '写入流量',
|
||||
`read_bytes` bigint NOT NULL COMMENT '读取流量',
|
||||
`date` datetime(3) NOT NULL COMMENT '时间',
|
||||
`date_str` varchar(20) NOT NULL COMMENT '时间 yyyy-MM',
|
||||
`create_time` datetime(3) NOT NULL COMMENT '创建时间',
|
||||
@@ -207,3 +242,4 @@ CREATE TABLE IF NOT EXISTS `flow_report_month` (
|
||||
KEY `I_flow_report_month_user_id` (`user_id`),
|
||||
KEY `I_flow_report_month_license_id` (`license_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
ALTER TABLE `flow_report_minute` MODIFY COLUMN `read_bytes` BIGINT NOT NULL COMMENT '读取流量';
|
||||
ALTER TABLE `flow_report_minute` MODIFY COLUMN `write_bytes` BIGINT NOT NULL COMMENT '写入流量';
|
||||
ALTER TABLE `flow_report_hour` MODIFY COLUMN `read_bytes` BIGINT NOT NULL COMMENT '读取流量';
|
||||
ALTER TABLE `flow_report_hour` MODIFY COLUMN `write_bytes` BIGINT NOT NULL COMMENT '写入流量';
|
||||
ALTER TABLE `flow_report_day` MODIFY COLUMN `read_bytes` BIGINT NOT NULL COMMENT '读取流量';
|
||||
ALTER TABLE `flow_report_day` MODIFY COLUMN `write_bytes` BIGINT NOT NULL COMMENT '写入流量';
|
||||
ALTER TABLE `flow_report_month` MODIFY COLUMN `read_bytes` BIGINT NOT NULL COMMENT '读取流量';
|
||||
ALTER TABLE `flow_report_month` MODIFY COLUMN `write_bytes` BIGINT NOT NULL COMMENT '写入流量';
|
||||
@@ -0,0 +1,38 @@
|
||||
#安全组
|
||||
CREATE TABLE IF NOT EXISTS `security_group` (
|
||||
`id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`name` varchar(20) NOT NULL COMMENT '安全组名称',
|
||||
`description` varchar(255) COMMENT '安全组描述',
|
||||
`user_id` int NOT NULL COMMENT '用户ID',
|
||||
`enable` int NOT NULL COMMENT '是否启用(1、启用 2、禁用)',
|
||||
`default_pass_type` int NOT NULL COMMENT '默认放行类型',
|
||||
`create_time` datetime(3) NOT NULL COMMENT '创建时间',
|
||||
`update_time` datetime(3) NOT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
#安全组规则
|
||||
CREATE TABLE IF NOT EXISTS `security_rule` (
|
||||
`id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`group_id` int NOT NULL COMMENT '关联安全组',
|
||||
`name` varchar(20) NOT NULL COMMENT '规则名称',
|
||||
`description` varchar(255) NOT NULL COMMENT '规则描述',
|
||||
`rule` text NOT NULL COMMENT '规则内容',
|
||||
`pass_type`int NOT NULL COMMENT '放行类型',
|
||||
`priority` int(1) NOT NULL COMMENT '优先级',
|
||||
`user_id` int NOT NULL COMMENT '用户ID',
|
||||
`enable` int NOT NULL COMMENT '是否启用(1、启用 2、禁用)',
|
||||
`create_time` datetime(3) NOT NULL COMMENT '创建时间',
|
||||
`update_time` datetime(3) NOT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `I_security_rule_group_id_priority` (`group_id`, `priority`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
# port_mapping表增加字段
|
||||
ALTER TABLE `port_mapping` ADD COLUMN `security_group_id` int DEFAULT 0 COMMENT '安全组Id';
|
||||
ALTER TABLE `port_mapping` ADD COLUMN `up_limit_rate` varchar(20) DEFAULT NULL COMMENT '上传限速';
|
||||
ALTER TABLE `port_mapping` ADD COLUMN `down_limit_rate` varchar(20) DEFAULT NULL COMMENT '下载限速';
|
||||
|
||||
# license表增加字段
|
||||
ALTER TABLE `license` ADD COLUMN `up_limit_rate` varchar(20) DEFAULT NULL COMMENT '上传限速';
|
||||
ALTER TABLE `license` ADD COLUMN `down_limit_rate` varchar(20) DEFAULT NULL COMMENT '下载限速';
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.dromara.neutrinoproxy.server;
|
||||
|
||||
import org.dromara.neutrinoproxy.core.util.NeutrinoProxyVersion;
|
||||
import org.dromara.neutrinoproxy.server.app.AppBaseTest;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author songyinyin
|
||||
* @since 2023/10/31 11:51
|
||||
*/
|
||||
public class VersionTest extends AppBaseTest {
|
||||
|
||||
@Test
|
||||
public void testVersion() {
|
||||
Assert.assertNotNull(NeutrinoProxyVersion.getVersion());
|
||||
System.out.println("version: " + NeutrinoProxyVersion.getVersion());
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package org.dromara.neutrinoproxy.server.app;
|
||||
|
||||
import org.dromara.neutrinoproxy.server.ProxyServer;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.noear.solon.test.SolonJUnit4ClassRunner;
|
||||
import org.noear.solon.test.SolonTest;
|
||||
|
||||
/**
|
||||
* @author songyinyin
|
||||
* @since 2023/10/31 11:56
|
||||
*/
|
||||
@SolonTest(value = ProxyServer.class, properties = "server.port=18888")
|
||||
@RunWith(SolonJUnit4ClassRunner.class)
|
||||
public class AppBaseTest {
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 278 KiB |
@@ -12,7 +12,7 @@ docker run -it -p 9000-9200:9000-9200/tcp -p 8888:8888 \
|
||||
-v /root/neutrino-proxy-server/config:/root/neutrino-proxy/config \
|
||||
-v /root/neutrino-proxy-server/data:/root/neutrino-proxy/data \
|
||||
-v /root/neutrino-proxy-server/logs:/root/neutrino-proxy/logs \
|
||||
registry.cn-hangzhou.aliyuncs.com/asgc/neutrino-proxy:latest
|
||||
aoshiguchen/neutrino-proxy-server:latest
|
||||
```
|
||||
|
||||
### 指定自己的mysql数据库
|
||||
|
||||
@@ -29,7 +29,7 @@ neutrino:
|
||||
db:
|
||||
type: mysql
|
||||
# 自己的数据库实例,创建一个空的名为'neutrino-proxy'的数据库即可,首次启动服务端会自动初始化
|
||||
url: jdbc:mysql://xxxx:3306/neutrino-proxy?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&useAffectedRows=true&useSSL=false
|
||||
url: jdbc:mysql://xxxx:3306/neutrino-proxy?useUnicode=true&allowMultiQueries=true&useAffectedRows=true&useSSL=false
|
||||
driver-class: com.mysql.jdbc.Driver
|
||||
# 数据库帐号
|
||||
username: xxx
|
||||
|
||||
@@ -16,7 +16,8 @@ permalink: /pages/50ce10/
|
||||
solon.logging.logger:
|
||||
"root":
|
||||
level: info
|
||||
|
||||
|
||||
neutrino:
|
||||
proxy:
|
||||
tunnel:
|
||||
# 线程池相关配置,用于技术调优,可忽略
|
||||
|
||||
@@ -6,9 +6,15 @@ permalink: /pages/cded59/
|
||||
|
||||
| 日期 | 渠道 | 金额 |昵称| 备注 |
|
||||
|:-----------|:---|:-----|:-|:-----------------|
|
||||
|2023-10-16|微信转账|50|Mark Isaac赵方丈|金额不大,开源感恩。|
|
||||
|2023-10-11|微信红包|50|喜鸽小宝||
|
||||
|2023-10-10|微信红包|20|海洋||
|
||||
|2023-11-30|Gitee捐助|10|26263|感谢您的开源项目!|
|
||||
|2023-11-30|微信红包|10|姫野永遠||
|
||||
| 2023-11-26 |微信转账|180|Teacher Du||
|
||||
| 2023-11-10 |微信红包|50|喜鸽小宝||
|
||||
| 2023-11-01 |微信红包|20|Sun|感谢大佬,请你喝杯奶茶[微笑]|
|
||||
| 2023-10-30 |微信赞赏|50|杨娃娃||
|
||||
| 2023-10-16 |微信转账|50|Mark Isaac赵方丈|金额不大,开源感恩。|
|
||||
| 2023-10-11 |微信红包|50|喜鸽小宝||
|
||||
| 2023-10-10 |微信红包|20|海洋||
|
||||
| 2023-07-31 |Gitee捐助| 50 |失败女神| 感谢您的开源项目! |
|
||||
| 2023-07-28 |微信转账| 50 |AdrianPteLtd.com-咨询| |
|
||||
| 2023-07-12 |微信红包| 100 |MaxKeyTop| 请大佬抽包烟 |
|
||||
|
||||
@@ -146,9 +146,13 @@ postList: none
|
||||
|
||||
<div class="cardListContainer">
|
||||
<div class="card-list">
|
||||
<a href="https://www.xigexb.com" target="_blank" class="card-item row-3" style="background-color:#102863;--random-color:#102863;color:#FFFFFF;">
|
||||
<a href="https://www.xigexb.com?from=neutrino-proxy" target="_blank" class="card-item row-3" style="background-color:#102863;--random-color:#102863;color:#FFFFFF;">
|
||||
<img src="img/sponsor/xigexiaobao.jpg" class="no-zoom">
|
||||
<div><p class="name">喜鸽小宝</p> <p class="desc">一个爱好写代码的同学</p></div>
|
||||
<div><p class="name">喜鸽小宝</p> <p class="desc">一个爱好写代码的同学。</p></div>
|
||||
</a>
|
||||
<a href="https://7bu.top?from=neutrino-proxy" target="_blank" class="card-item row-3" style="background-color:#c6ddff;--random-color:#c6ddff;color:#000000;">
|
||||
<img src="img/sponsor/7bu.ico" class="no-zoom">
|
||||
<div><p class="name">去不图床</p> <p class="desc">杜老师说旗下付费图片外链平台。</p></div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.noear</groupId>
|
||||
<artifactId>solon-parent</artifactId>
|
||||
<version>2.5.12-M1</version>
|
||||
<version>2.5.12</version>
|
||||
<relativePath />
|
||||
</parent>
|
||||
|
||||
@@ -26,11 +26,11 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
|
||||
<revision>1.1-SNAPSHOT</revision>
|
||||
<revision>2.0.1-SNAPSHOT</revision>
|
||||
|
||||
<native.version>0.9.28</native.version>
|
||||
|
||||
<java.version>17</java.version>
|
||||
<java.version>21</java.version>
|
||||
<maven-compiler-plugin.version>3.8.0</maven-compiler-plugin.version>
|
||||
<maven-flatten.version>1.1.0</maven-flatten.version>
|
||||
</properties>
|
||||
@@ -110,6 +110,7 @@
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
@@ -121,8 +122,8 @@
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<groupId>org.noear</groupId>
|
||||
<artifactId>solon-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
@@ -216,7 +217,7 @@
|
||||
<plugin>
|
||||
<groupId>org.noear</groupId>
|
||||
<artifactId>solon-maven-plugin</artifactId>
|
||||
<version>${solon-maven-plugin.version}</version>
|
||||
<version>${solon.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>process-aot</id>
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#!/bin/sh
|
||||
# 中微子代理客户端编译打包脚本,基础参数请自行修改
|
||||
|
||||
export JAVA_HOME=/Users/yangwen/my/service/graalvm/graalvm-community-openjdk-17.0.8+7.1/Contents/Home
|
||||
export JAVA_HOME=/Users/yangwen/my/service/graalvm/graalvm-community-openjdk-21.0.1+12.1/Contents/Home
|
||||
#export JAVA_HOME=/Users/yangwen/my/service/jdk/jdk17/jdk-17.0.4.1.jdk/Contents/Home
|
||||
export MAVEN_HOME=/Users/yangwen/my/service/maven/apache-maven-3.8.1
|
||||
export PATH=:$PATH:$JAVA_HOME/bin:$MAVEN_HOME/bin
|
||||
|
||||
@@ -25,6 +26,6 @@ cp ./neutrino-proxy-client/target/neutrino-proxy-client.jar $clientDeployDir/neu
|
||||
cd $clientDeployDir
|
||||
mkdir neutrino-proxy-client-jar
|
||||
cp ../../neutrino-proxy-client/target/neutrino-proxy-client.jar ./neutrino-proxy-client-jar/neutrino-proxy-client.jar
|
||||
cp ../../neutrino-proxy-client/src/main/resources/app.yml ./neutrino-proxy-client-jar/app.yml
|
||||
cp ../../neutrino-proxy-client/src/main/resources/app-copy.yml ./neutrino-proxy-client-jar/app.yml
|
||||
zip -r neutrino-proxy-client-jar.zip ./neutrino-proxy-client-jar
|
||||
rm -rf $clientDeployDir/neutrino-proxy-client-jar
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
# 中微子代理客户端编译打包脚本,基础参数请自行修改
|
||||
|
||||
export JAVA_HOME=/Users/yangwen/my/service/graalvm/graalvm-community-openjdk-17.0.8+7.1/Contents/Home
|
||||
export JAVA_HOME=/Users/yangwen/my/service/graalvm/graalvm-community-openjdk-21.0.1+12.1/Contents/Home
|
||||
export MAVEN_HOME=/Users/yangwen/my/service/maven/apache-maven-3.8.1
|
||||
export PATH=:$PATH:$JAVA_HOME/bin:$MAVEN_HOME/bin
|
||||
|
||||
@@ -40,13 +40,13 @@ cd $clientDeployDir
|
||||
## jar
|
||||
mkdir neutrino-proxy-client-jar
|
||||
cp ../../neutrino-proxy-client/target/neutrino-proxy-client.jar ./neutrino-proxy-client-jar/neutrino-proxy-client.jar
|
||||
cp ../../neutrino-proxy-client/src/main/resources/app.yml ./neutrino-proxy-client-jar/app.yml
|
||||
cp ../../neutrino-proxy-client/src/main/resources/app-copy.yml ./neutrino-proxy-client-jar/app.yml
|
||||
zip -r neutrino-proxy-client-jar.zip ./neutrino-proxy-client-jar
|
||||
rm -rf ./neutrino-proxy-client-jar
|
||||
|
||||
## native
|
||||
mkdir neutrino-proxy-client-${machine}-native
|
||||
cp ../../neutrino-proxy-client/target/neutrino-proxy-client ./neutrino-proxy-client-${machine}-native/neutrino-proxy-client
|
||||
cp ../../neutrino-proxy-client/src/main/resources/app.yml ./neutrino-proxy-client-${machine}-native/app.yml
|
||||
cp ../../neutrino-proxy-client/src/main/resources/app-copy.yml ./neutrino-proxy-client-${machine}-native/app.yml
|
||||
zip -r neutrino-proxy-client-${machine}-native.zip ./neutrino-proxy-client-${machine}-native
|
||||
rm -rf ./neutrino-proxy-client-${machine}-native
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# 中微子代理客户端启动脚本,基础参数请自行修改
|
||||
|
||||
JAVA_OPS="-server -Xms256m -Xmx512m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/work/$NAME/heapError/"
|
||||
export JAVA_HOME=/Users/yangwen/my/service/graalvm/graalvm-community-openjdk-17.0.8+7.1/Contents/Home
|
||||
export JAVA_HOME=/Users/yangwen/my/service/graalvm/graalvm-community-openjdk-21.0.1+12.1/Contents/Home
|
||||
export PATH=:$PATH:$JAVA_HOME/bin
|
||||
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
|
||||
mkdir -p /work/$NAME/heapError/
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#!/bin/sh
|
||||
# 中微子代理服务端编译打包脚本,基础参数请自行修改
|
||||
|
||||
export JAVA_HOME=/Users/yangwen/my/service/graalvm/graalvm-community-openjdk-17.0.8+7.1/Contents/Home
|
||||
export JAVA_HOME=/Users/yangwen/my/service/graalvm/graalvm-community-openjdk-21.0.1+12.1/Contents/Home
|
||||
#export JAVA_HOME=/Users/yangwen/my/service/jdk/jdk17/jdk-17.0.4.1.jdk/Contents/Home
|
||||
export MAVEN_HOME=/Users/yangwen/my/service/maven/apache-maven-3.8.1
|
||||
export PATH=:$PATH:$JAVA_HOME/bin:$MAVEN_HOME/bin
|
||||
|
||||
@@ -25,6 +26,6 @@ cp ./neutrino-proxy-server/target/neutrino-proxy-server.jar $serverDeployDir/neu
|
||||
cd $serverDeployDir
|
||||
mkdir neutrino-proxy-server-jar
|
||||
cp ../../neutrino-proxy-server/target/neutrino-proxy-server.jar ./neutrino-proxy-server-jar/neutrino-proxy-server.jar
|
||||
cp ../../neutrino-proxy-server/src/main/resources/app.yml ./neutrino-proxy-server-jar/app.yml
|
||||
cp ../../neutrino-proxy-server/src/main/resources/app-copy.yml ./neutrino-proxy-server-jar/app.yml
|
||||
zip -r neutrino-proxy-server-jar.zip ./neutrino-proxy-server-jar
|
||||
rm -rf $serverDeployDir/neutrino-proxy-server-jar
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
# 中微子代理服务端编译打包脚本,基础参数请自行修改
|
||||
|
||||
export JAVA_HOME=/Users/yangwen/my/service/graalvm/graalvm-community-openjdk-17.0.8+7.1/Contents/Home
|
||||
export JAVA_HOME=/Users/yangwen/my/service/graalvm/graalvm-community-openjdk-21.0.1+12.1/Contents/Home
|
||||
export MAVEN_HOME=/Users/yangwen/my/service/maven/apache-maven-3.8.1
|
||||
export PATH=:$PATH:$JAVA_HOME/bin:$MAVEN_HOME/bin
|
||||
|
||||
@@ -49,13 +49,13 @@ cd $serverDeployDir
|
||||
## jar
|
||||
mkdir neutrino-proxy-server-jar
|
||||
cp ../../neutrino-proxy-server/target/neutrino-proxy-server.jar ./neutrino-proxy-server-jar/neutrino-proxy-server.jar
|
||||
cp ../../neutrino-proxy-server/src/main/resources/app.yml ./neutrino-proxy-server-jar/app.yml
|
||||
cp ../../neutrino-proxy-server/src/main/resources/app-copy.yml ./neutrino-proxy-server-jar/app.yml
|
||||
zip -r neutrino-proxy-server-jar.zip ./neutrino-proxy-server-jar
|
||||
rm -rf ./neutrino-proxy-server-jar
|
||||
|
||||
## native
|
||||
mkdir neutrino-proxy-server-${machine}-native
|
||||
cp ../../neutrino-proxy-server/target/neutrino-proxy-server ./neutrino-proxy-server-${machine}-native/neutrino-proxy-server
|
||||
cp ../../neutrino-proxy-server/src/main/resources/app.yml ./neutrino-proxy-server-${machine}-native/app.yml
|
||||
cp ../../neutrino-proxy-server/src/main/resources/app-copy.yml ./neutrino-proxy-server-${machine}-native/app.yml
|
||||
zip -r neutrino-proxy-server-${machine}-native.zip ./neutrino-proxy-server-${machine}-native
|
||||
rm -rf ./neutrino-proxy-server-${machine}-native
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# 中微子代理服务端启动脚本,基础参数请自行修改
|
||||
|
||||
JAVA_OPS="-server -Xms256m -Xmx1024m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/work/$NAME/heapError/"
|
||||
export JAVA_HOME=/Users/yangwen/my/service/graalvm/graalvm-community-openjdk-17.0.8+7.1/Contents/Home
|
||||
export JAVA_HOME=/Users/yangwen/my/service/graalvm/graalvm-community-openjdk-21.0.1+12.1/Contents/Home
|
||||
export PATH=:$PATH:$JAVA_HOME/bin
|
||||
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
|
||||
mkdir -p /work/$NAME/heapError/
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo 'hello'
|
||||
+21
-51
@@ -1,54 +1,21 @@
|
||||
# 1.x规划
|
||||
- Bug
|
||||
- 优化
|
||||
- 添加端口映射时,验证端口是否被其他服务占用
|
||||
- 拉下搜索license,支持模糊搜索
|
||||
- license下拉用户搜索,支持模糊搜索
|
||||
- UDP支持
|
||||
- 官网文档完善
|
||||
- HTTPS配置说明
|
||||
- 协议重构
|
||||
- 代码重构
|
||||
|
||||
# 1.8.6
|
||||
- [x] 端口映射选择端口支持分页
|
||||
- [x] 新增/更新端口映射,增加端口占用检测
|
||||
- [x] 拉下搜索license,支持模糊搜索
|
||||
- [x] license下拉用户搜索,支持模糊搜索
|
||||
- [x] 端口映射编辑时,如果端口号没有变动,则不验证。避免出现端口映射正在使用时,无法更新端口映射其他信息的问题
|
||||
- [x] 端口映射HTTP(S)新增打开网页按钮
|
||||
- [x] 客户端断开连接时,记录日志空指针异常问题修复
|
||||
|
||||
# 1.9.0
|
||||
- [x] 支持UDP
|
||||
- 服务端
|
||||
- 原`neutrino.proxy.server`配置移到`neutrino.proxy.server.tcp`下
|
||||
- 客户端
|
||||
- 原`neutrino.proxy.client`配置移到`neutrino.proxy.tunnel`下
|
||||
- [x] 端口映射HTTP(S)新增打开网页按钮,优先使用域名打开
|
||||
- [x] 新增/编辑端口映射时端口占用检测功能屏蔽,解决docker下使用的各种问题
|
||||
|
||||
# 1.9.1
|
||||
- [ ] 如果UDP映射服务端端口变动,流量统计似乎不准,转发功能或许也受到影响,需要评估、测试、思考如何优化
|
||||
- [ ] 增加服务端/客户端jar式一键部署脚本
|
||||
- [ ] 排查解决问题:https://gitee.com/dromara/neutrino-proxy/issues/I7LGLB
|
||||
- [ ] 访问白名单
|
||||
- [ ] 端口映射分组
|
||||
|
||||
# Bug
|
||||
- 指令通达被close的问题,org.dromara.neutrinoproxy.server.proxy.core.ProxyTunnelChannelHandler.channelInactive
|
||||
- windows环境下直接运行发布版的jar包,日志输出乱码
|
||||
- 代理mysql时,使用未开启远程访问的账号走代理访问mysql,代理客户端出现断开现象
|
||||
- 客户端连接映射某个端口以后,如果在服务器端禁用了,没有立刻反映出来,要灯客户端重连以后才会屏蔽被禁用的端口。
|
||||
|
||||
# 2.x规划
|
||||
- 插件开发
|
||||
- [ ] neutrino-proxy-solon-plugin
|
||||
- [ ] neutrino-proxy-jetbrains-plugin
|
||||
- [ ] neutrino-proxy-starter (SpringBoot)
|
||||
- 思考
|
||||
- 流量编排
|
||||
- 插件化定制
|
||||
- 重构
|
||||
- 代码重构
|
||||
- 多租户支持
|
||||
- 多个代理服务端节点支持
|
||||
- 协议重构
|
||||
- 支持多个隧道协议,支持扩展(TCP、KCP、QUIC)
|
||||
- 支持不同语言客户端、服务端接入
|
||||
- 基础优化
|
||||
- [ ] 访问白名单
|
||||
- [ ] 端口映射分组
|
||||
- [ ] 支持批量端口映射
|
||||
- [ ] 代理协议规范化,方便后续更好扩展、支持不同语言客户端接入
|
||||
- [ ] 如果UDP映射服务端端口变动,流量统计似乎不准,转发功能或许也受到影响,需要评估、测试、思考如何优化
|
||||
- [ ] 排查解决问题:https://gitee.com/dromara/neutrino-proxy/issues/I7LGLB
|
||||
- 监控运维
|
||||
- [ ] 监控服务端状态
|
||||
- [ ] 支持调整服务端端口、证书
|
||||
@@ -56,11 +23,14 @@
|
||||
- [ ] 服务端日志
|
||||
- [ ] 支持持管理后台动态调整日志级别。
|
||||
- [ ] 动态调整转发、报文、心跳输出
|
||||
- client+计划启动
|
||||
- [ ] 安卓客户端
|
||||
- [ ] 基于electron-egg的多平台客户端
|
||||
|
||||
# 3.x规划
|
||||
- [ ] 支持针对用户限速、限流
|
||||
- [ ] 支持P2P穿透
|
||||
- [ ] 支持原生编译
|
||||
- 插件开发
|
||||
- [ ] neutrino-proxy-solon-plugin
|
||||
- [ ] neutrino-proxy-jetbrains-plugin
|
||||
- [ ] neutrino-proxy-starter (SpringBoot)
|
||||
- client+计划启动
|
||||
- [ ] 安卓客户端
|
||||
- [ ] 基于electron-egg的多平台客户端
|
||||
|
||||
Reference in New Issue
Block a user