Compare 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 | ||
|
|
e90bc0f10a | ||
|
|
66d98711bf | ||
|
|
de0ac5b500 | ||
|
|
1dffa1d921 | ||
|
|
42dedf03e1 | ||
|
|
f1ebc47f51 | ||
|
|
4ca43572a0 | ||
|
|
116f3d7b36 | ||
|
|
265699c3dc | ||
|
|
c644128552 | ||
|
|
fa63ec71a5 | ||
|
|
07d5c9f5e4 | ||
|
|
cb9aa5da81 | ||
|
|
03a9d2e971 | ||
|
|
52d96157a4 | ||
|
|
c998512549 | ||
|
|
ac0487432d | ||
|
|
530b0e2ef9 | ||
|
|
311b4a266d | ||
|
|
94fea242e1 | ||
|
|
65f6d23eda | ||
|
|
635544b66d | ||
|
|
52cc45901e | ||
|
|
66898bded2 | ||
|
|
914813c904 | ||
|
|
1dd00f09a8 | ||
|
|
8b564cb2f5 | ||
|
|
d9dfd05180 | ||
|
|
066b63d38a | ||
|
|
78c5014cb0 | ||
|
|
768422d498 | ||
|
|
54d81092a0 | ||
|
|
49b4006f1b | ||
|
|
4dd23134e4 | ||
|
|
9257605be5 | ||
|
|
cd471c1eb4 | ||
|
|
8b358ccadf | ||
|
|
35f9f7756e | ||
|
|
2c2b169460 | ||
|
|
f15eec426d | ||
|
|
798a61e905 | ||
|
|
f8e93a7eaa | ||
|
|
2716addc77 | ||
|
|
833bfe94a9 | ||
|
|
f07912a189 | ||
|
|
d3eb245db1 | ||
|
|
d06af96102 | ||
|
|
3bbc9a1193 | ||
|
|
f193dfc42c | ||
|
|
6f129cad30 | ||
|
|
6412c4c081 | ||
|
|
05c709e33a | ||
|
|
d32cfa5d51 | ||
|
|
7baf60e8a7 | ||
|
|
c40142321f | ||
|
|
18cbc3dced | ||
|
|
6de1bbc74a | ||
|
|
7dce301bef | ||
|
|
543ea25fb0 | ||
|
|
8587241714 | ||
|
|
38847902c8 | ||
|
|
4685a15d5a | ||
|
|
a9608a449d | ||
|
|
9c0b3f3086 | ||
|
|
446910fd44 | ||
|
|
c4e05aad9e | ||
|
|
4db971aabb | ||
|
|
4c975798d7 | ||
|
|
ddc52af4bb | ||
|
|
0cc4608983 | ||
|
|
99bfce9a31 | ||
|
|
cb0cbee532 | ||
|
|
268e17273e | ||
|
|
840dd2d344 | ||
|
|
e50c303437 | ||
|
|
3cf64596c6 | ||
|
|
35327cc9a5 | ||
|
|
4d8e4190ba | ||
|
|
2da08e1b55 | ||
|
|
8d9fc4cff6 | ||
|
|
4d380dbdf3 | ||
|
|
d5abf90954 | ||
|
|
e416c76ea8 | ||
|
|
33704b1694 | ||
|
|
491f042b2f | ||
|
|
fd306ce8c3 | ||
|
|
6880898321 | ||
|
|
5578874df7 | ||
|
|
67c362b423 | ||
|
|
b026b46647 | ||
|
|
bfe880a6c6 | ||
|
|
f46332db4a | ||
|
|
5b2fe447b2 | ||
|
|
0301f15628 | ||
|
|
4b278216e5 | ||
|
|
5fbf3684a6 | ||
|
|
85d3ed914f | ||
|
|
bf5028e056 | ||
|
|
3bd011b58d | ||
|
|
3610de97db | ||
|
|
40a03c1630 | ||
|
|
f1ea585cec | ||
|
|
9647006ed1 | ||
|
|
8c5a6b2f0d | ||
|
|
3991fcb91c | ||
|
|
93e8879bf5 | ||
|
|
0466710f73 | ||
|
|
ef8cab0a36 | ||
|
|
7a9e81c27a | ||
|
|
3f42b58471 | ||
|
|
323d86b49d | ||
|
|
e2226f7d0b | ||
|
|
5094700b66 | ||
|
|
b737535b0f | ||
|
|
7a95fbddbc | ||
|
|
f00d8d1479 | ||
|
|
4550a677db | ||
|
|
f604e8b011 | ||
|
|
a400fccf77 | ||
|
|
87e4af5ba5 | ||
|
|
1d11dd3f85 | ||
|
|
b3e85b6a65 | ||
|
|
c76c4d8257 | ||
|
|
64fcd43be5 | ||
|
|
a7b077af8c | ||
|
|
a4c2addb33 | ||
|
|
dd6493cc66 | ||
|
|
52ce6d265a | ||
|
|
eacc98d18f | ||
|
|
65af658be5 | ||
|
|
a7b2694204 | ||
|
|
abab45785b | ||
|
|
9da00e47bd | ||
|
|
4eea46fa46 | ||
|
|
b7518bfbeb | ||
|
|
a95b534701 | ||
|
|
04747296c5 | ||
|
|
0a5d50b84d | ||
|
|
22461066a4 | ||
|
|
cd4c9f2aae | ||
|
|
30b115610b | ||
|
|
c971bee96c | ||
|
|
7ea723b578 | ||
|
|
1625187bb1 | ||
|
|
934ceaadca | ||
|
|
bb7fe668b1 | ||
|
|
f78a74cd0b | ||
|
|
c385030fc4 | ||
|
|
767860643d | ||
|
|
c20a6db44a | ||
|
|
f423056361 | ||
|
|
86a3cf92b5 | ||
|
|
b28d476081 | ||
|
|
48c8df15e7 | ||
|
|
e715976726 | ||
|
|
f66791678c |
@@ -0,0 +1,8 @@
|
||||
root=true
|
||||
|
||||
[*.{groovy,java,kt,xml}]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
[*.sh]
|
||||
end_of_line=lf
|
||||
@@ -0,0 +1,94 @@
|
||||
name: Build linux and mac native image
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
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']
|
||||
name: build - ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
# https://github.com/softprops/action-gh-release/issues/236#issuecomment-1150530128
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: setup node v13.12.0
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 13.12.0
|
||||
# cache: 'npm' # 使用缓存需要把 package-lock.json 也上传到 git 上
|
||||
- name: build neutrino-proxy-admin
|
||||
run: |
|
||||
cd neutrino-proxy-admin
|
||||
npm install
|
||||
npm run build:docker·
|
||||
cp -rf ./dist/ ./../neutrino-proxy-server/src/main/resources/static/
|
||||
- name: GitHub Action for GraalVM JDK 21
|
||||
uses: graalvm/setup-graalvm@v1
|
||||
with:
|
||||
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
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.m2/repository
|
||||
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
|
||||
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-${{ 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-${{ 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-${{ 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-${{ env.VERSION }}'
|
||||
filename: neutrino-proxy-client-${{ env.OS }}-${{ env.VERSION }}.zip
|
||||
# GitHub 上创建 release
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
files: |
|
||||
neutrino-proxy-server/target/neutrino-proxy-server.jar
|
||||
neutrino-proxy-client/target/neutrino-proxy-client.jar
|
||||
neutrino-proxy-server-${{ env.OS }}-${{ env.VERSION }}.zip
|
||||
neutrino-proxy-client-${{ env.OS }}-${{ env.VERSION }}.zip
|
||||
prerelease: true
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -0,0 +1,91 @@
|
||||
name: Build windows native image
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
# see: https://docs.github.com/zh/actions/using-jobs/choosing-the-runner-for-a-job
|
||||
os: ['windows-2022']
|
||||
name: build - ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
# https://github.com/softprops/action-gh-release/issues/236#issuecomment-1150530128
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: setup node v13.12.0
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 13.12.0
|
||||
# cache: 'npm' # 使用缓存需要把 package-lock.json 也上传到 git 上
|
||||
- name: build neutrino-proxy-admin
|
||||
run: |
|
||||
cd neutrino-proxy-admin
|
||||
npm install
|
||||
npm run build:docker
|
||||
cp -r ./dist/ ./../neutrino-proxy-server/src/main/resources/static/
|
||||
- name: GitHub Action for GraalVM JDK 21
|
||||
uses: graalvm/setup-graalvm@v1
|
||||
with:
|
||||
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
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.m2/repository
|
||||
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"
|
||||
mvn clean install -pl neutrino-proxy-core -am -DskipTests --no-transfer-progress
|
||||
cd neutrino-proxy-server
|
||||
mvn clean native:compile -P native --file pom.xml --no-transfer-progress
|
||||
cp target/neutrino-proxy-server.exe ./../neutrino-proxy-server.exe
|
||||
- name: Archive zip (neutrino-proxy-server)
|
||||
uses: thedoctor0/zip-release@master
|
||||
with:
|
||||
type: 'zip'
|
||||
path: 'neutrino-proxy-server.exe'
|
||||
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"
|
||||
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
|
||||
cp target/neutrino-proxy-client.exe ./../neutrino-proxy-client.exe
|
||||
- name: Archive zip (neutrino-proxy-client)
|
||||
uses: thedoctor0/zip-release@master
|
||||
with:
|
||||
type: 'zip'
|
||||
path: 'neutrino-proxy-client.exe'
|
||||
filename: neutrino-proxy-client-${{ env.OS }}-${{ env.VERSION }}.zip
|
||||
# GitHub 上创建 release
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
files: |
|
||||
neutrino-proxy-server/target/neutrino-proxy-server.jar
|
||||
neutrino-proxy-client/target/neutrino-proxy-client.jar
|
||||
neutrino-proxy-server-${{ env.OS }}-${{ env.VERSION }}.zip
|
||||
neutrino-proxy-client-${{ env.OS }}-${{ env.VERSION }}.zip
|
||||
prerelease: true
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -57,3 +57,6 @@ hs_err_pid*
|
||||
neutrino-proxy-vuepress/deploy.sh
|
||||
.NEUTRINO_PROXY_CLIENT_ID
|
||||
logs
|
||||
data
|
||||
**/cert/**
|
||||
neutrino-proxy-server/src/main/resources/static/**
|
||||
|
||||
|
After Width: | Height: | Size: 12 KiB |
@@ -0,0 +1,16 @@
|
||||
- 2022-06-16 1.0.0版本发布,基于自研应用框架、纯配置无管理后台
|
||||
- 2022-10-12 1.5.0版本发布,底层框架优化,新增管理后台
|
||||
- 2022-11-23 1.6.0版本发布,新增日志管理模块,新增首页流量统计
|
||||
- 2023-01-08 中微子代理Gitee Star突破100
|
||||
- 2023-01-16 加入Dromara组织
|
||||
- 2023-02-23 1.6.4版本发布,管理后台增、删、改、禁用实时生效,启动参数、GZip优化
|
||||
- 2023-03-12 1.7.0版本发布,底层框架更换为Solon + MybatisPlus
|
||||
- 2023-03-26 1.7.1版本发布,新增端口池分组、新增报表管理模块、首页图表优化
|
||||
- 2023-04-03 1.8.0版本发布,端口映射支持选择协议,HTTP映射支持子域名
|
||||
- 2023-05-27 1.8.2版本发布,增加HTTPS支持
|
||||
- 2023-06-03 1.8.3版本发布,客户端重连优化、服务端验证客户端身份逻辑优化
|
||||
- 2023-06-08 1.8.4版本发布,增加对mariadb的支持、配置文件支持指定日志级别、重连参数
|
||||
- 2023-07-04 1.8.5版本发布,后台若干细节优化、配置文件优化
|
||||
- 2023-09-07 1.8.6版本发布,后台若干细节优化
|
||||
- 2023-09-22 1.9.0版本发布,端口映射支持UDP协议
|
||||
- 2023-09-25 中微子代理Gitee Star数突破1000
|
||||
@@ -4,8 +4,8 @@
|
||||
<p align="center">
|
||||
<a href='https://gitee.com/dromara/neutrino-proxy/stargazers'><img src='https://gitee.com/dromara/neutrino-proxy/badge/star.svg?theme=dark' alt='star'></img></a>
|
||||
<a href='https://gitee.com/dromara/neutrino-proxy/members'><img src='https://gitee.com/dromara/neutrino-proxy/badge/fork.svg?theme=dark' alt='fork'></img></a>
|
||||
<a target="_blank" href="https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html">
|
||||
<img src="https://img.shields.io/badge/JDK-8+-red.svg" />
|
||||
<a target="_blank" href="https://www.oracle.com/java/technologies/javase/javase-jdk17-downloads.html">
|
||||
<img src="https://img.shields.io/badge/JDK-17+-red.svg" />
|
||||
</a>
|
||||
<a href="./LICENSE">
|
||||
<img src="https://img.shields.io/badge/license-MIT-red" alt="license MIT">
|
||||
@@ -34,180 +34,62 @@
|
||||

|
||||

|
||||
|
||||
# 4、项目结构
|
||||
- neutrino-proxy
|
||||
- neutrino-proxy-core 与代理相关的公共常量、编解码器
|
||||
- neutrino-proxy-client 代理客户端项目
|
||||
- neutrino-proxy-server 代理服务端项目
|
||||
- neutrino-proxy-admin 代理监控项目(基于vue-element-admin开发)
|
||||
|
||||
# 5、运行
|
||||
## 5.1、使用keytool工具生成ssl证书, 若不需要ssl加密可跳过
|
||||
```shell
|
||||
keytool -genkey -alias test1 -keyalg RSA -keysize 1024 -validity 3650 -keypass 123456 -storepass 123456 -keystore "./test.jks"
|
||||
```
|
||||
|
||||
## 5.2、修改服务端配置(app.yml)
|
||||
```yml
|
||||
application:
|
||||
name: neutrino-proxy-server
|
||||
|
||||
neutrino:
|
||||
proxy:
|
||||
protocol:
|
||||
max-frame-length: 2097152
|
||||
length-field-offset: 0
|
||||
length-field-length: 4
|
||||
initial-bytes-to-strip: 0
|
||||
length-adjustment: 0
|
||||
read-idle-time: 60
|
||||
write-idle-time: 40
|
||||
all-idle-time-seconds: 0
|
||||
tunnel:
|
||||
boss-thread-count: 2
|
||||
work-thread-count: 10
|
||||
# 服务端端口,用于保持与客户端的连接,非SSL
|
||||
port: ${OPEN_PORT:9000}
|
||||
# 服务端端口,用于保持与客户端的连接,SSL,需要jks证书文件,若不需要ssl支持,可不配置
|
||||
ssl-port: ${SSL_PORT:9002}
|
||||
# 证书配置,用于隧道通信SSL加密
|
||||
key-store-password: ${STORE_PASS:123456}
|
||||
key-manager-password: ${MGR_PASS:123456}
|
||||
jks-path: ${JKS_PATH:classpath:/test.jks}
|
||||
server:
|
||||
boss-thread-count: 5
|
||||
work-thread-count: 20
|
||||
# HTTP代理端口,默认80,也可以用其他端口,走nginx转发
|
||||
http-proxy-port: ${HTTP_PROXY_PORT:80}
|
||||
# HTTPS代理端口,默认443,也可以用其他端口,走nginx转发
|
||||
https-proxy-port: ${HTTPS_PROXY_PORT:443}
|
||||
# 如果不配置,则不支持域名映射
|
||||
domain-name: ${DOMAIN_NAME:}
|
||||
# 证书配置,用于支持HTTPS
|
||||
key-store-password: ${HTTPS_STORE_PASS:}
|
||||
jks-path: ${HTTPS_JKS_PATH:}
|
||||
data:
|
||||
# 数据库配置(支持mysql)
|
||||
type: sqlite
|
||||
url: jdbc:sqlite:data.db
|
||||
driver-class: org.sqlite.JDBC
|
||||
username:
|
||||
password:
|
||||
```
|
||||
|
||||
## 5.3、启动服务端
|
||||
> java -jar neutrino-proxy-server.jar
|
||||
|
||||
## 5.4、修改客户端配置
|
||||
```yml
|
||||
application:
|
||||
name: neutrino-proxy-client
|
||||
|
||||
proxy:
|
||||
protocol:
|
||||
max-frame-length: 2097152
|
||||
length-field-offset: 0
|
||||
length-field-length: 4
|
||||
initial-bytes-to-strip: 0
|
||||
length-adjustment: 0
|
||||
read-idle-time: 60
|
||||
write-idle-time: 30
|
||||
all-idle-time-seconds: 0
|
||||
client:
|
||||
# ssl证书密码
|
||||
key-store-password: 123456
|
||||
# ssl证书存放位置
|
||||
jks-path: classpath:/test.jks
|
||||
# 服务端ip,若部署到服务器,则配置服务器的ip
|
||||
server-ip: localhost
|
||||
# 服务端端口,若使用ssl,则需要配置为服务端的"ssl-port"
|
||||
server-port: 9000
|
||||
# 是否启用ssl,启用则必须配置ssl相关参数
|
||||
ssl-enable: false
|
||||
```
|
||||
## 5.5、代理示意图
|
||||
# 4、代理示意图
|
||||

|
||||
|
||||
## 5.6、启动客户端
|
||||
### 5.6.1、启动参数直接指定配置
|
||||
> java -jar neutrino-proxy-client.jar serverIp=localhost serverPort=9000 licenseKey=b0a907332b474b25897c4dcb31fc7eb6
|
||||
|
||||
### 5.6.2、启动参数指定外部配置文件
|
||||
> java -jar neutrino-proxy-client.jar config=app.properties
|
||||
|
||||
配置文件格式如下:
|
||||
```
|
||||
neutrino.proxy.client.server-ip=localhost
|
||||
neutrino.proxy.client.server-port=9002
|
||||
neutrino.proxy.client.ssl-enable=true
|
||||
neutrino.proxy.client.key-store-password=123456
|
||||
neutrino.proxy.client.jks-path=classpath:/test.jks
|
||||
neutrino.proxy.client.license-key=b0a907332b474b25897c4dcb31fc7eb6
|
||||
```
|
||||
|
||||
## 5.7、Docker快速启动
|
||||
```shell script
|
||||
# 一键部署前端和后端,客户端按上方部署即可
|
||||
docker run -it -p 9000-9200:9000-9200/tcp -p 8888:8888 -d --name neutrino registry.cn-hangzhou.aliyuncs.com/asgc/aoshiguchen-docker-images:1.64
|
||||
# 如没docker环境,可以一键部署docker环境(centos 7.8)系统
|
||||
curl http://www.wangke666.cn/static/createDocker.sh | bash
|
||||
```
|
||||
|
||||
# 6、演示环境
|
||||
> 可使用分配好的游客license试用。服务器带宽较低,仅供学习使用!
|
||||
- 管理后台地址:http://103.163.47.16:9527
|
||||
- 游客账号:visitor/123456
|
||||
|
||||
# 7、未来迭代方向
|
||||
- 优化代码、增强稳定性
|
||||
- 服务端增加管理页面,提供报表、授权、限流等功能
|
||||
- 从项目中分离、孵化出另一个开源项目(neutrino-framework)
|
||||
|
||||
# 8、技术文档
|
||||
- [Aop](./docs/Aop.MD)
|
||||
- [Channel](./docs/Channel.MD)
|
||||
|
||||
# 9、联系我们
|
||||
# 5、联系我们
|
||||
- 微信: yuyunshize
|
||||
- Gitee: https://gitee.com/asgc/neutrino-proxy
|
||||
|
||||
# 10、贡献者列表
|
||||
# 6、贡献者列表
|
||||
<p>
|
||||
<a href="https://gitee.com/zcans" target="_blank">
|
||||
<img src="assets/developer/zcans.png" width="12%">
|
||||
<img src="assets/developer/zcans.png" width="11%">
|
||||
</a>
|
||||
<a href="https://gitee.com/bmlt" target="_blank">
|
||||
<img src="assets/developer/jiuye.png" width="12%">
|
||||
<img src="assets/developer/jiuye.png" width="11%">
|
||||
</a>
|
||||
<a href="https://gitee.com/wangke666" target="_blank">
|
||||
<img src="assets/developer/keke.png" width="12%">
|
||||
<img src="assets/developer/keke.png" width="11%">
|
||||
</a>
|
||||
<a href="https://gitee.com/xue-fangming" target="_blank">
|
||||
<img src="assets/developer/fangming.png" width="12%">
|
||||
<img src="assets/developer/fangming.png" width="11%">
|
||||
</a>
|
||||
<a href="https://gitee.com/y0hanes" target="_blank">
|
||||
<img src="assets/developer/yohanes.png" width="12%">
|
||||
<img src="assets/developer/yohanes.png" width="11%">
|
||||
</a>
|
||||
<a href="https://gitee.com/noear_admin" target="_blank">
|
||||
<img src="assets/developer/near.png" width="12%">
|
||||
<img src="assets/developer/near.png" width="11%">
|
||||
</a>
|
||||
<a href="https://gitee.com/westboy" target="_blank">
|
||||
<img src="assets/developer/westboy.jpg" width="12%">
|
||||
<img src="assets/developer/westboy.jpg" width="11%">
|
||||
</a>
|
||||
<a href="https://gitee.com/liugddx" target="_blank">
|
||||
<img src="assets/developer/liugddx.png" width="12%">
|
||||
<img src="assets/developer/liugddx.png" width="11%">
|
||||
</a>
|
||||
<a href="https://gitee.com/DianZiFaPiao" target="_blank">
|
||||
<img src="assets/developer/tan90.png" width="12%">
|
||||
</a>
|
||||
<a href="https://gitee.com/dearsny" target="_blank">
|
||||
<img src="assets/developer/pingon.png" width="12%">
|
||||
<img src="assets/developer/pingon.png" width="11%">
|
||||
</a>
|
||||
<a href="https://gitee.com/ixxxk" target="_blank">
|
||||
<img src="assets/developer/tany.png" width="12%">
|
||||
<img src="assets/developer/tany.png" width="11%">
|
||||
</a>
|
||||
<a href="https://gitee.com/zoo-plus" target="_blank">
|
||||
<img src="assets/developer/zoo-plus.png" width="12%">
|
||||
<img src="assets/developer/zoo-plus.png" width="11%">
|
||||
</a>
|
||||
<a href="https://gitee.com/MetalXingxing" target="_blank">
|
||||
<img src="assets/developer/metal.png" width="11%">
|
||||
</a>
|
||||
<a href="https://gitee.com/click33" target="_blank">
|
||||
<img src="assets/developer/click33.png" width="11%">
|
||||
</a>
|
||||
<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>
|
||||
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
# 1.x
|
||||
## 1.0.0
|
||||
> 第一个基本可用版本
|
||||
- 基于自研底层应用框架、Netty
|
||||
- 纯配置实现、无管理后台
|
||||
- 支持TCP代理
|
||||
|
||||
## 1.5.0
|
||||
- 管理后台新增用户管理、License管理、端口映射、调度管理、客户端连接日志、调度日志
|
||||
- 支持默认sqlite数据库
|
||||
- 底层框架Aop、Banner、SqlMapper、Ioc、@Value注解、Yml配置加载、静态资源服务等优化
|
||||
- 底层框架新增@Async、@Singleton等注解
|
||||
- 新增AsgcCompiler、ApplicationEvent机制封装
|
||||
|
||||
## 1.6.0
|
||||
- 新增日志管理模块,调度日志迁移至日志管理
|
||||
- 管理后台新增登录日志
|
||||
- 新增首页流量统计
|
||||
|
||||
## 1.6.4
|
||||
- 支持代理服务端用户(删除/禁用)、端口池(删除/禁用/启用)、License(删除/禁用/启用)、端口映射(新增/删除/禁用/启用)实时生效
|
||||
- 启动参数优化
|
||||
- 服务端静态资源服务支持缓存、gzip压缩,提升响应速度
|
||||
|
||||
## 1.7.0
|
||||
- 底层框架更换为Solon + MybatisPlus
|
||||
|
||||
## 1.7.1
|
||||
- 针对管理后台各页面的排序、搜索条件的优化
|
||||
- 增加端口池分组、相关的端口映射优化
|
||||
- 增加了报表管理模块:用户流量报表、license流量报表、用户流量月度明细、license流量月度明细
|
||||
- 完成首页图表展示:license统计、端口映射统计、今日流量统计、汇总流量统计、最近15日流量折线图
|
||||
|
||||
## 1.8.0
|
||||
- 端口映射支持选择协议
|
||||
- HTTP协议下映射支持配置子域名(前提是server端配置了域名)
|
||||
|
||||
## 1.8.2
|
||||
- 增加HTTPS的支持。
|
||||
|
||||
## 1.8.3
|
||||
- 客户端重连优化
|
||||
- 服务端验证客户端身份逻辑优化
|
||||
|
||||
## 1.8.4
|
||||
- 增加对mariadb的支持
|
||||
- 服务端/客户端,支持配置文件、启动参数指定日志级别
|
||||
- 客户端支持配置文件指定重连间隔,是否开启无限重连
|
||||
|
||||
## 1.8.5
|
||||
- 后台端口池管理支持批量删除
|
||||
- 端口映射下拉选择端口支持搜索
|
||||
- 客户端/服务端配置增加心跳日志开关,有需要时开启,方便排查问题
|
||||
- 客户端/服务端读写超时逻辑微调
|
||||
|
||||
## 1.8.6
|
||||
- 端口映射选择端口支持分页
|
||||
- 新增/更新端口映射,增加端口占用检测(端口映射编辑时,如果端口号没有变动,则不验证。避免出现端口映射正在使用时,无法更新端口映射其他信息的问题)
|
||||
- 下拉搜索license,支持模糊搜索
|
||||
- license下拉用户搜索,支持模糊搜索
|
||||
- 端口映射HTTP(S)新增打开网页按钮
|
||||
- 客户端断开连接时,记录日志空指针异常问题修复
|
||||
|
||||
## 1.9.0
|
||||
- 端口映射支持UDP协议
|
||||
- 端口映射HTTP(S)新增打开网页按钮,优先使用域名打开
|
||||
- 新增/编辑端口映射时端口占用检测功能屏蔽,解决docker下使用的各种问题
|
||||
|
||||
# 2.x
|
||||
## 2.0.0
|
||||
- solon版本升级为`2.5.11`
|
||||
- jdk版本升级为17
|
||||
- 支持原生编译改造
|
||||
- 默认支持的数据库由sqlite改为h2
|
||||
|
||||
## 2.0.1
|
||||
- jdk版本升级为21
|
||||
- 解决HTTP(S)映射时使用tcp端口访问正常,使用域名访问偶现一直loading的问题
|
||||
- 新增安全组模块,支持黑名单、白名单限制
|
||||
- 支持对用户、license限速
|
||||
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 350 KiB |
|
After Width: | Height: | Size: 1.0 MiB |
|
After Width: | Height: | Size: 67 KiB |
|
After Width: | Height: | Size: 262 KiB |
|
After Width: | Height: | Size: 123 KiB |
|
After Width: | Height: | Size: 502 KiB |
@@ -0,0 +1,137 @@
|
||||
# 内网穿透神器NeutrinoProxy 1.9.0版本发布
|
||||
|
||||
## 更新内容
|
||||
> 与1.8.0版本对比,更新内容如下:
|
||||
- 核心功能
|
||||
- 域名映射支持HTTPS
|
||||
- 支持UDP协议代理
|
||||
- 客户端断开连接时,记录日志空指针异常问题修复
|
||||
- 基础优化
|
||||
- 客户端重连逻辑优化,支持配置文件指定重连间隔,是否开启无限重连
|
||||
- 增加对mariadb的支持
|
||||
- 服务端/客户端,支持配置文件、启动参数指定日志级别
|
||||
- 后台端口池管理支持批量删除
|
||||
- 后台下拉选择license、用户支持模糊搜索
|
||||
- 端口映射下拉选择端口支持搜索、分野
|
||||
- 客户端/服务端配置增加心跳日志开关,有需要时开启,方便排查问题
|
||||
- 端口映射HTTP(S)新增打开网页快捷操作,优先使用绑定域名打开
|
||||
|
||||
## 升级须知
|
||||
> 从1.9.0之前的版本升级需要注意:
|
||||
- 在项目`neutrino-proxy-server/src/main/resources/sql`目录下找到mysql/sqlite的增量sql文件`UPDATE-20230922.SQL`,执行更新自己的中微子代理数据库
|
||||
- 参照[官网服务端配置](https://dromara.gitee.io/neutrino-proxy/pages/f2d0f1)调整现有的服务端配置
|
||||
- 参照[官网客户端配置](https://dromara.gitee.io/neutrino-proxy/pages/50ce10)吊证现有的客户端配置
|
||||
- 从[仓库发行版](https://gitee.com/dromara/neutrino-proxy/releases)下载最新版本的客户端(neutrino-proxy-client.jar)、服务端(neutrino-proxy-server.jar、 neutrino-proxy-admin.zip)部署文件。若为服务端是docker镜像部署,则更新镜像重启即可
|
||||
|
||||
## 项目简介
|
||||
- [中微子代理(neutrino-proxy)](https://gitee.com/dromara/neutrino-proxy) 是一款基于netty的内网穿透神器。该项目采用最为宽松的MIT协议,因此您可以对它进行复制、修改、传播并用于任何个人或商业行为。
|
||||
- Gitee地址:https://gitee.com/dromara/neutrino-proxy
|
||||
- 官网地址:http://neutrino-proxy.dromara.org
|
||||
- 服务端管理后台截图:
|
||||
<img src="./home.png" width="100%"/>
|
||||
|
||||
## 主要特点:
|
||||
- 1、流量监控:首页图表、报表管理多维度流量监控。全方位掌握实时、历史代理数据。
|
||||
- 2、用户/License:支持多用户、多客户端使用。后台禁用实时生效。
|
||||
- 3、端口池:对外端口统一管理,支持用户、License独占端口。
|
||||
- 4、端口映射:新增、编辑、删除、禁用实时生效。
|
||||
- 5、Docker:服务端支持Docker一键部署。
|
||||
- 6、SSL证书:支持SSL,保护您的信息安全。
|
||||
- 7、域名映射:支持绑定子域名,方便本地调试三方回调
|
||||
- 8、多协议:支持代理TCP、HTTP(S)、UDP多种协议
|
||||
- 9、采用最为宽松的MIT协议,免去你的后顾之忧
|
||||
|
||||
## 快速使用
|
||||
> 更多使用姿势、细节请通过官网或结尾微信二维码加我备注"中微子代理"入群交流。
|
||||
|
||||
### 1、 部署服务端
|
||||
#### 1.1、 Docker一键部署
|
||||
> 当前最新版本为1.9.0,下面的脚本中,可以使用:`registry.cn-hangzhou.aliyuncs.com/asgc/neutrino-proxy:1.9.0` 指定版本安装,推荐使用`latest`直接安装最新版。
|
||||
|
||||
##### 使用默认sqlite数据库
|
||||
```shell
|
||||
docker run -it -p 9000-9200:9000-9200/tcp -p 8888:8888 \
|
||||
-d --restart=always --name neutrino-proxy \
|
||||
registry.cn-hangzhou.aliyuncs.com/asgc/neutrino-proxy:latest
|
||||
```
|
||||
|
||||
##### 指定自己的mysql数据库
|
||||
- 在服务器上创建目录:/root/neutrino-proxy/config
|
||||
- 在该目录下创建`app.yml`文本文件,并配置如下内容:
|
||||
```yml
|
||||
neutrino:
|
||||
data:
|
||||
db:
|
||||
type: mysql
|
||||
# 自己的数据库实例,创建一个空的名为'neutrino-proxy'的数据库即可,首次启动服务端会自动初始化
|
||||
url: jdbc:mysql://xxxx:3306/neutrino-proxy?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&useAffectedRows=true&useSSL=false
|
||||
driver-class: com.mysql.jdbc.Driver
|
||||
# 数据库帐号
|
||||
username: xxx
|
||||
# 数据库密码
|
||||
password: xxx
|
||||
```
|
||||
- 然后执行如下命令:
|
||||
```shell
|
||||
docker run -it -p 9000-9200:9000-9200/tcp -p 8888:8888 \
|
||||
-v /root/neutrino-proxy/config:/root/neutrino-proxy/config \
|
||||
-d --restart=always --name neutrino \
|
||||
registry.cn-hangzhou.aliyuncs.com/asgc/neutrino-proxy:latest
|
||||
```
|
||||
|
||||
#### 1.2、使用jar包自行部署
|
||||
- 首先确保服务器上已安装java8运行环境
|
||||
- 打开[发行版页面](https://gitee.com/dromara/neutrino-proxy/releases),下载最新的release包:`neutrino-proxy-server.jar`、`neutrino-proxy-admin.zip`
|
||||
- 在服务器上新建部署目录:`/work/projects/neutrino-proxy-server`
|
||||
- 将` neutrino-proxy-server.jar`、`neutrino-proxy-admin.zip`上传至服务器部署目录。
|
||||
- 解压`neutrino-proxy-admin.zip`文件
|
||||
- 执行命令`java -jar neutrino-proxy-server.jar`启动服务端完成部署,默认使用sqlite数据库。
|
||||
- 若需要指定自己的mysql数据库,同样的需要在当前目录下新建`app.yml`文件,文件内容同上。执行命令`java -jar neutrino-proxy-server.jar config=app.yml`启动服务端完成部署
|
||||
- 可参照 https://gitee.com/dromara/neutrino-proxy/blob/master/bin/server_start.sh 使用shell脚本启动服务端。
|
||||
|
||||
### 2、管理后台配置
|
||||
- 服务端部署成功后,访问`http://{服务端IP}:8888`打开后台管理页面。
|
||||
- 使用默认的管理员帐号登录:admin/123456
|
||||
- 打开`代理配置>License管理`页面,可以看到系统已经自动为管理员初始化了一条License记录,复制该`LicenseKey`备用,后续客户端配置需要。
|
||||
- 打开`代理配置>端口映射`页面,可以看到系统已经自动为初始化了几条端口映射。可根据需要自行添加、修改。这里我们以`9101 -> 127.0.0.1:8080`映射为例
|
||||
|
||||
### 3、启动客户端
|
||||
- 首先确保本地已安装java8运行环境
|
||||
- 打开[发行版页面](https://gitee.com/dromara/neutrino-proxy/releases),下载最新的release包:`neutrino-proxy-client.jar`
|
||||
- 在本地`neutrino-proxy-client.jar`同级别目录下新建`app.yml`文件,并配置如下内容:
|
||||
```yml
|
||||
neutrino:
|
||||
proxy:
|
||||
tunnel:
|
||||
# ssl证书密钥(使用jjar包内自带的证书,则此处无需修改)
|
||||
key-store-password: 123456
|
||||
# ssl证书管理密钥(使用jjar包内自带的证书,则此处无需修改。自定义证书,则此处配置对应的路径)
|
||||
jks-path: classpath:/test.jks
|
||||
# 代理服务端IP
|
||||
server-ip: localhost
|
||||
# 代理服务端IP, 若是非ssl端口,则ssl-enable需要配置为false
|
||||
server-port: 9002
|
||||
# 是否启用ssl
|
||||
ssl-enable: true
|
||||
# licenseKey,客户端凭证。此处需要配置刚刚从管理后台复制的LicenseKey
|
||||
license-key: xxxx
|
||||
```
|
||||
- 执行命令`java -jar neutrino-proxy-client.jar`启动客户端
|
||||
- 查看服务端License管理,刷新页面,对应的License在线状态为`在线`,则表明客户端已正常连接。
|
||||
|
||||
### 4、代理验证
|
||||
- 本地启动被代理服务,如:redis、本地web项目、本地mysql等等
|
||||
- 先确保本地能正常访问被代理服务,如果本地都不能访问,不用想代理更不可能!!!
|
||||
- 通过服务端IP+9101(上面License配置的端口映射重的服务端端口)访问本地被代理服务
|
||||
|
||||
## 联系我们
|
||||
笔者时间、能力有限,且开源项目非一朝一夕之事,存在众多问题亦在所难免。使用、学习过程中有任何问题欢迎大家与我联系。
|
||||
|
||||
对项目有什么想法或者建议,可以加我微信拉交流群,或者创建[issues](https://gitee.com/dromara/neutrino-proxy/issues),一起完善项目
|
||||
|
||||
- 微信号:yuyunshize
|
||||
- Email: aoshiguchen@dromara.org
|
||||
- 中微子代理官网:http://neutrino-proxy.dromara.org
|
||||
- 中微子代理仓库:https://gitee.com/dromara/neutrino-proxy
|
||||
- 微信二维码:
|
||||
<img src="MyWeChatQRCode.jpeg" width="100%"/>
|
||||
|
After Width: | Height: | Size: 123 KiB |
|
After Width: | Height: | Size: 502 KiB |
@@ -0,0 +1,60 @@
|
||||
# 中微子代理(NeutrinoProxy)2.0.0重磅发布
|
||||
|
||||
## 项目简介
|
||||
- [中微子代理(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协议,免去你的后顾之忧
|
||||
|
||||
## 本次更新内容
|
||||
- solon版本升级为`2.5.12-M1`
|
||||
- jdk版本升级为17
|
||||
- 支持原生编译改造
|
||||
- 默认支持的数据库由sqlite改为h2
|
||||
- 官方默认使用的docker镜像仓库从阿里云改为dockerhub
|
||||
|
||||
## 安装使用说明
|
||||
- 快速上手:[点击这里](https://neutrino-proxy.dromara.org/neutrino-proxy/pages/793dcb/)
|
||||
- 升级须知:
|
||||
- jdk版本升级为了jdk17,jar部署时请注意
|
||||
- 去掉了默认的sqlite数据库,改为了h2。如果之前使用sqlite,请自行处理数据迁移
|
||||
- 配置文件做了较大调整,请参照官网使用须知中的`服务端配置`、`客户端配置`进行更新
|
||||
|
||||
## 运行示例
|
||||
#### 本地原生启动截图
|
||||
<img src="./run1.png" width="100%"/>
|
||||
|
||||
#### 管理后台首页
|
||||
<img src="./home.png" width="100%"/>
|
||||
|
||||
#### 端口映射
|
||||
<img src="./port-mapping2.png" width="100%"/>
|
||||
|
||||
## 联系我们
|
||||
笔者时间、能力有限,且开源项目非一朝一夕之事,存在众多问题亦在所难免。使用、学习过程中有任何问题欢迎大家与我联系。
|
||||
|
||||
对项目有什么想法或者建议,可以加我微信拉交流群,或者创建[issues](https://gitee.com/dromara/neutrino-proxy/issues),一起完善项目
|
||||
|
||||
- 微信号:yuyunshize
|
||||
- Email: aoshiguchen@dromara.org
|
||||
- 微信二维码(添加时请备注"中微子进群"):
|
||||
<img src="MyWeChatQRCode.jpeg" width="100%"/>
|
||||
|
After Width: | Height: | Size: 262 KiB |
|
After Width: | Height: | Size: 2.3 MiB |
|
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生态已经初具规模,社区汇聚了一大批开源爱好者。
|
||||
|
||||
大鹏一日通风起,扶摇直上九万里。我相信国产开源在大家的努力下,一定会越来越好!
|
||||
@@ -1,3 +1,13 @@
|
||||
# native 打包
|
||||
```shell
|
||||
mvn clean install -pl neutrino-proxy-core -am -DskipTests
|
||||
|
||||
cd neutrino-proxy-server
|
||||
|
||||
mvn clean native:compile -P native -DskipTests
|
||||
|
||||
```
|
||||
|
||||
# 管理后台问题汇总
|
||||
## 问题1...
|
||||
> 描述、解决方式
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module.exports = {
|
||||
NODE_ENV: '"development"',
|
||||
ENV_CONFIG: '"dev"',
|
||||
BASE_API: '"http://103.163.47.16:8888"',
|
||||
BASE_API: '"https://neutrino-proxy.asgc.fun/neutrino-proxy-server"',
|
||||
USER_NAME: '"visitor"',
|
||||
USER_PWD: '"123456"'
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
module.exports = {
|
||||
NODE_ENV: '"development"',
|
||||
ENV_CONFIG: '"docker"',
|
||||
BASE_API: '"/"'
|
||||
BASE_API: '"/neutrino-proxy-server"'
|
||||
}
|
||||
|
||||
@@ -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'
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -14,13 +14,11 @@ export function portPoolList() {
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
export function availablePortList(licenseId) {
|
||||
export function availablePortList(query) {
|
||||
return request({
|
||||
url: '/port-pool/get-available-port-list',
|
||||
method: 'get',
|
||||
params: {
|
||||
licenseId: licenseId
|
||||
}
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
@@ -60,3 +58,21 @@ export function deletePortPool(id) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function deleteBatchPortPool(ids) {
|
||||
return request({
|
||||
url: '/port-pool/delete-batch',
|
||||
method: 'post',
|
||||
data: {
|
||||
ids: ids
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function portAvailable(query) {
|
||||
return request({
|
||||
url: '/port-pool/port-available',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -8,60 +8,68 @@
|
||||
<el-button size="mini" @click="handleCancelClick">{{cancelText}}</el-button>
|
||||
<el-button type="primary" size="mini" @click="handleCommitClick">{{okText}}</el-button>
|
||||
</div>
|
||||
<el-button slot="reference" :type="type" :size="size">{{buttonText}}</el-button>
|
||||
<el-button slot="reference" :type="type" :size="size" :icon="icon" :disabled="disabled">{{buttonText}}</el-button>
|
||||
</el-popover>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
export default {
|
||||
name: 'deleteButton',
|
||||
props: {
|
||||
width: {
|
||||
type: Number,
|
||||
default: 160
|
||||
export default {
|
||||
name: 'deleteButton',
|
||||
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: '取消'
|
||||
}
|
||||
},
|
||||
buttonText: {
|
||||
type: String,
|
||||
default: '删除'
|
||||
data() {
|
||||
return {
|
||||
visible: false
|
||||
}
|
||||
},
|
||||
type: {
|
||||
type: String,
|
||||
default: 'danger'
|
||||
},
|
||||
size: {
|
||||
type: String,
|
||||
default: 'mini'
|
||||
},
|
||||
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')
|
||||
methods: {
|
||||
handleCancelClick() {
|
||||
this.visible = false
|
||||
this.$emit('handleCancelClick')
|
||||
},
|
||||
handleCommitClick() {
|
||||
this.visible = false
|
||||
this.$emit('handleCommitClick')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style rel="stylesheet/scss" lang="scss" scoped>
|
||||
|
||||
@@ -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>
|
||||
@@ -0,0 +1,168 @@
|
||||
<!--
|
||||
采用github上面的开源组件https://github.com/johnhom1024/vue-load-select
|
||||
不过有个bug,就是没办法展示下拉的箭头,目前修复的方式:等dom加载完毕后,补充箭头的class
|
||||
参考:https://blog.csdn.net/weixin_42381896/article/details/122258563
|
||||
-->
|
||||
<template>
|
||||
<el-select
|
||||
ref="selectLoadMore"
|
||||
:value="value"
|
||||
v-loadmore="loadMore"
|
||||
@focus="focus"
|
||||
@clear="clear"
|
||||
filterable
|
||||
remote
|
||||
:filter-method="handleSearch"
|
||||
:loading="loading"
|
||||
clearable
|
||||
v-bind="$attrs"
|
||||
v-on="$listeners"
|
||||
>
|
||||
<el-option
|
||||
v-for="option in data"
|
||||
:label="option[dictLabel]"
|
||||
:value="option[dictValue]"
|
||||
:key="option.value"
|
||||
></el-option>
|
||||
<!-- 此处加载中的value可以随便设置,只要不与其他数据重复即可 -->
|
||||
<el-option
|
||||
v-if="hasMore"
|
||||
disabled
|
||||
label="加载中..."
|
||||
value="-1" />
|
||||
<!--补充页面无数据时,显示无数据的效果-->
|
||||
<el-option
|
||||
v-if="!hasMore && data.length==0"
|
||||
disabled
|
||||
label="暂无数据"
|
||||
value="-2" />
|
||||
</el-select>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "SelectLoadMore",
|
||||
props: {
|
||||
value: {
|
||||
default: null
|
||||
},
|
||||
// 列表数据
|
||||
data: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
dictLabel: {
|
||||
type: String,
|
||||
default: "label"
|
||||
},
|
||||
dictValue: {
|
||||
type: String,
|
||||
default: "value"
|
||||
},
|
||||
// 调用页数的接口
|
||||
request: {
|
||||
type: Function,
|
||||
default: () => {
|
||||
}
|
||||
},
|
||||
// 传入的页码
|
||||
page: {
|
||||
type: [Number, String],
|
||||
default: 1
|
||||
},
|
||||
// 是否还有更多数据
|
||||
hasMore: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
}
|
||||
},
|
||||
directives: {
|
||||
// 这里实现一个组件内部的自定义指令
|
||||
loadmore: {
|
||||
// 指令的定义
|
||||
bind(el, binding) {
|
||||
const SELECTWRAP = el.querySelector(
|
||||
".el-select-dropdown .el-select-dropdown__wrap"
|
||||
);
|
||||
if (!SELECTWRAP) {
|
||||
throw new Error('获取不到"el-select-dropdown__wrap"节点');
|
||||
}
|
||||
SELECTWRAP.addEventListener("scroll", () => {
|
||||
// scrollTop 这里可能因为浏览器缩放存在小数点的情况,导致了滚动到底部时
|
||||
// scrollHeight 减去滚动到底部时的scrollTop ,依然大于clientHeight 导致无法请求更多数据
|
||||
// 这里将scrollTop向上取整 保证滚到底部时,触发调用
|
||||
const CONDITION =
|
||||
SELECTWRAP.scrollHeight -
|
||||
Math.ceil(SELECTWRAP.scrollTop) <=
|
||||
SELECTWRAP.clientHeight;
|
||||
// el.scrollTop !== 0 当输入时,如果搜索结果很少,以至于没看到滚动条,那么此时的CONDITION计算结果是true,会执行bind.value(),此时不应该执行,否则搜索结果不匹配
|
||||
if (CONDITION && SELECTWRAP.scrollTop !== 0) {
|
||||
binding.value();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
keyword: "", // 存储关键字用
|
||||
loading: false
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
// 请求下一页的数据
|
||||
loadMore() {
|
||||
// 如果没有更多数据,则不请求
|
||||
if (!this.hasMore) {
|
||||
return;
|
||||
}
|
||||
// 如果intercept属性为true则不请求数据,
|
||||
if (this.loadMore.intercept) {
|
||||
return;
|
||||
}
|
||||
this.loadMore.intercept = true;
|
||||
this.request({
|
||||
page: this.page + 1,
|
||||
more: true,
|
||||
keyword: this.keyword
|
||||
}).then(() => {
|
||||
this.loadMore.intercept = false;
|
||||
});
|
||||
},
|
||||
// 选中下拉框没有数据时,自动请求第一页的数据
|
||||
focus() {
|
||||
if (!this.data.length) {
|
||||
this.request({page: 1});
|
||||
}
|
||||
},
|
||||
handleSearch(keyword) {
|
||||
this.keyword = keyword;
|
||||
this.loading = true;
|
||||
console.log(keyword);
|
||||
this.request({page: 1, keyword: keyword}).then(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
// 删除选中时,如果请求了关键字,则清除关键字再请求第一页的数据
|
||||
clear() {
|
||||
if (this.keyword) {
|
||||
this.keyword = "";
|
||||
this.request({page: 1});
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.$nextTick(function () {
|
||||
// github代码有个bug,下拉的箭头无法加载的问题,需要等dom页面加载完毕后,添加箭头的class
|
||||
let rulesDom = this.$refs["selectLoadMore"].$el.querySelector(
|
||||
".el-input .el-input__suffix .el-input__suffix-inner .el-input__icon"
|
||||
);// 找到dom
|
||||
rulesDom.classList.add("el-icon-arrow-up");// 对dom新增class
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -97,10 +97,12 @@ export default {
|
||||
readings: 'Readings',
|
||||
status: 'Status',
|
||||
actions: 'Actions',
|
||||
access: 'Access',
|
||||
edit: 'Edit',
|
||||
publish: 'Publish',
|
||||
draft: 'Draft',
|
||||
delete: 'Delete',
|
||||
deleteBatch: 'DeleteBatch',
|
||||
cancel: 'Cancel',
|
||||
confirm: 'Confirm',
|
||||
portOrRange: 'example: 3306 or 1000-2000'
|
||||
|
||||
@@ -48,6 +48,8 @@ export default {
|
||||
user: '用户管理',
|
||||
system: '系统管理',
|
||||
portPool: '端口池管理',
|
||||
securityGroup: '安全组管理',
|
||||
securityRule: '安全规则管理',
|
||||
portGroup: '端口分组管理',
|
||||
protocal: '协议管理',
|
||||
proxy: '代理配置',
|
||||
@@ -117,14 +119,18 @@ export default {
|
||||
readings: '阅读数',
|
||||
status: '状态',
|
||||
actions: '操作',
|
||||
access: '访问',
|
||||
openWebPage: '打开网页',
|
||||
edit: '编辑',
|
||||
publish: '发布',
|
||||
draft: '草稿',
|
||||
delete: '删除',
|
||||
deleteBatch: '批量删除',
|
||||
cancel: '取 消',
|
||||
confirm: '确 定',
|
||||
userId: '用户ID',
|
||||
userName: '用户名',
|
||||
name: '名称',
|
||||
group: '分组',
|
||||
groupName: '分组名称',
|
||||
groupPossessor: '分组所属',
|
||||
@@ -166,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' }}
|
||||
]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="app-container calendar-list-container">
|
||||
<div class="filter-container">
|
||||
<el-select v-model="listQuery.userId" placeholder="请选择用户" clearable>
|
||||
<el-select v-model="listQuery.userId" placeholder="请选择用户" filterable clearable>
|
||||
<el-option v-for="item in userList" :key="item.id" :label="item.name" :value="item.id"/>
|
||||
</el-select>
|
||||
<el-select v-model="listQuery.isOnline" placeholder="请选择在线状态" clearable>
|
||||
@@ -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>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<template>
|
||||
<div class="app-container calendar-list-container">
|
||||
<div class="filter-container" style="display:flex">
|
||||
<el-select v-model="listQuery.userId" placeholder="请选择用户" clearable style="margin-right:10px;width: 120px;">
|
||||
<el-select v-model="listQuery.userId" placeholder="请选择用户" filterable clearable style="margin-right:10px;width: 120px;">
|
||||
<el-option v-for="item in userList" :key="item.loginName" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
<el-select v-model="listQuery.licenseId" placeholder="请选择license" clearable style="margin-right:10px;width: 135px;">
|
||||
<el-select v-model="listQuery.licenseId" placeholder="请选择license" filterable clearable style="margin-right:10px;width: 135px;">
|
||||
<el-option v-for="item in licenseList" :key="item.key" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
<el-select v-model="listQuery.protocal" placeholder="请选择协议" clearable style="margin-right:10px;width: 120px;">
|
||||
@@ -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>
|
||||
@@ -90,13 +95,16 @@
|
||||
<el-tag :type="scope.row.isOnline | statusFilter">{{ scope.row.isOnline | isOnlineName }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" :label="$t('table.actions')" width="230" class-name="small-padding fixed-width">
|
||||
<el-table-column class-name="status-col" :label="$t('table.access')" width="120">
|
||||
<template slot-scope="scope">
|
||||
<el-button size="mini" v-if="(scope.row.protocal === 'HTTP' || scope.row.protocal === 'HTTP(S)')" @click="handleOpenWebPage(scope.row)">{{$t('table.openWebPage')}}</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" :label="$t('table.actions')" width="320" class-name="small-padding fixed-width">
|
||||
<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 == '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 size="mini" type="danger" @click="handleDelete(scope.row,'deleted')">{{$t('table.delete')}}</el-button>-->
|
||||
<ButtonPopover @handleCommitClick="handleDelete2(scope.row)" style="margin-left: 10px" />
|
||||
|
||||
@@ -142,11 +150,16 @@
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('服务端端口')" prop="serverPort">
|
||||
<el-select style="width: 280px;" class="filter-item" v-model="temp.serverPort" placeholder="请选择">
|
||||
<el-option v-for="item in serverPortList" :key="item.port" :label="item.port" :value="item.port">
|
||||
</el-option>
|
||||
</el-select>
|
||||
<el-form-item :label="$t('服务端端口')" prop="serverPort" >
|
||||
<load-select style="width: 280px;" class="filter-item"
|
||||
v-model="temp.serverPort"
|
||||
:data="serverPortList"
|
||||
:page="loadServerPortQuery.page"
|
||||
:hasMore="more"
|
||||
:clearable="false"
|
||||
:dictLabel="'port'"
|
||||
:dictValue="'port'"
|
||||
:request="loadServerPort"/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('客户端IP')" prop="clientIp">
|
||||
<el-input v-model="temp.clientIp"></el-input>
|
||||
@@ -159,6 +172,26 @@
|
||||
<template slot="append">.{{ domainName }}</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('响应数量')" prop="proxyResponses" v-if="temp.protocal === 'UDP'">
|
||||
<el-input v-model="temp.proxyResponses"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('超时时间')" prop="proxyTimeoutMs" v-if="temp.protocal === 'UDP'">
|
||||
<el-input v-model="temp.proxyTimeoutMs">
|
||||
<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>
|
||||
@@ -187,7 +220,8 @@
|
||||
|
||||
<script>
|
||||
import { fetchList, createUserPortMapping, updateUserPortMapping, updateEnableStatus, deletePortMapping } from '@/api/portMapping'
|
||||
import { portPoolList, availablePortList } from '@/api/portPool'
|
||||
import { fetchGroupList } from '@/api/securityGroup'
|
||||
import { availablePortList, portAvailable } from '@/api/portPool'
|
||||
import { licenseList, licenseAuthList } from '@/api/license'
|
||||
import { protocalList } from '@/api/protocal'
|
||||
import { userList } from '@/api/user'
|
||||
@@ -196,6 +230,8 @@ import waves from '@/directive/waves' // 水波纹指令
|
||||
import { parseTime } from '@/utils'
|
||||
import ButtonPopover from '../../components/Button/buttonPopover'
|
||||
import DropdownTable from '../../components/Dropdown/DropdownTable'
|
||||
// 下拉选择加载组件
|
||||
import loadSelect from "@/components/Select/SelectLoadMore";
|
||||
|
||||
const calendarTypeOptions = [
|
||||
{ key: 'CN', display_name: 'China' },
|
||||
@@ -217,9 +253,22 @@ export default {
|
||||
},
|
||||
components: {
|
||||
DropdownTable,
|
||||
ButtonPopover
|
||||
ButtonPopover,
|
||||
loadSelect
|
||||
},
|
||||
data() {
|
||||
const isPortAvailable = (rule, value, callback) => {
|
||||
if (value != null) {
|
||||
const param = { port: value, portMappingId: this.temp.id }
|
||||
portAvailable(param).then(res => {
|
||||
if (!res.data.data) {
|
||||
return callback(new Error('该端口被占用'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
return {
|
||||
tableKey: 0,
|
||||
list: null,
|
||||
@@ -257,7 +306,9 @@ export default {
|
||||
serverPort: undefined,
|
||||
clientIp: undefined,
|
||||
clientPort: undefined,
|
||||
protocal: undefined
|
||||
protocal: undefined,
|
||||
proxyResponses: undefined,
|
||||
proxyTimeoutMs: undefined
|
||||
},
|
||||
selectObj: {
|
||||
statusOptions: [{ label: '启用', value: 1 }, { label: '禁用', value: 2 }],
|
||||
@@ -273,7 +324,9 @@ export default {
|
||||
pvData: [],
|
||||
rules: {
|
||||
licenseId: [{ required: true, message: '请选择License', trigger: 'blur,change' }],
|
||||
serverPort: [{ required: true, message: '请输入服务端端口', trigger: 'blur' }],
|
||||
serverPort: [{ required: true, message: '请输入服务端端口', trigger: 'blur' },
|
||||
// { validator: isPortAvailable, trigger: 'change' }
|
||||
],
|
||||
clientIp: [{ required: true, message: '请输入客户端IP', trigger: 'blur' }],
|
||||
clientPort: [{ required: true, message: '请输入客户端端口', trigger: 'blur' }],
|
||||
protocal: [{ required: true, message: '请选择协议', trigger: 'blur' }]
|
||||
@@ -282,7 +335,14 @@ export default {
|
||||
countryColumns: [
|
||||
{ prop: 'userName', label: '用户名', align: 'center' },
|
||||
{ prop: 'name', label: 'License', align: 'center' }
|
||||
]
|
||||
],
|
||||
loadServerPortQuery:{ //下拉框加载数据请求参数
|
||||
page:1,
|
||||
size:50,
|
||||
licenseId:null,
|
||||
},
|
||||
more: true,
|
||||
securityGroupList: []
|
||||
}
|
||||
},
|
||||
filters: {
|
||||
@@ -317,6 +377,7 @@ export default {
|
||||
this.getLicenseList()
|
||||
this.getLicenseAuthList()
|
||||
this.getProtocalList()
|
||||
this.fetchSecurityGroupList()
|
||||
},
|
||||
methods: {
|
||||
getList() {
|
||||
@@ -338,20 +399,21 @@ 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
|
||||
})
|
||||
},
|
||||
getPortPoolList() {
|
||||
portPoolList().then(response => {
|
||||
this.serverPortList = response.data.data
|
||||
})
|
||||
},
|
||||
getAvailablePortList(licenseId) {
|
||||
availablePortList(licenseId).then(response => {
|
||||
this.serverPortList = response.data.data
|
||||
})
|
||||
this.loadServerPortQuery.licenseId = licenseId;
|
||||
this.serverPortList = []; //清掉数据
|
||||
},
|
||||
getAllUserList() {
|
||||
userList().then(response => {
|
||||
@@ -405,9 +467,13 @@ export default {
|
||||
serverPort: undefined,
|
||||
clientIp: '127.0.0.1',
|
||||
clientPort: undefined,
|
||||
userId: undefined
|
||||
userId: undefined,
|
||||
proxyResponses: undefined,
|
||||
proxyTimeoutMs: undefined
|
||||
}
|
||||
this.serverPortList = []
|
||||
this.loadServerPortQuery.licenseId = null;
|
||||
this.more = true;
|
||||
},
|
||||
handleCreate() {
|
||||
this.resetTemp()
|
||||
@@ -435,8 +501,18 @@ export default {
|
||||
}
|
||||
})
|
||||
},
|
||||
handleOpenWebPage(row) {
|
||||
let url = location.protocol + '//' + location.hostname + ':' + row.serverPort
|
||||
if (row.domain) {
|
||||
url = location.protocol + '//' + row.domain
|
||||
}
|
||||
open(url)
|
||||
},
|
||||
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
|
||||
@@ -526,6 +602,36 @@ export default {
|
||||
return v[j]
|
||||
}
|
||||
}))
|
||||
},
|
||||
// 传入给load-select组件的函数
|
||||
loadServerPort({page = 1, more = false, keyword = ""} = {}) {
|
||||
if(this.loadServerPortQuery.licenseId==null || this.loadServerPortQuery.licenseId==''){
|
||||
this.more = false;
|
||||
this.$message({
|
||||
message: '请先选择License',
|
||||
type: 'warning'
|
||||
})
|
||||
return ;
|
||||
}
|
||||
return new Promise(resolve => {
|
||||
this.loadServerPortQuery.page = page;
|
||||
this.loadServerPortQuery.keyword = keyword;
|
||||
// 访问后端接口API
|
||||
availablePortList(this.loadServerPortQuery).then(res => {
|
||||
let result = res.data;
|
||||
if (more) {
|
||||
this.serverPortList = [...this.serverPortList, ...result.data.records];
|
||||
} else {
|
||||
this.serverPortList = result.data.records;
|
||||
}
|
||||
|
||||
// this.loadServerPortQuery.page = result.data.current;
|
||||
let {total, current, size} = result.data;
|
||||
this.more = page * size < total;
|
||||
this.loadServerPortQuery.page = current;
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,13 @@
|
||||
</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>
|
||||
<button-popover class="filter-item" style="margin-left: 10px;" size="medium" icon="el-icon-delete"
|
||||
:buttonText="$t('table.deleteBatch')" :disabled="checkBoxData.length==0" @handleCommitClick="handleDeleteBatch" />
|
||||
</div>
|
||||
|
||||
<el-table :key='tableKey' :data="list" v-loading="listLoading" element-loading-text="给我一点时间" border fit highlight-current-row
|
||||
style="width: 100%">
|
||||
style="width: 100%" @selection-change="onTableRowChange">
|
||||
<el-table-column align="center" width="40" type="selection" />
|
||||
<el-table-column align="center" :label="$t('table.id')" width="120">
|
||||
<template slot-scope="scope">
|
||||
<span>{{scope.row.id}}</span>
|
||||
@@ -92,7 +95,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { createPortPool, deletePortPool, fetchList, updateEnableStatus, updatePortPool } from '@/api/portPool'
|
||||
import { createPortPool, deletePortPool, deleteBatchPortPool, fetchList, updateEnableStatus, updatePortPool } from '@/api/portPool'
|
||||
import { portGroupList } from '@/api/portGroup'
|
||||
import waves from '@/directive/waves' // 水波纹指令
|
||||
import { parseTime } from '@/utils'
|
||||
@@ -157,7 +160,8 @@ const calendarTypeOptions = [
|
||||
rules: {
|
||||
port: [{ required: true, message: '端口必填', trigger: 'blur' }]
|
||||
},
|
||||
downloadLoading: false
|
||||
downloadLoading: false,
|
||||
checkBoxData:[], //表单勾选的行
|
||||
}
|
||||
},
|
||||
filters: {
|
||||
@@ -320,6 +324,24 @@ const calendarTypeOptions = [
|
||||
return v[j]
|
||||
}
|
||||
}))
|
||||
},
|
||||
onTableRowChange(val){ //表单勾选后赋值
|
||||
this.checkBoxData = val
|
||||
},
|
||||
handleDeleteBatch(){ //批量删除操作
|
||||
let ids = []
|
||||
this.checkBoxData.forEach(item => {ids.push(item.id)})
|
||||
deleteBatchPortPool(ids).then(response => {
|
||||
if (response.data.code === 0) {
|
||||
this.$notify({
|
||||
title: '成功',
|
||||
message: '删除成功',
|
||||
type: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
this.getList()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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:8-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 ../neutrino-proxy-client/target/neutrino-proxy-client.jar /root/neutrino-proxy/neutrino-proxy-client.jar
|
||||
COPY ../neutrino-proxy-client/src/main/resources/app.yml /root/neutrino-proxy/config
|
||||
COPY ./target/neutrino-proxy-client.jar /root/neutrino-proxy/neutrino-proxy-client.jar
|
||||
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,12 +28,19 @@
|
||||
<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>
|
||||
|
||||
<excludes>
|
||||
<exclude>app-*.yml</exclude>
|
||||
<exclude>app-dev.yml</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
package org.dromara.neutrinoproxy.client;
|
||||
|
||||
import ch.qos.logback.classic.Level;
|
||||
import ch.qos.logback.classic.Logger;
|
||||
import ch.qos.logback.classic.LoggerContext;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.noear.solon.Solon;
|
||||
import org.noear.solon.SolonApp;
|
||||
import org.noear.solon.Utils;
|
||||
import org.noear.solon.annotation.SolonMain;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -22,15 +17,20 @@ public class ProxyClient {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Solon.start(ProxyClient.class, args, app -> {
|
||||
setAlias("neutrino.proxy.client.serverIp", "serverIp");
|
||||
setAlias("neutrino.proxy.client.serverPort", "serverPort");
|
||||
setAlias("neutrino.proxy.client.sslEnable", "sslEnable");
|
||||
setAlias("neutrino.proxy.client.jksPath", "jksPath");
|
||||
setAlias("neutrino.proxy.client.keyStorePassword", "keyStorePassword");
|
||||
setAlias("neutrino.proxy.client.licenseKey", "licenseKey");
|
||||
// 设置日志级别
|
||||
setLogLevel(app);
|
||||
});
|
||||
String loglevel = System.getenv("LOG_LEVEL");
|
||||
if (Utils.isNotEmpty(loglevel)) {
|
||||
app.cfg().put("solon.logging.logger.root.level", loglevel);
|
||||
}
|
||||
|
||||
setAlias("neutrino.proxy.tunnel.server-ip", "serverIp");
|
||||
setAlias("neutrino.proxy.tunnel.server-port", "serverPort");
|
||||
setAlias("neutrino.proxy.tunnel.ssl-enable", "sslEnable");
|
||||
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"));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,20 +45,4 @@ public class ProxyClient {
|
||||
}
|
||||
}
|
||||
|
||||
private static void setLogLevel(SolonApp app) {
|
||||
String loggerLevel = app.cfg().get("neutrino.proxy.logger.level");
|
||||
if (StringUtils.isBlank(loggerLevel)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Level level = Level.toLevel(loggerLevel);
|
||||
LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
|
||||
for (Logger logger : loggerContext.getLoggerList()) {
|
||||
logger.setLevel(level);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("日志级别设置失败", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package org.dromara.neutrinoproxy.client.config;
|
||||
|
||||
import org.noear.solon.annotation.Component;
|
||||
import org.noear.solon.aot.RuntimeNativeMetadata;
|
||||
import org.noear.solon.aot.RuntimeNativeRegistrar;
|
||||
import org.noear.solon.aot.hint.MemberCategory;
|
||||
import org.noear.solon.core.AppContext;
|
||||
|
||||
/**
|
||||
* @author songyinyin
|
||||
* @since 2023/10/21 22:50
|
||||
*/
|
||||
@Component
|
||||
public class NeutrinoClientRuntimeNativeRegistrar implements RuntimeNativeRegistrar {
|
||||
@Override
|
||||
public void register(AppContext context, RuntimeNativeMetadata metadata) {
|
||||
metadata.registerResourceInclude("test.jks");
|
||||
|
||||
metadata.registerReflection(ProxyConfig.Protocol.class, MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.INVOKE_DECLARED_METHODS);
|
||||
metadata.registerReflection(ProxyConfig.Client.class, MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.INVOKE_DECLARED_METHODS);
|
||||
metadata.registerReflection(ProxyConfig.Tunnel.class, MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.INVOKE_DECLARED_METHODS);
|
||||
metadata.registerReflection(ProxyConfig.Tcp.class, MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.INVOKE_DECLARED_METHODS);
|
||||
metadata.registerReflection(ProxyConfig.Udp.class, MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.INVOKE_DECLARED_METHODS);
|
||||
metadata.registerReflection(ProxyConfig.Reconnection.class, MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.INVOKE_DECLARED_METHODS);
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,8 @@ import org.noear.solon.annotation.Inject;
|
||||
public class ProxyConfig {
|
||||
@Inject("${neutrino.proxy.protocol}")
|
||||
private Protocol protocol;
|
||||
@Inject("${neutrino.proxy.tunnel}")
|
||||
private Tunnel tunnel;
|
||||
@Inject("${neutrino.proxy.client}")
|
||||
private Client client;
|
||||
|
||||
@@ -30,7 +32,7 @@ public class ProxyConfig {
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Client {
|
||||
public static class Tunnel {
|
||||
private String keyStorePassword;
|
||||
private String jksPath;
|
||||
private String serverIp;
|
||||
@@ -41,12 +43,32 @@ public class ProxyConfig {
|
||||
private Integer threadCount;
|
||||
private String clientId;
|
||||
private Boolean transferLogEnable;
|
||||
private Boolean heartbeatLogEnable;
|
||||
private Reconnection reconnection;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Client {
|
||||
// private Tcp tcp;
|
||||
private Udp udp;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Reconnection {
|
||||
private Integer intervalSeconds;
|
||||
private Boolean unlimited;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Tcp {
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Udp {
|
||||
private Integer bossThreadCount;
|
||||
private Integer workThreadCount;
|
||||
private String puppetPortRange;
|
||||
private Boolean transferLogEnable;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,18 @@
|
||||
package org.dromara.neutrinoproxy.client.config;
|
||||
|
||||
import org.dromara.neutrinoproxy.core.ProxyDataTypeEnum;
|
||||
import org.dromara.neutrinoproxy.core.ProxyMessage;
|
||||
import org.dromara.neutrinoproxy.core.ProxyMessageHandler;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
import io.netty.channel.nio.NioEventLoopGroup;
|
||||
import io.netty.channel.socket.SocketChannel;
|
||||
import io.netty.channel.socket.nio.NioDatagramChannel;
|
||||
import io.netty.channel.socket.nio.NioSocketChannel;
|
||||
import io.netty.handler.logging.LoggingHandler;
|
||||
import io.netty.handler.timeout.IdleStateHandler;
|
||||
import org.dromara.neutrinoproxy.client.core.*;
|
||||
import org.dromara.neutrinoproxy.client.util.ProxyUtil;
|
||||
import org.dromara.neutrinoproxy.core.*;
|
||||
import org.dromara.neutrinoproxy.core.aot.NeutrinoCoreRuntimeNativeRegistrar;
|
||||
import org.dromara.neutrinoproxy.core.dispatcher.DefaultDispatcher;
|
||||
import org.dromara.neutrinoproxy.core.dispatcher.Dispatcher;
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
@@ -10,8 +20,10 @@ import io.netty.channel.ChannelHandlerContext;
|
||||
import org.noear.solon.Solon;
|
||||
import org.noear.solon.annotation.Bean;
|
||||
import org.noear.solon.annotation.Configuration;
|
||||
import org.noear.solon.annotation.Inject;
|
||||
import org.noear.solon.core.bean.LifecycleBean;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -25,25 +37,177 @@ public class ProxyConfiguration implements LifecycleBean {
|
||||
@Override
|
||||
public void start() throws Throwable {
|
||||
List<ProxyMessageHandler> list = Solon.context().getBeansOfType(ProxyMessageHandler.class);
|
||||
Dispatcher<ChannelHandlerContext, ProxyMessage> dispatcher = new DefaultDispatcher<>("消息调度器", list,
|
||||
Dispatcher<ChannelHandlerContext, ProxyMessage> dispatcher = new DefaultDispatcher<>("MessageDispatcher", list,
|
||||
proxyMessage -> ProxyDataTypeEnum.of((int)proxyMessage.getType()) == null ?
|
||||
null : ProxyDataTypeEnum.of((int)proxyMessage.getType()).getName());
|
||||
Solon.context().wrapAndPut(Dispatcher.class, dispatcher);
|
||||
}
|
||||
|
||||
@Bean("cmdTunnelBootstrap")
|
||||
public Bootstrap cmdTunnelBootstrap() {
|
||||
return new Bootstrap();
|
||||
@Bean("tunnelWorkGroup")
|
||||
public NioEventLoopGroup tunnelWorkGroup(@Inject ProxyConfig proxyConfig) {
|
||||
return new NioEventLoopGroup(proxyConfig.getTunnel().getThreadCount());
|
||||
}
|
||||
|
||||
@Bean("proxyTunnelBootstrap")
|
||||
public Bootstrap proxyTunnelBootstrap() {
|
||||
return new Bootstrap();
|
||||
@Bean("tcpRealServerWorkGroup")
|
||||
public NioEventLoopGroup tcpRealServerWorkGroup(@Inject ProxyConfig proxyConfig) {
|
||||
// 暂时先公用此配置
|
||||
return new NioEventLoopGroup(proxyConfig.getTunnel().getThreadCount());
|
||||
}
|
||||
|
||||
@Bean("udpServerGroup")
|
||||
public NioEventLoopGroup udpServerGroup(@Inject ProxyConfig proxyConfig) {
|
||||
// 暂时先公用此配置
|
||||
return new NioEventLoopGroup(proxyConfig.getClient().getUdp().getBossThreadCount());
|
||||
}
|
||||
|
||||
@Bean("udpWorkGroup")
|
||||
public NioEventLoopGroup udpWorkGroup(@Inject ProxyConfig proxyConfig) {
|
||||
// 暂时先公用此配置
|
||||
return new NioEventLoopGroup(proxyConfig.getClient().getUdp().getWorkThreadCount());
|
||||
}
|
||||
|
||||
@Bean("cmdTunnelBootstrap")
|
||||
public Bootstrap cmdTunnelBootstrap(@Inject ProxyConfig proxyConfig,
|
||||
@Inject("tunnelWorkGroup") NioEventLoopGroup tunnelWorkGroup) {
|
||||
Bootstrap bootstrap = new Bootstrap();
|
||||
bootstrap.group(tunnelWorkGroup);
|
||||
bootstrap.channel(NioSocketChannel.class);
|
||||
// bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 3000);
|
||||
// bootstrap.option(ChannelOption.SO_KEEPALIVE, true);
|
||||
// /**
|
||||
// * TCP/IP协议中,无论发送多少数据,总是要在数据前面加上协议头,同时,对方接收到数据,也需要发送ACK表示确认。为了尽可能的利用网络带宽,TCP总是希望尽可能的发送足够大的数据。(一个连接会设置MSS参数,因此,TCP/IP希望每次都能够以MSS尺寸的数据块来发送数据)。
|
||||
// * Nagle算法就是为了尽可能发送大块数据,避免网络中充斥着许多小数据块。
|
||||
// */
|
||||
// bootstrap.option(ChannelOption.TCP_NODELAY, true);
|
||||
bootstrap.remoteAddress(InetSocketAddress.createUnresolved(proxyConfig.getTunnel().getServerIp(), proxyConfig.getTunnel().getServerPort()));
|
||||
|
||||
bootstrap.handler(new ChannelInitializer<SocketChannel>() {
|
||||
|
||||
@Override
|
||||
public void initChannel(SocketChannel ch) throws Exception {
|
||||
if (proxyConfig.getTunnel().getSslEnable()) {
|
||||
ch.pipeline().addLast(ProxyUtil.createSslHandler(proxyConfig));
|
||||
}
|
||||
if (null != proxyConfig.getTunnel().getTransferLogEnable() && proxyConfig.getTunnel().getTransferLogEnable()) {
|
||||
ch.pipeline().addFirst(new LoggingHandler(CmdChannelHandler.class));
|
||||
}
|
||||
ch.pipeline().addLast(new ProxyMessageDecoder(proxyConfig.getProtocol().getMaxFrameLength(),
|
||||
proxyConfig.getProtocol().getLengthFieldOffset(), proxyConfig.getProtocol().getLengthFieldLength(),
|
||||
proxyConfig.getProtocol().getLengthAdjustment(), proxyConfig.getProtocol().getInitialBytesToStrip()));
|
||||
ch.pipeline().addLast(new ProxyMessageEncoder());
|
||||
ch.pipeline().addLast(new IdleStateHandler(proxyConfig.getProtocol().getReadIdleTime(), proxyConfig.getProtocol().getWriteIdleTime(), proxyConfig.getProtocol().getAllIdleTimeSeconds()));
|
||||
ch.pipeline().addLast(new CmdChannelHandler());
|
||||
}
|
||||
});
|
||||
return bootstrap;
|
||||
}
|
||||
|
||||
@Bean("tcpProxyTunnelBootstrap")
|
||||
public Bootstrap tcpProxyTunnelBootstrap(@Inject ProxyConfig proxyConfig,
|
||||
@Inject("tunnelWorkGroup") NioEventLoopGroup tunnelWorkGroup) {
|
||||
Bootstrap bootstrap = new Bootstrap();
|
||||
bootstrap.group(tunnelWorkGroup);
|
||||
bootstrap.channel(NioSocketChannel.class);
|
||||
bootstrap.remoteAddress(InetSocketAddress.createUnresolved(proxyConfig.getTunnel().getServerIp(), proxyConfig.getTunnel().getServerPort()));
|
||||
bootstrap.handler(new ChannelInitializer<SocketChannel>() {
|
||||
|
||||
@Override
|
||||
public void initChannel(SocketChannel ch) throws Exception {
|
||||
if (proxyConfig.getTunnel().getSslEnable()) {
|
||||
ch.pipeline().addLast(ProxyUtil.createSslHandler(proxyConfig));
|
||||
}
|
||||
if (null != proxyConfig.getTunnel().getTransferLogEnable() && proxyConfig.getTunnel().getTransferLogEnable()) {
|
||||
ch.pipeline().addFirst(new LoggingHandler(TcpProxyChannelHandler.class));
|
||||
}
|
||||
ch.pipeline().addLast(new ProxyMessageDecoder(proxyConfig.getProtocol().getMaxFrameLength(),
|
||||
proxyConfig.getProtocol().getLengthFieldOffset(), proxyConfig.getProtocol().getLengthFieldLength(),
|
||||
proxyConfig.getProtocol().getLengthAdjustment(), proxyConfig.getProtocol().getInitialBytesToStrip()));
|
||||
ch.pipeline().addLast(new ProxyMessageEncoder());
|
||||
ch.pipeline().addLast(new IdleStateHandler(proxyConfig.getProtocol().getReadIdleTime(), proxyConfig.getProtocol().getWriteIdleTime(), proxyConfig.getProtocol().getAllIdleTimeSeconds()));
|
||||
ch.pipeline().addLast(new TcpProxyChannelHandler());
|
||||
}
|
||||
});
|
||||
return bootstrap;
|
||||
}
|
||||
|
||||
@Bean("udpProxyTunnelBootstrap")
|
||||
public Bootstrap udpProxyTunnelBootstrap(@Inject ProxyConfig proxyConfig,
|
||||
@Inject("tunnelWorkGroup") NioEventLoopGroup tunnelWorkGroup) {
|
||||
Bootstrap bootstrap = new Bootstrap();
|
||||
bootstrap.group(tunnelWorkGroup);
|
||||
bootstrap.channel(NioSocketChannel.class);
|
||||
bootstrap.remoteAddress(InetSocketAddress.createUnresolved(proxyConfig.getTunnel().getServerIp(), proxyConfig.getTunnel().getServerPort()));
|
||||
bootstrap.handler(new ChannelInitializer<SocketChannel>() {
|
||||
|
||||
@Override
|
||||
public void initChannel(SocketChannel ch) throws Exception {
|
||||
if (proxyConfig.getTunnel().getSslEnable()) {
|
||||
ch.pipeline().addLast(ProxyUtil.createSslHandler(proxyConfig));
|
||||
}
|
||||
if (null != proxyConfig.getTunnel().getTransferLogEnable() && proxyConfig.getTunnel().getTransferLogEnable()) {
|
||||
ch.pipeline().addFirst(new LoggingHandler(TcpProxyChannelHandler.class));
|
||||
}
|
||||
ch.pipeline().addLast(new ProxyMessageDecoder(proxyConfig.getProtocol().getMaxFrameLength(),
|
||||
proxyConfig.getProtocol().getLengthFieldOffset(), proxyConfig.getProtocol().getLengthFieldLength(),
|
||||
proxyConfig.getProtocol().getLengthAdjustment(), proxyConfig.getProtocol().getInitialBytesToStrip()));
|
||||
ch.pipeline().addLast(new ProxyMessageEncoder());
|
||||
ch.pipeline().addLast(new IdleStateHandler(proxyConfig.getProtocol().getReadIdleTime(), proxyConfig.getProtocol().getWriteIdleTime(), proxyConfig.getProtocol().getAllIdleTimeSeconds()));
|
||||
ch.pipeline().addLast(new UdpProxyChannelHandler());
|
||||
}
|
||||
});
|
||||
return bootstrap;
|
||||
}
|
||||
|
||||
@Bean("realServerBootstrap")
|
||||
public Bootstrap realServerBootstrap() {
|
||||
return new Bootstrap();
|
||||
public Bootstrap realServerBootstrap(@Inject ProxyConfig proxyConfig,
|
||||
@Inject("tcpRealServerWorkGroup") NioEventLoopGroup tcpRealServerWorkGroup
|
||||
) {
|
||||
Bootstrap bootstrap = new Bootstrap();
|
||||
bootstrap.group(tcpRealServerWorkGroup);
|
||||
bootstrap.channel(NioSocketChannel.class);
|
||||
bootstrap.handler(new ChannelInitializer<SocketChannel>() {
|
||||
|
||||
@Override
|
||||
public void initChannel(SocketChannel ch) throws Exception {
|
||||
if (null != proxyConfig.getTunnel().getTransferLogEnable() && proxyConfig.getTunnel().getTransferLogEnable()) {
|
||||
ch.pipeline().addFirst(new LoggingHandler(RealServerChannelHandler.class));
|
||||
}
|
||||
ch.pipeline().addLast(new RealServerChannelHandler());
|
||||
}
|
||||
});
|
||||
return bootstrap;
|
||||
}
|
||||
|
||||
@Bean("udpServerBootstrap")
|
||||
public Bootstrap udpServerBootstrap(@Inject ProxyConfig proxyConfig,
|
||||
@Inject("udpServerGroup") NioEventLoopGroup udpServerGroup,
|
||||
@Inject("udpWorkGroup") NioEventLoopGroup udpWorkGroup) {
|
||||
Bootstrap bootstrap = new Bootstrap();
|
||||
bootstrap.group(udpServerGroup)
|
||||
// 主线程处理
|
||||
.channel(NioDatagramChannel.class)
|
||||
// 广播
|
||||
.option(ChannelOption.SO_BROADCAST, true)
|
||||
// 设置读缓冲区为2M
|
||||
.option(ChannelOption.SO_RCVBUF, 2048 * 1024)
|
||||
// 设置写缓冲区为1M
|
||||
.option(ChannelOption.SO_SNDBUF, 1024 * 1024)
|
||||
.handler(new ChannelInitializer<NioDatagramChannel>() {
|
||||
@Override
|
||||
protected void initChannel(NioDatagramChannel ch) {
|
||||
ChannelPipeline pipeline = ch.pipeline();
|
||||
if (null != proxyConfig.getClient().getUdp().getTransferLogEnable() && proxyConfig.getClient().getUdp().getTransferLogEnable()) {
|
||||
ch.pipeline().addFirst(new LoggingHandler(UdpRealServerHandler.class));
|
||||
}
|
||||
pipeline.addLast(udpWorkGroup, new UdpRealServerHandler());
|
||||
}
|
||||
});
|
||||
return bootstrap;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public NeutrinoCoreRuntimeNativeRegistrar neutrinoCoreRuntimeNativeRegistrar() {
|
||||
return new NeutrinoCoreRuntimeNativeRegistrar();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package org.dromara.neutrinoproxy.client.constant;
|
||||
|
||||
import io.netty.util.AttributeKey;
|
||||
import org.dromara.neutrinoproxy.client.util.UdpChannelBindInfo;
|
||||
|
||||
/**
|
||||
* @author: aoshiguchen
|
||||
* @date: 2023/9/21
|
||||
*/
|
||||
public interface Constants {
|
||||
AttributeKey<UdpChannelBindInfo> UDP_CHANNEL_BIND_KEY = AttributeKey.newInstance("udpChannelBindKey");
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.dromara.neutrinoproxy.client.core;
|
||||
|
||||
import org.dromara.neutrinoproxy.client.config.ProxyConfig;
|
||||
import org.dromara.neutrinoproxy.client.util.ProxyUtil;
|
||||
import org.dromara.neutrinoproxy.core.Constants;
|
||||
import org.dromara.neutrinoproxy.core.ProxyMessage;
|
||||
@@ -19,12 +20,19 @@ import org.noear.solon.Solon;
|
||||
*/
|
||||
@Slf4j
|
||||
public class CmdChannelHandler extends SimpleChannelInboundHandler<ProxyMessage> {
|
||||
private static volatile Boolean transferLogEnable = Boolean.FALSE;
|
||||
|
||||
public CmdChannelHandler() {
|
||||
ProxyConfig proxyConfig = Solon.context().getBean(ProxyConfig.class);
|
||||
if (null != proxyConfig.getClient() && null != proxyConfig.getTunnel().getHeartbeatLogEnable()) {
|
||||
transferLogEnable = proxyConfig.getTunnel().getHeartbeatLogEnable();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void channelRead0(ChannelHandlerContext ctx, ProxyMessage proxyMessage) throws Exception {
|
||||
if (ProxyMessage.TYPE_HEARTBEAT != proxyMessage.getType()) {
|
||||
log.debug("Client CmdChannel recieved proxy message, type is {}", proxyMessage.getType());
|
||||
if (ProxyMessage.TYPE_HEARTBEAT != proxyMessage.getType() || transferLogEnable) {
|
||||
log.debug("[CMD Channel]Client CmdChannel recieved proxy message, type is {}", proxyMessage.getType());
|
||||
}
|
||||
Solon.context().getBean(Dispatcher.class).dispatch(ctx, proxyMessage);
|
||||
}
|
||||
@@ -41,7 +49,7 @@ public class CmdChannelHandler extends SimpleChannelInboundHandler<ProxyMessage>
|
||||
|
||||
@Override
|
||||
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
||||
log.info("Client CmdChannel 与服务端断开连接");
|
||||
log.info("[CMD Channel]Client CmdChannel disconnect");
|
||||
ProxyUtil.setCmdChannel(null);
|
||||
ProxyUtil.clearRealServerChannels();
|
||||
|
||||
@@ -50,7 +58,7 @@ public class CmdChannelHandler extends SimpleChannelInboundHandler<ProxyMessage>
|
||||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
||||
log.error("Client CmdChannel Error channelId:{}", ctx.channel().id().asLongText(), cause);
|
||||
log.error("[CMD Channel]Client CmdChannel Error channelId:{}", ctx.channel().id().asLongText(), cause);
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
@@ -61,14 +69,14 @@ public class CmdChannelHandler extends SimpleChannelInboundHandler<ProxyMessage>
|
||||
switch (event.state()) {
|
||||
case READER_IDLE:
|
||||
// 读超时,断开连接
|
||||
// log.info("读超时");
|
||||
// ctx.channel().close();
|
||||
log.error("[CMD Channel] Read timeout disconnect");
|
||||
ctx.channel().close();
|
||||
break;
|
||||
case WRITER_IDLE:
|
||||
ctx.channel().writeAndFlush(ProxyMessage.buildHeartbeatMessage());
|
||||
break;
|
||||
case ALL_IDLE:
|
||||
log.info("Client CmdChannel 读写超时");
|
||||
log.error("[CMD Channel] ReadWrite timeout disconnect");
|
||||
ctx.close();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,33 +1,18 @@
|
||||
package org.dromara.neutrinoproxy.client.core;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import io.netty.handler.logging.LoggingHandler;
|
||||
import org.dromara.neutrinoproxy.client.config.ProxyConfig;
|
||||
import org.dromara.neutrinoproxy.client.util.ProxyUtil;
|
||||
import org.dromara.neutrinoproxy.client.util.UdpServerUtil;
|
||||
import org.dromara.neutrinoproxy.core.ProxyMessage;
|
||||
import org.dromara.neutrinoproxy.core.ProxyMessageDecoder;
|
||||
import org.dromara.neutrinoproxy.core.ProxyMessageEncoder;
|
||||
import org.dromara.neutrinoproxy.core.util.FileUtil;
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.channel.*;
|
||||
import io.netty.channel.nio.NioEventLoopGroup;
|
||||
import io.netty.channel.socket.SocketChannel;
|
||||
import io.netty.channel.socket.nio.NioSocketChannel;
|
||||
import io.netty.handler.ssl.SslHandler;
|
||||
import io.netty.handler.timeout.IdleStateHandler;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.noear.solon.Solon;
|
||||
import org.noear.solon.annotation.Component;
|
||||
import org.noear.solon.annotation.Init;
|
||||
import org.noear.solon.annotation.Inject;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLEngine;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
import java.io.InputStream;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.security.KeyStore;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -44,24 +29,13 @@ public class ProxyClientService {
|
||||
private ProxyConfig proxyConfig;
|
||||
@Inject("cmdTunnelBootstrap")
|
||||
private Bootstrap cmdTunnelBootstrap;
|
||||
@Inject("proxyTunnelBootstrap")
|
||||
private Bootstrap proxyTunnelBootstrap;
|
||||
@Inject("realServerBootstrap")
|
||||
private Bootstrap realServerBootstrap;
|
||||
@Inject("udpServerBootstrap")
|
||||
private Bootstrap udpServerBootstrap;
|
||||
private volatile Channel channel;
|
||||
// /**
|
||||
// * 重连间隔(秒)
|
||||
// */
|
||||
// private static final long RECONNECT_INTERVAL_SECONDS = 5;
|
||||
/**
|
||||
* 重连次数
|
||||
*/
|
||||
private volatile int reconnectCount = 0;
|
||||
// /**
|
||||
// * 启用重连服务
|
||||
// */
|
||||
// private volatile boolean reconnectServiceEnable = false;
|
||||
private NioEventLoopGroup workerGroup;
|
||||
/**
|
||||
* 重连服务执行器
|
||||
*/
|
||||
@@ -69,95 +43,35 @@ public class ProxyClientService {
|
||||
|
||||
@Init
|
||||
public void init() {
|
||||
this.reconnectExecutor.scheduleWithFixedDelay(this::reconnect, 10, proxyConfig.getClient().getReconnection().getIntervalSeconds(), TimeUnit.SECONDS);
|
||||
this.workerGroup = new NioEventLoopGroup(proxyConfig.getClient().getThreadCount());
|
||||
|
||||
realServerBootstrap.group(workerGroup);
|
||||
realServerBootstrap.channel(NioSocketChannel.class);
|
||||
realServerBootstrap.handler(new ChannelInitializer<SocketChannel>() {
|
||||
|
||||
@Override
|
||||
public void initChannel(SocketChannel ch) throws Exception {
|
||||
ch.pipeline().addLast(new RealServerChannelHandler());
|
||||
}
|
||||
});
|
||||
|
||||
proxyTunnelBootstrap.group(workerGroup);
|
||||
proxyTunnelBootstrap.channel(NioSocketChannel.class);
|
||||
proxyTunnelBootstrap.remoteAddress(InetSocketAddress.createUnresolved(proxyConfig.getClient().getServerIp(), proxyConfig.getClient().getServerPort()));
|
||||
proxyTunnelBootstrap.handler(new ChannelInitializer<SocketChannel>() {
|
||||
|
||||
@Override
|
||||
public void initChannel(SocketChannel ch) throws Exception {
|
||||
if (proxyConfig.getClient().getSslEnable()) {
|
||||
ch.pipeline().addLast(createSslHandler());
|
||||
}
|
||||
// ch.pipeline().addFirst(new LoggingHandler(ProxyClientService.class));
|
||||
ch.pipeline().addLast(new ProxyMessageDecoder(proxyConfig.getProtocol().getMaxFrameLength(),
|
||||
proxyConfig.getProtocol().getLengthFieldOffset(), proxyConfig.getProtocol().getLengthFieldLength(),
|
||||
proxyConfig.getProtocol().getLengthAdjustment(), proxyConfig.getProtocol().getInitialBytesToStrip()));
|
||||
ch.pipeline().addLast(new ProxyMessageEncoder());
|
||||
ch.pipeline().addLast(new IdleStateHandler(proxyConfig.getProtocol().getReadIdleTime(), proxyConfig.getProtocol().getWriteIdleTime(), proxyConfig.getProtocol().getAllIdleTimeSeconds()));
|
||||
ch.pipeline().addLast(new ProxyChannelHandler());
|
||||
}
|
||||
});
|
||||
|
||||
cmdTunnelBootstrap.group(workerGroup);
|
||||
cmdTunnelBootstrap.channel(NioSocketChannel.class);
|
||||
// cmdTunnelBootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 3000);
|
||||
// cmdTunnelBootstrap.option(ChannelOption.SO_KEEPALIVE, true);
|
||||
// /**
|
||||
// * TCP/IP协议中,无论发送多少数据,总是要在数据前面加上协议头,同时,对方接收到数据,也需要发送ACK表示确认。为了尽可能的利用网络带宽,TCP总是希望尽可能的发送足够大的数据。(一个连接会设置MSS参数,因此,TCP/IP希望每次都能够以MSS尺寸的数据块来发送数据)。
|
||||
// * Nagle算法就是为了尽可能发送大块数据,避免网络中充斥着许多小数据块。
|
||||
// */
|
||||
// cmdTunnelBootstrap.option(ChannelOption.TCP_NODELAY, true);
|
||||
cmdTunnelBootstrap.remoteAddress(InetSocketAddress.createUnresolved(proxyConfig.getClient().getServerIp(), proxyConfig.getClient().getServerPort()));
|
||||
|
||||
cmdTunnelBootstrap.handler(new ChannelInitializer<SocketChannel>() {
|
||||
|
||||
@Override
|
||||
public void initChannel(SocketChannel ch) throws Exception {
|
||||
if (proxyConfig.getClient().getSslEnable()) {
|
||||
ch.pipeline().addLast(createSslHandler());
|
||||
}
|
||||
if (null != proxyConfig.getClient().getTransferLogEnable() && proxyConfig.getClient().getTransferLogEnable()) {
|
||||
ch.pipeline().addFirst(new LoggingHandler(ProxyClientService.class));
|
||||
}
|
||||
ch.pipeline().addLast(new ProxyMessageDecoder(proxyConfig.getProtocol().getMaxFrameLength(),
|
||||
proxyConfig.getProtocol().getLengthFieldOffset(), proxyConfig.getProtocol().getLengthFieldLength(),
|
||||
proxyConfig.getProtocol().getLengthAdjustment(), proxyConfig.getProtocol().getInitialBytesToStrip()));
|
||||
ch.pipeline().addLast(new ProxyMessageEncoder());
|
||||
ch.pipeline().addLast(new IdleStateHandler(proxyConfig.getProtocol().getReadIdleTime(), proxyConfig.getProtocol().getWriteIdleTime(), proxyConfig.getProtocol().getAllIdleTimeSeconds()));
|
||||
ch.pipeline().addLast(new CmdChannelHandler());
|
||||
}
|
||||
});
|
||||
this.reconnectExecutor.scheduleWithFixedDelay(this::reconnect, 10, proxyConfig.getTunnel().getReconnection().getIntervalSeconds(), TimeUnit.SECONDS);
|
||||
|
||||
try {
|
||||
this.start();
|
||||
UdpServerUtil.initCache(proxyConfig, udpServerBootstrap);
|
||||
} catch (Exception e) {
|
||||
// 启动连不上也做一下重连,因此先catch异常
|
||||
log.error("[客户端指令隧道] 启动异常", e);
|
||||
log.error("[CmdChannel] start error", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void start() {
|
||||
if (StrUtil.isEmpty(proxyConfig.getClient().getServerIp())) {
|
||||
if (StrUtil.isEmpty(proxyConfig.getTunnel().getServerIp())) {
|
||||
log.error("not found server-ip config.");
|
||||
Solon.stop();
|
||||
return;
|
||||
}
|
||||
if (null == proxyConfig.getClient().getServerPort()) {
|
||||
if (null == proxyConfig.getTunnel().getServerPort()) {
|
||||
log.error("not found server-port config.");
|
||||
Solon.stop();
|
||||
return;
|
||||
}
|
||||
if (null != proxyConfig.getClient().getSslEnable() && proxyConfig.getClient().getSslEnable()
|
||||
&& StrUtil.isEmpty(proxyConfig.getClient().getJksPath())) {
|
||||
if (null != proxyConfig.getTunnel().getSslEnable() && proxyConfig.getTunnel().getSslEnable()
|
||||
&& StrUtil.isEmpty(proxyConfig.getTunnel().getJksPath())) {
|
||||
log.error("not found jks-path config.");
|
||||
Solon.stop();
|
||||
return;
|
||||
}
|
||||
if (StrUtil.isEmpty(proxyConfig.getClient().getLicenseKey())) {
|
||||
if (StrUtil.isEmpty(proxyConfig.getTunnel().getLicenseKey())) {
|
||||
log.error("not found license-key config.");
|
||||
Solon.stop();
|
||||
return;
|
||||
@@ -169,7 +83,7 @@ public class ProxyClientService {
|
||||
log.error("client start error", e);
|
||||
}
|
||||
} else {
|
||||
channel.writeAndFlush(ProxyMessage.buildAuthMessage(proxyConfig.getClient().getLicenseKey(), ProxyUtil.getClientId()));
|
||||
channel.writeAndFlush(ProxyMessage.buildAuthMessage(proxyConfig.getTunnel().getLicenseKey(), ProxyUtil.getClientId()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,45 +100,19 @@ public class ProxyClientService {
|
||||
channel = future.channel();
|
||||
// 连接成功,向服务器发送客户端认证信息(licenseKey)
|
||||
ProxyUtil.setCmdChannel(future.channel());
|
||||
future.channel().writeAndFlush(ProxyMessage.buildAuthMessage(proxyConfig.getClient().getLicenseKey(), ProxyUtil.getClientId()));
|
||||
log.info("[客户端指令隧道] 连接代理服务成功. channelId:{}", future.channel().id().asLongText());
|
||||
future.channel().writeAndFlush(ProxyMessage.buildAuthMessage(proxyConfig.getTunnel().getLicenseKey(), ProxyUtil.getClientId()));
|
||||
log.info("[CmdChannel] connect proxy server success. channelId:{}", future.channel().id().asLongText());
|
||||
|
||||
// reconnectServiceEnable = true;
|
||||
reconnectCount = 0;
|
||||
} else {
|
||||
log.info("[客户端指令隧道] 连接代理服务失败!");
|
||||
log.info("[CmdChannel] connect proxy server failed!");
|
||||
}
|
||||
}
|
||||
}).sync();
|
||||
}
|
||||
|
||||
private ChannelHandler createSslHandler() {
|
||||
try {
|
||||
InputStream jksInputStream = FileUtil.getInputStream(proxyConfig.getClient().getJksPath());
|
||||
|
||||
SSLContext clientContext = SSLContext.getInstance("TLS");
|
||||
final KeyStore ks = KeyStore.getInstance("JKS");
|
||||
ks.load(jksInputStream, proxyConfig.getClient().getKeyStorePassword().toCharArray());
|
||||
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
tmf.init(ks);
|
||||
TrustManager[] trustManagers = tmf.getTrustManagers();
|
||||
clientContext.init(null, trustManagers, null);
|
||||
|
||||
SSLEngine sslEngine = clientContext.createSSLEngine();
|
||||
sslEngine.setUseClientMode(true);
|
||||
|
||||
return new SslHandler(sslEngine);
|
||||
} catch (Exception e) {
|
||||
log.error("创建SSL处理器失败", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected synchronized void reconnect() {
|
||||
// if (!reconnectServiceEnable) {
|
||||
// return;
|
||||
// }
|
||||
if (null != channel) {
|
||||
if (channel.isActive()) {
|
||||
return;
|
||||
@@ -232,11 +120,11 @@ public class ProxyClientService {
|
||||
channel.close();
|
||||
}
|
||||
|
||||
log.info("[客户端指令隧道] 客户端重连 seq:{}", ++reconnectCount);
|
||||
log.info("[CmdChannel] client reconnect seq:{}", ++reconnectCount);
|
||||
try {
|
||||
connectProxyServer();
|
||||
} catch (Exception e) {
|
||||
log.error("[客户端指令隧道] 重连异常", e);
|
||||
log.error("[CmdChannel] reconnect error", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,17 @@ public class RealServerChannelHandler extends SimpleChannelInboundHandler<ByteBu
|
||||
// 代理客户端连接断开
|
||||
ctx.channel().close();
|
||||
} else {
|
||||
|
||||
if (proxyChannel.isWritable()) {
|
||||
if (!realServerChannel.config().isAutoRead()) {
|
||||
realServerChannel.config().setAutoRead(true);
|
||||
}
|
||||
} else {
|
||||
if (realServerChannel.config().isAutoRead()) {
|
||||
realServerChannel.config().setAutoRead(false);
|
||||
}
|
||||
}
|
||||
|
||||
byte[] bytes = new byte[buf.readableBytes()];
|
||||
buf.readBytes(bytes);
|
||||
String visitorId = ProxyUtil.getVisitorIdByRealServerChannel(realServerChannel);
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
package org.dromara.neutrinoproxy.client.core;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
import io.netty.handler.timeout.IdleStateEvent;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.neutrinoproxy.client.util.ProxyUtil;
|
||||
import org.dromara.neutrinoproxy.core.Constants;
|
||||
import org.dromara.neutrinoproxy.core.ProxyMessage;
|
||||
import org.dromara.neutrinoproxy.core.dispatcher.Dispatcher;
|
||||
import org.noear.solon.Solon;
|
||||
|
||||
/**
|
||||
* 处理与服务端之间的数据传输
|
||||
* @author: aoshiguchen
|
||||
* @date: 2022/6/16
|
||||
*/
|
||||
@Slf4j
|
||||
public class TcpProxyChannelHandler extends SimpleChannelInboundHandler<ProxyMessage> {
|
||||
|
||||
|
||||
@Override
|
||||
protected void channelRead0(ChannelHandlerContext ctx, ProxyMessage proxyMessage) throws Exception {
|
||||
if (ProxyMessage.TYPE_HEARTBEAT != proxyMessage.getType()) {
|
||||
log.debug("[TCP Proxy Channel]Client ProxyChannel recieved proxy message, type is {}", proxyMessage.getType());
|
||||
}
|
||||
Solon.context().getBean(Dispatcher.class).dispatch(ctx, proxyMessage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception {
|
||||
Channel realServerChannel = ctx.channel().attr(Constants.NEXT_CHANNEL).get();
|
||||
if (realServerChannel != null) {
|
||||
realServerChannel.config().setOption(ChannelOption.AUTO_READ, ctx.channel().isWritable());
|
||||
}
|
||||
|
||||
super.channelWritabilityChanged(ctx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
||||
// 数据传输连接
|
||||
Channel realServerChannel = ctx.channel().attr(Constants.NEXT_CHANNEL).get();
|
||||
if (realServerChannel != null && realServerChannel.isActive()) {
|
||||
realServerChannel.close();
|
||||
}
|
||||
|
||||
ProxyUtil.removeTcpProxyChanel(ctx.channel());
|
||||
super.channelInactive(ctx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
||||
log.error("[TCP Proxy Channel]Client ProxyChannel Error channelId:{}", ctx.channel().id().asLongText(), cause);
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
|
||||
if(evt instanceof IdleStateEvent) {
|
||||
IdleStateEvent event = (IdleStateEvent)evt;
|
||||
switch (event.state()) {
|
||||
case READER_IDLE:
|
||||
if (ctx.channel().isWritable()) {
|
||||
// 读超时,断开连接
|
||||
log.info("[TCP Proxy Channel]Read timeout");
|
||||
ctx.channel().close();
|
||||
}
|
||||
break;
|
||||
case WRITER_IDLE:
|
||||
ctx.channel().writeAndFlush(ProxyMessage.buildHeartbeatMessage());
|
||||
break;
|
||||
case ALL_IDLE:
|
||||
// log.debug("[TCP Proxy Channel]ReadWrite timeout");
|
||||
// ctx.close();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,13 +18,13 @@ import org.noear.solon.Solon;
|
||||
* @date: 2022/6/16
|
||||
*/
|
||||
@Slf4j
|
||||
public class ProxyChannelHandler extends SimpleChannelInboundHandler<ProxyMessage> {
|
||||
public class UdpProxyChannelHandler extends SimpleChannelInboundHandler<ProxyMessage> {
|
||||
|
||||
|
||||
@Override
|
||||
protected void channelRead0(ChannelHandlerContext ctx, ProxyMessage proxyMessage) throws Exception {
|
||||
if (ProxyMessage.TYPE_HEARTBEAT != proxyMessage.getType()) {
|
||||
log.debug("Client ProxyChannel recieved proxy message, type is {}", proxyMessage.getType());
|
||||
log.debug("[UDP Proxy Channel]Client ProxyChannel recieved proxy message, type is {}", proxyMessage.getType());
|
||||
}
|
||||
Solon.context().getBean(Dispatcher.class).dispatch(ctx, proxyMessage);
|
||||
}
|
||||
@@ -47,13 +47,13 @@ public class ProxyChannelHandler extends SimpleChannelInboundHandler<ProxyMessag
|
||||
realServerChannel.close();
|
||||
}
|
||||
|
||||
ProxyUtil.removeProxyChanel(ctx.channel());
|
||||
ProxyUtil.removeTcpProxyChanel(ctx.channel());
|
||||
super.channelInactive(ctx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
||||
log.error("Client ProxyChannel Error channelId:{}", ctx.channel().id().asLongText(), cause);
|
||||
log.error("[UDP Proxy Channel]Client ProxyChannel Error channelId:{}", ctx.channel().id().asLongText(), cause);
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
@@ -64,14 +64,14 @@ public class ProxyChannelHandler extends SimpleChannelInboundHandler<ProxyMessag
|
||||
switch (event.state()) {
|
||||
case READER_IDLE:
|
||||
// 读超时,断开连接
|
||||
// log.info("读超时");
|
||||
// ctx.channel().close();
|
||||
log.info("[UDP Proxy Channel]Read timeout");
|
||||
ctx.channel().close();
|
||||
break;
|
||||
case WRITER_IDLE:
|
||||
ctx.channel().writeAndFlush(ProxyMessage.buildHeartbeatMessage());
|
||||
break;
|
||||
case ALL_IDLE:
|
||||
log.debug("读写超时");
|
||||
log.debug("[UDP Proxy Channel]ReadWrite timeout");
|
||||
ctx.close();
|
||||
break;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package org.dromara.neutrinoproxy.client.core;
|
||||
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
import io.netty.channel.socket.DatagramPacket;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.neutrinoproxy.client.constant.Constants;
|
||||
import org.dromara.neutrinoproxy.client.util.UdpChannelBindInfo;
|
||||
import org.dromara.neutrinoproxy.core.ProxyMessage;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
/**
|
||||
* @author: aoshiguchen
|
||||
* @date: 2023/9/21
|
||||
*/
|
||||
@Slf4j
|
||||
public class UdpRealServerHandler extends SimpleChannelInboundHandler<DatagramPacket> {
|
||||
|
||||
@Override
|
||||
protected void channelRead0(ChannelHandlerContext ctx, DatagramPacket datagramPacket) throws Exception {
|
||||
log.debug("chid---<:{} port:{}", ctx.channel().id().asLongText(), ((InetSocketAddress)ctx.channel().localAddress()).getPort());
|
||||
UdpChannelBindInfo udpChannelBindInfo = ctx.channel().attr(Constants.UDP_CHANNEL_BIND_KEY).get();
|
||||
if (null != udpChannelBindInfo) {
|
||||
byte[] bytes = new byte[datagramPacket.content().readableBytes()];
|
||||
datagramPacket.content().readBytes(bytes);
|
||||
|
||||
udpChannelBindInfo.getTunnelChannel().writeAndFlush(ProxyMessage.buildUdpTransferMessage(new ProxyMessage.UdpBaseInfo()
|
||||
.setVisitorId(udpChannelBindInfo.getVisitorId())
|
||||
.setVisitorIp(udpChannelBindInfo.getVisitorIp())
|
||||
.setVisitorPort(udpChannelBindInfo.getVisitorPort())
|
||||
.setServerPort(udpChannelBindInfo.getServerPort())
|
||||
.setTargetIp(udpChannelBindInfo.getTargetIp())
|
||||
.setTargetPort(udpChannelBindInfo.getTargetPort()))
|
||||
.setData(bytes)
|
||||
);
|
||||
|
||||
udpChannelBindInfo.getLockChannel().setResponseCount(udpChannelBindInfo.getLockChannel().getResponseCount() + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,14 @@
|
||||
package org.dromara.neutrinoproxy.client.handler;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.neutrinoproxy.client.config.ProxyConfig;
|
||||
import org.dromara.neutrinoproxy.core.Constants;
|
||||
import org.dromara.neutrinoproxy.core.ExceptionEnum;
|
||||
import org.dromara.neutrinoproxy.core.ProxyMessage;
|
||||
import org.dromara.neutrinoproxy.core.ProxyMessageHandler;
|
||||
import org.dromara.neutrinoproxy.core.dispatcher.Match;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.noear.snack.ONode;
|
||||
import org.noear.solon.Solon;
|
||||
import org.noear.solon.annotation.Component;
|
||||
import org.noear.solon.annotation.Inject;
|
||||
@@ -27,14 +27,14 @@ public class ProxyMessageAuthHandler implements ProxyMessageHandler {
|
||||
@Override
|
||||
public void handle(ChannelHandlerContext context, ProxyMessage proxyMessage) {
|
||||
String info = proxyMessage.getInfo();
|
||||
JSONObject data = JSONObject.parseObject(info);
|
||||
Integer code = data.getInteger("code");
|
||||
log.info("认证结果:{}", info);
|
||||
ONode load = ONode.load(info);
|
||||
Integer code = load.get("code").getInt();
|
||||
log.info("Auth result:{}", info);
|
||||
if (ExceptionEnum.AUTH_FAILED.getCode().equals(code)) {
|
||||
// 客户端认证失败,直接停止服务
|
||||
log.info("client auth failed , client stop.");
|
||||
context.channel().close();
|
||||
if (!proxyConfig.getClient().getReconnection().getUnlimited()) {
|
||||
if (!proxyConfig.getTunnel().getReconnection().getUnlimited()) {
|
||||
Solon.stop();
|
||||
}
|
||||
} else if (ExceptionEnum.CONNECT_FAILED.getCode().equals(code) ||
|
||||
|
||||
@@ -21,8 +21,8 @@ import org.noear.solon.annotation.Inject;
|
||||
@Match(type = Constants.ProxyDataTypeName.CONNECT)
|
||||
@Component
|
||||
public class ProxyMessageConnectHandler implements ProxyMessageHandler {
|
||||
@Inject("proxyTunnelBootstrap")
|
||||
private Bootstrap proxyTunnelBootstrap;
|
||||
@Inject("tcpProxyTunnelBootstrap")
|
||||
private Bootstrap tcpProxyTunnelBootstrap;
|
||||
@Inject("realServerBootstrap")
|
||||
private Bootstrap realServerBootstrap;
|
||||
@Inject
|
||||
@@ -48,7 +48,7 @@ public class ProxyMessageConnectHandler implements ProxyMessageHandler {
|
||||
realServerChannel.config().setOption(ChannelOption.AUTO_READ, false);
|
||||
|
||||
// 获取连接
|
||||
ProxyUtil.borrowProxyChanel(proxyTunnelBootstrap, new ProxyChannelBorrowListener() {
|
||||
ProxyUtil.borrowTcpProxyChanel(tcpProxyTunnelBootstrap, new ProxyChannelBorrowListener() {
|
||||
|
||||
@Override
|
||||
public void success(Channel channel) {
|
||||
@@ -57,7 +57,7 @@ public class ProxyMessageConnectHandler implements ProxyMessageHandler {
|
||||
realServerChannel.attr(Constants.NEXT_CHANNEL).set(channel);
|
||||
|
||||
// 远程绑定
|
||||
channel.writeAndFlush(ProxyMessage.buildConnectMessage(visitorId + "@" + proxyConfig.getClient().getLicenseKey()));
|
||||
channel.writeAndFlush(ProxyMessage.buildConnectMessage(visitorId + "@" + proxyConfig.getTunnel().getLicenseKey()));
|
||||
|
||||
realServerChannel.config().setOption(ChannelOption.AUTO_READ, true);
|
||||
ProxyUtil.addRealServerChannel(visitorId, realServerChannel);
|
||||
|
||||
@@ -26,9 +26,10 @@ public class ProxyMessageDisconnectHandler implements ProxyMessageHandler {
|
||||
Channel realServerChannel = ctx.channel().attr(Constants.NEXT_CHANNEL).get();
|
||||
if (null != realServerChannel) {
|
||||
ctx.channel().attr(Constants.NEXT_CHANNEL).remove();
|
||||
ProxyUtil.returnProxyChanel(ctx.channel());
|
||||
ProxyUtil.returnTcpProxyChanel(ctx.channel());
|
||||
realServerChannel.writeAndFlush(Unpooled.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE);
|
||||
}
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package org.dromara.neutrinoproxy.client.handler;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.dromara.neutrinoproxy.core.*;
|
||||
import org.dromara.neutrinoproxy.core.*;
|
||||
import org.dromara.neutrinoproxy.core.dispatcher.Match;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.neutrinoproxy.core.Constants;
|
||||
import org.dromara.neutrinoproxy.core.ExceptionEnum;
|
||||
import org.dromara.neutrinoproxy.core.ProxyDataTypeEnum;
|
||||
import org.dromara.neutrinoproxy.core.ProxyMessage;
|
||||
import org.dromara.neutrinoproxy.core.ProxyMessageHandler;
|
||||
import org.dromara.neutrinoproxy.core.dispatcher.Match;
|
||||
import org.noear.snack.ONode;
|
||||
import org.noear.solon.annotation.Component;
|
||||
|
||||
/**
|
||||
@@ -20,9 +23,9 @@ public class ProxyMessageErrorHandler implements ProxyMessageHandler {
|
||||
|
||||
@Override
|
||||
public void handle(ChannelHandlerContext ctx, ProxyMessage proxyMessage) {
|
||||
log.info("异常信息: {}", proxyMessage.getInfo());
|
||||
JSONObject data = JSONObject.parseObject(proxyMessage.getInfo());
|
||||
Integer code = data.getInteger("code");
|
||||
log.info("error: {}", proxyMessage.getInfo());
|
||||
ONode load = ONode.load(proxyMessage.getInfo());
|
||||
Integer code = load.get("code").getInt();
|
||||
if (ExceptionEnum.AUTH_FAILED.getCode().equals(code)) {
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,10 @@ public class ProxyMessageTransferHandler implements ProxyMessageHandler {
|
||||
public void handle(ChannelHandlerContext ctx, ProxyMessage proxyMessage) {
|
||||
Channel realServerChannel = ctx.channel().attr(Constants.NEXT_CHANNEL).get();
|
||||
if (realServerChannel != null) {
|
||||
|
||||
// 自己可写,则设置来源可读。自己不可写,则设置来源不可读
|
||||
ctx.channel().config().setAutoRead(realServerChannel.isWritable());
|
||||
|
||||
ByteBuf buf = ctx.alloc().buffer(proxyMessage.getData().length);
|
||||
buf.writeBytes(proxyMessage.getData());
|
||||
realServerChannel.writeAndFlush(buf);
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package org.dromara.neutrinoproxy.client.handler;
|
||||
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.neutrinoproxy.client.config.ProxyConfig;
|
||||
import org.dromara.neutrinoproxy.client.core.ProxyChannelBorrowListener;
|
||||
import org.dromara.neutrinoproxy.client.util.ProxyUtil;
|
||||
import org.dromara.neutrinoproxy.core.Constants;
|
||||
import org.dromara.neutrinoproxy.core.ProxyDataTypeEnum;
|
||||
import org.dromara.neutrinoproxy.core.ProxyMessage;
|
||||
import org.dromara.neutrinoproxy.core.ProxyMessageHandler;
|
||||
import org.dromara.neutrinoproxy.core.dispatcher.Match;
|
||||
import org.noear.snack.ONode;
|
||||
import org.noear.solon.annotation.Component;
|
||||
import org.noear.solon.annotation.Inject;
|
||||
|
||||
/**
|
||||
* @author: aoshiguchen
|
||||
* @date: 2023/9/19
|
||||
*/
|
||||
@Slf4j
|
||||
@Match(type = Constants.ProxyDataTypeName.UDP_CONNECT)
|
||||
@Component
|
||||
public class UdpProxyMessageConnectHandler implements ProxyMessageHandler {
|
||||
@Inject
|
||||
private ProxyConfig proxyConfig;
|
||||
@Inject("udpProxyTunnelBootstrap")
|
||||
private Bootstrap udpProxyTunnelBootstrap;
|
||||
|
||||
@Override
|
||||
public void handle(ChannelHandlerContext ctx, ProxyMessage proxyMessage) {
|
||||
final Channel cmdChannel = ctx.channel();
|
||||
final ProxyMessage.UdpBaseInfo udpBaseInfo = ONode.deserialize(proxyMessage.getInfo(), ProxyMessage.UdpBaseInfo.class);
|
||||
log.info("[UDP connect]info:{}", proxyMessage.getInfo());
|
||||
|
||||
// 获取连接
|
||||
ProxyUtil.borrowUdpProxyChanel(udpProxyTunnelBootstrap, new ProxyChannelBorrowListener() {
|
||||
|
||||
@Override
|
||||
public void success(Channel channel) {
|
||||
channel.writeAndFlush(ProxyMessage.buildUdpConnectMessage(new ProxyMessage.UdpBaseInfo()
|
||||
.setVisitorId(udpBaseInfo.getVisitorId())
|
||||
.setServerPort(udpBaseInfo.getServerPort())
|
||||
.setTargetIp(udpBaseInfo.getTargetIp())
|
||||
.setTargetPort(udpBaseInfo.getTargetPort())
|
||||
).setData(proxyConfig.getTunnel().getLicenseKey().getBytes()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(Throwable cause) {
|
||||
cmdChannel.writeAndFlush(ProxyMessage.buildDisconnectMessage(udpBaseInfo.toJsonString()));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return ProxyDataTypeEnum.UDP_CONNECT.getDesc();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package org.dromara.neutrinoproxy.client.handler;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.socket.DatagramPacket;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.neutrinoproxy.client.util.UdpServerUtil;
|
||||
import org.dromara.neutrinoproxy.core.Constants;
|
||||
import org.dromara.neutrinoproxy.core.ProxyDataTypeEnum;
|
||||
import org.dromara.neutrinoproxy.core.ProxyMessage;
|
||||
import org.dromara.neutrinoproxy.core.ProxyMessageHandler;
|
||||
import org.dromara.neutrinoproxy.core.dispatcher.Match;
|
||||
import org.noear.snack.ONode;
|
||||
import org.noear.solon.annotation.Component;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
/**
|
||||
* @author: aoshiguchen
|
||||
* @date: 2023/9/20
|
||||
*/
|
||||
@Slf4j
|
||||
@Match(type = Constants.ProxyDataTypeName.UDP_TRANSFER)
|
||||
@Component
|
||||
public class UdpProxyMessageTransferHandler implements ProxyMessageHandler {
|
||||
|
||||
@Override
|
||||
public void handle(ChannelHandlerContext ctx, ProxyMessage proxyMessage) {
|
||||
final ProxyMessage.UdpBaseInfo udpBaseInfo = ONode.deserialize(proxyMessage.getInfo(), ProxyMessage.UdpBaseInfo.class);
|
||||
log.debug("[UDP transfer]info:{} data:{}", proxyMessage.getInfo(), new String(proxyMessage.getData()));
|
||||
Channel channel = UdpServerUtil.takeChannel(udpBaseInfo, ctx.channel());
|
||||
if (null == channel) {
|
||||
log.error("[UDP transfer] take udp channel failed.");
|
||||
return;
|
||||
}
|
||||
log.debug("chid--->:{} port:{}", ctx.channel().id().asLongText(), ((InetSocketAddress)channel.localAddress()).getPort());
|
||||
InetSocketAddress address = new InetSocketAddress(udpBaseInfo.getTargetIp(), udpBaseInfo.getTargetPort());
|
||||
ByteBuf byteBuf = Unpooled.copiedBuffer(proxyMessage.getData());
|
||||
channel.writeAndFlush(new DatagramPacket(byteBuf, address));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return ProxyDataTypeEnum.UDP_TRANSFER.getDesc();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package org.dromara.neutrinoproxy.client.util;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author: aoshiguchen
|
||||
* @date: 2023/9/21
|
||||
*/
|
||||
@Accessors(chain = true)
|
||||
@Data
|
||||
public class LockChannel {
|
||||
// 端口号
|
||||
private int port;
|
||||
// 通道
|
||||
private Channel channel;
|
||||
// 期望的响应次数
|
||||
private int proxyResponses;
|
||||
// 超时时间(毫秒)
|
||||
private long proxyTimeoutMs;
|
||||
// 被获取的时间
|
||||
private Date takeTime;
|
||||
// 已经响应的次数
|
||||
private int responseCount;
|
||||
}
|
||||
@@ -21,6 +21,9 @@
|
||||
*/
|
||||
package org.dromara.neutrinoproxy.client.util;
|
||||
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.handler.ssl.SslHandler;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dromara.neutrinoproxy.client.config.ProxyConfig;
|
||||
import org.dromara.neutrinoproxy.client.core.ProxyChannelBorrowListener;
|
||||
@@ -34,6 +37,12 @@ import io.netty.util.AttributeKey;
|
||||
import org.dromara.neutrinoproxy.core.util.FileUtil;
|
||||
import org.noear.solon.Solon;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLEngine;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
import java.io.InputStream;
|
||||
import java.security.KeyStore;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
@@ -45,6 +54,7 @@ import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
* @author: aoshiguchen
|
||||
* @date: 2022/8/31
|
||||
*/
|
||||
@Slf4j
|
||||
public class ProxyUtil {
|
||||
private static final AttributeKey<Boolean> USER_CHANNEL_WRITEABLE = AttributeKey.newInstance("user_channel_writeable");
|
||||
|
||||
@@ -54,21 +64,22 @@ public class ProxyUtil {
|
||||
|
||||
private static Map<String, Channel> realServerChannels = new ConcurrentHashMap<String, Channel>();
|
||||
|
||||
private static ConcurrentLinkedQueue<Channel> proxyChannelPool = new ConcurrentLinkedQueue<Channel>();
|
||||
private static ConcurrentLinkedQueue<Channel> tcpProxyChannelPool = new ConcurrentLinkedQueue<Channel>();
|
||||
private static ConcurrentLinkedQueue<Channel> udpProxyChannelPool = new ConcurrentLinkedQueue<>();
|
||||
|
||||
private static volatile Channel cmdChannel;
|
||||
|
||||
private static String clientId;
|
||||
private static final String CLIENT_ID_FILE = ".NEUTRINO_PROXY_CLIENT_ID";
|
||||
|
||||
public static void borrowProxyChanel(Bootstrap proxyTunnelBootstrap, final ProxyChannelBorrowListener borrowListener) {
|
||||
Channel channel = proxyChannelPool.poll();
|
||||
public static void borrowTcpProxyChanel(Bootstrap tcpProxyTunnelBootstrap, final ProxyChannelBorrowListener borrowListener) {
|
||||
Channel channel = tcpProxyChannelPool.poll();
|
||||
if (null != channel) {
|
||||
borrowListener.success(channel);
|
||||
return;
|
||||
}
|
||||
|
||||
proxyTunnelBootstrap.connect().addListener((ChannelFutureListener) future -> {
|
||||
tcpProxyTunnelBootstrap.connect().addListener((ChannelFutureListener) future -> {
|
||||
if (future.isSuccess()) {
|
||||
borrowListener.success(future.channel());
|
||||
} else {
|
||||
@@ -77,18 +88,52 @@ public class ProxyUtil {
|
||||
});
|
||||
}
|
||||
|
||||
public static void returnProxyChanel(Channel proxyChanel) {
|
||||
if (proxyChannelPool.size() > MAX_POOL_SIZE) {
|
||||
public static void returnTcpProxyChanel(Channel proxyChanel) {
|
||||
if (tcpProxyChannelPool.size() > MAX_POOL_SIZE) {
|
||||
proxyChanel.close();
|
||||
} else {
|
||||
proxyChanel.config().setOption(ChannelOption.AUTO_READ, true);
|
||||
proxyChanel.attr(Constants.NEXT_CHANNEL).remove();
|
||||
proxyChannelPool.offer(proxyChanel);
|
||||
tcpProxyChannelPool.offer(proxyChanel);
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeProxyChanel(Channel proxyChanel) {
|
||||
proxyChannelPool.remove(proxyChanel);
|
||||
|
||||
|
||||
public static void removeTcpProxyChanel(Channel proxyChanel) {
|
||||
tcpProxyChannelPool.remove(proxyChanel);
|
||||
}
|
||||
|
||||
public static void borrowUdpProxyChanel(Bootstrap tcpProxyTunnelBootstrap, final ProxyChannelBorrowListener borrowListener) {
|
||||
Channel channel = udpProxyChannelPool.poll();
|
||||
if (null != channel) {
|
||||
borrowListener.success(channel);
|
||||
return;
|
||||
}
|
||||
|
||||
tcpProxyTunnelBootstrap.connect().addListener((ChannelFutureListener) future -> {
|
||||
if (future.isSuccess()) {
|
||||
borrowListener.success(future.channel());
|
||||
} else {
|
||||
borrowListener.error(future.cause());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void returnUdpProxyChanel(Channel proxyChanel) {
|
||||
if (udpProxyChannelPool.size() > MAX_POOL_SIZE) {
|
||||
proxyChanel.close();
|
||||
} else {
|
||||
proxyChanel.config().setOption(ChannelOption.AUTO_READ, true);
|
||||
proxyChanel.attr(Constants.NEXT_CHANNEL).remove();
|
||||
udpProxyChannelPool.offer(proxyChanel);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void removeUdpProxyChanel(Channel proxyChanel) {
|
||||
udpProxyChannelPool.remove(proxyChanel);
|
||||
}
|
||||
|
||||
public static void setCmdChannel(Channel cmdChannel) {
|
||||
@@ -140,8 +185,8 @@ public class ProxyUtil {
|
||||
return clientId;
|
||||
}
|
||||
ProxyConfig proxyConfig = Solon.context().getBean(ProxyConfig.class);
|
||||
if (StringUtils.isNotBlank(proxyConfig.getClient().getClientId())) {
|
||||
clientId = proxyConfig.getClient().getClientId();
|
||||
if (StringUtils.isNotBlank(proxyConfig.getTunnel().getClientId())) {
|
||||
clientId = proxyConfig.getTunnel().getClientId();
|
||||
return clientId;
|
||||
}
|
||||
String id = FileUtil.readContentAsString(CLIENT_ID_FILE);
|
||||
@@ -154,4 +199,28 @@ public class ProxyUtil {
|
||||
clientId = id;
|
||||
return id;
|
||||
}
|
||||
|
||||
public static ChannelHandler createSslHandler(ProxyConfig proxyConfig) {
|
||||
try {
|
||||
InputStream jksInputStream = FileUtil.getInputStream(proxyConfig.getTunnel().getJksPath());
|
||||
|
||||
SSLContext clientContext = SSLContext.getInstance("TLS");
|
||||
final KeyStore ks = KeyStore.getInstance("JKS");
|
||||
ks.load(jksInputStream, proxyConfig.getTunnel().getKeyStorePassword().toCharArray());
|
||||
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
tmf.init(ks);
|
||||
TrustManager[] trustManagers = tmf.getTrustManagers();
|
||||
clientContext.init(null, trustManagers, null);
|
||||
|
||||
SSLEngine sslEngine = clientContext.createSSLEngine();
|
||||
sslEngine.setUseClientMode(true);
|
||||
|
||||
return new SslHandler(sslEngine);
|
||||
} catch (Exception e) {
|
||||
log.error("create SSL handler failed", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package org.dromara.neutrinoproxy.client.util;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @author: aoshiguchen
|
||||
* @date: 2023/9/21
|
||||
*/
|
||||
@Accessors(chain = true)
|
||||
@Data
|
||||
public class UdpChannelBindInfo {
|
||||
private Channel tunnelChannel;
|
||||
private LockChannel lockChannel;
|
||||
private String visitorId;
|
||||
private String visitorIp;
|
||||
private int visitorPort;
|
||||
private int serverPort;
|
||||
private String targetIp;
|
||||
private int targetPort;
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
package org.dromara.neutrinoproxy.client.util;
|
||||
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dromara.neutrinoproxy.client.config.ProxyConfig;
|
||||
import org.dromara.neutrinoproxy.client.constant.Constants;
|
||||
import org.dromara.neutrinoproxy.client.core.CustomThreadFactory;
|
||||
import org.dromara.neutrinoproxy.core.ProxyMessage;
|
||||
import org.noear.solon.core.runtime.NativeDetector;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
/**
|
||||
* @author: aoshiguchen
|
||||
* @date: 2023/9/21
|
||||
*/
|
||||
@Slf4j
|
||||
public class UdpServerUtil {
|
||||
private static final Boolean isSupportUdp = Boolean.FALSE;
|
||||
private static int udpServerPortMin = 0;
|
||||
private static int udpServerPortMax = 0;
|
||||
private static int nextUdpServerPort = 0;
|
||||
private static Bootstrap udpServerBootstrap;
|
||||
private static int defaultUdpServerPort;
|
||||
private static Channel defaultUdpServerChannel;
|
||||
private static Map<Integer, Channel> portToChannelMap = new ConcurrentHashMap<>();
|
||||
/**
|
||||
* udp服务空闲端口池
|
||||
*/
|
||||
private static ConcurrentLinkedQueue<Integer> udpServerFreePortPool = new ConcurrentLinkedQueue<>();
|
||||
private static List<LockChannel> lockChannelList = new ArrayList<>();
|
||||
/**
|
||||
* lockChannel扫描器
|
||||
*/
|
||||
private static final ScheduledExecutorService lockChannelScanner = Executors.newSingleThreadScheduledExecutor(new CustomThreadFactory("lockChannelScanner"));
|
||||
|
||||
/**
|
||||
* 初始化UDP缓存
|
||||
* 1、初始化一个基础UDP服务,用于不需要响应的UDP转发
|
||||
* 2、维护一个UDP服务池,用于需要响应的UDP转发
|
||||
* @param proxyConfig
|
||||
*/
|
||||
public static void initCache(ProxyConfig proxyConfig, Bootstrap udpServerBootstrap) {
|
||||
// aot 阶段,不初始化UDP服务
|
||||
if (NativeDetector.isAotRuntime()) {
|
||||
return;
|
||||
}
|
||||
if (null == proxyConfig.getClient().getUdp() || StringUtils.isEmpty(proxyConfig.getClient().getUdp().getPuppetPortRange())) {
|
||||
return;
|
||||
}
|
||||
ProxyConfig.Udp udpConfig = proxyConfig.getClient().getUdp();
|
||||
if (StringUtils.isEmpty(udpConfig.getPuppetPortRange())) {
|
||||
return;
|
||||
}
|
||||
String[] tmp = udpConfig.getPuppetPortRange().split("-");
|
||||
if (null == tmp || tmp.length != 2) {
|
||||
log.error("client udp config error!");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
udpServerPortMin = Integer.parseInt(tmp[0]);
|
||||
udpServerPortMax = Integer.parseInt(tmp[1]);
|
||||
if (udpServerPortMax <= udpServerPortMin) {
|
||||
// 至少得给1个udp端口,一个用于基础无响应UDP转发
|
||||
throw new RuntimeException("client udp config error!");
|
||||
}
|
||||
nextUdpServerPort = udpServerPortMin;
|
||||
UdpServerUtil.udpServerBootstrap = udpServerBootstrap;
|
||||
log.info("udp proxy server port: {} ~ {}", udpServerPortMin, udpServerPortMax);
|
||||
// 初始化udp服务
|
||||
initUdpServer();
|
||||
// 初始化lockChannel扫描器
|
||||
lockChannelScanner.scheduleWithFixedDelay(UdpServerUtil::lockChannelScan, 5, 3, TimeUnit.SECONDS);
|
||||
} catch (Exception e) {
|
||||
log.error("client udp config error!", e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化udp服务
|
||||
*/
|
||||
private static void initUdpServer() {
|
||||
defaultUdpServerPort = nextUdpServerPort();
|
||||
defaultUdpServerChannel = bindPort(defaultUdpServerPort);
|
||||
// 初始化默认最多额外开启5个udp服务,其他的需要时再启动
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if (!hasNextUdpServerPort()) {
|
||||
return;
|
||||
}
|
||||
int port = nextUdpServerPort();
|
||||
Channel ch = bindPort(port);
|
||||
portToChannelMap.put(port, ch);
|
||||
udpServerFreePortPool.offer(port);
|
||||
}
|
||||
while (hasNextUdpServerPort()) {
|
||||
udpServerFreePortPool.offer(nextUdpServerPort());
|
||||
}
|
||||
}
|
||||
|
||||
private static Channel bindPort(int port) {
|
||||
try {
|
||||
ChannelFuture channelFuture = udpServerBootstrap.bind(port).sync();
|
||||
log.info("[udp server] bind port:{} success!", port);
|
||||
return channelFuture.channel();
|
||||
} catch (InterruptedException e) {
|
||||
log.error("[udp server] bind port:{} error!", port);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static Boolean hasNextUdpServerPort() {
|
||||
return nextUdpServerPort <= udpServerPortMax;
|
||||
}
|
||||
|
||||
public static synchronized int nextUdpServerPort() {
|
||||
return nextUdpServerPort++;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一个可用的udp通道
|
||||
* 1、如果期待的响应为0,或者超时时间<=0,则认为不需要响应,直接返回默认的udp服务,否则继续下一步
|
||||
* 2、从可用端口队列中找到一个可用端口,若不存在可用端口,则降级为不需要响应,返回默认的udp服务。否则继续下一步
|
||||
* 3、根据该端口找到udp服务通道,找不到则绑定端口开启一个通道并返回。将该端口添加到锁定列表
|
||||
* 4、维护一个定时器的,定时扫描锁定列表,及时释放锁定的端口
|
||||
* @param info
|
||||
* @return
|
||||
*/
|
||||
public static synchronized Channel takeChannel(ProxyMessage.UdpBaseInfo info, Channel tunnelChannel) {
|
||||
if (info.getProxyResponses() <= 0 || info.getProxyTimeoutMs() <= 0) {
|
||||
return defaultUdpServerChannel;
|
||||
}
|
||||
Integer port = udpServerFreePortPool.poll();
|
||||
if (null == port) {
|
||||
return defaultUdpServerChannel;
|
||||
}
|
||||
Channel channel = portToChannelMap.get(port);
|
||||
if (null == channel) {
|
||||
channel = bindPort(port);
|
||||
portToChannelMap.put(port, channel);
|
||||
}
|
||||
// 添加到锁定队列
|
||||
LockChannel lockChannel = new LockChannel()
|
||||
.setPort(port)
|
||||
.setChannel(channel)
|
||||
.setProxyResponses(info.getProxyResponses())
|
||||
.setProxyTimeoutMs(info.getProxyTimeoutMs())
|
||||
.setTakeTime(new Date())
|
||||
.setResponseCount(0);
|
||||
lockChannelList.add(lockChannel);
|
||||
channel.attr(Constants.UDP_CHANNEL_BIND_KEY).set(new UdpChannelBindInfo()
|
||||
.setTunnelChannel(tunnelChannel)
|
||||
.setVisitorId(info.getVisitorId())
|
||||
.setVisitorIp(info.getVisitorIp())
|
||||
.setVisitorPort(info.getVisitorPort())
|
||||
.setServerPort(info.getServerPort())
|
||||
.setTargetIp(info.getTargetIp())
|
||||
.setTargetPort(info.getTargetPort())
|
||||
.setLockChannel(lockChannel)
|
||||
);
|
||||
return channel;
|
||||
}
|
||||
|
||||
/**
|
||||
* lockChannel扫描
|
||||
*/
|
||||
public static synchronized void lockChannelScan() {
|
||||
if (lockChannelList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Iterator<LockChannel> iter = lockChannelList.iterator();
|
||||
if (iter.hasNext()) {
|
||||
LockChannel lockChannel = iter.next();
|
||||
if (lockChannel.getResponseCount() >= lockChannel.getProxyResponses() ||
|
||||
System.currentTimeMillis() - lockChannel.getTakeTime().getTime() >= lockChannel.getProxyTimeoutMs()
|
||||
) {
|
||||
iter.remove();
|
||||
UdpChannelBindInfo udpChannelBindInfo = lockChannel.getChannel().attr(Constants.UDP_CHANNEL_BIND_KEY).get();
|
||||
// 此处必须释放代理隧道
|
||||
closeChannel(udpChannelBindInfo.getTunnelChannel());
|
||||
lockChannel.getChannel().attr(Constants.UDP_CHANNEL_BIND_KEY).set(null);
|
||||
udpServerFreePortPool.offer(lockChannel.getPort());
|
||||
log.debug("[udp channel]release udp channel port:{}", lockChannel.getPort());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void closeChannel(Channel channel) {
|
||||
try {
|
||||
channel.writeAndFlush(Unpooled.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE);
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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,3 +1,22 @@
|
||||
solon:
|
||||
config:
|
||||
add: ./app.yml
|
||||
app:
|
||||
name: neutrino-proxy-client
|
||||
version: 2.0.1
|
||||
# 日志级别
|
||||
solon.logging.appender:
|
||||
console:
|
||||
pattern: "%d{yyyy-MM-dd HH:mm:ss.SSS} %highlight(%-5level) %magenta(${PID:-}) --- %-15([%15.15thread]) %-56(%cyan(%-40.40logger{39}%L)) : %msg%n"
|
||||
file:
|
||||
enable: true
|
||||
pattern: "%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level ${PID:-} --- %-15([%15.15thread]) %-56(%-40.40logger{39}%L) : %msg%n"
|
||||
name: "logs/${neutrino.application.name}"
|
||||
rolling: "logs/${neutrino.application.name}_%d{yyyy-MM-dd}_%i.log.gz"
|
||||
solon.logging.logger:
|
||||
"root":
|
||||
level: info
|
||||
|
||||
neutrino:
|
||||
application:
|
||||
name: neutrino-proxy-client
|
||||
@@ -9,13 +28,10 @@ neutrino:
|
||||
length-field-length: 4
|
||||
initial-bytes-to-strip: 0
|
||||
length-adjustment: 0
|
||||
read-idle-time: 8
|
||||
write-idle-time: 3
|
||||
all-idle-time-seconds: 8
|
||||
logger:
|
||||
# 日志级别
|
||||
level: ${LOG_LEVEL:info}
|
||||
client:
|
||||
read-idle-time: 120
|
||||
write-idle-time: 20
|
||||
all-idle-time-seconds: 0
|
||||
tunnel:
|
||||
# 线程池相关配置,用于技术调优,可忽略
|
||||
thread-count: 50
|
||||
# 隧道SSL证书配置
|
||||
@@ -33,9 +49,20 @@ neutrino:
|
||||
client-id: ${CLIENT_ID:}
|
||||
# 是否开启隧道传输报文日志(日志级别为debug时开启才有效)
|
||||
transfer-log-enable: ${CLIENT_LOG:false}
|
||||
# 是否开启心跳日志
|
||||
heartbeat-log-enable: ${HEARTBEAT_LOG: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: ${CLIENT_LOG:false}
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<property name="LOG_FILE" value="./logs/neutrino-proxy-client.log"/>
|
||||
<property name="LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} %contextName [%thread] %-5level %logger{50} - %msg%n"/>
|
||||
<!-- <property name="ENCODE" value="utf8" />-->
|
||||
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||
<level>DEBUG</level>
|
||||
</filter>
|
||||
<encoder>
|
||||
<pattern>${LOG_PATTERN}</pattern>
|
||||
<!-- <charset>${ENCODE}</charset>-->
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${LOG_FILE}</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>${LOG_FILE}.%d{yyyy-MM-dd}.zip</fileNamePattern>
|
||||
<maxHistory>7</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${LOG_PATTERN}</pattern>
|
||||
<!-- <charset>${ENCODE}</charset>-->
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="DEBUG">
|
||||
<appender-ref ref="console"/>
|
||||
<appender-ref ref="file"/>
|
||||
</root>
|
||||
|
||||
<logger name="com.example.logback" level="warn"/>
|
||||
<logger name="io.netty" level="warn"/>
|
||||
</configuration>
|
||||
@@ -13,6 +13,13 @@
|
||||
<artifactId>neutrino-proxy-core</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<!--solon aot start(用于 aot 时注册 native 元信息)-->
|
||||
<dependency>
|
||||
<groupId>org.noear</groupId>
|
||||
<artifactId>solon.aot</artifactId>
|
||||
</dependency>
|
||||
<!--solon aot end-->
|
||||
|
||||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-all</artifactId>
|
||||
@@ -23,11 +30,24 @@
|
||||
<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>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
|
||||
<includes>
|
||||
<include>META-INF/native-image/neutrino-proxy-core/*.json</include>
|
||||
</includes>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
||||
@@ -25,6 +25,8 @@ package org.dromara.neutrinoproxy.core;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.util.AttributeKey;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author: aoshiguchen
|
||||
@@ -38,6 +40,20 @@ public interface Constants {
|
||||
|
||||
AttributeKey<Integer> LICENSE_ID = AttributeKey.newInstance("license_id");
|
||||
|
||||
AttributeKey<String> TARGET_IP = AttributeKey.newInstance("targetIp");
|
||||
AttributeKey<Integer> TARGET_PORT = AttributeKey.newInstance("targetPort");
|
||||
AttributeKey<Integer> PROXY_RESPONSES = AttributeKey.newInstance("proxyResponses");
|
||||
AttributeKey<Long> PROXY_TIMEOUT_MS = AttributeKey.newInstance("proxyTimeoutMs");
|
||||
|
||||
// 临时解决 udp channel被close的问题
|
||||
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;
|
||||
int SERIAL_NUMBER_SIZE = 8;
|
||||
@@ -49,6 +65,9 @@ public interface Constants {
|
||||
String CONNECT = "CONNECT";
|
||||
String DISCONNECT = "DISCONNECT";
|
||||
String TRANSFER = "TRANSFER";
|
||||
String UDP_CONNECT = "UDP_CONNECT";
|
||||
String UDP_DISCONNECT = "UDP_DISCONNECT";
|
||||
String UDP_TRANSFER = "UDP_TRANSFER";
|
||||
String ERROR = "ERROR";
|
||||
String PORT_MAPPING_SYNC = "PORT_MAPPING_SYNC";
|
||||
}
|
||||
|
||||
@@ -33,11 +33,11 @@ import lombok.Getter;
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum ExceptionEnum {
|
||||
SUCCESS(0, "成功"),
|
||||
AUTH_FAILED(1, "认证失败"),
|
||||
CONNECT_FAILED(2, "连接失败"),
|
||||
SUCCESS(0, "success"),
|
||||
AUTH_FAILED(1, "auth failed"),
|
||||
CONNECT_FAILED(2, "connect failed"),
|
||||
@Deprecated
|
||||
LICENSE_CANNOT_REPEAT_CONNECT(3, "license不能多个客户端同时使用"),
|
||||
LICENSE_CANNOT_REPEAT_CONNECT(3, "license cannot multiple client simultaneous use"),
|
||||
;
|
||||
|
||||
private Integer code;
|
||||
|
||||
@@ -38,13 +38,16 @@ import java.util.stream.Stream;
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum ProxyDataTypeEnum {
|
||||
HEARTBEAT(0x01, Constants.ProxyDataTypeName.HEARTBEAT, "心跳"),
|
||||
AUTH(0x02, Constants.ProxyDataTypeName.AUTH,"认证"),
|
||||
CONNECT(0x03, Constants.ProxyDataTypeName.CONNECT,"连接"),
|
||||
DISCONNECT(0x04, Constants.ProxyDataTypeName.DISCONNECT,"断开连接"),
|
||||
TRANSFER(0x05, Constants.ProxyDataTypeName.TRANSFER,"数据传输"),
|
||||
ERROR(0x06, Constants.ProxyDataTypeName.ERROR,"异常"),
|
||||
PORT_MAPPING_SYNC(0x07, Constants.ProxyDataTypeName.PORT_MAPPING_SYNC, "端口映射同步");
|
||||
HEARTBEAT(0x01, Constants.ProxyDataTypeName.HEARTBEAT, "HEARTBEAT"),
|
||||
AUTH(0x02, Constants.ProxyDataTypeName.AUTH,"AUTH"),
|
||||
CONNECT(0x03, Constants.ProxyDataTypeName.CONNECT,"CONNECT"),
|
||||
DISCONNECT(0x04, Constants.ProxyDataTypeName.DISCONNECT,"DISCONNECT"),
|
||||
TRANSFER(0x05, Constants.ProxyDataTypeName.TRANSFER,"TRANSFER"),
|
||||
ERROR(0x06, Constants.ProxyDataTypeName.ERROR,"ERROR"),
|
||||
PORT_MAPPING_SYNC(0x07, Constants.ProxyDataTypeName.PORT_MAPPING_SYNC, "PORT_MAPPING_SYNC"),
|
||||
UDP_CONNECT(0x08, Constants.ProxyDataTypeName.UDP_CONNECT,"UDP_CONNECT"),
|
||||
UDP_DISCONNECT(0x09, Constants.ProxyDataTypeName.UDP_DISCONNECT,"UDP_DISCONNECT"),
|
||||
UDP_TRANSFER(0x10, Constants.ProxyDataTypeName.UDP_TRANSFER,"UDP_TRANSFER");
|
||||
private static Map<Integer,ProxyDataTypeEnum> cache = Stream.of(values()).collect(Collectors.toMap(ProxyDataTypeEnum::getType, Function.identity()));
|
||||
|
||||
private int type;
|
||||
|
||||
@@ -22,9 +22,9 @@
|
||||
|
||||
package org.dromara.neutrinoproxy.core;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.noear.snack.ONode;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -66,6 +66,18 @@ public class ProxyMessage {
|
||||
* 通用异常信息
|
||||
*/
|
||||
public static final byte TYPE_ERROR = 0x06;
|
||||
/**
|
||||
* UDP代理隧道连接
|
||||
*/
|
||||
public static final byte TYPE_UDP_CONNECT = 0x08;
|
||||
/**
|
||||
* UDP代理隧道断开连接
|
||||
*/
|
||||
public static final byte TYPE_UDP_DISCONNECT = 0x09;
|
||||
/**
|
||||
* UDP数据传输
|
||||
*/
|
||||
public static final byte TYPE_UDP_TRANSFER = 0x10;
|
||||
|
||||
/**
|
||||
* 消息类型
|
||||
@@ -106,12 +118,12 @@ public class ProxyMessage {
|
||||
}
|
||||
|
||||
public static ProxyMessage buildAuthResultMessage(Integer code, String msg, String licenseKey) {
|
||||
JSONObject data = new JSONObject();
|
||||
data.put("code", code);
|
||||
data.put("msg", msg);
|
||||
data.put("licenseKey", licenseKey);
|
||||
ONode data = ONode.newObject();
|
||||
data.set("code", code);
|
||||
data.set("msg", msg);
|
||||
data.set("licenseKey", licenseKey);
|
||||
return create().setType(TYPE_AUTH)
|
||||
.setInfo(data.toJSONString());
|
||||
.setInfo(data.toJson());
|
||||
}
|
||||
|
||||
public static ProxyMessage buildConnectMessage(String visitorId) {
|
||||
@@ -130,16 +142,53 @@ public class ProxyMessage {
|
||||
.setData(data);
|
||||
}
|
||||
|
||||
|
||||
public static ProxyMessage buildUdpConnectMessage(UdpBaseInfo info) {
|
||||
return create().setType(TYPE_UDP_CONNECT)
|
||||
.setInfo(info.toJsonString());
|
||||
}
|
||||
|
||||
public static ProxyMessage buildUdpDisconnectMessage() {
|
||||
return create().setType(TYPE_UDP_DISCONNECT);
|
||||
}
|
||||
|
||||
public static ProxyMessage buildUdpTransferMessage(UdpBaseInfo info) {
|
||||
return create().setType(TYPE_UDP_TRANSFER)
|
||||
.setInfo(info.toJsonString());
|
||||
}
|
||||
|
||||
public static ProxyMessage buildErrMessage(ExceptionEnum exceptionEnum, String info) {
|
||||
JSONObject data = new JSONObject();
|
||||
data.put("code", exceptionEnum.getCode());
|
||||
data.put("msg", exceptionEnum.getMsg());
|
||||
data.put("info", info);
|
||||
ONode data = ONode.newObject();
|
||||
data.set("code", exceptionEnum.getCode());
|
||||
data.set("msg", exceptionEnum.getMsg());
|
||||
data.set("info", info);
|
||||
return create().setType(TYPE_ERROR)
|
||||
.setInfo(data.toJSONString());
|
||||
.setInfo(data.toJson());
|
||||
}
|
||||
|
||||
public static ProxyMessage buildErrMessage(ExceptionEnum exceptionEnum) {
|
||||
return buildErrMessage(exceptionEnum, null);
|
||||
}
|
||||
|
||||
@Accessors(chain = true)
|
||||
@Data
|
||||
public static class UdpBaseInfo {
|
||||
private String visitorId;
|
||||
private String visitorIp;
|
||||
private int visitorPort;
|
||||
private int serverPort;
|
||||
private String targetIp;
|
||||
private int targetPort;
|
||||
/**
|
||||
* 期待的响应数
|
||||
*/
|
||||
private int proxyResponses;
|
||||
/**
|
||||
* 超时时间(<=0时,相当于不需要响应)
|
||||
*/
|
||||
private long proxyTimeoutMs;
|
||||
public String toJsonString() {
|
||||
return ONode.serialize(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package org.dromara.neutrinoproxy.core.aot;
|
||||
|
||||
import cn.hutool.core.util.ClassUtil;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
import org.dromara.neutrinoproxy.core.ProxyMessage;
|
||||
import org.noear.solon.aot.RuntimeNativeMetadata;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author songyinyin
|
||||
* @since 2023/10/23 21:33
|
||||
*/
|
||||
public class NeutrinoCoreRuntimeNativeRegistrar implements RuntimeNativeRegistrar {
|
||||
@Override
|
||||
public void register(AppContext context, RuntimeNativeMetadata metadata) {
|
||||
Set<Class<?>> channelInboundClasses = ClassUtil.scanPackageBySuper("org.dromara.neutrinoproxy", SimpleChannelInboundHandler.class);
|
||||
for (Class<?> clazz : channelInboundClasses) {
|
||||
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("-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");
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,9 @@ package org.dromara.neutrinoproxy.core.dispatcher;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.dromara.neutrinoproxy.core.util.TypeUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.neutrinoproxy.core.util.TypeUtil;
|
||||
import org.noear.snack.ONode;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -35,10 +35,10 @@ public class DefaultDispatcher<Context, Data> implements Dispatcher<Context, Dat
|
||||
private Function<Data,String> matcher;
|
||||
|
||||
public DefaultDispatcher(String name, List<? extends Handler<Context,Data>> handlerList, Function<Data,String> matcher) {
|
||||
Assert.notNull(name, "名称不能为空!");
|
||||
Assert.notNull(matcher, "匹配器不能为空!");
|
||||
Assert.notNull(name, "name cannot empty!");
|
||||
Assert.notNull(matcher, "matcher cannot empty!");
|
||||
if (CollectionUtil.isEmpty(handlerList)) {
|
||||
log.error("{} 处理器列表为空.", name);
|
||||
log.error("{} handler list empty.", name);
|
||||
return;
|
||||
}
|
||||
this.name = name == null ? "" : name;
|
||||
@@ -48,20 +48,20 @@ public class DefaultDispatcher<Context, Data> implements Dispatcher<Context, Dat
|
||||
for (Handler handler : handlerList) {
|
||||
Match match = handler.getClass().getAnnotation(Match.class);
|
||||
if (null == match) {
|
||||
log.warn("{} 类: {} 缺失Match注解", this.name, handler.getClass().getName());
|
||||
log.warn("{} class: {} notfound Match annotation", this.name, handler.getClass().getName());
|
||||
continue;
|
||||
}
|
||||
if (StrUtil.isEmpty(match.type())) {
|
||||
log.warn("{} 类: {} match注解缺失type参数!", this.name, handler.getClass().getName());
|
||||
log.warn("{} class: {} match annotation notfound type param!", this.name, handler.getClass().getName());
|
||||
continue;
|
||||
}
|
||||
if (handlerMap.containsKey(match.type())) {
|
||||
log.warn("{} 类: {} match注解type值{} 存在重复!", this.name, handler.getClass().getName(), match.type());
|
||||
log.warn("{} class: {} match annotation type value {} repeat!", this.name, handler.getClass().getName(), match.type());
|
||||
continue;
|
||||
}
|
||||
handlerMap.put(match.type(), handler);
|
||||
}
|
||||
log.info("{} 处理器初始化完成", this.name);
|
||||
log.info("{} dispatcher init success", this.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -71,19 +71,18 @@ public class DefaultDispatcher<Context, Data> implements Dispatcher<Context, Dat
|
||||
}
|
||||
String type = matcher.apply(data);
|
||||
if (null == type) {
|
||||
log.warn("{} 获取匹配类型失败 data:{}", this.name, JSONObject.toJSONString(data));
|
||||
log.warn("{} get match type failed data:{}", this.name, ONode.serialize(data));
|
||||
return;
|
||||
}
|
||||
Handler<Context,Data> handler = handlerMap.get(type);
|
||||
if (null == handler) {
|
||||
// log.debug("{} 找不到匹配的处理器 type:{}", this.name, type);
|
||||
return;
|
||||
}
|
||||
String handlerName = handler.name();
|
||||
if (StrUtil.isEmpty(handlerName)) {
|
||||
handlerName = TypeUtil.getSimpleName(handler.getClass());
|
||||
}
|
||||
log.debug("{} 处理器[{}]执行.", this.name, handlerName);
|
||||
log.debug("{} handler[{}]execute.", this.name, handlerName);
|
||||
handler.handle(context, data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import org.dromara.neutrinoproxy.core.base.MetaDataConstant;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.jar.JarEntry;
|
||||
@@ -56,7 +57,7 @@ public class FileUtil {
|
||||
* @throws IOException
|
||||
*/
|
||||
public static String readContentAsString(String path) {
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(getInputStream(path)))){
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(getInputStream(path), StandardCharsets.UTF_8))){
|
||||
return br.lines().collect(Collectors.joining("\n"));
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
@@ -70,7 +71,7 @@ public class FileUtil {
|
||||
* @throws IOException
|
||||
*/
|
||||
public static String readContentAsString(InputStream in) {
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(in))){
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8))){
|
||||
return br.lines().collect(Collectors.joining("\n"));
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
@@ -84,7 +85,7 @@ public class FileUtil {
|
||||
* @throws IOException
|
||||
*/
|
||||
public static List<String> readContentAsStringList(String path) {
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(getInputStream(path)))){
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(getInputStream(path), StandardCharsets.UTF_8))){
|
||||
return br.lines().collect(Collectors.toList());
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
[
|
||||
{
|
||||
"name": "java.nio.channels.spi.SelectorProvider",
|
||||
"allDeclaredMethods": true
|
||||
},
|
||||
{
|
||||
"name": "sun.nio.ch.KQueueSelectorProvider",
|
||||
"allDeclaredMethods": true
|
||||
},
|
||||
{
|
||||
"name": "sun.nio.ch.PollSelectorProvider",
|
||||
"allDeclaredMethods": true
|
||||
},
|
||||
{
|
||||
"name": "sun.nio.ch.SelectorProviderImpl",
|
||||
"allDeclaredMethods": true
|
||||
}
|
||||
]
|
||||
@@ -1,15 +1,16 @@
|
||||
FROM openjdk:8-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
|
||||
RUN mkdir -p /root/neutrino-proxy/neutrino-proxy-admin
|
||||
WORKDIR /root/neutrino-proxy
|
||||
COPY ../neutrino-proxy-server/target/neutrino-proxy-server.jar /root/neutrino-proxy/neutrino-proxy-server.jar
|
||||
COPY ../neutrino-proxy-server/src/main/resources/app.yml /root/neutrino-proxy/config
|
||||
COPY ../neutrino-proxy-admin/dist /root/neutrino-proxy/neutrino-proxy-admin/dist
|
||||
COPY ./target/neutrino-proxy-server.jar /root/neutrino-proxy/neutrino-proxy-server.jar
|
||||
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"]
|
||||
|
||||
#docker run -it -p 9000-9200:9000-9200/tcp -p 8888:8888 -v /root/neutrino-proxy/config:/root/neutrino-proxy/config -d --restart=always --name neutrino registry.cn-hangzhou.aliyuncs.com/asgc/aoshiguchen-docker-images:1.7
|
||||
#docker run -it -p 9000-9200:9000-9200/tcp -p 8888:8888 -v /root/neutrino-proxy/config:/root/neutrino-proxy/config -d --restart=always --name neutrino registry.cn-hangzhou.aliyuncs.com/asgc/aoshiguchen-docker-images:1.7
|
||||
|
||||
@@ -24,28 +24,24 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.noear</groupId>
|
||||
<artifactId>mybatis-pagehelper-solon-plugin</artifactId>
|
||||
<artifactId>mybatis-plus-extension-solon-plugin</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.noear</groupId>
|
||||
<artifactId>activerecord-solon-plugin</artifactId>
|
||||
<artifactId>wood-solon-plugin</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dromara.solon-plugins</groupId>
|
||||
<artifactId>job-solon-plugin</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dromara.solon-plugins</groupId>
|
||||
<artifactId>orika-solon-plugin</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dromara.neutrino-proxy</groupId>
|
||||
<artifactId>neutrino-proxy-core</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.xerial</groupId>
|
||||
<artifactId>sqlite-jdbc</artifactId>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
@@ -65,12 +61,19 @@
|
||||
<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>
|
||||
|
||||
<excludes>
|
||||
<exclude>app-*.yml</exclude>
|
||||
<exclude>app-dev.yml</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
@@ -1,18 +1,11 @@
|
||||
package org.dromara.neutrinoproxy.server;
|
||||
|
||||
import ch.qos.logback.classic.Level;
|
||||
import ch.qos.logback.classic.Logger;
|
||||
import ch.qos.logback.classic.LoggerContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dromara.solonplugins.job.annotation.EnableJob;
|
||||
import org.noear.solon.Solon;
|
||||
import org.noear.solon.SolonApp;
|
||||
import org.noear.solon.Utils;
|
||||
import org.noear.solon.annotation.SolonMain;
|
||||
import org.noear.solon.web.cors.CrossFilter;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -28,25 +21,11 @@ public class ProxyServer {
|
||||
Solon.start(ProxyServer.class, args, app -> {
|
||||
// 跨域支持。加-1 优先级更高
|
||||
app.filter(-1, new CrossFilter().allowedOrigins("*"));
|
||||
// 设置日志级别
|
||||
setLogLevel(app);
|
||||
String loglevel = System.getenv("LOG_LEVEL");
|
||||
if (Utils.isNotEmpty(loglevel)) {
|
||||
app.cfg().put("solon.logging.logger.root.level", loglevel);
|
||||
}
|
||||
log.info("NeutrinoProxy Server :{}", app.cfg().get("solon.app.version"));
|
||||
});
|
||||
}
|
||||
|
||||
private static void setLogLevel(SolonApp app) {
|
||||
String loggerLevel = app.cfg().get("neutrino.proxy.logger.level");
|
||||
if (StringUtils.isBlank(loggerLevel)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Level level = Level.toLevel(loggerLevel);
|
||||
LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
|
||||
for (Logger logger : loggerContext.getLoggerList()) {
|
||||
logger.setLevel(level);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("日志级别设置失败", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
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.*;
|
||||
import org.dromara.neutrinoproxy.server.service.*;
|
||||
import org.dromara.solonplugins.job.JobBean;
|
||||
import org.noear.solon.annotation.Component;
|
||||
import org.noear.solon.aot.RuntimeNativeMetadata;
|
||||
import org.noear.solon.aot.RuntimeNativeRegistrar;
|
||||
import org.noear.solon.aot.hint.MemberCategory;
|
||||
import org.noear.solon.core.AppContext;
|
||||
|
||||
/**
|
||||
* native 打包
|
||||
*
|
||||
* @author songyinyin
|
||||
* @since 2023/10/20 11:24
|
||||
*/
|
||||
@Component
|
||||
public class NeutrinoServerRuntimeNativeRegistrar implements RuntimeNativeRegistrar {
|
||||
@Override
|
||||
public void register(AppContext context, RuntimeNativeMetadata metadata) {
|
||||
metadata.registerResourceInclude("test.jks");
|
||||
metadata.registerResourceInclude("sql/.*");
|
||||
|
||||
// 使用 MP lambda 的类,需要注册序列化
|
||||
metadata.registerLambdaSerialization(ClientConnectRecordService.class);
|
||||
metadata.registerLambdaSerialization(JobInfoService.class);
|
||||
metadata.registerLambdaSerialization(JobLogService.class);
|
||||
metadata.registerLambdaSerialization(LicenseService.class);
|
||||
metadata.registerLambdaSerialization(PortGroupService.class);
|
||||
metadata.registerLambdaSerialization(PortMappingService.class);
|
||||
metadata.registerLambdaSerialization(PortPoolService.class);
|
||||
metadata.registerLambdaSerialization(ReportService.class);
|
||||
metadata.registerLambdaSerialization(UserLoginRecordService.class);
|
||||
metadata.registerLambdaSerialization(UserService.class);
|
||||
metadata.registerLambdaSerialization(SecurityGroupService.class);
|
||||
|
||||
|
||||
metadata.registerLambdaSerialization(LicenseMapper.class);
|
||||
metadata.registerLambdaSerialization(ClientConnectRecordMapper.class);
|
||||
metadata.registerLambdaSerialization(FlowReportDayMapper.class);
|
||||
metadata.registerLambdaSerialization(FlowReportHourMapper.class);
|
||||
metadata.registerLambdaSerialization(FlowReportMinuteMapper.class);
|
||||
metadata.registerLambdaSerialization(FlowReportMonthMapper.class);
|
||||
metadata.registerLambdaSerialization(JobInfoMapper.class);
|
||||
metadata.registerLambdaSerialization(PortMappingMapper.class);
|
||||
metadata.registerLambdaSerialization(PortPoolMapper.class);
|
||||
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);
|
||||
metadata.registerReflection(HomeDataView.License.class, MemberCategory.DECLARED_FIELDS);
|
||||
metadata.registerReflection(HomeDataView.PortMapping.class, MemberCategory.DECLARED_FIELDS);
|
||||
metadata.registerReflection(HomeDataView.Series.class, MemberCategory.DECLARED_FIELDS);
|
||||
metadata.registerReflection(HomeDataView.SingleDayFlow.class, MemberCategory.DECLARED_FIELDS);
|
||||
metadata.registerReflection(HomeDataView.TodayFlow.class, MemberCategory.DECLARED_FIELDS);
|
||||
metadata.registerReflection(HomeDataView.TotalFlow.class, MemberCategory.DECLARED_FIELDS);
|
||||
|
||||
metadata.registerReflection(ResponseBody.class, MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.INVOKE_DECLARED_METHODS);
|
||||
metadata.registerSerialization(ResponseBody.class);
|
||||
|
||||
metadata.registerReflection(ProxyConfig.Protocol.class, MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.INVOKE_DECLARED_METHODS);
|
||||
metadata.registerReflection(ProxyConfig.Server.class, MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.INVOKE_DECLARED_METHODS);
|
||||
metadata.registerReflection(ProxyConfig.Tunnel.class, MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.INVOKE_DECLARED_METHODS);
|
||||
metadata.registerReflection(ProxyConfig.Tcp.class, MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.INVOKE_DECLARED_METHODS);
|
||||
metadata.registerReflection(ProxyConfig.Udp.class, MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.INVOKE_DECLARED_METHODS);
|
||||
|
||||
metadata.registerReflection(JobBean.class, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,16 +24,18 @@ package org.dromara.neutrinoproxy.server.base.db;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.jfinal.plugin.activerecord.Db;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.neutrinoproxy.core.util.Assert;
|
||||
import org.dromara.neutrinoproxy.core.util.FileUtil;
|
||||
import org.dromara.neutrinoproxy.server.constant.DbTypeEnum;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.noear.solon.annotation.Component;
|
||||
import org.noear.solon.annotation.Init;
|
||||
import org.noear.solon.annotation.Inject;
|
||||
import org.noear.solon.core.event.AppLoadEndEvent;
|
||||
import org.noear.solon.core.event.EventListener;
|
||||
import org.noear.solon.core.runtime.NativeDetector;
|
||||
import org.noear.wood.DbContext;
|
||||
import org.noear.wood.annotation.Db;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -51,13 +53,20 @@ public class DBInitialize implements EventListener<AppLoadEndEvent> {
|
||||
|
||||
private DbTypeEnum dbTypeEnum;
|
||||
|
||||
@Db
|
||||
DbContext dbContext;
|
||||
|
||||
@Init
|
||||
public void init() throws Throwable {
|
||||
// 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取值异常!");
|
||||
|
||||
log.info("{}数据库初始化...", dbConfig.getType());
|
||||
log.info("{} database init...", dbConfig.getType());
|
||||
initDBStructure();
|
||||
initDBData();
|
||||
}
|
||||
@@ -82,8 +91,8 @@ public class DBInitialize implements EventListener<AppLoadEndEvent> {
|
||||
}
|
||||
sql += "\r\n" + line.trim();
|
||||
if (sql.endsWith(";")) {
|
||||
log.debug("初始化数据库表 sql:{}", sql);
|
||||
Db.update(sql);
|
||||
log.debug("init database table sql:{}", sql);
|
||||
dbContext.exe(sql);
|
||||
sql = "";
|
||||
}
|
||||
}
|
||||
@@ -101,8 +110,8 @@ public class DBInitialize implements EventListener<AppLoadEndEvent> {
|
||||
for (String tableName : initDataTableNameList) {
|
||||
// 表里没有数据的时候,才进行初始化操作
|
||||
|
||||
int count = Db.queryInt(String.format("select count(1) from `%s`", tableName));
|
||||
if (count > 0) {
|
||||
Object result = dbContext.exe(String.format("select count(1) from `%s`", tableName));
|
||||
if (result != null && ((Number) result).intValue() > 0) {
|
||||
continue;
|
||||
}
|
||||
List<String> lines = FileUtil.readContentAsStringList(String.format("classpath:/sql/%s/%s.data.sql", dbConfig.getType(), tableName));
|
||||
@@ -116,8 +125,8 @@ public class DBInitialize implements EventListener<AppLoadEndEvent> {
|
||||
}
|
||||
sql += "\r\n" + line.trim();
|
||||
if (sql.endsWith(";")) {
|
||||
log.debug("初始化数据[table={}] sql:{}", tableName, sql);
|
||||
Db.update(sql);
|
||||
log.debug("init database data[table={}] sql:{}", tableName, sql);
|
||||
dbContext.exe(sql);
|
||||
sql = "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,14 +4,14 @@ import com.baomidou.mybatisplus.core.MybatisConfiguration;
|
||||
import com.baomidou.mybatisplus.core.MybatisSqlSessionFactoryBuilder;
|
||||
import com.baomidou.mybatisplus.core.config.GlobalConfig;
|
||||
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||
import com.baomidou.mybatisplus.solon.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.solon.plugins.inner.PaginationInnerInterceptor;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import org.apache.ibatis.solon.annotation.Db;
|
||||
import org.dromara.neutrinoproxy.server.constant.DbTypeEnum;
|
||||
import org.noear.solon.annotation.Bean;
|
||||
import org.noear.solon.annotation.Configuration;
|
||||
import org.noear.solon.annotation.Inject;
|
||||
import org.sqlite.SQLiteConfig;
|
||||
import org.sqlite.SQLiteDataSource;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
@@ -25,11 +25,8 @@ public class DbConfiguration {
|
||||
@Bean(value = "db", typed = true)
|
||||
public DataSource dataSource(@Inject DbConfig dbConfig) {
|
||||
DbTypeEnum dbTypeEnum = DbTypeEnum.of(dbConfig.getType());
|
||||
if (DbTypeEnum.SQLITE == dbTypeEnum) {
|
||||
SQLiteDataSource dataSource = new SQLiteDataSource();
|
||||
dataSource.setUrl(dbConfig.getUrl());
|
||||
dataSource.setJournalMode(SQLiteConfig.JournalMode.WAL.getValue());
|
||||
return dataSource;
|
||||
if (DbTypeEnum.H2 == dbTypeEnum) {
|
||||
return newHikariDataSource(dbConfig, "org.h2.Driver");
|
||||
} else if (DbTypeEnum.MYSQL == dbTypeEnum) {
|
||||
String driver = "com.mysql.cj.jdbc.Driver";
|
||||
try {
|
||||
@@ -66,8 +63,12 @@ public class DbConfiguration {
|
||||
|
||||
@Bean
|
||||
public void db1_ext2(@Db("db") MybatisConfiguration config) {
|
||||
config.getTypeHandlerRegistry().register("fun.asgc.neutrino.proxy.server.dal");
|
||||
config.getTypeHandlerRegistry().register("org.dromara.neutrinoproxy.server.dal.entity");
|
||||
config.setDefaultEnumTypeHandler(null);
|
||||
|
||||
MybatisPlusInterceptor plusInterceptor = new MybatisPlusInterceptor();
|
||||
plusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor());
|
||||
config.addInterceptor(plusInterceptor);
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.dromara.neutrinoproxy.server.base.page;
|
||||
|
||||
import com.baomidou.mybatisplus.solon.plugins.pagination.Page;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
@@ -101,11 +102,20 @@ public class PageInfo<T> implements Serializable {
|
||||
}
|
||||
|
||||
public static <T> PageInfo<T> of(List<T> records, Long total, Integer current, Integer size) {
|
||||
PageInfo<T> pageInfo = new PageInfo();
|
||||
PageInfo<T> pageInfo = new PageInfo<>();
|
||||
pageInfo.setRecords(records);
|
||||
pageInfo.setTotal(total);
|
||||
pageInfo.setCurrent(current);
|
||||
pageInfo.setSize(size);
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
public static <T> PageInfo<T> of(List<T> records, Page<?> page) {
|
||||
PageInfo<T> pageInfo = new PageInfo<>();
|
||||
pageInfo.setRecords(records);
|
||||
pageInfo.setTotal(page.getTotal());
|
||||
pageInfo.setCurrent((int) page.getCurrent());
|
||||
pageInfo.setSize((int) page.getSize());
|
||||
return pageInfo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,14 +42,8 @@ public class ProxyConfig {
|
||||
|
||||
@Data
|
||||
public static class Server {
|
||||
private Integer bossThreadCount;
|
||||
private Integer workThreadCount;
|
||||
private String domainName;
|
||||
private Integer httpProxyPort;
|
||||
private Integer httpsProxyPort;
|
||||
private String keyStorePassword;
|
||||
private String jksPath;
|
||||
private Boolean transferLogEnable;
|
||||
private Tcp tcp;
|
||||
private Udp udp;
|
||||
}
|
||||
|
||||
@Data
|
||||
@@ -62,6 +56,25 @@ public class ProxyConfig {
|
||||
private String keyManagerPassword;
|
||||
private String jksPath;
|
||||
private Boolean transferLogEnable;
|
||||
private Boolean heartbeatLogEnable;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Tcp {
|
||||
private Integer bossThreadCount;
|
||||
private Integer workThreadCount;
|
||||
private String domainName;
|
||||
private Integer httpProxyPort;
|
||||
private Integer httpsProxyPort;
|
||||
private String keyStorePassword;
|
||||
private String jksPath;
|
||||
private Boolean transferLogEnable;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Udp {
|
||||
private Integer bossThreadCount;
|
||||
private Integer workThreadCount;
|
||||
private Boolean transferLogEnable;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,28 @@
|
||||
package org.dromara.neutrinoproxy.server.base.proxy;
|
||||
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
import io.netty.channel.socket.SocketChannel;
|
||||
import io.netty.channel.socket.nio.NioDatagramChannel;
|
||||
import io.netty.channel.socket.nio.NioServerSocketChannel;
|
||||
import io.netty.handler.logging.LoggingHandler;
|
||||
import org.dromara.neutrinoproxy.core.ProxyDataTypeEnum;
|
||||
import org.dromara.neutrinoproxy.core.ProxyMessage;
|
||||
import org.dromara.neutrinoproxy.core.ProxyMessageHandler;
|
||||
import org.dromara.neutrinoproxy.core.aot.NeutrinoCoreRuntimeNativeRegistrar;
|
||||
import org.dromara.neutrinoproxy.core.dispatcher.DefaultDispatcher;
|
||||
import org.dromara.neutrinoproxy.core.dispatcher.Dispatcher;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.nio.NioEventLoopGroup;
|
||||
import org.dromara.neutrinoproxy.server.proxy.core.BytesMetricsHandler;
|
||||
import org.dromara.neutrinoproxy.server.proxy.core.ProxyTunnelServer;
|
||||
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;
|
||||
@@ -34,44 +42,88 @@ public class ProxyConfiguration implements LifecycleBean {
|
||||
@Override
|
||||
public void start() throws Throwable {
|
||||
List<ProxyMessageHandler> list = Solon.context().getBeansOfType(ProxyMessageHandler.class);
|
||||
Dispatcher<ChannelHandlerContext, ProxyMessage> dispatcher = new DefaultDispatcher<>("消息调度器", list,
|
||||
proxyMessage -> ProxyDataTypeEnum.of((int)proxyMessage.getType()) == null ?
|
||||
null : ProxyDataTypeEnum.of((int)proxyMessage.getType()).getName());
|
||||
Dispatcher<ChannelHandlerContext, ProxyMessage> dispatcher = new DefaultDispatcher<>("MessageDispatcher", list,
|
||||
proxyMessage -> ProxyDataTypeEnum.of((int)proxyMessage.getType()) == null ?
|
||||
null : ProxyDataTypeEnum.of((int)proxyMessage.getType()).getName());
|
||||
|
||||
Solon.context().wrapAndPut(Dispatcher.class, dispatcher);
|
||||
}
|
||||
|
||||
@Bean("serverBossGroup")
|
||||
public NioEventLoopGroup serverBossGroup(@Inject ProxyConfig proxyConfig) {
|
||||
return new NioEventLoopGroup(proxyConfig.getServer().getBossThreadCount());
|
||||
@Bean("tcpServerBossGroup")
|
||||
public NioEventLoopGroup tcpServerBossGroup(@Inject ProxyConfig proxyConfig) {
|
||||
ProxyConfig.Server server = proxyConfig.getServer();
|
||||
ProxyConfig.Tcp tcp = server.getTcp();
|
||||
return new NioEventLoopGroup(tcp.getBossThreadCount());
|
||||
}
|
||||
|
||||
@Bean("serverWorkerGroup")
|
||||
public NioEventLoopGroup serverWorkerGroup(@Inject ProxyConfig proxyConfig) {
|
||||
return new NioEventLoopGroup(proxyConfig.getServer().getWorkThreadCount());
|
||||
@Bean("tcpServerWorkerGroup")
|
||||
public NioEventLoopGroup tcpServerWorkerGroup(@Inject ProxyConfig proxyConfig) {
|
||||
return new NioEventLoopGroup(proxyConfig.getServer().getTcp().getWorkThreadCount());
|
||||
}
|
||||
|
||||
@Bean("tcpServerBootstrap")
|
||||
public ServerBootstrap tcpServerBootstrap(@Inject("serverBossGroup") NioEventLoopGroup serverBossGroup,
|
||||
@Inject("serverWorkerGroup") NioEventLoopGroup serverWorkerGroup,
|
||||
public ServerBootstrap tcpServerBootstrap(@Inject("tcpServerBossGroup") NioEventLoopGroup tcpServerBossGroup,
|
||||
@Inject("tcpServerWorkerGroup") NioEventLoopGroup tcpServerWorkerGroup,
|
||||
@Inject ProxyConfig proxyConfig
|
||||
) {
|
||||
ServerBootstrap bootstrap = new ServerBootstrap();
|
||||
bootstrap.group(serverBossGroup, serverWorkerGroup)
|
||||
.channel(NioServerSocketChannel.class)
|
||||
.childHandler(new ChannelInitializer<SocketChannel>() {
|
||||
@Override
|
||||
public void initChannel(SocketChannel ch) throws Exception {
|
||||
if (null != proxyConfig.getServer().getTransferLogEnable() && proxyConfig.getServer().getTransferLogEnable()) {
|
||||
ch.pipeline().addFirst(new LoggingHandler(ProxyTunnelServer.class));
|
||||
}
|
||||
ch.pipeline().addFirst(new BytesMetricsHandler());
|
||||
ch.pipeline().addLast(new TcpVisitorChannelHandler());
|
||||
bootstrap.group(tcpServerBossGroup, tcpServerWorkerGroup)
|
||||
.channel(NioServerSocketChannel.class)
|
||||
.childHandler(new ChannelInitializer<SocketChannel>() {
|
||||
@Override
|
||||
public void initChannel(SocketChannel ch) throws Exception {
|
||||
if (null != proxyConfig.getServer().getTcp().getTransferLogEnable() && proxyConfig.getServer().getTcp().getTransferLogEnable()) {
|
||||
ch.pipeline().addFirst(new LoggingHandler(TcpVisitorChannelHandler.class));
|
||||
}
|
||||
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());
|
||||
}
|
||||
});
|
||||
return bootstrap;
|
||||
}
|
||||
|
||||
@Bean("udpServerBossGroup")
|
||||
public NioEventLoopGroup udpServerBossGroup(@Inject ProxyConfig proxyConfig) {
|
||||
return new NioEventLoopGroup(proxyConfig.getServer().getUdp().getBossThreadCount());
|
||||
}
|
||||
|
||||
@Bean("udpServerWorkerGroup")
|
||||
public NioEventLoopGroup udpServerWorkerGroup(@Inject ProxyConfig proxyConfig) {
|
||||
return new NioEventLoopGroup(proxyConfig.getServer().getUdp().getWorkThreadCount());
|
||||
}
|
||||
|
||||
@Bean("udpServerBootstrap")
|
||||
public Bootstrap udpServerBootstrap(@Inject("udpServerBossGroup") NioEventLoopGroup udpServerBossGroup,
|
||||
@Inject("udpServerWorkerGroup") NioEventLoopGroup udpServerWorkerGroup,
|
||||
@Inject ProxyConfig proxyConfig) {
|
||||
Bootstrap bootstrap = new Bootstrap();
|
||||
bootstrap.group(udpServerBossGroup)
|
||||
// 主线程处理
|
||||
.channel(NioDatagramChannel.class)
|
||||
// 广播
|
||||
.option(ChannelOption.SO_BROADCAST, true)
|
||||
// 设置读缓冲区为2M
|
||||
.option(ChannelOption.SO_RCVBUF, 2048 * 1024)
|
||||
// 设置写缓冲区为1M
|
||||
.option(ChannelOption.SO_SNDBUF, 1024 * 1024)
|
||||
.handler(new ChannelInitializer<NioDatagramChannel>() {
|
||||
@Override
|
||||
protected void initChannel(NioDatagramChannel ch) {
|
||||
ChannelPipeline pipeline = ch.pipeline();
|
||||
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());
|
||||
}
|
||||
});
|
||||
return bootstrap;
|
||||
}
|
||||
|
||||
@Bean("tunnelBossGroup")
|
||||
public NioEventLoopGroup tunnelBossGroup(@Inject ProxyConfig proxyConfig) {
|
||||
return new NioEventLoopGroup(proxyConfig.getTunnel().getBossThreadCount());
|
||||
@@ -82,4 +134,9 @@ public class ProxyConfiguration implements LifecycleBean {
|
||||
return new NioEventLoopGroup(proxyConfig.getTunnel().getWorkThreadCount());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public NeutrinoCoreRuntimeNativeRegistrar neutrinoCoreRuntimeNativeRegistrar() {
|
||||
return new NeutrinoCoreRuntimeNativeRegistrar();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ public class ServiceException extends RuntimeException {
|
||||
private String msg;
|
||||
|
||||
public ServiceException(int code, String msg) {
|
||||
super(msg);
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ public class BaseAuthInterceptor implements RouterInterceptor {
|
||||
}
|
||||
|
||||
if (result instanceof Throwable) {
|
||||
log.error("全局异常", (Throwable) result);
|
||||
log.error("global error", (Throwable) result);
|
||||
|
||||
if (result instanceof ServiceException) {
|
||||
ServiceException exception = (ServiceException) result;
|
||||
|
||||
@@ -23,7 +23,7 @@ public class GlobalExceptionFilter implements Filter {
|
||||
try {
|
||||
chain.doFilter(ctx);
|
||||
} catch (Throwable e) {
|
||||
log.error("全局异常", e);
|
||||
log.error("global error", e);
|
||||
|
||||
if (e instanceof ServiceException) {
|
||||
ServiceException serviceException = (ServiceException) e;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.dromara.neutrinoproxy.server.base.rest.interceptor;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.noear.snack.ONode;
|
||||
import org.noear.solon.annotation.Component;
|
||||
import org.noear.solon.core.handle.Action;
|
||||
import org.noear.solon.core.handle.Context;
|
||||
@@ -31,10 +31,10 @@ public class VisitLogInterceptor implements RouterInterceptor {
|
||||
} finally {
|
||||
Date now = new Date();
|
||||
long elapsedTime = now.getTime() - startTime.getTime();
|
||||
log.debug("\n-----------------------------------------------------------------接口请求日志:\n{} url:{} 执行耗时:{}\n请求体参数:{}\n响应结果:{}\n客户端IP:{}\n",
|
||||
log.debug("\n-----------------------------------------------------------------interface request log:\n{} url:{} elapsed time:{}\nrequest:{}\nresponse:{}\nclient ip:{}\n",
|
||||
ctx.method(), ctx.path(), getElapsedTimeStr(elapsedTime),
|
||||
JSONObject.toJSONString(ctx.paramMap()),
|
||||
JSONObject.toJSONString(JSONObject.toJSONString(ctx.result)),
|
||||
ONode.serialize(ctx.paramMap()),
|
||||
ONode.serialize(ctx.result),
|
||||
ctx.realIp()
|
||||
);
|
||||
}
|
||||
@@ -47,11 +47,11 @@ public class VisitLogInterceptor implements RouterInterceptor {
|
||||
*/
|
||||
private static String getElapsedTimeStr(long elapsedTime) {
|
||||
if (elapsedTime < 1000) {
|
||||
return String.format("%s毫秒", elapsedTime);
|
||||
return String.format("%sms", elapsedTime);
|
||||
} else if (elapsedTime < 60000) {
|
||||
return String.format("%.2f秒", (elapsedTime * 1.0) / 1000);
|
||||
return String.format("%.2fs", (elapsedTime * 1.0) / 1000);
|
||||
}
|
||||
return String.format("%.2f分钟", (elapsedTime * 1.0) / 1000 / 60);
|
||||
return String.format("%.2fm", (elapsedTime * 1.0) / 1000 / 60);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ import java.util.stream.Stream;
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum DbTypeEnum {
|
||||
SQLITE("sqlite"),
|
||||
H2("h2"),
|
||||
MYSQL("mysql"),
|
||||
MARIADB("mariadb"),
|
||||
;
|
||||
|
||||
@@ -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)
|
||||
@@ -50,6 +50,7 @@ public enum ExceptionConstant {
|
||||
ORIGIN_PASSWORD_CHECK_FAIL(12002, "原密码验证失败"),
|
||||
LOGIN_PASSWORD_LENGTH_CHECK_FAIL(12003, "登录密码不能小于6位数"),
|
||||
LOGIN_PASSWORD_NO_CHANGE_MODIFY_FAIL(12004, "密码没有变化,修改失败"),
|
||||
LICENSE_CANNOT_BE_DELETED(12005, "license下存在[{}]个端口映射!"),
|
||||
// 端口池管理(13000)
|
||||
PORT_CANNOT_REPEAT(13000,"端口不能重复"),
|
||||
PORT_NOT_EXIST(13001, "该端口在端口池中不存在"),
|
||||
@@ -66,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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -21,7 +21,7 @@ public class DomainNameController {
|
||||
@Get
|
||||
@Mapping("/bind-info")
|
||||
public String bindInfo () {
|
||||
return proxyConfig.getServer().getDomainName();
|
||||
return proxyConfig.getServer().getTcp().getDomainName();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -40,7 +42,9 @@ public class PortMappingController {
|
||||
ParamCheckUtil.checkNotNull(req.getServerPort(), "serverPort");
|
||||
ParamCheckUtil.checkNotNull(req.getClientPort(), "clientPort");
|
||||
ParamCheckUtil.checkNotEmpty(req.getProtocal(), "protocal");
|
||||
ParamCheckUtil.checkMaxLength(req.getDescription(), 50, "描述", "50");
|
||||
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");
|
||||
@@ -52,19 +56,30 @@ public class PortMappingController {
|
||||
req.setSubdomain(null);
|
||||
}
|
||||
req.setProtocal(networkProtocolEnum.getDesc());
|
||||
if (null == req.getProxyResponses()) {
|
||||
req.setProxyResponses(0);
|
||||
}
|
||||
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");
|
||||
@@ -76,8 +91,17 @@ public class PortMappingController {
|
||||
req.setSubdomain(null);
|
||||
}
|
||||
req.setProtocal(networkProtocolEnum.getDesc());
|
||||
if (null == req.getProxyResponses()) {
|
||||
req.setProxyResponses(0);
|
||||
}
|
||||
if (null == req.getProxyTimeoutMs()) {
|
||||
req.setProxyTimeoutMs(0L);
|
||||
}
|
||||
if (null == req.getSecurityGroupId()) {
|
||||
req.setSecurityGroupId(0);
|
||||
}
|
||||
|
||||
return portMappingService.update(req);
|
||||
portMappingService.update(req);
|
||||
}
|
||||
|
||||
@Get
|
||||
@@ -107,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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ public class PortPoolController {
|
||||
|
||||
@Get
|
||||
@Mapping("/get-available-port-list")
|
||||
public List<PortPoolListRes> getAvailablePortList(AvailablePortListReq req) {
|
||||
public PageInfo<PortPoolListRes> getAvailablePortList(AvailablePortListReq req) {
|
||||
ParamCheckUtil.checkNotNull(req, "req");
|
||||
ParamCheckUtil.checkNotNull(req.getLicenseId(), "licenseId");
|
||||
return portPoolService.getAvailablePortList(req);
|
||||
@@ -123,4 +123,22 @@ public class PortPoolController {
|
||||
ParamCheckUtil.checkNotEmpty(req.getPortIdList(), "portIdList");
|
||||
return portPoolService.updateGroup(req);
|
||||
}
|
||||
|
||||
@Post
|
||||
@Mapping("/delete-batch")
|
||||
@Authorization(onlyAdmin = true)
|
||||
public void deleteBatch(PortPoolDeleteBatchReq req) {
|
||||
ParamCheckUtil.checkNotNull(req, "req");
|
||||
ParamCheckUtil.checkNotNull(req.getIds(), "ids");
|
||||
|
||||
portPoolService.deleteBatch(req.getIds());
|
||||
}
|
||||
|
||||
@Get
|
||||
@Mapping("/port-available")
|
||||
public boolean portAvailable(Integer port, Integer portMappingId) {
|
||||
ParamCheckUtil.checkNotNull(port, "port");
|
||||
|
||||
return portPoolService.portAvailable(port, portMappingId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -38,4 +38,12 @@ public class LicenseCreateReq {
|
||||
* 用户ID
|
||||
*/
|
||||
private Integer userId;
|
||||
/**
|
||||
* 上传限速
|
||||
*/
|
||||
private String upLimitRate;
|
||||
/**
|
||||
* 下载限速
|
||||
*/
|
||||
private String downLimitRate;
|
||||
}
|
||||
|
||||
@@ -30,8 +30,16 @@ import lombok.Data;
|
||||
*/
|
||||
@Data
|
||||
public class LicenseListReq {
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private Integer userId;
|
||||
/**
|
||||
* 是否在线
|
||||
*/
|
||||
private Integer isOnline;
|
||||
/**
|
||||
* 启动状态 1启用 2禁用
|
||||
*/
|
||||
private Integer enable;
|
||||
}
|
||||
|
||||
@@ -38,4 +38,12 @@ public class LicenseUpdateReq {
|
||||
* license名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 上传限速
|
||||
*/
|
||||
private String upLimitRate;
|
||||
/**
|
||||
* 下载限速
|
||||
*/
|
||||
private String downLimitRate;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -54,6 +54,28 @@ public class PortMappingCreateReq {
|
||||
* 客户端端口
|
||||
*/
|
||||
private Integer clientPort;
|
||||
/**
|
||||
* 上传限速
|
||||
*/
|
||||
private String upLimitRate;
|
||||
/**
|
||||
* 下载限速
|
||||
*/
|
||||
private String downLimitRate;
|
||||
/**
|
||||
* 代理响应数量(响应数据包数量,如果没有拆包则等于数据条数)
|
||||
*/
|
||||
private Integer proxyResponses;
|
||||
/**
|
||||
* 代理超时时间
|
||||
*/
|
||||
private Long proxyTimeoutMs;
|
||||
|
||||
/**
|
||||
* 安全组Id
|
||||
*/
|
||||
private Integer securityGroupId;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
|
||||
@@ -58,6 +58,28 @@ public class PortMappingUpdateReq {
|
||||
* 客户端端口
|
||||
*/
|
||||
private Integer clientPort;
|
||||
/**
|
||||
* 上传限速
|
||||
*/
|
||||
private String upLimitRate;
|
||||
/**
|
||||
* 下载限速
|
||||
*/
|
||||
private String downLimitRate;
|
||||
/**
|
||||
* 代理响应数量(响应数据包数量,如果没有拆包则等于数据条数)
|
||||
*/
|
||||
private Integer proxyResponses;
|
||||
/**
|
||||
* 代理超时时间
|
||||
*/
|
||||
private Long proxyTimeoutMs;
|
||||
|
||||
/**
|
||||
* 安全组Id
|
||||
*/
|
||||
private Integer securityGroupId;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
|
||||
@@ -12,4 +12,18 @@ public class AvailablePortListReq {
|
||||
* licenseId
|
||||
*/
|
||||
private Integer licenseId;
|
||||
|
||||
/**
|
||||
* 当前页
|
||||
*/
|
||||
private int page = 1;
|
||||
/**
|
||||
* 分页大小
|
||||
*/
|
||||
private int size = 10;
|
||||
|
||||
/**
|
||||
* 搜索关键字
|
||||
*/
|
||||
private String keyword;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package org.dromara.neutrinoproxy.server.controller.req.system;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author: Metal
|
||||
* @date: 2023/7/3
|
||||
*/
|
||||
@Data
|
||||
public class PortPoolDeleteBatchReq {
|
||||
private List<Integer> ids;
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -32,6 +32,14 @@ public class LicenseListRes {
|
||||
* 用户名
|
||||
*/
|
||||
private String userName;
|
||||
/**
|
||||
* 上传限速
|
||||
*/
|
||||
private String upLimitRate;
|
||||
/**
|
||||
* 下载限速
|
||||
*/
|
||||
private String downLimitRate;
|
||||
/**
|
||||
* 是否在线
|
||||
* {@link OnlineStatusEnum}
|
||||
|
||||
@@ -49,6 +49,14 @@ public class PortMappingDetailRes {
|
||||
* {@link OnlineStatusEnum}
|
||||
*/
|
||||
private Integer isOnline;
|
||||
/**
|
||||
* 代理响应数量(响应数据包数量,如果没有拆包则等于数据条数)
|
||||
*/
|
||||
private Integer proxyResponses;
|
||||
/**
|
||||
* 代理超时时间
|
||||
*/
|
||||
private Long proxyTimeoutMs;
|
||||
/**
|
||||
* 启用状态
|
||||
* {@link EnableStatusEnum}
|
||||
|
||||
@@ -75,6 +75,14 @@ public class PortMappingListRes {
|
||||
* 客户端端口
|
||||
*/
|
||||
private Integer clientPort;
|
||||
/**
|
||||
* 上传限速
|
||||
*/
|
||||
private String upLimitRate;
|
||||
/**
|
||||
* 下载限速
|
||||
*/
|
||||
private String downLimitRate;
|
||||
/**
|
||||
* 客户端端口
|
||||
*/
|
||||
@@ -89,10 +97,24 @@ public class PortMappingListRes {
|
||||
* {@link EnableStatusEnum}
|
||||
*/
|
||||
private Integer enable;
|
||||
/**
|
||||
* 代理响应数量(响应数据包数量,如果没有拆包则等于数据条数)
|
||||
*/
|
||||
private Integer proxyResponses;
|
||||
/**
|
||||
* 代理超时时间
|
||||
*/
|
||||
private Long proxyTimeoutMs;
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 安全组Id
|
||||
*/
|
||||
private Integer securityGroupId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package org.dromara.neutrinoproxy.server.controller.res.system;
|
||||
|
||||
/**
|
||||
* @author: aoshiguchen
|
||||
* @date: 2023/12/10
|
||||
*/
|
||||
public class SecurityRuleUpdateEnableStatueRes {
|
||||
}
|
||||
@@ -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)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.dromara.neutrinoproxy.server.dal;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import org.dromara.neutrinoproxy.server.controller.req.system.PortGroupListReq;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.system.PortGroupListRes;
|
||||
@@ -14,7 +15,7 @@ import java.util.List;
|
||||
@Mapper
|
||||
public interface PortGroupMapper extends BaseMapper<PortGroupDO> {
|
||||
|
||||
List<PortGroupListRes> selectPortGroupListResList(PortGroupListReq res);
|
||||
List<PortGroupListRes> selectPortGroupListResList(IPage<PortGroupListRes> page, PortGroupListReq res);
|
||||
|
||||
|
||||
default void updateEnableStatus(Integer id, Integer enable, Date now){
|
||||
|
||||
@@ -4,6 +4,7 @@ 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.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import org.dromara.neutrinoproxy.server.constant.EnableStatusEnum;
|
||||
import org.dromara.neutrinoproxy.server.controller.req.proxy.PortMappingListReq;
|
||||
@@ -74,6 +75,14 @@ public interface PortMappingMapper extends BaseMapper<PortMappingDO> {
|
||||
);
|
||||
}
|
||||
|
||||
default PortMappingDO findByLicenseIdAndServerPort(Integer licenseId, Integer serverPort) {
|
||||
return this.selectOne(new LambdaQueryWrapper<PortMappingDO>()
|
||||
.eq(PortMappingDO::getLicenseId, licenseId)
|
||||
.eq(PortMappingDO::getServerPort, serverPort)
|
||||
.last("limit 1")
|
||||
);
|
||||
}
|
||||
|
||||
default void updateOnlineStatus(Integer licenseId,Integer serverPort, Integer isOnline, Date updateTime) {
|
||||
this.update(null, new LambdaUpdateWrapper<PortMappingDO>()
|
||||
.eq(PortMappingDO::getLicenseId, licenseId)
|
||||
@@ -98,5 +107,5 @@ public interface PortMappingMapper extends BaseMapper<PortMappingDO> {
|
||||
);
|
||||
}
|
||||
|
||||
List<PortMappingDO> selectPortMappingByCondition(@Param("req") PortMappingListReq req);
|
||||
List<PortMappingDO> selectPortMappingByCondition(IPage<PortMappingDO> page, @Param("req") PortMappingListReq req);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ package org.dromara.neutrinoproxy.server.dal;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.dromara.neutrinoproxy.server.controller.req.system.PortPoolListReq;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.system.PortPoolListRes;
|
||||
import org.dromara.neutrinoproxy.server.dal.entity.PortPoolDO;
|
||||
@@ -65,7 +66,7 @@ public interface PortPoolMapper extends BaseMapper<PortPoolDO> {
|
||||
);
|
||||
}
|
||||
|
||||
List<PortPoolListRes> selectResList(@Param("req") PortPoolListReq req);
|
||||
List<PortPoolListRes> selectResList(IPage<PortPoolListRes> page, @Param("req") PortPoolListReq req);
|
||||
|
||||
List<PortPoolListRes> getAvailablePortList(@Param("licenseId") Integer licenseId,@Param("userId") Integer userId);
|
||||
List<PortPoolListRes> getAvailablePortList(IPage<PortPoolListRes> page, @Param("licenseId") Integer licenseId,@Param("userId") Integer userId, @Param("keyword") String keyword);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.dromara.neutrinoproxy.server.dal;
|
||||
|
||||
import com.baomidou.mybatisplus.solon.plugins.pagination.Page;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.report.*;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.report.LicenseFlowMonthReportRes;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.report.LicenseFlowReportRes;
|
||||
@@ -24,26 +25,26 @@ public interface ReportMapper {
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
List<UserFlowReportRes> userFlowReportList(@Param("userId") Integer userId, @Param("curMonthBeginDate") Date curMonthBeginDate, @Param("curDayBeginDate") Date curDayBeginDate, @Param("curDate") Date curDate);
|
||||
List<UserFlowReportRes> userFlowReportList(Page<UserFlowReportRes> page, @Param("userId") Integer userId, @Param("curMonthBeginDate") Date curMonthBeginDate, @Param("curDayBeginDate") Date curDayBeginDate, @Param("curDate") Date curDate);
|
||||
/**
|
||||
* 基于License维度的流量报表
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
List<LicenseFlowReportRes> licenseFLowReportList(@Param("userId") Integer userId, @Param("curMonthBeginDate") Date curMonthBeginDate, @Param("curDayBeginDate") Date curDayBeginDate, @Param("curDate") Date curDate);
|
||||
List<LicenseFlowReportRes> licenseFLowReportList(Page<LicenseFlowReportRes> page, @Param("userId") Integer userId, @Param("curMonthBeginDate") Date curMonthBeginDate, @Param("curDayBeginDate") Date curDayBeginDate, @Param("curDate") Date curDate);
|
||||
|
||||
/**
|
||||
* 用户流量月度明细
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
List<UserFlowMonthReportRes> userFlowMonthReportList(@Param("userId") Integer userId, @Param("curMonthBeginDate") Date curMonthBeginDate, @Param("curDayBeginDate") Date curDayBeginDate, @Param("curDate") Date curDate);
|
||||
List<UserFlowMonthReportRes> userFlowMonthReportList(Page<UserFlowMonthReportRes> page, @Param("userId") Integer userId, @Param("curMonthBeginDate") Date curMonthBeginDate, @Param("curDayBeginDate") Date curDayBeginDate, @Param("curDate") Date curDate);
|
||||
/**
|
||||
* License流量月度明细
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
List<LicenseFlowMonthReportRes> licenseFLowMonthReportList(@Param("userId") Integer userId, @Param("licenseId") Integer licenseId, @Param("curMonthBeginDate") Date curMonthBeginDate, @Param("curDayBeginDate") Date curDayBeginDate, @Param("curDate") Date curDate);
|
||||
List<LicenseFlowMonthReportRes> licenseFLowMonthReportList(Page<LicenseFlowMonthReportRes> page, @Param("userId") Integer userId, @Param("licenseId") Integer licenseId, @Param("curMonthBeginDate") Date curMonthBeginDate, @Param("curDayBeginDate") Date curDayBeginDate, @Param("curDate") Date curDate);
|
||||
|
||||
/**
|
||||
* 首页 - 今日流量
|
||||
|
||||
@@ -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)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.log.ClientConnectRecordListRes;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@@ -34,4 +35,17 @@ public class ClientConnectRecordDO {
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
public ClientConnectRecordListRes toRes() {
|
||||
ClientConnectRecordListRes res = new ClientConnectRecordListRes();
|
||||
res.setId(id);
|
||||
res.setIp(ip);
|
||||
res.setLicenseId(licenseId);
|
||||
res.setType(type);
|
||||
res.setMsg(msg);
|
||||
res.setCode(code);
|
||||
res.setErr(err);
|
||||
res.setCreateTime(createTime);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import lombok.Data;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.dromara.neutrinoproxy.server.constant.EnableStatusEnum;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.system.JobInfoListRes;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@@ -64,4 +65,19 @@ public class JobInfoDO {
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
public JobInfoListRes toRes() {
|
||||
JobInfoListRes res = new JobInfoListRes();
|
||||
res.setId(id);
|
||||
res.setCron(cron);
|
||||
res.setDesc(desc);
|
||||
res.setAlarmEmail(alarmEmail);
|
||||
res.setAlarmDing(alarmDing);
|
||||
res.setHandler(handler);
|
||||
res.setParam(param);
|
||||
res.setEnable(enable);
|
||||
res.setCreateTime(createTime);
|
||||
res.setUpdateTime(updateTime);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.log.JobLogListRes;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@@ -52,4 +53,17 @@ public class JobLogDO {
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
public JobLogListRes toRes() {
|
||||
JobLogListRes res = new JobLogListRes();
|
||||
res.setId(id);
|
||||
res.setJobId(jobId);
|
||||
res.setHandler(handler);
|
||||
res.setParam(param);
|
||||
res.setCode(code);
|
||||
res.setMsg(msg);
|
||||
res.setAlarmStatus(alarmStatus);
|
||||
res.setCreateTime(createTime);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -30,6 +31,7 @@ import org.dromara.neutrinoproxy.server.constant.OnlineStatusEnum;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.proxy.LicenseListRes;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@@ -58,6 +60,14 @@ public class LicenseDO {
|
||||
* 用户ID
|
||||
*/
|
||||
private Integer userId;
|
||||
/**
|
||||
* 上传限速
|
||||
*/
|
||||
private String upLimitRate;
|
||||
/**
|
||||
* 下载限速
|
||||
*/
|
||||
private String downLimitRate;
|
||||
/**
|
||||
* 是否在线
|
||||
* {@link OnlineStatusEnum}
|
||||
@@ -76,4 +86,10 @@ public class LicenseDO {
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
public LicenseListRes toRes() {
|
||||
LicenseListRes res = new LicenseListRes();
|
||||
BeanUtil.copyProperties(this, res);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -29,6 +30,7 @@ import org.dromara.neutrinoproxy.server.constant.OnlineStatusEnum;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.proxy.PortMappingListRes;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@@ -68,6 +70,14 @@ public class PortMappingDO {
|
||||
* 客户端端口
|
||||
*/
|
||||
private Integer clientPort;
|
||||
/**
|
||||
* 上传限速
|
||||
*/
|
||||
private String upLimitRate;
|
||||
/**
|
||||
* 下载限速
|
||||
*/
|
||||
private String downLimitRate;
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@@ -78,11 +88,25 @@ public class PortMappingDO {
|
||||
* {@link OnlineStatusEnum}
|
||||
*/
|
||||
private Integer isOnline;
|
||||
/**
|
||||
* 代理响应数量(响应数据包数量,如果没有拆包则等于数据条数)
|
||||
*/
|
||||
private Integer proxyResponses;
|
||||
/**
|
||||
* 代理超时时间
|
||||
*/
|
||||
private Long proxyTimeoutMs;
|
||||
/**
|
||||
* 启用状态
|
||||
* {@link EnableStatusEnum}
|
||||
*/
|
||||
private Integer enable;
|
||||
|
||||
/**
|
||||
* 安全组Id
|
||||
*/
|
||||
private Integer securityGroupId = 0; // 设置为null不生效,不知道为啥
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@@ -91,4 +115,10 @@ public class PortMappingDO {
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
public PortMappingListRes toRes() {
|
||||
PortMappingListRes res = new PortMappingListRes();
|
||||
BeanUtil.copyProperties(this, res);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.system.PortPoolListRes;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@@ -64,4 +65,15 @@ public class PortPoolDO {
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
public PortPoolListRes toRes() {
|
||||
PortPoolListRes res = new PortPoolListRes();
|
||||
res.setId(id);
|
||||
res.setGroupId(groupId);
|
||||
res.setPort(port);
|
||||
res.setEnable(enable);
|
||||
res.setCreateTime(createTime);
|
||||
res.setUpdateTime(updateTime);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,6 +26,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.system.UserListRes;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@@ -36,7 +37,7 @@ import java.util.Date;
|
||||
*/
|
||||
@ToString
|
||||
@Data
|
||||
@TableName("user")
|
||||
@TableName("`user`")
|
||||
public class UserDO {
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
@@ -64,4 +65,15 @@ public class UserDO {
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
public UserListRes toRes() {
|
||||
UserListRes res = new UserListRes();
|
||||
res.setId(id);
|
||||
res.setName(name);
|
||||
res.setLoginName(loginName);
|
||||
res.setEnable(enable);
|
||||
res.setCreateTime(createTime);
|
||||
res.setUpdateTime(updateTime);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.log.UserLoginRecordListRes;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@@ -62,4 +63,14 @@ public class UserLoginRecordDO {
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
public UserLoginRecordListRes toRes() {
|
||||
UserLoginRecordListRes res = new UserLoginRecordListRes();
|
||||
res.setId(id);
|
||||
res.setUserId(userId);
|
||||
res.setIp(ip);
|
||||
res.setType(type);
|
||||
res.setCreateTime(createTime);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
package org.dromara.neutrinoproxy.server.job;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.dromara.neutrinoproxy.core.util.DateUtil;
|
||||
import org.dromara.neutrinoproxy.server.dal.*;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dromara.neutrinoproxy.core.util.DateUtil;
|
||||
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.JobLogMapper;
|
||||
import org.dromara.neutrinoproxy.server.dal.UserLoginRecordMapper;
|
||||
import org.dromara.solonplugins.job.IJobHandler;
|
||||
import org.dromara.solonplugins.job.annotation.JobHandler;
|
||||
import org.noear.snack.ONode;
|
||||
import org.noear.solon.annotation.Component;
|
||||
import org.noear.solon.annotation.Inject;
|
||||
|
||||
@@ -70,37 +75,37 @@ public class DataCleanJob implements IJobHandler {
|
||||
|
||||
{
|
||||
Date date = DateUtil.addDate(new Date(), Calendar.DATE, -1 * jobParams.getJobLogKeepDays());
|
||||
log.info("清理调度管理日志 date:{}", sdf.format(date));
|
||||
log.info("clean job log date:{}", sdf.format(date));
|
||||
jobLogMapper.clean(date);
|
||||
}
|
||||
|
||||
{
|
||||
Date date = DateUtil.addDate(new Date(), Calendar.DATE, -1 * jobParams.getUserLoginRecordKeepDays());
|
||||
log.info("清理用户登录日志 date:{}", sdf.format(date));
|
||||
log.info("clean user login record date:{}", sdf.format(date));
|
||||
userLoginRecordMapper.clean(date);
|
||||
}
|
||||
|
||||
{
|
||||
Date date = DateUtil.addDate(new Date(), Calendar.DATE, -1 * jobParams.getClientConnectRecordKeepDays());
|
||||
log.info("清理客户端连接日志 date:{}", sdf.format(date));
|
||||
log.info("clean client connect record date:{}", sdf.format(date));
|
||||
clientConnectRecordMapper.clean(date);
|
||||
}
|
||||
|
||||
{
|
||||
Date date = DateUtil.addDate(new Date(), Calendar.DATE, -1 * jobParams.getFlowMinuteReportKeepDays());
|
||||
log.info("清理流通统计分钟报表日志 date:{}", sdf.format(date));
|
||||
log.info("clean flow report minute record date:{}", sdf.format(date));
|
||||
flowReportMinuteMapper.clean(date);
|
||||
}
|
||||
|
||||
{
|
||||
Date date = DateUtil.addDate(new Date(), Calendar.DATE, -1 * jobParams.getFlowHourReportKeepDays());
|
||||
log.info("清理流通统计小时报表日志 date:{}", sdf.format(date));
|
||||
log.info("clean flow report hour record date:{}", sdf.format(date));
|
||||
flowReportHourMapper.clean(date);
|
||||
}
|
||||
|
||||
{
|
||||
Date date = DateUtil.addDate(new Date(), Calendar.DATE, -1 * jobParams.getFlowDayReportKeepDays());
|
||||
log.info("清理流通统计日报表日志 date:{}", sdf.format(date));
|
||||
log.info("clean flow report day record date:{}", sdf.format(date));
|
||||
flowReportDayMapper.clean(date);
|
||||
}
|
||||
}
|
||||
@@ -108,7 +113,7 @@ public class DataCleanJob implements IJobHandler {
|
||||
public static JobParams getParams(String s) {
|
||||
try {
|
||||
if (StringUtils.isNotBlank(s)) {
|
||||
return JSONObject.parseObject(s, JobParams.class);
|
||||
return ONode.deserialize(s, JobParams.class);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
|
||||
@@ -25,6 +25,7 @@ package org.dromara.neutrinoproxy.server.proxy.core;
|
||||
import org.dromara.neutrinoproxy.core.Constants;
|
||||
import org.dromara.neutrinoproxy.core.ProxyMessage;
|
||||
import org.dromara.neutrinoproxy.core.dispatcher.Dispatcher;
|
||||
import org.dromara.neutrinoproxy.server.base.proxy.ProxyConfig;
|
||||
import org.dromara.neutrinoproxy.server.constant.ClientConnectTypeEnum;
|
||||
import org.dromara.neutrinoproxy.server.constant.SuccessCodeEnum;
|
||||
import org.dromara.neutrinoproxy.server.dal.entity.ClientConnectRecordDO;
|
||||
@@ -49,21 +50,29 @@ import java.util.Date;
|
||||
@Slf4j
|
||||
public class ProxyTunnelChannelHandler extends SimpleChannelInboundHandler<ProxyMessage> {
|
||||
private static volatile Dispatcher<ChannelHandlerContext, ProxyMessage> dispatcher;
|
||||
private static volatile Boolean transferLogEnable = Boolean.FALSE;
|
||||
|
||||
public ProxyTunnelChannelHandler() {
|
||||
dispatcher = Solon.context().getBean(Dispatcher.class);
|
||||
ProxyConfig proxyConfig = Solon.context().getBean(ProxyConfig.class);
|
||||
if (null != proxyConfig.getTunnel() && null != proxyConfig.getTunnel().getHeartbeatLogEnable()) {
|
||||
transferLogEnable = proxyConfig.getTunnel().getHeartbeatLogEnable();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void channelRead0(ChannelHandlerContext ctx, ProxyMessage proxyMessage) throws Exception {
|
||||
if (ProxyMessage.TYPE_HEARTBEAT != proxyMessage.getType() || transferLogEnable) {
|
||||
log.debug("Server CmdChannel recieved proxy message, type is {}", proxyMessage.getType());
|
||||
}
|
||||
dispatcher.dispatch(ctx, proxyMessage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception {
|
||||
Channel userChannel = ctx.channel().attr(Constants.NEXT_CHANNEL).get();
|
||||
if (userChannel != null) {
|
||||
userChannel.config().setOption(ChannelOption.AUTO_READ, ctx.channel().isWritable());
|
||||
Channel visitorChannel = ctx.channel().attr(Constants.NEXT_CHANNEL).get();
|
||||
if (visitorChannel != null) {
|
||||
visitorChannel.config().setOption(ChannelOption.AUTO_READ, ctx.channel().isWritable());
|
||||
}
|
||||
|
||||
super.channelWritabilityChanged(ctx);
|
||||
@@ -80,8 +89,11 @@ public class ProxyTunnelChannelHandler extends SimpleChannelInboundHandler<Proxy
|
||||
if (null != cmdChannel) {
|
||||
ProxyUtil.removeVisitorChannelFromCmdChannel(cmdChannel, visitorId);
|
||||
}
|
||||
ProxyUtil.remoteProxyConnectAttachment(visitorId);
|
||||
|
||||
if (visitorChannel.isActive()) {
|
||||
// 此处如果时UDP的 visitorChannel,则不能close,先临时判断一下
|
||||
Boolean isUdp = visitorChannel.attr(Constants.IS_UDP_KEY).get();
|
||||
if (visitorChannel.isActive() && null == isUdp) {
|
||||
// 数据发送完成后再关闭连接,解决http1.0数据传输问题
|
||||
visitorChannel.writeAndFlush(Unpooled.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE);
|
||||
visitorChannel.close();
|
||||
@@ -97,16 +109,16 @@ public class ProxyTunnelChannelHandler extends SimpleChannelInboundHandler<Proxy
|
||||
// 防止下次换一个客户端,无法连接的情况
|
||||
ProxyUtil.removeClientIdByLicenseId(cmdChannelAttachInfo.getLicenseId());
|
||||
}
|
||||
// 即便是因为上述原因断开,断开的日志依然要记录,方便排查问题
|
||||
Solon.context().getBean(ClientConnectRecordService.class).add(new ClientConnectRecordDO()
|
||||
.setIp(((InetSocketAddress)ctx.channel().remoteAddress()).getAddress().getHostAddress())
|
||||
.setLicenseId(cmdChannelAttachInfo.getLicenseId())
|
||||
.setType(ClientConnectTypeEnum.DISCONNECT.getType())
|
||||
.setMsg("")
|
||||
.setCode(SuccessCodeEnum.SUCCESS.getCode())
|
||||
.setCreateTime(new Date())
|
||||
);
|
||||
}
|
||||
// 即便是因为上述原因断开,断开的日志依然要记录,方便排查问题
|
||||
Solon.context().getBean(ClientConnectRecordService.class).add(new ClientConnectRecordDO()
|
||||
.setIp(((InetSocketAddress)ctx.channel().remoteAddress()).getAddress().getHostAddress())
|
||||
.setLicenseId(cmdChannelAttachInfo.getLicenseId())
|
||||
.setType(ClientConnectTypeEnum.DISCONNECT.getType())
|
||||
.setMsg("")
|
||||
.setCode(SuccessCodeEnum.SUCCESS.getCode())
|
||||
.setCreateTime(new Date())
|
||||
);
|
||||
}
|
||||
|
||||
super.channelInactive(ctx);
|
||||
@@ -114,10 +126,11 @@ public class ProxyTunnelChannelHandler extends SimpleChannelInboundHandler<Proxy
|
||||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
||||
super.exceptionCaught(ctx, cause);
|
||||
if (ctx.channel().isActive()) {
|
||||
ctx.channel().close();
|
||||
}
|
||||
// super.exceptionCaught(ctx, cause);
|
||||
// if (ctx.channel().isActive()) {
|
||||
// ctx.channel().close();
|
||||
// }
|
||||
log.error("[Tunnel Channel] error", cause);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -126,11 +139,14 @@ public class ProxyTunnelChannelHandler extends SimpleChannelInboundHandler<Proxy
|
||||
IdleStateEvent event = (IdleStateEvent)evt;
|
||||
switch (event.state()) {
|
||||
case READER_IDLE:
|
||||
// 读超时,断开连接
|
||||
log.debug("读超时");
|
||||
ctx.channel().close();
|
||||
if (ctx.channel().isWritable()) {
|
||||
// 读超时,断开连接
|
||||
log.warn("[Tunnel Channel]Read timeout");
|
||||
ctx.channel().close();
|
||||
}
|
||||
break;
|
||||
case WRITER_IDLE:
|
||||
ctx.channel().writeAndFlush(ProxyMessage.buildHeartbeatMessage());
|
||||
break;
|
||||
case ALL_IDLE:
|
||||
break;
|
||||
|
||||
@@ -18,6 +18,7 @@ import org.noear.solon.annotation.Component;
|
||||
import org.noear.solon.annotation.Inject;
|
||||
import org.noear.solon.core.event.AppLoadEndEvent;
|
||||
import org.noear.solon.core.event.EventListener;
|
||||
import org.noear.solon.core.runtime.NativeDetector;
|
||||
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
@@ -42,8 +43,11 @@ public class ProxyTunnelServer implements EventListener<AppLoadEndEvent> {
|
||||
private NioEventLoopGroup serverWorkerGroup;
|
||||
@Override
|
||||
public void onEvent(AppLoadEndEvent appLoadEndEvent) throws Throwable {
|
||||
startProxyServer();
|
||||
startProxyServerForSSL();
|
||||
// aot 阶段,不启动代理服务
|
||||
if (NativeDetector.isNotAotRuntime()) {
|
||||
startProxyServer();
|
||||
startProxyServerForSSL();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 启动代理服务
|
||||
@@ -59,9 +63,9 @@ public class ProxyTunnelServer implements EventListener<AppLoadEndEvent> {
|
||||
});
|
||||
try {
|
||||
bootstrap.bind(proxyConfig.getTunnel().getPort()).sync();
|
||||
log.info("代理服务启动,端口:{}", proxyConfig.getTunnel().getPort());
|
||||
log.info("proxy server started,port:{}", proxyConfig.getTunnel().getPort());
|
||||
} catch (Exception e) {
|
||||
log.error("代理服务异常", e);
|
||||
log.error("proxy server error", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,9 +84,9 @@ public class ProxyTunnelServer implements EventListener<AppLoadEndEvent> {
|
||||
});
|
||||
try {
|
||||
bootstrap.bind(proxyConfig.getTunnel().getSslPort()).sync();
|
||||
log.info("代理服务启动,SSL端口: {}", proxyConfig.getTunnel().getSslPort());
|
||||
log.info("proxy server started,SSL port: {}", proxyConfig.getTunnel().getSslPort());
|
||||
} catch (Exception e) {
|
||||
log.error("代理服务异常", e);
|
||||
log.error("proxy server error", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +109,7 @@ public class ProxyTunnelServer implements EventListener<AppLoadEndEvent> {
|
||||
|
||||
return new SslHandler(sslEngine);
|
||||
} catch (Exception e) {
|
||||
log.error("创建SSL处理器失败", e);
|
||||
log.error("create SSL handler error", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
package org.dromara.neutrinoproxy.server.proxy.core;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.neutrinoproxy.core.Constants;
|
||||
import org.dromara.neutrinoproxy.core.ProxyMessage;
|
||||
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 lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.neutrinoproxy.core.Constants;
|
||||
import org.dromara.neutrinoproxy.core.ProxyMessage;
|
||||
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 org.noear.solon.Solon;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
@@ -42,9 +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());
|
||||
|
||||
// 转发代理数据
|
||||
String visitorId = ProxyUtil.getVisitorIdByChannel(visitorChannel);
|
||||
proxyChannel.writeAndFlush(ProxyMessage.buildTransferMessage(visitorId, bytes));
|
||||
|
||||
@@ -57,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();
|
||||
@@ -76,7 +81,7 @@ public class TcpVisitorChannelHandler extends SimpleChannelInboundHandler<ByteBu
|
||||
visitorChannel.config().setOption(ChannelOption.AUTO_READ, false);
|
||||
|
||||
String visitorId = ProxyUtil.newVisitorId();
|
||||
ProxyUtil.addVisitorChannelToCmdChannel(cmdChannel, visitorId, visitorChannel, sa.getPort());
|
||||
ProxyUtil.addVisitorChannelToCmdChannel(NetworkProtocolEnum.TCP, cmdChannel, visitorId, visitorChannel, sa.getPort());
|
||||
cmdChannel.writeAndFlush(ProxyMessage.buildConnectMessage(visitorId).setData(lanInfo.getBytes()));
|
||||
|
||||
super.channelActive(ctx);
|
||||
@@ -128,7 +133,8 @@ public class TcpVisitorChannelHandler extends SimpleChannelInboundHandler<ByteBu
|
||||
if (null == cmdChannel) {
|
||||
// 该端口还没有代理客户端
|
||||
ctx.channel().close();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Channel proxyChannel = visitorChannel.attr(Constants.NEXT_CHANNEL).get();
|
||||
if (null != proxyChannel) {
|
||||
proxyChannel.config().setOption(ChannelOption.AUTO_READ, visitorChannel.isWritable());
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
package org.dromara.neutrinoproxy.server.proxy.core;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
import io.netty.channel.socket.DatagramPacket;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.neutrinoproxy.core.Constants;
|
||||
import org.dromara.neutrinoproxy.core.ProxyMessage;
|
||||
import org.dromara.neutrinoproxy.server.constant.NetworkProtocolEnum;
|
||||
import org.dromara.neutrinoproxy.server.proxy.domain.ProxyAttachment;
|
||||
import org.dromara.neutrinoproxy.server.proxy.domain.VisitorChannelAttachInfo;
|
||||
import org.dromara.neutrinoproxy.server.service.FlowReportService;
|
||||
import org.dromara.neutrinoproxy.server.util.ProxyUtil;
|
||||
import org.noear.solon.Solon;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
/**
|
||||
* @author: aoshiguchen
|
||||
* @date: 2023/9/16
|
||||
*/
|
||||
@Slf4j
|
||||
public class UdpVisitorChannelHandler extends SimpleChannelInboundHandler<DatagramPacket> {
|
||||
|
||||
@Override
|
||||
protected void channelRead0(ChannelHandlerContext ctx, DatagramPacket datagramPacket) throws Exception {
|
||||
Channel visitorChannel = ctx.channel();
|
||||
InetSocketAddress sa = (InetSocketAddress) visitorChannel.localAddress();
|
||||
|
||||
byte[] bytes = new byte[datagramPacket.content().readableBytes()];
|
||||
datagramPacket.content().readBytes(bytes);
|
||||
datagramPacket.content().resetReaderIndex();
|
||||
ProxyAttachment proxyAttachment = new ProxyAttachment(ctx.channel(), bytes, (channel, buf) -> {
|
||||
Channel proxyChannel = channel.attr(Constants.NEXT_CHANNEL).get();
|
||||
|
||||
if (null == proxyChannel) {
|
||||
// // 该端口还没有代理客户端
|
||||
// ctx.channel().close();
|
||||
return;
|
||||
}
|
||||
|
||||
proxyChannel.attr(Constants.SENDER).set(datagramPacket.sender());
|
||||
String targetIp = proxyChannel.attr(Constants.TARGET_IP).get();
|
||||
int targetPort = proxyChannel.attr(Constants.TARGET_PORT).get();
|
||||
Integer proxyResponses = proxyChannel.attr(Constants.PROXY_RESPONSES).get();
|
||||
Long proxyTimeoutMs = proxyChannel.attr(Constants.PROXY_TIMEOUT_MS).get();
|
||||
|
||||
// 转发代理数据
|
||||
String visitorId = ProxyUtil.getVisitorIdByChannel(channel);
|
||||
proxyChannel.writeAndFlush(ProxyMessage.buildUdpTransferMessage(new ProxyMessage.UdpBaseInfo()
|
||||
.setVisitorId(visitorId)
|
||||
.setVisitorIp(datagramPacket.sender().getAddress().getHostAddress())
|
||||
.setVisitorPort(datagramPacket.sender().getPort())
|
||||
.setTargetIp(targetIp)
|
||||
.setTargetPort(targetPort)
|
||||
.setProxyTimeoutMs(proxyTimeoutMs)
|
||||
.setProxyResponses(proxyResponses)
|
||||
).setData(bytes));
|
||||
|
||||
// 增加流量计数
|
||||
VisitorChannelAttachInfo visitorChannelAttachInfo = ProxyUtil.getAttachInfo(channel);
|
||||
Solon.context().getBean(FlowReportService.class).addWriteByte(visitorChannelAttachInfo.getLicenseId(), bytes.length);
|
||||
});
|
||||
|
||||
Channel proxyChannel = ctx.channel().attr(Constants.NEXT_CHANNEL).get();
|
||||
if (null != proxyChannel && proxyChannel.isActive()) {
|
||||
// UDP代理隧道已就绪,直接转发
|
||||
proxyAttachment.execute();
|
||||
return;
|
||||
}
|
||||
|
||||
Channel cmdChannel = ProxyUtil.getCmdChannelByServerPort(sa.getPort());
|
||||
|
||||
// 没有指令通道,直接结束
|
||||
if (null == cmdChannel) {
|
||||
// 该端口还没有代理客户端
|
||||
// ctx.channel().close();
|
||||
return;
|
||||
}
|
||||
|
||||
// 根据代理服务端端口,获取被代理客户端局域网连接信息
|
||||
String lanInfo = ProxyUtil.getClientLanInfoByServerPort(sa.getPort());
|
||||
if (StrUtil.isEmpty(lanInfo)) {
|
||||
ctx.channel().close();
|
||||
return;
|
||||
}
|
||||
|
||||
String[] targetInfo = lanInfo.split(":");
|
||||
String targetIp = targetInfo[0];
|
||||
int targetPort = Integer.parseInt(targetInfo[1]);
|
||||
|
||||
// // 用户连接到代理服务器时,设置用户连接不可读,等待代理后端服务器连接成功后再改变为可读状态
|
||||
// visitorChannel.config().setOption(ChannelOption.AUTO_READ, false);
|
||||
|
||||
// TODO UDP此处叫visitor似有不妥,与TCP不同,2.x重构思考
|
||||
String visitorId = ProxyUtil.newVisitorId();
|
||||
// 此处需要和tcp分开
|
||||
ProxyUtil.addVisitorChannelToCmdChannel(NetworkProtocolEnum.UDP, cmdChannel, visitorId, visitorChannel, sa.getPort());
|
||||
ProxyUtil.addProxyConnectAttachment(visitorId, proxyAttachment);
|
||||
cmdChannel.writeAndFlush(ProxyMessage.buildUdpConnectMessage(new ProxyMessage.UdpBaseInfo()
|
||||
.setVisitorId(visitorId)
|
||||
.setServerPort(sa.getPort())
|
||||
.setTargetIp(targetIp)
|
||||
.setTargetPort(targetPort)
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||
super.channelActive(ctx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
|
||||
// 当出现异常就关闭连接
|
||||
ctx.close();
|
||||
log.error("[UDP Visitor Channel]VisitorChannel error", cause);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception {
|
||||
|
||||
// 通知代理客户端
|
||||
Channel visitorChannel = ctx.channel();
|
||||
InetSocketAddress sa = (InetSocketAddress) visitorChannel.localAddress();
|
||||
Channel cmdChannel = ProxyUtil.getCmdChannelByServerPort(sa.getPort());
|
||||
|
||||
if (null == cmdChannel) {
|
||||
// 该端口还没有代理客户端
|
||||
ctx.channel().close();
|
||||
}
|
||||
else {
|
||||
Channel proxyChannel = visitorChannel.attr(Constants.NEXT_CHANNEL).get();
|
||||
if (null != proxyChannel) {
|
||||
proxyChannel.config().setOption(ChannelOption.AUTO_READ, visitorChannel.isWritable());
|
||||
}
|
||||
}
|
||||
|
||||
super.channelWritabilityChanged(ctx);
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ package org.dromara.neutrinoproxy.server.proxy.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.dromara.neutrinoproxy.server.constant.NetworkProtocolEnum;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -32,6 +33,7 @@ import lombok.experimental.Accessors;
|
||||
@Accessors(chain = true)
|
||||
@Data
|
||||
public class VisitorChannelAttachInfo {
|
||||
private NetworkProtocolEnum protocol;
|
||||
private String visitorId;
|
||||
private String lanInfo;
|
||||
private Integer serverPort;
|
||||
|
||||
@@ -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;
|
||||
@@ -28,7 +30,7 @@ public class HttpProxy implements EventListener<AppLoadEndEvent> {
|
||||
private ProxyConfig proxyConfig;
|
||||
@Override
|
||||
public void onEvent(AppLoadEndEvent appLoadEndEvent) throws Throwable {
|
||||
if (StrUtil.isBlank(proxyConfig.getServer().getDomainName()) || null == proxyConfig.getServer().getHttpProxyPort()) {
|
||||
if (StrUtil.isBlank(proxyConfig.getServer().getTcp().getDomainName()) || null == proxyConfig.getServer().getTcp().getHttpProxyPort()) {
|
||||
log.info("no config domain name,nonsupport http proxy.");
|
||||
return;
|
||||
}
|
||||
@@ -42,15 +44,17 @@ public class HttpProxy implements EventListener<AppLoadEndEvent> {
|
||||
.channel(NioServerSocketChannel.class).childHandler(new ChannelInitializer<SocketChannel>() {
|
||||
@Override
|
||||
public void initChannel(SocketChannel ch) throws Exception {
|
||||
if (null != proxyConfig.getServer().getTransferLogEnable() && proxyConfig.getServer().getTransferLogEnable()) {
|
||||
ch.pipeline().addFirst(new LoggingHandler(ProxyTunnelServer.class));
|
||||
if (null != proxyConfig.getServer().getTcp().getTransferLogEnable() && proxyConfig.getServer().getTcp().getTransferLogEnable()) {
|
||||
ch.pipeline().addFirst(new LoggingHandler(HttpProxy.class));
|
||||
}
|
||||
ch.pipeline().addFirst(new BytesMetricsHandler());
|
||||
ch.pipeline().addLast(new HttpVisitorChannelHandler(proxyConfig.getServer().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().getHttpProxyPort()).sync();
|
||||
log.info("Http代理服务启动成功!port:{}", proxyConfig.getServer().getHttpProxyPort());
|
||||
bootstrap.bind("0.0.0.0", proxyConfig.getServer().getTcp().getHttpProxyPort()).sync();
|
||||
log.info("Http proxy server start success!port:{}", proxyConfig.getServer().getTcp().getHttpProxyPort());
|
||||
} catch (Exception e) {
|
||||
log.error("http proxy start err!", e);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -10,6 +9,7 @@ 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;
|
||||
import org.dromara.neutrinoproxy.server.proxy.domain.ProxyAttachment;
|
||||
import org.dromara.neutrinoproxy.server.proxy.domain.VisitorChannelAttachInfo;
|
||||
import org.dromara.neutrinoproxy.server.service.FlowReportService;
|
||||
@@ -24,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();
|
||||
@@ -67,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();
|
||||
@@ -98,7 +69,7 @@ public class HttpVisitorChannelHandler extends SimpleChannelInboundHandler<ByteB
|
||||
}
|
||||
|
||||
visitorId = ProxyUtil.newVisitorId();
|
||||
ProxyUtil.addVisitorChannelToCmdChannel(cmdChannel, visitorId, ctx.channel(), serverPort);
|
||||
ProxyUtil.addVisitorChannelToCmdChannel(NetworkProtocolEnum.HTTP, cmdChannel, visitorId, ctx.channel(), serverPort);
|
||||
ProxyUtil.addProxyConnectAttachment(visitorId, proxyAttachment);
|
||||
cmdChannel.writeAndFlush(ProxyMessage.buildConnectMessage(visitorId).setData(lanInfo.getBytes()));
|
||||
}
|
||||
@@ -149,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -35,8 +37,8 @@ public class HttpsProxy implements EventListener<AppLoadEndEvent> {
|
||||
private ProxyConfig proxyConfig;
|
||||
@Override
|
||||
public void onEvent(AppLoadEndEvent appLoadEndEvent) throws Throwable {
|
||||
if (StrUtil.isBlank(proxyConfig.getServer().getDomainName()) || null == proxyConfig.getServer().getHttpsProxyPort() ||
|
||||
StringUtils.isEmpty(proxyConfig.getServer().getJksPath()) || StringUtils.isEmpty(proxyConfig.getServer().getKeyStorePassword())) {
|
||||
if (StrUtil.isBlank(proxyConfig.getServer().getTcp().getDomainName()) || null == proxyConfig.getServer().getTcp().getHttpsProxyPort() ||
|
||||
StringUtils.isEmpty(proxyConfig.getServer().getTcp().getJksPath()) || StringUtils.isEmpty(proxyConfig.getServer().getTcp().getKeyStorePassword())) {
|
||||
log.info("no config domain name,nonsupport https proxy.");
|
||||
return;
|
||||
}
|
||||
@@ -50,16 +52,18 @@ public class HttpsProxy implements EventListener<AppLoadEndEvent> {
|
||||
.channel(NioServerSocketChannel.class).childHandler(new ChannelInitializer<SocketChannel>() {
|
||||
@Override
|
||||
public void initChannel(SocketChannel ch) throws Exception {
|
||||
if (null != proxyConfig.getServer().getTransferLogEnable() && proxyConfig.getServer().getTransferLogEnable()) {
|
||||
ch.pipeline().addFirst(new LoggingHandler(ProxyTunnelServer.class));
|
||||
if (null != proxyConfig.getServer().getTcp().getTransferLogEnable() && proxyConfig.getServer().getTcp().getTransferLogEnable()) {
|
||||
ch.pipeline().addFirst(new LoggingHandler(HttpsProxy.class));
|
||||
}
|
||||
ch.pipeline().addLast(createSslHandler());
|
||||
ch.pipeline().addFirst(new BytesMetricsHandler());
|
||||
ch.pipeline().addLast(new HttpVisitorChannelHandler(proxyConfig.getServer().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().getHttpsProxyPort()).sync();
|
||||
log.info("Https代理服务启动成功!port:{}", proxyConfig.getServer().getHttpsProxyPort());
|
||||
bootstrap.bind("0.0.0.0", proxyConfig.getServer().getTcp().getHttpsProxyPort()).sync();
|
||||
log.info("Https proxy server started!port:{}", proxyConfig.getServer().getTcp().getHttpsProxyPort());
|
||||
} catch (Exception e) {
|
||||
log.error("https proxy start err!", e);
|
||||
}
|
||||
@@ -67,13 +71,13 @@ public class HttpsProxy implements EventListener<AppLoadEndEvent> {
|
||||
|
||||
private ChannelHandler createSslHandler() {
|
||||
try {
|
||||
InputStream jksInputStream = FileUtil.getInputStream(proxyConfig.getServer().getJksPath());
|
||||
InputStream jksInputStream = FileUtil.getInputStream(proxyConfig.getServer().getTcp().getJksPath());
|
||||
SSLContext serverContext = SSLContext.getInstance("TLS");
|
||||
final KeyStore ks = KeyStore.getInstance("JKS");
|
||||
|
||||
ks.load(jksInputStream, proxyConfig.getServer().getKeyStorePassword().toCharArray());
|
||||
ks.load(jksInputStream, proxyConfig.getServer().getTcp().getKeyStorePassword().toCharArray());
|
||||
final KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
|
||||
kmf.init(ks, proxyConfig.getServer().getKeyStorePassword().toCharArray());
|
||||
kmf.init(ks, proxyConfig.getServer().getTcp().getKeyStorePassword().toCharArray());
|
||||
TrustManager[] trustManagers = null;
|
||||
|
||||
serverContext.init(kmf.getKeyManagers(), trustManagers, null);
|
||||
@@ -84,7 +88,7 @@ public class HttpsProxy implements EventListener<AppLoadEndEvent> {
|
||||
|
||||
return new SslHandler(sslEngine);
|
||||
} catch (Exception e) {
|
||||
log.error("创建SSL处理器失败", e);
|
||||
log.error("create SSL handler failed", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -89,37 +89,37 @@ public class ProxyMessageAuthHandler implements ProxyMessageHandler {
|
||||
}
|
||||
|
||||
if (StrUtil.isEmpty(licenseKey)) {
|
||||
log.warn("[客户端连接] license不能为空 info:{} ", info);
|
||||
ctx.channel().writeAndFlush(ProxyMessage.buildAuthResultMessage(ExceptionEnum.AUTH_FAILED.getCode(), "license不能为空!", licenseKey));
|
||||
log.warn("[client connection] license cannot empty info:{} ", info);
|
||||
ctx.channel().writeAndFlush(ProxyMessage.buildAuthResultMessage(ExceptionEnum.AUTH_FAILED.getCode(), "license cannot be empty!", licenseKey));
|
||||
ctx.channel().close();
|
||||
clientConnectRecordService.add(new ClientConnectRecordDO()
|
||||
.setIp(ip)
|
||||
.setType(ClientConnectTypeEnum.CONNECT.getType())
|
||||
.setMsg(licenseKey)
|
||||
.setCode(SuccessCodeEnum.FAIL.getCode())
|
||||
.setErr("license不能为空!")
|
||||
.setErr("license cannot empty!")
|
||||
.setCreateTime(now)
|
||||
);
|
||||
return;
|
||||
}
|
||||
LicenseDO licenseDO = licenseService.findByKey(licenseKey);
|
||||
if (null == licenseDO) {
|
||||
log.warn("[客户端连接] license不存在 info:{} ", info);
|
||||
ctx.channel().writeAndFlush(ProxyMessage.buildAuthResultMessage(ExceptionEnum.AUTH_FAILED.getCode(), "license不存在!", licenseKey));
|
||||
log.warn("[client connection] license notfound info:{} ", info);
|
||||
ctx.channel().writeAndFlush(ProxyMessage.buildAuthResultMessage(ExceptionEnum.AUTH_FAILED.getCode(), "license not found!", licenseKey));
|
||||
ctx.channel().close();
|
||||
clientConnectRecordService.add(new ClientConnectRecordDO()
|
||||
.setIp(ip)
|
||||
.setType(ClientConnectTypeEnum.CONNECT.getType())
|
||||
.setMsg(licenseKey)
|
||||
.setCode(SuccessCodeEnum.FAIL.getCode())
|
||||
.setErr("license不存在!")
|
||||
.setErr("license notfound!")
|
||||
.setCreateTime(now)
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (EnableStatusEnum.DISABLE.getStatus().equals(licenseDO.getEnable())) {
|
||||
log.warn("[客户端连接] 当前license已被禁用 info:{} ", info);
|
||||
ctx.channel().writeAndFlush(ProxyMessage.buildAuthResultMessage(ExceptionEnum.AUTH_FAILED.getCode(), "当前license已被禁用!", licenseKey));
|
||||
log.warn("[client connection] the license disabled info:{} ", info);
|
||||
ctx.channel().writeAndFlush(ProxyMessage.buildAuthResultMessage(ExceptionEnum.AUTH_FAILED.getCode(), "the license disabled!", licenseKey));
|
||||
ctx.channel().close();
|
||||
clientConnectRecordService.add(new ClientConnectRecordDO()
|
||||
.setIp(ip)
|
||||
@@ -127,14 +127,14 @@ public class ProxyMessageAuthHandler implements ProxyMessageHandler {
|
||||
.setType(ClientConnectTypeEnum.CONNECT.getType())
|
||||
.setMsg(licenseKey)
|
||||
.setCode(SuccessCodeEnum.FAIL.getCode())
|
||||
.setErr("当前license已被禁用!")
|
||||
.setErr("the license disabled!")
|
||||
.setCreateTime(now));
|
||||
return;
|
||||
}
|
||||
UserDO userDO = userService.findById(licenseDO.getUserId());
|
||||
if (null == userDO || EnableStatusEnum.DISABLE.getStatus().equals(userDO.getEnable())) {
|
||||
log.warn("[客户端连接] 当前license无效 info:{} ", info);
|
||||
ctx.channel().writeAndFlush(ProxyMessage.buildAuthResultMessage(ExceptionEnum.AUTH_FAILED.getCode(), "当前license无效!", licenseKey));
|
||||
log.warn("[client connection] the license invalid info:{} ", info);
|
||||
ctx.channel().writeAndFlush(ProxyMessage.buildAuthResultMessage(ExceptionEnum.AUTH_FAILED.getCode(), "the license invalid!", licenseKey));
|
||||
ctx.channel().close();
|
||||
clientConnectRecordService.add(new ClientConnectRecordDO()
|
||||
.setIp(ip)
|
||||
@@ -142,7 +142,7 @@ public class ProxyMessageAuthHandler implements ProxyMessageHandler {
|
||||
.setType(ClientConnectTypeEnum.CONNECT.getType())
|
||||
.setMsg(licenseKey)
|
||||
.setCode(SuccessCodeEnum.FAIL.getCode())
|
||||
.setErr("当前license无效!")
|
||||
.setErr("the license invalid!")
|
||||
.setCreateTime(now));
|
||||
return;
|
||||
}
|
||||
@@ -150,8 +150,8 @@ public class ProxyMessageAuthHandler implements ProxyMessageHandler {
|
||||
if (null != cmdChannel) {
|
||||
String _clientId = ProxyUtil.getClientIdByLicenseId(licenseDO.getId());
|
||||
if (!clientId.equals(_clientId)) {
|
||||
log.warn("[客户端连接] 当前license已被另一节点使用 info:{} _clientId:{}", info, _clientId);
|
||||
ctx.channel().writeAndFlush(ProxyMessage.buildAuthResultMessage(ExceptionEnum.AUTH_FAILED.getCode(), "当前license已被另一节点使用!", licenseKey));
|
||||
log.warn("[client connection] the license on another no used info:{} _clientId:{}", info, _clientId);
|
||||
ctx.channel().writeAndFlush(ProxyMessage.buildAuthResultMessage(ExceptionEnum.AUTH_FAILED.getCode(), "the license on another no used!", licenseKey));
|
||||
ctx.channel().close();
|
||||
clientConnectRecordService.add(new ClientConnectRecordDO()
|
||||
.setIp(ip)
|
||||
@@ -159,13 +159,13 @@ public class ProxyMessageAuthHandler implements ProxyMessageHandler {
|
||||
.setType(ClientConnectTypeEnum.CONNECT.getType())
|
||||
.setMsg(licenseKey)
|
||||
.setCode(SuccessCodeEnum.FAIL.getCode())
|
||||
.setErr("当前license已被另一节点使用!")
|
||||
.setErr("the license on another no used!")
|
||||
.setCreateTime(now));
|
||||
return;
|
||||
}
|
||||
}
|
||||
// 发送认证成功消息
|
||||
ctx.channel().writeAndFlush(ProxyMessage.buildAuthResultMessage(ExceptionEnum.SUCCESS.getCode(), "认证成功!", licenseKey));
|
||||
ctx.channel().writeAndFlush(ProxyMessage.buildAuthResultMessage(ExceptionEnum.SUCCESS.getCode(), "auth success!", licenseKey));
|
||||
|
||||
clientConnectRecordService.add(new ClientConnectRecordDO()
|
||||
.setIp(ip)
|
||||
@@ -178,7 +178,7 @@ public class ProxyMessageAuthHandler implements ProxyMessageHandler {
|
||||
// 设置当前licenseId对应的客户端ID
|
||||
ProxyUtil.setLicenseIdToClientIdMap(licenseDO.getId(), clientId);
|
||||
|
||||
log.warn("[客户端连接] 认证成功 info:{} ", info);
|
||||
log.warn("[client connection] auth success info:{} ", info);
|
||||
|
||||
// 更新license在线状态
|
||||
licenseMapper.updateOnlineStatus(licenseDO.getId(), OnlineStatusEnum.ONLINE.getStatus(), now);
|
||||
|
||||
@@ -34,14 +34,14 @@ public class ProxyMessageConnectHandler implements ProxyMessageHandler {
|
||||
public void handle(ChannelHandlerContext ctx, ProxyMessage proxyMessage) {
|
||||
String info = proxyMessage.getInfo();
|
||||
if (StrUtil.isEmpty(info)) {
|
||||
ctx.channel().writeAndFlush(ProxyMessage.buildErrMessage(ExceptionEnum.CONNECT_FAILED, "info不能为空!"));
|
||||
ctx.channel().writeAndFlush(ProxyMessage.buildErrMessage(ExceptionEnum.CONNECT_FAILED, "info cannot be empty!"));
|
||||
ctx.channel().close();
|
||||
return;
|
||||
}
|
||||
|
||||
String[] tokens = info.split("@");
|
||||
if (tokens.length != 2) {
|
||||
ctx.channel().writeAndFlush(ProxyMessage.buildErrMessage(ExceptionEnum.CONNECT_FAILED, "info格式有误!"));
|
||||
ctx.channel().writeAndFlush(ProxyMessage.buildErrMessage(ExceptionEnum.CONNECT_FAILED, "info format error!"));
|
||||
ctx.channel().close();
|
||||
return;
|
||||
}
|
||||
@@ -50,18 +50,18 @@ public class ProxyMessageConnectHandler implements ProxyMessageHandler {
|
||||
|
||||
LicenseDO licenseDO = licenseService.findByKey(licenseKey);
|
||||
if (null == licenseDO) {
|
||||
ctx.channel().writeAndFlush(ProxyMessage.buildErrMessage(ExceptionEnum.CONNECT_FAILED, "license不存在!"));
|
||||
ctx.channel().writeAndFlush(ProxyMessage.buildErrMessage(ExceptionEnum.CONNECT_FAILED, "the license not found!"));
|
||||
ctx.channel().close();
|
||||
return;
|
||||
}
|
||||
if (EnableStatusEnum.DISABLE.getStatus().equals(licenseDO.getEnable())) {
|
||||
ctx.channel().writeAndFlush(ProxyMessage.buildErrMessage(ExceptionEnum.CONNECT_FAILED, "当前license已被禁用!"));
|
||||
ctx.channel().writeAndFlush(ProxyMessage.buildErrMessage(ExceptionEnum.CONNECT_FAILED, "the license invalid!"));
|
||||
ctx.channel().close();
|
||||
return;
|
||||
}
|
||||
UserDO userDO = userService.findById(licenseDO.getUserId());
|
||||
if (null == userDO || EnableStatusEnum.DISABLE.getStatus().equals(userDO.getEnable())) {
|
||||
ctx.channel().writeAndFlush(ProxyMessage.buildErrMessage(ExceptionEnum.CONNECT_FAILED, "当前license无效!"));
|
||||
ctx.channel().writeAndFlush(ProxyMessage.buildErrMessage(ExceptionEnum.CONNECT_FAILED, "the license invalid!"));
|
||||
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, "服务端异常,指令通道不存在!"));
|
||||
ctx.channel().writeAndFlush(ProxyMessage.buildErrMessage(ExceptionEnum.CONNECT_FAILED, "server error,cmd channel not found!"));
|
||||
ctx.channel().close();
|
||||
return;
|
||||
}
|
||||
@@ -82,12 +82,15 @@ 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);
|
||||
|
||||
// 获取代理附加对象
|
||||
ProxyAttachment proxyAttachment = ProxyUtil.getProxyConnectAttachment(visitorId);
|
||||
if (null != proxyAttachment) {
|
||||
// 及时释放
|
||||
ProxyUtil.remoteProxyConnectAttachment(visitorId);
|
||||
proxyAttachment.execute();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,17 @@ public class ProxyMessageTransferHandler implements ProxyMessageHandler {
|
||||
public void handle(ChannelHandlerContext ctx, ProxyMessage proxyMessage) {
|
||||
Channel visitorChannel = ctx.channel().attr(Constants.NEXT_CHANNEL).get();
|
||||
if (null != visitorChannel) {
|
||||
if (!visitorChannel.isWritable()) {
|
||||
//自己不可写,通道可以读,让通道关闭读
|
||||
//自己可写,通道不可以读,让通道打开读
|
||||
if (ctx.channel().config().isAutoRead()) {
|
||||
ctx.channel().config().setAutoRead(false);
|
||||
}
|
||||
} else {
|
||||
if (!ctx.channel().config().isAutoRead()) {
|
||||
ctx.channel().config().setAutoRead(true);
|
||||
}
|
||||
}
|
||||
ByteBuf buf = ctx.alloc().buffer(proxyMessage.getData().length);
|
||||
buf.writeBytes(proxyMessage.getData());
|
||||
visitorChannel.writeAndFlush(buf);
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
package org.dromara.neutrinoproxy.server.proxy.handler;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.neutrinoproxy.core.Constants;
|
||||
import org.dromara.neutrinoproxy.core.ExceptionEnum;
|
||||
import org.dromara.neutrinoproxy.core.ProxyDataTypeEnum;
|
||||
import org.dromara.neutrinoproxy.core.ProxyMessage;
|
||||
import org.dromara.neutrinoproxy.core.ProxyMessageHandler;
|
||||
import org.dromara.neutrinoproxy.core.dispatcher.Match;
|
||||
import org.dromara.neutrinoproxy.server.constant.EnableStatusEnum;
|
||||
import org.dromara.neutrinoproxy.server.dal.PortMappingMapper;
|
||||
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.proxy.domain.ProxyAttachment;
|
||||
import org.dromara.neutrinoproxy.server.service.LicenseService;
|
||||
import org.dromara.neutrinoproxy.server.service.UserService;
|
||||
import org.dromara.neutrinoproxy.server.util.ProxyUtil;
|
||||
import org.noear.snack.ONode;
|
||||
import org.noear.solon.annotation.Component;
|
||||
import org.noear.solon.annotation.Inject;
|
||||
|
||||
/**
|
||||
* @author: aoshiguchen
|
||||
* @date: 2023/9/19
|
||||
*/
|
||||
@Slf4j
|
||||
@Match(type = Constants.ProxyDataTypeName.UDP_CONNECT)
|
||||
@Component
|
||||
public class UdpProxyMessageConnectHandler implements ProxyMessageHandler {
|
||||
@Inject
|
||||
private LicenseService licenseService;
|
||||
@Inject
|
||||
private UserService userService;
|
||||
@Inject
|
||||
private PortMappingMapper portMappingMapper;
|
||||
|
||||
@Override
|
||||
public void handle(ChannelHandlerContext ctx, ProxyMessage proxyMessage) {
|
||||
final ProxyMessage.UdpBaseInfo udpBaseInfo = ONode.deserialize(proxyMessage.getInfo(), ProxyMessage.UdpBaseInfo.class);
|
||||
final String licenseKey = new String(proxyMessage.getData());
|
||||
log.info("[UDP connect]info:{} licenseKey:{}", proxyMessage.getInfo(), licenseKey);
|
||||
|
||||
LicenseDO licenseDO = licenseService.findByKey(licenseKey);
|
||||
if (null == licenseDO) {
|
||||
ctx.channel().writeAndFlush(ProxyMessage.buildErrMessage(ExceptionEnum.CONNECT_FAILED, "the license notfound!"));
|
||||
ctx.channel().close();
|
||||
return;
|
||||
}
|
||||
if (EnableStatusEnum.DISABLE.getStatus().equals(licenseDO.getEnable())) {
|
||||
ctx.channel().writeAndFlush(ProxyMessage.buildErrMessage(ExceptionEnum.CONNECT_FAILED, "the license disabled!"));
|
||||
ctx.channel().close();
|
||||
return;
|
||||
}
|
||||
UserDO userDO = userService.findById(licenseDO.getUserId());
|
||||
if (null == userDO || EnableStatusEnum.DISABLE.getStatus().equals(userDO.getEnable())) {
|
||||
ctx.channel().writeAndFlush(ProxyMessage.buildErrMessage(ExceptionEnum.CONNECT_FAILED, "the license invalid!"));
|
||||
ctx.channel().close();
|
||||
return;
|
||||
}
|
||||
|
||||
Channel cmdChannel = ProxyUtil.getCmdChannelByLicenseId(licenseDO.getId());
|
||||
|
||||
if (null == cmdChannel) {
|
||||
ctx.channel().writeAndFlush(ProxyMessage.buildErrMessage(ExceptionEnum.CONNECT_FAILED, "server error,cmd channel notfound!"));
|
||||
ctx.channel().close();
|
||||
return;
|
||||
}
|
||||
|
||||
Channel visitorChannel = ProxyUtil.getVisitorChannel(cmdChannel, udpBaseInfo.getVisitorId());
|
||||
if (null == visitorChannel) {
|
||||
return;
|
||||
}
|
||||
PortMappingDO portMappingDO = portMappingMapper.findByLicenseIdAndServerPort(licenseDO.getId(), udpBaseInfo.getServerPort());
|
||||
if (null == portMappingDO || !EnableStatusEnum.ENABLE.getStatus().equals(portMappingDO.getEnable())) {
|
||||
ctx.channel().writeAndFlush(ProxyMessage.buildErrMessage(ExceptionEnum.CONNECT_FAILED, "server error, port mapping notfound!"));
|
||||
ctx.channel().close();
|
||||
return;
|
||||
}
|
||||
|
||||
ctx.channel().attr(Constants.VISITOR_ID).set(udpBaseInfo.getVisitorId());
|
||||
ctx.channel().attr(Constants.LICENSE_ID).set(licenseDO.getId());
|
||||
ctx.channel().attr(Constants.NEXT_CHANNEL).set(visitorChannel);
|
||||
ctx.channel().attr(Constants.TARGET_IP).set(portMappingDO.getClientIp());
|
||||
ctx.channel().attr(Constants.TARGET_PORT).set(portMappingDO.getClientPort());
|
||||
ctx.channel().attr(Constants.PROXY_RESPONSES).set(portMappingDO.getProxyResponses());
|
||||
ctx.channel().attr(Constants.PROXY_TIMEOUT_MS).set(portMappingDO.getProxyTimeoutMs());
|
||||
visitorChannel.attr(Constants.NEXT_CHANNEL).set(ctx.channel());
|
||||
visitorChannel.attr(Constants.IS_UDP_KEY).set(Boolean.TRUE);
|
||||
// // 代理客户端与后端服务器连接成功,修改用户连接为可读状态
|
||||
// visitorChannel.config().setOption(ChannelOption.AUTO_READ, true);
|
||||
// 获取代理附加对象
|
||||
ProxyAttachment proxyAttachment = ProxyUtil.getProxyConnectAttachment(udpBaseInfo.getVisitorId());
|
||||
if (null != proxyAttachment) {
|
||||
// 及时释放
|
||||
ProxyUtil.remoteProxyConnectAttachment(udpBaseInfo.getVisitorId());
|
||||
proxyAttachment.execute();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return ProxyDataTypeEnum.UDP_CONNECT.getDesc();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package org.dromara.neutrinoproxy.server.proxy.handler;
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.socket.DatagramPacket;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.neutrinoproxy.core.Constants;
|
||||
import org.dromara.neutrinoproxy.core.ProxyDataTypeEnum;
|
||||
import org.dromara.neutrinoproxy.core.ProxyMessage;
|
||||
import org.dromara.neutrinoproxy.core.ProxyMessageHandler;
|
||||
import org.dromara.neutrinoproxy.core.dispatcher.Match;
|
||||
import org.dromara.neutrinoproxy.server.service.FlowReportService;
|
||||
import org.noear.snack.ONode;
|
||||
import org.noear.solon.Solon;
|
||||
import org.noear.solon.annotation.Component;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
/**
|
||||
* @author: aoshiguchen
|
||||
* @date: 2023/9/21
|
||||
*/
|
||||
@Slf4j
|
||||
@Match(type = Constants.ProxyDataTypeName.UDP_TRANSFER)
|
||||
@Component
|
||||
public class UdpProxyMessageTransferHandler implements ProxyMessageHandler {
|
||||
@Override
|
||||
public void handle(ChannelHandlerContext ctx, ProxyMessage proxyMessage) {
|
||||
final ProxyMessage.UdpBaseInfo udpBaseInfo = ONode.deserialize(proxyMessage.getInfo(), ProxyMessage.UdpBaseInfo.class);
|
||||
log.debug("[UDP transfer]info:{} data:{}", proxyMessage.getInfo(), new String(proxyMessage.getData()));
|
||||
|
||||
Channel visitorChannel = ctx.channel().attr(Constants.NEXT_CHANNEL).get();
|
||||
if (null != visitorChannel) {
|
||||
|
||||
if (!visitorChannel.isWritable()) {
|
||||
//自己不可写,通道可以读,让通道关闭读
|
||||
//自己可写,通道不可以读,让通道打开读
|
||||
if (ctx.channel().config().isAutoRead()) {
|
||||
ctx.channel().config().setAutoRead(false);
|
||||
}
|
||||
} else {
|
||||
if (ctx.channel().config().isAutoRead()) {
|
||||
ctx.channel().config().setAutoRead(true);
|
||||
}
|
||||
}
|
||||
|
||||
// InetSocketAddress address = new InetSocketAddress(udpBaseInfo.getVisitorIp(), udpBaseInfo.getVisitorPort());
|
||||
// ByteBuf byteBuf = Unpooled.copiedBuffer(proxyMessage.getData());
|
||||
// visitorChannel.writeAndFlush(new DatagramPacket(byteBuf, address));
|
||||
InetSocketAddress address = ctx.channel().attr(Constants.SENDER).get();
|
||||
if (null != address) {
|
||||
visitorChannel.writeAndFlush(new DatagramPacket(Unpooled.copiedBuffer(proxyMessage.getData()), address));
|
||||
}
|
||||
|
||||
// 增加流量计数(TODO 如果UDP映射服务端端口修改,这个似乎不准)
|
||||
Integer licenseId = visitorChannel.attr(Constants.LICENSE_ID).get();
|
||||
if (null != licenseId) {
|
||||
Solon.context().getBean(FlowReportService.class).addReadByte(licenseId, proxyMessage.getData().length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return ProxyDataTypeEnum.UDP_TRANSFER.getDesc();
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,8 +3,9 @@ package org.dromara.neutrinoproxy.server.service;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
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;
|
||||
@@ -16,11 +17,7 @@ import org.dromara.neutrinoproxy.server.dal.UserMapper;
|
||||
import org.dromara.neutrinoproxy.server.dal.entity.ClientConnectRecordDO;
|
||||
import org.dromara.neutrinoproxy.server.dal.entity.LicenseDO;
|
||||
import org.dromara.neutrinoproxy.server.dal.entity.UserDO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import ma.glasnost.orika.MapperFacade;
|
||||
import org.apache.ibatis.solon.annotation.Db;
|
||||
import org.noear.solon.annotation.Component;
|
||||
import org.noear.solon.annotation.Inject;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -35,8 +32,6 @@ import java.util.stream.Collectors;
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ClientConnectRecordService {
|
||||
@Inject
|
||||
private MapperFacade mapperFacade;
|
||||
@Db
|
||||
private ClientConnectRecordMapper clientConnectRecordMapper;
|
||||
@Db
|
||||
@@ -49,19 +44,18 @@ public class ClientConnectRecordService {
|
||||
}
|
||||
|
||||
public PageInfo<ClientConnectRecordListRes> page(PageQuery pageQuery, ClientConnectRecordListReq req) {
|
||||
Page<ClientConnectRecordListRes> result = PageHelper.startPage(pageQuery.getCurrent(), pageQuery.getSize());
|
||||
List<ClientConnectRecordDO> list = clientConnectRecordMapper.selectList(new LambdaQueryWrapper<ClientConnectRecordDO>()
|
||||
.eq(null != req.getLicenseId(), ClientConnectRecordDO::getLicenseId, req.getLicenseId())
|
||||
.orderByDesc(ClientConnectRecordDO::getId)
|
||||
Page<ClientConnectRecordDO> pageResult = clientConnectRecordMapper.selectPage(new Page<>(pageQuery.getCurrent(), pageQuery.getSize()), new LambdaQueryWrapper<ClientConnectRecordDO>()
|
||||
.eq(null != req.getLicenseId(), ClientConnectRecordDO::getLicenseId, req.getLicenseId())
|
||||
.orderByDesc(ClientConnectRecordDO::getId)
|
||||
);
|
||||
List<ClientConnectRecordListRes> respList = mapperFacade.mapAsList(list, ClientConnectRecordListRes.class);
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return PageInfo.of(respList, result.getTotal(), pageQuery.getCurrent(), pageQuery.getSize());
|
||||
List<ClientConnectRecordListRes> respList = pageResult.getRecords().stream().map(ClientConnectRecordDO::toRes).collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(pageResult.getRecords())) {
|
||||
return PageInfo.of(respList, pageResult.getTotal(), pageQuery.getCurrent(), pageQuery.getSize());
|
||||
}
|
||||
Set<Integer> licenseIds = respList.stream().map(ClientConnectRecordListRes::getLicenseId).collect(Collectors.toSet());
|
||||
List<LicenseDO> licenseList = licenseMapper.findByIds(licenseIds);
|
||||
if (CollectionUtil.isEmpty(licenseList)) {
|
||||
return PageInfo.of(respList, result.getTotal(), pageQuery.getCurrent(), pageQuery.getSize());
|
||||
return PageInfo.of(respList, pageResult.getTotal(), pageQuery.getCurrent(), pageQuery.getSize());
|
||||
}
|
||||
Set<Integer> userIds = licenseList.stream().map(LicenseDO::getUserId).collect(Collectors.toSet());
|
||||
List<UserDO> userList = userMapper.findByIds(userIds);
|
||||
@@ -85,6 +79,6 @@ public class ClientConnectRecordService {
|
||||
item.setMsg("******");
|
||||
}
|
||||
});
|
||||
return PageInfo.of(respList, result.getTotal(), pageQuery.getCurrent(), pageQuery.getSize());
|
||||
return PageInfo.of(respList, pageResult);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,10 @@ package org.dromara.neutrinoproxy.server.service;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.baomidou.mybatisplus.solon.plugins.pagination.Page;
|
||||
import com.google.common.collect.Lists;
|
||||
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.constant.EnableStatusEnum;
|
||||
@@ -19,11 +20,13 @@ import org.dromara.neutrinoproxy.server.controller.res.system.JobInfoUpdateEnabl
|
||||
import org.dromara.neutrinoproxy.server.controller.res.system.JobInfoUpdateRes;
|
||||
import org.dromara.neutrinoproxy.server.dal.JobInfoMapper;
|
||||
import org.dromara.neutrinoproxy.server.dal.entity.JobInfoDO;
|
||||
import org.dromara.neutrinoproxy.server.job.*;
|
||||
import org.dromara.neutrinoproxy.server.job.DataCleanJob;
|
||||
import org.dromara.neutrinoproxy.server.job.DemoJob;
|
||||
import org.dromara.neutrinoproxy.server.job.FlowReportForDayJob;
|
||||
import org.dromara.neutrinoproxy.server.job.FlowReportForHourJob;
|
||||
import org.dromara.neutrinoproxy.server.job.FlowReportForMinuteJob;
|
||||
import org.dromara.neutrinoproxy.server.job.FlowReportForMonthJob;
|
||||
import org.dromara.neutrinoproxy.server.util.ParamCheckUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import ma.glasnost.orika.MapperFacade;
|
||||
import org.apache.ibatis.solon.annotation.Db;
|
||||
import org.dromara.solonplugins.job.IJobHandler;
|
||||
import org.dromara.solonplugins.job.IJobSource;
|
||||
import org.dromara.solonplugins.job.JobInfo;
|
||||
@@ -32,22 +35,18 @@ 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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author: aoshiguchen
|
||||
* @date: 2022/9/5
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class JobInfoService implements IJobSource {
|
||||
@Inject
|
||||
private MapperFacade mapperFacade;
|
||||
@Db
|
||||
private JobInfoMapper jobInfoMapper;
|
||||
@Inject
|
||||
@@ -66,21 +65,24 @@ public class JobInfoService implements IJobSource {
|
||||
|
||||
@Init
|
||||
public void init() {
|
||||
jobHandlerMap.put("DataCleanJob", dataCleanJob);
|
||||
jobHandlerMap.put("DemoJob", demoJob);
|
||||
jobHandlerMap.put("FlowReportForDayJob", flowReportForDayJob);
|
||||
jobHandlerMap.put("FlowReportForHourJob", flowReportForHourJob);
|
||||
jobHandlerMap.put("FlowReportForMinuteJob", flowReportForMinuteJob);
|
||||
jobHandlerMap.put("FlowReportForMonthJob", flowReportForMonthJob);
|
||||
// aot 阶段,不初始化
|
||||
if (NativeDetector.isAotRuntime()) {
|
||||
return;
|
||||
}
|
||||
jobHandlerMap.put("DataCleanJob", dataCleanJob);
|
||||
jobHandlerMap.put("DemoJob", demoJob);
|
||||
jobHandlerMap.put("FlowReportForDayJob", flowReportForDayJob);
|
||||
jobHandlerMap.put("FlowReportForHourJob", flowReportForHourJob);
|
||||
jobHandlerMap.put("FlowReportForMinuteJob", flowReportForMinuteJob);
|
||||
jobHandlerMap.put("FlowReportForMonthJob", flowReportForMonthJob);
|
||||
}
|
||||
|
||||
public PageInfo<JobInfoListRes> page(PageQuery pageQuery, JobInfoListReq req) {
|
||||
Page<JobInfoListRes> result = PageHelper.startPage(pageQuery.getCurrent(), pageQuery.getSize());
|
||||
List<JobInfoDO> list = jobInfoMapper.selectList(new LambdaQueryWrapper<JobInfoDO>()
|
||||
.orderByAsc(JobInfoDO::getId)
|
||||
Page<JobInfoDO> page = jobInfoMapper.selectPage(new Page<>(pageQuery.getCurrent(), pageQuery.getSize()), new LambdaQueryWrapper<JobInfoDO>()
|
||||
.orderByAsc(JobInfoDO::getId)
|
||||
);
|
||||
List<JobInfoListRes> respList = mapperFacade.mapAsList(list, JobInfoListRes.class);
|
||||
return PageInfo.of(respList, result.getTotal(), pageQuery.getCurrent(), pageQuery.getSize());
|
||||
List<JobInfoListRes> respList = page.getRecords().stream().map(JobInfoDO::toRes).collect(Collectors.toList());
|
||||
return PageInfo.of(respList, page);
|
||||
}
|
||||
|
||||
public List<JobInfoDO> findList() {
|
||||
@@ -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)) {
|
||||
@@ -114,13 +120,13 @@ public class JobInfoService implements IJobSource {
|
||||
}
|
||||
for (JobInfoDO item : jobInfoDOList) {
|
||||
jobInfoList.add(new JobInfo()
|
||||
.setId(String.valueOf(item.getId()))
|
||||
.setName(item.getHandler())
|
||||
.setDesc(item.getDesc())
|
||||
.setCron(item.getCron())
|
||||
.setParam(item.getParam())
|
||||
.setEnable(EnableStatusEnum.ENABLE.getStatus().equals(item.getEnable()))
|
||||
.setJobHandler(jobHandlerMap.get(item.getHandler()))
|
||||
.setId(String.valueOf(item.getId()))
|
||||
.setName(item.getHandler())
|
||||
.setDesc(item.getDesc())
|
||||
.setCron(item.getCron())
|
||||
.setParam(item.getParam())
|
||||
.setEnable(EnableStatusEnum.ENABLE.getStatus().equals(item.getEnable()))
|
||||
.setJobHandler(jobHandlerMap.get(item.getHandler()))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -128,8 +134,8 @@ public class JobInfoService implements IJobSource {
|
||||
}
|
||||
|
||||
public JobInfoUpdateRes update(JobInfoUpdateReq req) {
|
||||
JobInfoDO jobInfoDO = jobInfoMapper.findById(req.getId());
|
||||
ParamCheckUtil.checkNotNull( jobInfoDO, ExceptionConstant.PORT_MAPPING_NOT_EXIST);
|
||||
JobInfoDO jobInfoDO = jobInfoMapper.findById(req.getId());
|
||||
ParamCheckUtil.checkNotNull(jobInfoDO, ExceptionConstant.PORT_MAPPING_NOT_EXIST);
|
||||
JobInfoDO jobInfo = new JobInfoDO();
|
||||
jobInfo.setId(req.getId());
|
||||
jobInfo.setCron(req.getCron());
|
||||
|
||||
@@ -22,25 +22,25 @@
|
||||
package org.dromara.neutrinoproxy.server.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.baomidou.mybatisplus.solon.plugins.pagination.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
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.controller.req.log.JobLogListReq;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.log.JobLogListRes;
|
||||
import org.dromara.neutrinoproxy.server.dal.JobLogMapper;
|
||||
import org.dromara.neutrinoproxy.server.dal.entity.JobLogDO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import ma.glasnost.orika.MapperFacade;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.apache.ibatis.solon.annotation.Db;
|
||||
import org.dromara.solonplugins.job.IJobCallback;
|
||||
import org.dromara.solonplugins.job.JobInfo;
|
||||
import org.noear.solon.annotation.Component;
|
||||
import org.noear.solon.annotation.Inject;
|
||||
import org.noear.solon.core.runtime.NativeDetector;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -50,21 +50,23 @@ import java.util.List;
|
||||
@Slf4j
|
||||
@Component
|
||||
public class JobLogService implements IJobCallback {
|
||||
@Inject
|
||||
private MapperFacade mapperFacade;
|
||||
@Db
|
||||
private JobLogMapper jobLogMapper;
|
||||
|
||||
@Override
|
||||
public void executeLog(JobInfo jobInfo, String param, Throwable throwable) {
|
||||
// aot 阶段,不查数据库
|
||||
if (NativeDetector.isAotRuntime()) {
|
||||
return;
|
||||
}
|
||||
Integer code = 0;
|
||||
String msg = "";
|
||||
if (null == throwable) {
|
||||
msg = "执行成功";
|
||||
log.debug("job[id={},name={}]执行完毕", jobInfo.getId(), jobInfo.getName());
|
||||
msg = "execute success";
|
||||
log.debug("job[id={},name={}]execute success", jobInfo.getId(), jobInfo.getName());
|
||||
} else {
|
||||
log.error("job[id={},name={}]执行异常", jobInfo.getId(), jobInfo.getName(), throwable);
|
||||
msg = "执行异常:\r\n" + ExceptionUtils.getStackTrace(throwable);
|
||||
log.error("job[id={},name={}]execute error", jobInfo.getId(), jobInfo.getName(), throwable);
|
||||
msg = "execute error:\r\n" + ExceptionUtils.getStackTrace(throwable);
|
||||
code = -1;
|
||||
}
|
||||
jobLogMapper.insert(new JobLogDO()
|
||||
@@ -79,13 +81,12 @@ public class JobLogService implements IJobCallback {
|
||||
}
|
||||
|
||||
public PageInfo<JobLogListRes> page(PageQuery pageQuery, JobLogListReq req) {
|
||||
Page<JobLogListRes> result = PageHelper.startPage(pageQuery.getCurrent(), pageQuery.getSize());
|
||||
List<JobLogDO> list = jobLogMapper.selectList(new LambdaQueryWrapper<JobLogDO>()
|
||||
.eq(null != req.getJobId(), JobLogDO::getJobId, req.getJobId())
|
||||
.orderByDesc(JobLogDO::getId)
|
||||
);
|
||||
List<JobLogListRes> respList = mapperFacade.mapAsList(list, JobLogListRes.class);
|
||||
return PageInfo.of(respList, result.getTotal(), pageQuery.getCurrent(), pageQuery.getSize());
|
||||
Page<JobLogDO> page = jobLogMapper.selectPage(new Page<>(pageQuery.getCurrent(), pageQuery.getSize()), new LambdaQueryWrapper<JobLogDO>()
|
||||
.eq(null != req.getJobId(), JobLogDO::getJobId, req.getJobId())
|
||||
.orderByDesc(JobLogDO::getId)
|
||||
);
|
||||
List<JobLogListRes> respList = page.getRecords().stream().map(JobLogDO::toRes).collect(Collectors.toList());
|
||||
return PageInfo.of(respList, page);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
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.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.baomidou.mybatisplus.solon.plugins.pagination.Page;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.apache.ibatis.solon.annotation.Db;
|
||||
import org.dromara.neutrinoproxy.server.base.db.DBInitialize;
|
||||
import org.dromara.neutrinoproxy.server.base.page.PageInfo;
|
||||
import org.dromara.neutrinoproxy.server.base.page.PageQuery;
|
||||
import org.dromara.neutrinoproxy.server.base.rest.ServiceException;
|
||||
import org.dromara.neutrinoproxy.server.base.rest.SystemContextHolder;
|
||||
import org.dromara.neutrinoproxy.server.constant.EnableStatusEnum;
|
||||
import org.dromara.neutrinoproxy.server.constant.ExceptionConstant;
|
||||
@@ -17,242 +21,324 @@ import org.dromara.neutrinoproxy.server.controller.req.proxy.LicenseCreateReq;
|
||||
import org.dromara.neutrinoproxy.server.controller.req.proxy.LicenseListReq;
|
||||
import org.dromara.neutrinoproxy.server.controller.req.proxy.LicenseUpdateEnableStatusReq;
|
||||
import org.dromara.neutrinoproxy.server.controller.req.proxy.LicenseUpdateReq;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.proxy.*;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.proxy.LicenseCreateRes;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.proxy.LicenseDetailRes;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.proxy.LicenseListRes;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.proxy.LicenseUpdateEnableStatusRes;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.proxy.LicenseUpdateRes;
|
||||
import org.dromara.neutrinoproxy.server.dal.LicenseMapper;
|
||||
import org.dromara.neutrinoproxy.server.dal.PortMappingMapper;
|
||||
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 ma.glasnost.orika.MapperFacade;
|
||||
import org.apache.ibatis.solon.annotation.Db;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.proxy.*;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
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.Lifecycle;
|
||||
import org.noear.solon.core.bean.LifecycleBean;
|
||||
import org.noear.solon.core.runtime.NativeDetector;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* license服务
|
||||
*
|
||||
* @author: aoshiguchen
|
||||
* @date: 2022/8/6
|
||||
*/
|
||||
@Component
|
||||
public class LicenseService implements LifecycleBean {
|
||||
@Inject
|
||||
private MapperFacade mapperFacade;
|
||||
@Db
|
||||
private LicenseMapper licenseMapper;
|
||||
@Db
|
||||
private UserMapper userMapper;
|
||||
@Inject
|
||||
private VisitorChannelService visitorChannelService;
|
||||
@Inject
|
||||
private DBInitialize dbInitialize;
|
||||
@Db
|
||||
private LicenseMapper licenseMapper;
|
||||
@Db
|
||||
private PortMappingMapper portMappingMapper;
|
||||
@Db
|
||||
private UserMapper userMapper;
|
||||
@Inject
|
||||
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<LicenseListRes> result = PageHelper.startPage(pageQuery.getCurrent(), pageQuery.getSize());
|
||||
List<LicenseDO> list = licenseMapper.selectList(new LambdaQueryWrapper<LicenseDO>()
|
||||
.eq(req.getUserId() != null, LicenseDO::getUserId, req.getUserId())
|
||||
.eq(req.getIsOnline() != null, LicenseDO::getIsOnline, req.getIsOnline())
|
||||
.eq(req.getEnable() != null, LicenseDO::getEnable, req.getEnable())
|
||||
.orderByAsc(Arrays.asList(LicenseDO::getUserId, LicenseDO::getId))
|
||||
);
|
||||
List<LicenseListRes> respList = mapperFacade.mapAsList(list, LicenseListRes.class);
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return PageInfo.of(respList, result.getTotal(), pageQuery.getCurrent(), pageQuery.getSize());
|
||||
}
|
||||
if (!CollectionUtil.isEmpty(respList)) {
|
||||
Set<Integer> userIds = respList.stream().map(LicenseListRes::getUserId).collect(Collectors.toSet());
|
||||
List<UserDO> userList = userMapper.findByIds(userIds);
|
||||
Map<Integer, UserDO> userMap = userList.stream().collect(Collectors.toMap(UserDO::getId, Function.identity()));
|
||||
for (LicenseListRes item : respList) {
|
||||
UserDO userDO = userMap.get(item.getUserId());
|
||||
if (null != userDO) {
|
||||
item.setUserName(userDO.getName());
|
||||
}
|
||||
item.setKey(desensitization(item.getUserId(), item.getKey()));
|
||||
}
|
||||
}
|
||||
return PageInfo.of(respList, result.getTotal(), pageQuery.getCurrent(), pageQuery.getSize());
|
||||
}
|
||||
public PageInfo<LicenseListRes> page(PageQuery pageQuery, LicenseListReq req) {
|
||||
Page<LicenseDO> page = licenseMapper.selectPage(new Page<>(pageQuery.getCurrent(), pageQuery.getSize()), new LambdaQueryWrapper<LicenseDO>()
|
||||
.eq(req.getUserId() != null, LicenseDO::getUserId, req.getUserId())
|
||||
.eq(req.getIsOnline() != null, LicenseDO::getIsOnline, req.getIsOnline())
|
||||
.eq(req.getEnable() != null, LicenseDO::getEnable, req.getEnable())
|
||||
.orderByAsc(Arrays.asList(LicenseDO::getUserId, LicenseDO::getId))
|
||||
);
|
||||
List<LicenseListRes> respList = page.getRecords().stream().map(LicenseDO::toRes).collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(page.getRecords())) {
|
||||
return PageInfo.of(respList, page);
|
||||
}
|
||||
if (!CollectionUtil.isEmpty(respList)) {
|
||||
Set<Integer> userIds = respList.stream().map(LicenseListRes::getUserId).collect(Collectors.toSet());
|
||||
List<UserDO> userList = userMapper.findByIds(userIds);
|
||||
Map<Integer, UserDO> userMap = userList.stream().collect(Collectors.toMap(UserDO::getId, Function.identity()));
|
||||
for (LicenseListRes item : respList) {
|
||||
UserDO userDO = userMap.get(item.getUserId());
|
||||
if (null != userDO) {
|
||||
item.setUserName(userDO.getName());
|
||||
}
|
||||
item.setKey(desensitization(item.getUserId(), item.getKey()));
|
||||
}
|
||||
}
|
||||
return PageInfo.of(respList, page);
|
||||
}
|
||||
|
||||
public List<LicenseListRes> list(LicenseListReq req) {
|
||||
List<LicenseDO> list = licenseMapper.selectList(new LambdaQueryWrapper<LicenseDO>()
|
||||
.eq(null != req.getEnable(), LicenseDO::getEnable, req.getEnable())
|
||||
);
|
||||
List<LicenseListRes> licenseList = assembleConvertLicenses(list);
|
||||
return licenseList;
|
||||
}
|
||||
public List<LicenseListRes> list(LicenseListReq req) {
|
||||
List<LicenseDO> list = licenseMapper.selectList(new LambdaQueryWrapper<LicenseDO>()
|
||||
.eq(null != req.getEnable(), LicenseDO::getEnable, req.getEnable())
|
||||
);
|
||||
List<LicenseListRes> licenseList = assembleConvertLicenses(list);
|
||||
return licenseList;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private List<LicenseListRes> assembleConvertLicenses(List<LicenseDO> list) {
|
||||
List<LicenseListRes> licenseList = mapperFacade.mapAsList(list, LicenseListRes.class);
|
||||
if (!CollectionUtil.isEmpty(licenseList)) {
|
||||
Set<Integer> userIds = licenseList.stream().map(LicenseListRes::getUserId).collect(Collectors.toSet());
|
||||
List<UserDO> userList = userMapper.findByIds(userIds);
|
||||
Map<Integer, UserDO> userMap = userList.stream().collect(Collectors.toMap(UserDO::getId, Function.identity()));
|
||||
for (LicenseListRes item : licenseList) {
|
||||
UserDO userDO = userMap.get(item.getUserId());
|
||||
if (null != userDO) {
|
||||
item.setUserName(userDO.getName());
|
||||
}
|
||||
item.setKey(desensitization(item.getUserId(), item.getKey()));
|
||||
}
|
||||
}
|
||||
return licenseList;
|
||||
}
|
||||
private List<LicenseListRes> assembleConvertLicenses(List<LicenseDO> list) {
|
||||
List<LicenseListRes> licenseList = list.stream().map(LicenseDO::toRes).collect(Collectors.toList());
|
||||
if (!CollectionUtil.isEmpty(licenseList)) {
|
||||
Set<Integer> userIds = licenseList.stream().map(LicenseListRes::getUserId).collect(Collectors.toSet());
|
||||
List<UserDO> userList = userMapper.findByIds(userIds);
|
||||
Map<Integer, UserDO> userMap = userList.stream().collect(Collectors.toMap(UserDO::getId, Function.identity()));
|
||||
for (LicenseListRes item : licenseList) {
|
||||
UserDO userDO = userMap.get(item.getUserId());
|
||||
if (null != userDO) {
|
||||
item.setUserName(userDO.getName());
|
||||
}
|
||||
item.setKey(desensitization(item.getUserId(), item.getKey()));
|
||||
}
|
||||
}
|
||||
return licenseList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建license
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
public LicenseCreateRes create(LicenseCreateReq req) {
|
||||
LicenseDO licenseDO = licenseMapper.checkRepeat(req.getUserId(), req.getName());
|
||||
ParamCheckUtil.checkExpression(null == licenseDO, ExceptionConstant.LICENSE_NAME_CANNOT_REPEAT);
|
||||
/**
|
||||
* 创建license
|
||||
*
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
public LicenseCreateRes create(LicenseCreateReq req) {
|
||||
LicenseDO licenseDO = licenseMapper.checkRepeat(req.getUserId(), req.getName());
|
||||
ParamCheckUtil.checkExpression(null == licenseDO, ExceptionConstant.LICENSE_NAME_CANNOT_REPEAT);
|
||||
|
||||
String key = UUID.randomUUID().toString().replaceAll("-", "");
|
||||
Date now = new Date();
|
||||
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)
|
||||
);
|
||||
return new LicenseCreateRes();
|
||||
}
|
||||
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);
|
||||
|
||||
public LicenseUpdateRes update(LicenseUpdateReq req) {
|
||||
LicenseDO oldLicenseDO = licenseMapper.findById(req.getId());
|
||||
ParamCheckUtil.checkNotNull(oldLicenseDO, ExceptionConstant.LICENSE_NOT_EXIST);
|
||||
licenseMapper.insert(licenseDO);
|
||||
|
||||
LicenseDO licenseCheck = licenseMapper.checkRepeat(oldLicenseDO.getUserId(), req.getName(), Sets.newHashSet(oldLicenseDO.getId()));
|
||||
ParamCheckUtil.checkMustNull(licenseCheck, ExceptionConstant.LICENSE_NAME_CANNOT_REPEAT);
|
||||
// 刷新流量限制缓存
|
||||
refreshFlowLimitCache(licenseDO.getId(), licenseDO.getUpLimitRate(), licenseDO.getDownLimitRate());
|
||||
return new LicenseCreateRes();
|
||||
}
|
||||
|
||||
licenseMapper.update(req.getId(), req.getName(), new Date());
|
||||
return new LicenseUpdateRes();
|
||||
}
|
||||
public LicenseUpdateRes update(LicenseUpdateReq req) {
|
||||
LicenseDO oldLicenseDO = licenseMapper.findById(req.getId());
|
||||
ParamCheckUtil.checkNotNull(oldLicenseDO, ExceptionConstant.LICENSE_NOT_EXIST);
|
||||
|
||||
public LicenseDetailRes detail(Integer id) {
|
||||
LicenseDO licenseDO = licenseMapper.findById(id);
|
||||
if (null == licenseDO) {
|
||||
return null;
|
||||
}
|
||||
UserDO userDO = userMapper.findById(licenseDO.getUserId());
|
||||
String userName = "";
|
||||
if (null != userDO) {
|
||||
userName = userDO.getName();
|
||||
}
|
||||
return new LicenseDetailRes()
|
||||
.setId(licenseDO.getId())
|
||||
.setName(licenseDO.getName())
|
||||
.setKey(desensitization(licenseDO.getUserId(), licenseDO.getKey()))
|
||||
.setUserId(licenseDO.getUserId())
|
||||
.setUserName(userName)
|
||||
.setIsOnline(licenseDO.getIsOnline())
|
||||
.setEnable(licenseDO.getEnable())
|
||||
.setCreateTime(licenseDO.getCreateTime())
|
||||
.setUpdateTime(licenseDO.getUpdateTime())
|
||||
;
|
||||
}
|
||||
LicenseDO licenseCheck = licenseMapper.checkRepeat(oldLicenseDO.getUserId(), req.getName(), Sets.newHashSet(oldLicenseDO.getId()));
|
||||
ParamCheckUtil.checkMustNull(licenseCheck, ExceptionConstant.LICENSE_NAME_CANNOT_REPEAT);
|
||||
|
||||
/**
|
||||
* 更新license启用状态
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
public LicenseUpdateEnableStatusRes updateEnableStatus(LicenseUpdateEnableStatusReq req) {
|
||||
licenseMapper.updateEnableStatus(req.getId(), req.getEnable(), new Date());
|
||||
// 更新VisitorChannel
|
||||
visitorChannelService.updateVisitorChannelByLicenseId(req.getId(), req.getEnable());
|
||||
return new LicenseUpdateEnableStatusRes();
|
||||
}
|
||||
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())
|
||||
);
|
||||
|
||||
/**
|
||||
* 删除license
|
||||
* @param id
|
||||
*/
|
||||
public void delete(Integer id) {
|
||||
licenseMapper.deleteById(id);
|
||||
// 更新VisitorChannel
|
||||
visitorChannelService.updateVisitorChannelByLicenseId(id, EnableStatusEnum.DISABLE.getStatus());
|
||||
}
|
||||
// 刷新流量限制缓存
|
||||
refreshFlowLimitCache(req.getId(), req.getUpLimitRate(), req.getDownLimitRate());
|
||||
|
||||
/**
|
||||
* 重置license
|
||||
* @param id
|
||||
*/
|
||||
public void reset(Integer id) {
|
||||
String key = UUID.randomUUID().toString().replaceAll("-", "");
|
||||
Date now = new Date();
|
||||
return new LicenseUpdateRes();
|
||||
}
|
||||
|
||||
licenseMapper.reset(id, key, now);
|
||||
}
|
||||
public LicenseDetailRes detail(Integer id) {
|
||||
LicenseDO licenseDO = licenseMapper.findById(id);
|
||||
if (null == licenseDO) {
|
||||
return null;
|
||||
}
|
||||
UserDO userDO = userMapper.findById(licenseDO.getUserId());
|
||||
String userName = "";
|
||||
if (null != userDO) {
|
||||
userName = userDO.getName();
|
||||
}
|
||||
return new LicenseDetailRes()
|
||||
.setId(licenseDO.getId())
|
||||
.setName(licenseDO.getName())
|
||||
.setKey(desensitization(licenseDO.getUserId(), licenseDO.getKey()))
|
||||
.setUserId(licenseDO.getUserId())
|
||||
.setUserName(userName)
|
||||
.setIsOnline(licenseDO.getIsOnline())
|
||||
.setEnable(licenseDO.getEnable())
|
||||
.setCreateTime(licenseDO.getCreateTime())
|
||||
.setUpdateTime(licenseDO.getUpdateTime())
|
||||
;
|
||||
}
|
||||
|
||||
public LicenseDO findByKey(String license) {
|
||||
return licenseMapper.findByKey(license);
|
||||
}
|
||||
/**
|
||||
* 更新license启用状态
|
||||
*
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
public LicenseUpdateEnableStatusRes updateEnableStatus(LicenseUpdateEnableStatusReq req) {
|
||||
licenseMapper.updateEnableStatus(req.getId(), req.getEnable(), new Date());
|
||||
// 更新VisitorChannel
|
||||
visitorChannelService.updateVisitorChannelByLicenseId(req.getId(), req.getEnable());
|
||||
return new LicenseUpdateEnableStatusRes();
|
||||
}
|
||||
|
||||
/**
|
||||
* 脱敏处理
|
||||
* 非当前登录人的license,一律脱敏
|
||||
* @param userId
|
||||
* @param licenseKey
|
||||
* @return
|
||||
*/
|
||||
private String desensitization(Integer userId, String licenseKey) {
|
||||
Integer currentUserId = SystemContextHolder.getUser().getId();
|
||||
if (currentUserId.equals(userId)) {
|
||||
return licenseKey;
|
||||
}
|
||||
return licenseKey.substring(0, 10) + "****" + licenseKey.substring(licenseKey.length() - 10);
|
||||
}
|
||||
/**
|
||||
* 删除license
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
public void delete(Integer id) {
|
||||
List<PortMappingDO> portMappingDOList = portMappingMapper.findListByLicenseId(id);
|
||||
if (CollectionUtil.isNotEmpty(portMappingDOList)) {
|
||||
throw ServiceException.create(ExceptionConstant.LICENSE_CANNOT_BE_DELETED, portMappingDOList.size());
|
||||
}
|
||||
licenseMapper.deleteById(id);
|
||||
// 更新VisitorChannel
|
||||
visitorChannelService.updateVisitorChannelByLicenseId(id, EnableStatusEnum.DISABLE.getStatus());
|
||||
// 删除流量限制缓存
|
||||
flowLimitCache.remove(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 服务端项目停止、启动时,更新在线状态为离线
|
||||
*/
|
||||
@Init
|
||||
public void init() {
|
||||
licenseMapper.updateOnlineStatus(OnlineStatusEnum.OFFLINE.getStatus(), new Date());
|
||||
}
|
||||
/**
|
||||
* 重置license
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
public void reset(Integer id) {
|
||||
String key = UUID.randomUUID().toString().replaceAll("-", "");
|
||||
Date now = new Date();
|
||||
|
||||
licenseMapper.reset(id, key, now);
|
||||
}
|
||||
|
||||
public LicenseDO findByKey(String license) {
|
||||
return licenseMapper.findByKey(license);
|
||||
}
|
||||
|
||||
/**
|
||||
* 脱敏处理
|
||||
* 非当前登录人的license,一律脱敏
|
||||
*
|
||||
* @param userId
|
||||
* @param licenseKey
|
||||
* @return
|
||||
*/
|
||||
private String desensitization(Integer userId, String licenseKey) {
|
||||
Integer currentUserId = SystemContextHolder.getUser().getId();
|
||||
if (currentUserId.equals(userId)) {
|
||||
return licenseKey;
|
||||
}
|
||||
return licenseKey.substring(0, 10) + "****" + licenseKey.substring(licenseKey.length() - 10);
|
||||
}
|
||||
|
||||
/**
|
||||
* 服务端项目停止、启动时,更新在线状态为离线
|
||||
*/
|
||||
@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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void start() throws Throwable {
|
||||
/**
|
||||
* 刷新流量限制缓存
|
||||
* @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 stop() throws Throwable {
|
||||
licenseMapper.updateOnlineStatus(OnlineStatusEnum.OFFLINE.getStatus(), new Date());
|
||||
}
|
||||
@Override
|
||||
public void start() throws Throwable {
|
||||
|
||||
/**
|
||||
* 查询当前角色下的license,若为管理员 则返回全部license
|
||||
*/
|
||||
public List<LicenseListRes> queryCurUserLicense(LicenseListReq req) {
|
||||
if(SystemContextHolder.isAdmin()){
|
||||
return this.list(req);
|
||||
}
|
||||
}
|
||||
|
||||
List<LicenseDO> list = licenseMapper.selectList(new LambdaQueryWrapper<LicenseDO>()
|
||||
.eq(LicenseDO::getEnable, EnableStatusEnum.ENABLE.getStatus())
|
||||
.eq(LicenseDO::getUserId,SystemContextHolder.getUserId())
|
||||
);
|
||||
List<LicenseListRes> licenseList = assembleConvertLicenses(list);
|
||||
return licenseList;
|
||||
}
|
||||
/**
|
||||
* 服务端项目停止、启动时,更新在线状态为离线
|
||||
*/
|
||||
@Override
|
||||
public void stop() throws Throwable {
|
||||
licenseMapper.updateOnlineStatus(OnlineStatusEnum.OFFLINE.getStatus(), new Date());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询当前角色下的license,若为管理员 则返回全部license
|
||||
*/
|
||||
public List<LicenseListRes> queryCurUserLicense(LicenseListReq req) {
|
||||
if (SystemContextHolder.isAdmin()) {
|
||||
return this.list(req);
|
||||
}
|
||||
|
||||
List<LicenseDO> list = licenseMapper.selectList(new LambdaQueryWrapper<LicenseDO>()
|
||||
.eq(LicenseDO::getEnable, EnableStatusEnum.ENABLE.getStatus())
|
||||
.eq(LicenseDO::getUserId, SystemContextHolder.getUserId())
|
||||
);
|
||||
List<LicenseListRes> licenseList = assembleConvertLicenses(list);
|
||||
return licenseList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package org.dromara.neutrinoproxy.server.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.baomidou.mybatisplus.solon.plugins.pagination.Page;
|
||||
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.ServiceException;
|
||||
@@ -21,10 +21,7 @@ import org.dromara.neutrinoproxy.server.dal.PortPoolMapper;
|
||||
import org.dromara.neutrinoproxy.server.dal.entity.PortGroupDO;
|
||||
import org.dromara.neutrinoproxy.server.dal.entity.PortPoolDO;
|
||||
import org.dromara.neutrinoproxy.server.util.ParamCheckUtil;
|
||||
import ma.glasnost.orika.MapperFacade;
|
||||
import org.apache.ibatis.solon.annotation.Db;
|
||||
import org.noear.solon.annotation.Component;
|
||||
import org.noear.solon.annotation.Inject;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -36,9 +33,6 @@ import java.util.Objects;
|
||||
@Component
|
||||
public class PortGroupService {
|
||||
|
||||
@Inject
|
||||
private MapperFacade mapperFacade;
|
||||
|
||||
@Db
|
||||
private PortGroupMapper portGroupMapper;
|
||||
|
||||
@@ -64,14 +58,14 @@ public class PortGroupService {
|
||||
}
|
||||
|
||||
public PageInfo<PortGroupListRes> page(PageQuery pageQuery, PortGroupListReq req) {
|
||||
Page<PortGroupListRes> result = PageHelper.startPage(pageQuery.getCurrent(), pageQuery.getSize());
|
||||
List<PortGroupListRes> list = portGroupMapper.selectPortGroupListResList(req);
|
||||
Page<PortGroupListRes> page = new Page<>(pageQuery.getCurrent(), pageQuery.getSize());
|
||||
List<PortGroupListRes> list = portGroupMapper.selectPortGroupListResList(page, req);
|
||||
|
||||
return PageInfo.of(list, result.getTotal(), pageQuery.getCurrent(), pageQuery.getSize());
|
||||
return PageInfo.of(list, page.getTotal(), pageQuery.getCurrent(), pageQuery.getSize());
|
||||
}
|
||||
|
||||
public List<PortGroupListRes> list(PortGroupListReq req) {
|
||||
List<PortGroupListRes> list = portGroupMapper.selectPortGroupListResList(req);
|
||||
List<PortGroupListRes> list = portGroupMapper.selectPortGroupListResList(null, req);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
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.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.solon.plugins.pagination.Page;
|
||||
import com.google.common.collect.Sets;
|
||||
import ma.glasnost.orika.MapperFacade;
|
||||
import org.apache.ibatis.solon.annotation.Db;
|
||||
import org.dromara.neutrinoproxy.server.base.db.DBInitialize;
|
||||
import org.dromara.neutrinoproxy.server.base.page.PageInfo;
|
||||
@@ -23,7 +26,11 @@ import org.dromara.neutrinoproxy.server.controller.req.proxy.PortMappingCreateRe
|
||||
import org.dromara.neutrinoproxy.server.controller.req.proxy.PortMappingListReq;
|
||||
import org.dromara.neutrinoproxy.server.controller.req.proxy.PortMappingUpdateEnableStatusReq;
|
||||
import org.dromara.neutrinoproxy.server.controller.req.proxy.PortMappingUpdateReq;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.proxy.*;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.proxy.PortMappingCreateRes;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.proxy.PortMappingDetailRes;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.proxy.PortMappingListRes;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.proxy.PortMappingUpdateEnableStatusRes;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.proxy.PortMappingUpdateRes;
|
||||
import org.dromara.neutrinoproxy.server.dal.LicenseMapper;
|
||||
import org.dromara.neutrinoproxy.server.dal.PortMappingMapper;
|
||||
import org.dromara.neutrinoproxy.server.dal.PortPoolMapper;
|
||||
@@ -32,14 +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.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -49,8 +60,6 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
@Component
|
||||
public class PortMappingService implements LifecycleBean {
|
||||
@Inject
|
||||
private MapperFacade mapperFacade;
|
||||
@Db
|
||||
private PortMappingMapper portMappingMapper;
|
||||
@Db
|
||||
@@ -68,9 +77,19 @@ 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) {
|
||||
Page<PortMappingListRes> result = PageHelper.startPage(pageQuery.getCurrent(), pageQuery.getSize());
|
||||
if (StringUtils.isNotEmpty(req.getDescription())) {
|
||||
//描述字段为模糊查询,在应用层处理,否则sqlite不支持
|
||||
req.setDescription("%" + req.getDescription() + "%");
|
||||
@@ -82,16 +101,17 @@ public class PortMappingService implements LifecycleBean {
|
||||
req.setProtocal(networkProtocolEnum.getDesc());
|
||||
}
|
||||
|
||||
List<PortMappingDO> list = portMappingMapper.selectPortMappingByCondition(req);
|
||||
List<PortMappingListRes> respList = mapperFacade.mapAsList(list, PortMappingListRes.class);
|
||||
Page<PortMappingDO> page = new Page<>(pageQuery.getCurrent(), pageQuery.getSize());
|
||||
List<PortMappingDO> list = portMappingMapper.selectPortMappingByCondition(page, req);
|
||||
List<PortMappingListRes> respList = list.stream().map(PortMappingDO::toRes).collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return PageInfo.of(respList, result.getTotal(), pageQuery.getCurrent(), pageQuery.getSize());
|
||||
return PageInfo.of(respList, page.getTotal(), pageQuery.getCurrent(), pageQuery.getSize());
|
||||
}
|
||||
|
||||
Set<Integer> licenseIds = respList.stream().map(PortMappingListRes::getLicenseId).collect(Collectors.toSet());
|
||||
List<LicenseDO> licenseList = licenseMapper.findByIds(licenseIds);
|
||||
if (CollectionUtil.isEmpty(licenseList)) {
|
||||
return PageInfo.of(respList, result.getTotal(), pageQuery.getCurrent(), pageQuery.getSize());
|
||||
return PageInfo.of(respList, page.getTotal(), pageQuery.getCurrent(), pageQuery.getSize());
|
||||
}
|
||||
Set<Integer> userIds = licenseList.stream().map(LicenseDO::getUserId).collect(Collectors.toSet());
|
||||
List<UserDO> userList = userMapper.findByIds(userIds);
|
||||
@@ -110,16 +130,18 @@ public class PortMappingService implements LifecycleBean {
|
||||
return;
|
||||
}
|
||||
item.setUserName(user.getName());
|
||||
if (StrUtil.isNotBlank(proxyConfig.getServer().getDomainName()) && StrUtil.isNotBlank(item.getSubdomain())) {
|
||||
item.setDomain(item.getSubdomain() + "." + proxyConfig.getServer().getDomainName());
|
||||
if (StrUtil.isNotBlank(proxyConfig.getServer().getTcp().getDomainName()) && StrUtil.isNotBlank(item.getSubdomain())) {
|
||||
item.setDomain(item.getSubdomain() + "." + proxyConfig.getServer().getTcp().getDomainName());
|
||||
}
|
||||
if (NetworkProtocolEnum.HTTP.getDesc().equals(item.getProtocal())) {
|
||||
item.setProtocal("HTTP(S)");
|
||||
}
|
||||
});
|
||||
//sorted [userId asc] [licenseId asc] [createTime asc]
|
||||
respList = respList.stream().sorted(Comparator.comparing(PortMappingListRes::getUserId).thenComparing(PortMappingListRes::getLicenseId).thenComparing(PortMappingListRes::getCreateTime)).collect(Collectors.toList());
|
||||
return PageInfo.of(respList, result.getTotal(), pageQuery.getCurrent(), pageQuery.getSize());
|
||||
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());
|
||||
}
|
||||
|
||||
public PortMappingCreateRes create(PortMappingCreateReq req) {
|
||||
@@ -142,6 +164,10 @@ 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());
|
||||
portMappingDO.setIsOnline(OnlineStatusEnum.OFFLINE.getStatus());
|
||||
portMappingDO.setEnable(EnableStatusEnum.ENABLE.getStatus());
|
||||
@@ -151,13 +177,23 @@ public class PortMappingService implements LifecycleBean {
|
||||
// 更新VisitorChannel
|
||||
visitorChannelService.addVisitorChannelByPortMapping(portMappingDO);
|
||||
// 更新域名映射
|
||||
if (NetworkProtocolEnum.isHttp(portMappingDO.getProtocal()) && StrUtil.isNotBlank(proxyConfig.getServer().getDomainName()) && StrUtil.isNotBlank(portMappingDO.getSubdomain())) {
|
||||
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()) {
|
||||
@@ -173,29 +209,43 @@ 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.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())) {
|
||||
ProxyUtil.removeSubdomainToServerPort(oldPortMappingDO.getSubdomain());
|
||||
}
|
||||
// 更新域名映射
|
||||
if (NetworkProtocolEnum.isHttp(portMappingDO.getProtocal()) && StrUtil.isNotBlank(proxyConfig.getServer().getDomainName()) && StrUtil.isNotBlank(portMappingDO.getSubdomain())) {
|
||||
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) {
|
||||
@@ -203,7 +253,18 @@ public class PortMappingService implements LifecycleBean {
|
||||
if (null == portMappingDO) {
|
||||
return null;
|
||||
}
|
||||
PortMappingDetailRes res = new PortMappingDetailRes().setId(portMappingDO.getId()).setLicenseId(portMappingDO.getLicenseId()).setServerPort(portMappingDO.getServerPort()).setClientIp(portMappingDO.getClientIp()).setClientPort(portMappingDO.getClientPort()).setIsOnline(portMappingDO.getIsOnline()).setEnable(portMappingDO.getEnable()).setCreateTime(portMappingDO.getCreateTime()).setUpdateTime(portMappingDO.getUpdateTime());
|
||||
PortMappingDetailRes res = new PortMappingDetailRes()
|
||||
.setId(portMappingDO.getId())
|
||||
.setLicenseId(portMappingDO.getLicenseId())
|
||||
.setServerPort(portMappingDO.getServerPort())
|
||||
.setClientIp(portMappingDO.getClientIp())
|
||||
.setClientPort(portMappingDO.getClientPort())
|
||||
.setIsOnline(portMappingDO.getIsOnline())
|
||||
.setProxyTimeoutMs(portMappingDO.getProxyTimeoutMs())
|
||||
.setProxyResponses(portMappingDO.getProxyResponses())
|
||||
.setEnable(portMappingDO.getEnable())
|
||||
.setCreateTime(portMappingDO.getCreateTime())
|
||||
.setUpdateTime(portMappingDO.getUpdateTime());
|
||||
|
||||
LicenseDO license = licenseMapper.findById(portMappingDO.getLicenseId());
|
||||
if (null != license) {
|
||||
@@ -259,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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -271,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() {
|
||||
portMappingMapper.updateOnlineStatus(OnlineStatusEnum.OFFLINE.getStatus(), new Date());
|
||||
|
||||
// 未配置域名,则不需要处理域名映射逻辑
|
||||
if (StrUtil.isBlank(proxyConfig.getServer().getDomainName())) {
|
||||
// aot 阶段,不初始化
|
||||
if (NativeDetector.isAotRuntime()) {
|
||||
return;
|
||||
}
|
||||
List<PortMappingDO> portMappingDOList = portMappingMapper.selectList(new LambdaQueryWrapper<PortMappingDO>().eq(PortMappingDO::getProtocal, NetworkProtocolEnum.HTTP.getDesc()).isNotNull(PortMappingDO::getSubdomain));
|
||||
// 服务刚启动,所以默认所有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 = allMappingDOList.stream()
|
||||
.filter(item -> NetworkProtocolEnum.HTTP.getDesc().equals(item.getProtocal()) && item.getSubdomain() != null)
|
||||
.collect(Collectors.toList());
|
||||
if (CollectionUtil.isEmpty(portMappingDOList)) {
|
||||
return;
|
||||
}
|
||||
@@ -291,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 {
|
||||
|
||||
|
||||
@@ -3,31 +3,36 @@ package org.dromara.neutrinoproxy.server.service;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.baomidou.mybatisplus.solon.plugins.pagination.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
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.ServiceException;
|
||||
import org.dromara.neutrinoproxy.server.constant.EnableStatusEnum;
|
||||
import org.dromara.neutrinoproxy.server.constant.ExceptionConstant;
|
||||
import org.dromara.neutrinoproxy.server.controller.req.system.*;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.system.*;
|
||||
import org.dromara.neutrinoproxy.server.controller.req.system.AvailablePortListReq;
|
||||
import org.dromara.neutrinoproxy.server.controller.req.system.PortPoolCreateReq;
|
||||
import org.dromara.neutrinoproxy.server.controller.req.system.PortPoolListReq;
|
||||
import org.dromara.neutrinoproxy.server.controller.req.system.PortPoolUpdateEnableStatusReq;
|
||||
import org.dromara.neutrinoproxy.server.controller.req.system.PortPoolUpdateGroupReq;
|
||||
import org.dromara.neutrinoproxy.server.controller.req.system.PortPoolUpdateReq;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.system.PortPoolCreateRes;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.system.PortPoolListRes;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.system.PortPoolUpdateEnableStatusRes;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.system.PortPoolUpdateGroupRes;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.system.PortPoolUpdateRes;
|
||||
import org.dromara.neutrinoproxy.server.dal.LicenseMapper;
|
||||
import org.dromara.neutrinoproxy.server.dal.PortGroupMapper;
|
||||
import org.dromara.neutrinoproxy.server.dal.PortMappingMapper;
|
||||
import org.dromara.neutrinoproxy.server.dal.PortPoolMapper;
|
||||
import org.dromara.neutrinoproxy.server.dal.entity.*;
|
||||
import org.dromara.neutrinoproxy.server.dal.entity.LicenseDO;
|
||||
import org.dromara.neutrinoproxy.server.dal.entity.PortGroupDO;
|
||||
import org.dromara.neutrinoproxy.server.dal.entity.PortMappingDO;
|
||||
import org.dromara.neutrinoproxy.server.dal.entity.PortPoolDO;
|
||||
import org.dromara.neutrinoproxy.server.util.ParamCheckUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import ma.glasnost.orika.MapperFacade;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.solon.annotation.Db;
|
||||
import org.dromara.neutrinoproxy.server.controller.req.system.*;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.system.*;
|
||||
import org.dromara.neutrinoproxy.server.dal.entity.PortGroupDO;
|
||||
import org.dromara.neutrinoproxy.server.util.PortAvailableUtil;
|
||||
import org.noear.solon.annotation.Component;
|
||||
import org.noear.solon.annotation.Inject;
|
||||
|
||||
@@ -37,7 +42,9 @@ import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.dromara.neutrinoproxy.server.constant.ExceptionConstant.*;
|
||||
import static org.dromara.neutrinoproxy.server.constant.ExceptionConstant.PORT_CANNOT_REPEAT;
|
||||
import static org.dromara.neutrinoproxy.server.constant.ExceptionConstant.PORT_GROUP_NAME_DOES_NOT_EXIST;
|
||||
import static org.dromara.neutrinoproxy.server.constant.ExceptionConstant.PORT_RANGE_FAIL;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -47,8 +54,6 @@ import static org.dromara.neutrinoproxy.server.constant.ExceptionConstant.*;
|
||||
@Slf4j
|
||||
@Component
|
||||
public class PortPoolService {
|
||||
@Inject
|
||||
private MapperFacade mapperFacade;
|
||||
@Db
|
||||
private PortPoolMapper portPoolMapper;
|
||||
@Inject
|
||||
@@ -62,17 +67,18 @@ public class PortPoolService {
|
||||
private LicenseMapper licenseMapper;
|
||||
|
||||
public PageInfo<PortPoolListRes> page(PageQuery pageQuery, PortPoolListReq req) {
|
||||
Page<PortPoolListRes> result = PageHelper.startPage(pageQuery.getCurrent(), pageQuery.getSize());
|
||||
|
||||
List<PortPoolListRes> list = portPoolMapper.selectResList(req);
|
||||
return PageInfo.of(list, result.getTotal(), pageQuery.getCurrent(), pageQuery.getSize());
|
||||
Page<PortPoolListRes> page = new Page<>(pageQuery.getCurrent(), pageQuery.getSize());
|
||||
List<PortPoolListRes> list = portPoolMapper.selectResList(page, req);
|
||||
return PageInfo.of(list, page.getTotal(), pageQuery.getCurrent(), pageQuery.getSize());
|
||||
}
|
||||
|
||||
public List<PortPoolListRes> list(PortPoolListReq req) {
|
||||
List<PortPoolDO> list = portPoolMapper.selectList(new LambdaQueryWrapper<PortPoolDO>()
|
||||
.eq(PortPoolDO::getEnable, EnableStatusEnum.ENABLE.getStatus())
|
||||
);
|
||||
return mapperFacade.mapAsList(this.filterUsedPorts(list), PortPoolListRes.class);
|
||||
|
||||
List<PortPoolDO> resultList = this.filterUsedPorts(list);
|
||||
return resultList.stream().map(PortPoolDO::toRes).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private List<PortPoolDO> filterUsedPorts(List<PortPoolDO> list) {
|
||||
@@ -153,7 +159,7 @@ public class PortPoolService {
|
||||
|
||||
public List<PortPoolListRes> portListByGroupId(String groupId) {
|
||||
List<PortPoolDO> portPoolDOList = portPoolMapper.getByGroupId(groupId);
|
||||
List<PortPoolListRes> portPoolListReList = mapperFacade.mapAsList(portPoolDOList, PortPoolListRes.class);
|
||||
List<PortPoolListRes> portPoolListReList = portPoolDOList.stream().map(PortPoolDO::toRes).collect(Collectors.toList());
|
||||
return portPoolListReList;
|
||||
}
|
||||
|
||||
@@ -175,8 +181,44 @@ public class PortPoolService {
|
||||
* 游客:全局端口 + 当前选择用户独占端口 + 当前选择license独占端口
|
||||
* 非管理员身份时:下拉选择license,只能选当前用户下的LICENSE
|
||||
*/
|
||||
public List<PortPoolListRes> getAvailablePortList(AvailablePortListReq req) {
|
||||
public PageInfo<PortPoolListRes> getAvailablePortList(AvailablePortListReq req) {
|
||||
|
||||
LicenseDO licenseDO = licenseMapper.queryById(req.getLicenseId());
|
||||
return portPoolMapper.getAvailablePortList(req.getLicenseId(), licenseDO.getUserId());
|
||||
if(StringUtils.isNotEmpty(req.getKeyword())){
|
||||
req.setKeyword(req.getKeyword()+"%");
|
||||
}
|
||||
|
||||
Page<PortPoolListRes> page = new Page<>(req.getPage(), req.getSize());
|
||||
List<PortPoolListRes> portList = portPoolMapper.getAvailablePortList(page, req.getLicenseId(), licenseDO.getUserId(), req.getKeyword());
|
||||
|
||||
return PageInfo.of(portList, page.getTotal(), req.getPage(), req.getSize());
|
||||
}
|
||||
|
||||
public void deleteBatch(List<Integer> ids) {
|
||||
List<PortPoolDO> portPoolDOList = portPoolMapper.selectBatchIds(ids);
|
||||
ParamCheckUtil.checkNotNull(portPoolDOList, ExceptionConstant.PORT_NOT_EXIST);
|
||||
|
||||
portPoolMapper.deleteBatchIds(ids);
|
||||
// 更新visitorChannel
|
||||
portPoolDOList.stream().forEach(portPoolDO -> {
|
||||
visitorChannelService.updateVisitorChannelByPortPool(portPoolDO.getPort(), EnableStatusEnum.DISABLE.getStatus());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查端口是否被占用
|
||||
* 端口映射编辑时,如果端口号没有变动,则不验证。避免出现端口映射正在使用时,无法更新端口映射其他信息的问题
|
||||
* @param port
|
||||
* @param portMappingId
|
||||
* @return
|
||||
*/
|
||||
public boolean portAvailable(Integer port, Integer portMappingId) {
|
||||
if (null != portMappingId) {
|
||||
PortMappingDO portMappingDO = portMappingMapper.findById(portMappingId);
|
||||
if (null != portMappingDO && portMappingDO.getServerPort().equals(port)) {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
return PortAvailableUtil.isPortAvailable(port);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ 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("UDP").setEnable(Boolean.FALSE).setRemark("暂不支持")
|
||||
new ProtocalListRes().setName("HTTP(S)").setEnable(Boolean.TRUE).setRemark("支持绑定子域名,未绑定时等价于使用TCP。 若配置了证书,则同时支持HTTPS。"),
|
||||
new ProtocalListRes().setName("UDP").setEnable(Boolean.TRUE).setRemark("支持UDP转发、响应。需要配合响应数、超时时间使用")
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ public class ProxyMutualService {
|
||||
Date now = new Date();
|
||||
portMappingMapper.updateOnlineStatus(attachInfo.getLicenseId(), serverPort, OnlineStatusEnum.ONLINE.getStatus(), now);
|
||||
licenseMapper.updateOnlineStatus(attachInfo.getLicenseId(), OnlineStatusEnum.ONLINE.getStatus(), now);
|
||||
log.info("绑定服务端端口 licenseId:{},ip:{},serverPort:{}", attachInfo.getLicenseId(), attachInfo.getIp(), serverPort);
|
||||
log.info("bind server port licenseId:{},ip:{},serverPort:{}", attachInfo.getLicenseId(), attachInfo.getIp(), serverPort);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,7 +64,7 @@ public class ProxyMutualService {
|
||||
Date now = new Date();
|
||||
portMappingMapper.updateOnlineStatus(attachInfo.getLicenseId(), OnlineStatusEnum.OFFLINE.getStatus(), now);
|
||||
licenseMapper.updateOnlineStatus(attachInfo.getLicenseId(), OnlineStatusEnum.OFFLINE.getStatus(), now);
|
||||
log.info("客户端下线 licenseId:{},ip:{}", attachInfo.getLicenseId(), attachInfo.getIp());
|
||||
log.info("client offline licenseId:{},ip:{}", attachInfo.getLicenseId(), attachInfo.getIp());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,9 +2,10 @@ package org.dromara.neutrinoproxy.server.service;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.baomidou.mybatisplus.solon.plugins.pagination.Page;
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.ibatis.solon.annotation.Db;
|
||||
import org.dromara.neutrinoproxy.core.util.DateUtil;
|
||||
import org.dromara.neutrinoproxy.server.base.db.DbConfig;
|
||||
import org.dromara.neutrinoproxy.server.base.page.PageInfo;
|
||||
@@ -15,7 +16,11 @@ import org.dromara.neutrinoproxy.server.controller.req.report.LicenseFlowMonthRe
|
||||
import org.dromara.neutrinoproxy.server.controller.req.report.LicenseFlowReportReq;
|
||||
import org.dromara.neutrinoproxy.server.controller.req.report.UserFlowMonthReportReq;
|
||||
import org.dromara.neutrinoproxy.server.controller.req.report.UserFlowReportReq;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.report.*;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.report.HomeDataView;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.report.LicenseFlowMonthReportRes;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.report.LicenseFlowReportRes;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.report.UserFlowMonthReportRes;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.report.UserFlowReportRes;
|
||||
import org.dromara.neutrinoproxy.server.dal.LicenseMapper;
|
||||
import org.dromara.neutrinoproxy.server.dal.PortMappingMapper;
|
||||
import org.dromara.neutrinoproxy.server.dal.ReportMapper;
|
||||
@@ -24,13 +29,16 @@ import org.dromara.neutrinoproxy.server.dal.entity.PortMappingDO;
|
||||
import org.dromara.neutrinoproxy.server.service.bo.FlowBO;
|
||||
import org.dromara.neutrinoproxy.server.service.bo.SingleDayFlowBO;
|
||||
import org.dromara.neutrinoproxy.server.util.FormatUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import ma.glasnost.orika.MapperFacade;
|
||||
import org.apache.ibatis.solon.annotation.Db;
|
||||
import org.noear.solon.annotation.Component;
|
||||
import org.noear.solon.annotation.Inject;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -40,8 +48,6 @@ import java.util.stream.Collectors;
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ReportService {
|
||||
@Inject
|
||||
private MapperFacade mapperFacade;
|
||||
@Db
|
||||
private ReportMapper reportMapper;
|
||||
@Db
|
||||
@@ -77,17 +83,17 @@ public class ReportService {
|
||||
// 今日流量
|
||||
Date now = new Date();
|
||||
FlowBO todayFlow = reportMapper.homeTodayFlow(DateUtil.getDayBegin(now), now);
|
||||
homeDataView.setTodayFlow(mapperFacade.map(todayFlow, HomeDataView.TodayFlow.class));
|
||||
homeDataView.setTodayFlow(todayFlow.todayFlow());
|
||||
|
||||
// 总流量
|
||||
FlowBO totalFlow = reportMapper.homeTotalFlow(DateUtil.getMonthBegin(now), DateUtil.getDayBegin(now), now);
|
||||
homeDataView.setTotalFlow(mapperFacade.map(totalFlow, HomeDataView.TotalFlow.class));
|
||||
homeDataView.setTotalFlow(totalFlow.totalFlow());
|
||||
|
||||
// 最近n日流量
|
||||
Integer days = Constants.HOME_FLOW_DAYS;
|
||||
List<SingleDayFlowBO> last7dFlowList = reportMapper.homeLast7dFlowList(DateUtil.getDayBegin(DateUtil.addDate(now, Calendar.DATE, -(days - 1))), DateUtil.getDayBegin(now), now);
|
||||
homeDataView.setLast7dFlow(new HomeDataView.Last7dFlow());
|
||||
homeDataView.getLast7dFlow().setDataList(mapperFacade.mapAsList(last7dFlowList, HomeDataView.SingleDayFlow.class));
|
||||
homeDataView.getLast7dFlow().setDataList(last7dFlowList.stream().map(SingleDayFlowBO::toSingleDayFlow).collect(Collectors.toList()));
|
||||
|
||||
// 数据处理
|
||||
fillHomeDataView(homeDataView, now);
|
||||
@@ -101,11 +107,11 @@ public class ReportService {
|
||||
* @return
|
||||
*/
|
||||
public PageInfo<UserFlowReportRes> userFlowReportPage(PageQuery pageQuery, UserFlowReportReq req) {
|
||||
Page<UserFlowReportRes> result = PageHelper.startPage(pageQuery.getCurrent(), pageQuery.getSize());
|
||||
Page<UserFlowReportRes> page = new Page<>(pageQuery.getCurrent(), pageQuery.getSize());
|
||||
Date now = new Date();
|
||||
List<UserFlowReportRes> list = reportMapper.userFlowReportList(req.getUserId(), DateUtil.getMonthBegin(now), DateUtil.getDayBegin(now), now);
|
||||
List<UserFlowReportRes> list = reportMapper.userFlowReportList(page, req.getUserId(), DateUtil.getMonthBegin(now), DateUtil.getDayBegin(now), now);
|
||||
fillUserFlowReport(list);
|
||||
return PageInfo.of(list, result.getTotal(), pageQuery.getCurrent(), pageQuery.getSize());
|
||||
return PageInfo.of(list, page);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,11 +121,11 @@ public class ReportService {
|
||||
* @return
|
||||
*/
|
||||
public PageInfo<LicenseFlowReportRes> licenseFlowReportPage(PageQuery pageQuery, LicenseFlowReportReq req) {
|
||||
Page<LicenseFlowReportRes> result = PageHelper.startPage(pageQuery.getCurrent(), pageQuery.getSize());
|
||||
Page<LicenseFlowReportRes> page = new Page<>(pageQuery.getCurrent(), pageQuery.getSize());
|
||||
Date now = new Date();
|
||||
List<LicenseFlowReportRes> list = reportMapper.licenseFLowReportList(req.getUserId(), DateUtil.getMonthBegin(now), DateUtil.getDayBegin(now), now);
|
||||
List<LicenseFlowReportRes> list = reportMapper.licenseFLowReportList(page, req.getUserId(), DateUtil.getMonthBegin(now), DateUtil.getDayBegin(now), now);
|
||||
fillLicenseFlowReport(list);
|
||||
return PageInfo.of(list, result.getTotal(), pageQuery.getCurrent(), pageQuery.getSize());
|
||||
return PageInfo.of(list, page);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -129,11 +135,11 @@ public class ReportService {
|
||||
* @return
|
||||
*/
|
||||
public PageInfo<UserFlowMonthReportRes> userFlowMonthReportPage(PageQuery pageQuery, UserFlowMonthReportReq req) {
|
||||
Page<UserFlowMonthReportRes> result = PageHelper.startPage(pageQuery.getCurrent(), pageQuery.getSize());
|
||||
Page<UserFlowMonthReportRes> page = new Page<>(pageQuery.getCurrent(), pageQuery.getSize());
|
||||
Date now = new Date();
|
||||
List<UserFlowMonthReportRes> list = reportMapper.userFlowMonthReportList(req.getUserId(), DateUtil.getMonthBegin(now), DateUtil.getDayBegin(now), now);
|
||||
List<UserFlowMonthReportRes> list = reportMapper.userFlowMonthReportList(page, req.getUserId(), DateUtil.getMonthBegin(now), DateUtil.getDayBegin(now), now);
|
||||
fillUserFlowMonthReport(list);
|
||||
return PageInfo.of(list, result.getTotal(), pageQuery.getCurrent(), pageQuery.getSize());
|
||||
return PageInfo.of(list, page);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,11 +149,11 @@ public class ReportService {
|
||||
* @return
|
||||
*/
|
||||
public PageInfo<LicenseFlowMonthReportRes> licenseFlowMonthReportPage(PageQuery pageQuery, LicenseFlowMonthReportReq req) {
|
||||
Page<LicenseFlowMonthReportRes> result = PageHelper.startPage(pageQuery.getCurrent(), pageQuery.getSize());
|
||||
Page<LicenseFlowMonthReportRes> page = new Page<>(pageQuery.getCurrent(), pageQuery.getSize());
|
||||
Date now = new Date();
|
||||
List<LicenseFlowMonthReportRes> list = reportMapper.licenseFLowMonthReportList(req.getUserId(), req.getLicenseId(), DateUtil.getMonthBegin(now), DateUtil.getDayBegin(now), now);
|
||||
List<LicenseFlowMonthReportRes> list = reportMapper.licenseFLowMonthReportList(page, req.getUserId(), req.getLicenseId(), DateUtil.getMonthBegin(now), DateUtil.getDayBegin(now), now);
|
||||
fillLicenseFlowMonthReport(list);
|
||||
return PageInfo.of(list, result.getTotal(), pageQuery.getCurrent(), pageQuery.getSize());
|
||||
return PageInfo.of(list, page);
|
||||
}
|
||||
|
||||
private void fillUserFlowReport(List<UserFlowReportRes> list) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,8 @@ package org.dromara.neutrinoproxy.server.service;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.baomidou.mybatisplus.solon.plugins.pagination.Page;
|
||||
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.controller.req.log.UserLoginRecordListReq;
|
||||
@@ -13,10 +13,7 @@ import org.dromara.neutrinoproxy.server.dal.UserLoginRecordMapper;
|
||||
import org.dromara.neutrinoproxy.server.dal.UserMapper;
|
||||
import org.dromara.neutrinoproxy.server.dal.entity.UserDO;
|
||||
import org.dromara.neutrinoproxy.server.dal.entity.UserLoginRecordDO;
|
||||
import ma.glasnost.orika.MapperFacade;
|
||||
import org.apache.ibatis.solon.annotation.Db;
|
||||
import org.noear.solon.annotation.Component;
|
||||
import org.noear.solon.annotation.Inject;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -31,22 +28,19 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
@Component
|
||||
public class UserLoginRecordService {
|
||||
@Inject
|
||||
private MapperFacade mapperFacade;
|
||||
@Db
|
||||
private UserLoginRecordMapper userLoginRecordMapper;
|
||||
@Db
|
||||
private UserMapper userMapper;
|
||||
|
||||
public PageInfo<UserLoginRecordListRes> page(PageQuery pageQuery, UserLoginRecordListReq req) {
|
||||
Page<UserLoginRecordListRes> result = PageHelper.startPage(pageQuery.getCurrent(), pageQuery.getSize());
|
||||
List<UserLoginRecordDO> list = userLoginRecordMapper.selectList(new LambdaQueryWrapper<UserLoginRecordDO>()
|
||||
.eq(null != req.getUserId(), UserLoginRecordDO::getUserId, req.getUserId())
|
||||
.orderByDesc(UserLoginRecordDO::getCreateTime)
|
||||
Page<UserLoginRecordDO> page = userLoginRecordMapper.selectPage(new Page<>(pageQuery.getCurrent(), pageQuery.getSize()), new LambdaQueryWrapper<UserLoginRecordDO>()
|
||||
.eq(null != req.getUserId(), UserLoginRecordDO::getUserId, req.getUserId())
|
||||
.orderByDesc(UserLoginRecordDO::getCreateTime)
|
||||
);
|
||||
List<UserLoginRecordListRes> respList = mapperFacade.mapAsList(list, UserLoginRecordListRes.class);
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return PageInfo.of(respList, result.getTotal(), pageQuery.getCurrent(), pageQuery.getSize());
|
||||
List<UserLoginRecordListRes> respList = page.getRecords().stream().map(UserLoginRecordDO::toRes).collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(page.getRecords())) {
|
||||
return PageInfo.of(respList, page);
|
||||
}
|
||||
|
||||
if (!CollectionUtil.isEmpty(respList)) {
|
||||
@@ -60,6 +54,6 @@ public class UserLoginRecordService {
|
||||
}
|
||||
}
|
||||
}
|
||||
return PageInfo.of(respList, result.getTotal(), pageQuery.getCurrent(), pageQuery.getSize());
|
||||
return PageInfo.of(respList, page);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@ package org.dromara.neutrinoproxy.server.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.baomidou.mybatisplus.solon.plugins.pagination.Page;
|
||||
import org.apache.ibatis.solon.annotation.Db;
|
||||
import org.dromara.neutrinoproxy.core.util.DateUtil;
|
||||
import org.dromara.neutrinoproxy.server.base.page.PageInfo;
|
||||
import org.dromara.neutrinoproxy.server.base.page.PageQuery;
|
||||
@@ -11,8 +11,20 @@ import org.dromara.neutrinoproxy.server.base.rest.ServiceException;
|
||||
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.controller.req.system.*;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.system.*;
|
||||
import org.dromara.neutrinoproxy.server.controller.req.system.LoginReq;
|
||||
import org.dromara.neutrinoproxy.server.controller.req.system.UserCreateReq;
|
||||
import org.dromara.neutrinoproxy.server.controller.req.system.UserInfoReq;
|
||||
import org.dromara.neutrinoproxy.server.controller.req.system.UserListReq;
|
||||
import org.dromara.neutrinoproxy.server.controller.req.system.UserUpdateEnableStatusReq;
|
||||
import org.dromara.neutrinoproxy.server.controller.req.system.UserUpdatePasswordReq;
|
||||
import org.dromara.neutrinoproxy.server.controller.req.system.UserUpdateReq;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.system.LoginRes;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.system.UserCreateRes;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.system.UserInfoRes;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.system.UserListRes;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.system.UserUpdateEnableStatusRes;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.system.UserUpdatePasswordRes;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.system.UserUpdateRes;
|
||||
import org.dromara.neutrinoproxy.server.dal.UserLoginRecordMapper;
|
||||
import org.dromara.neutrinoproxy.server.dal.UserMapper;
|
||||
import org.dromara.neutrinoproxy.server.dal.UserTokenMapper;
|
||||
@@ -21,8 +33,6 @@ import org.dromara.neutrinoproxy.server.dal.entity.UserLoginRecordDO;
|
||||
import org.dromara.neutrinoproxy.server.dal.entity.UserTokenDO;
|
||||
import org.dromara.neutrinoproxy.server.util.Md5Util;
|
||||
import org.dromara.neutrinoproxy.server.util.ParamCheckUtil;
|
||||
import ma.glasnost.orika.MapperFacade;
|
||||
import org.apache.ibatis.solon.annotation.Db;
|
||||
import org.noear.solon.annotation.Component;
|
||||
import org.noear.solon.annotation.Inject;
|
||||
|
||||
@@ -30,6 +40,7 @@ import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -39,8 +50,7 @@ import java.util.UUID;
|
||||
@Component
|
||||
public class UserService {
|
||||
private static final String DEFAULT_PASSWORD = "123456";
|
||||
@Inject
|
||||
private MapperFacade mapperFacade;
|
||||
|
||||
@Db
|
||||
private UserMapper userMapper;
|
||||
@Db
|
||||
@@ -120,12 +130,11 @@ public class UserService {
|
||||
}
|
||||
|
||||
public PageInfo<UserListRes> page(PageQuery pageQuery, UserListReq req) {
|
||||
Page<UserListRes> result = PageHelper.startPage(pageQuery.getCurrent(), pageQuery.getSize());
|
||||
List<UserDO> list = userMapper.selectList(new LambdaQueryWrapper<UserDO>()
|
||||
.orderByAsc(UserDO::getId)
|
||||
);
|
||||
List<UserListRes> respList = mapperFacade.mapAsList(list, UserListRes.class);
|
||||
return PageInfo.of(respList, result.getTotal(), pageQuery.getCurrent(), pageQuery.getSize());
|
||||
Page<UserDO> page = userMapper.selectPage(new Page<>(pageQuery.getCurrent(), pageQuery.getSize()), new LambdaQueryWrapper<UserDO>()
|
||||
.orderByAsc(UserDO::getId)
|
||||
);
|
||||
List<UserListRes> respList = page.getRecords().stream().map(UserDO::toRes).collect(Collectors.toList());
|
||||
return PageInfo.of(respList, page);
|
||||
}
|
||||
|
||||
public List<UserListRes> list(UserListReq req) {
|
||||
@@ -133,7 +142,7 @@ public class UserService {
|
||||
.eq(UserDO::getEnable, EnableStatusEnum.ENABLE.getStatus())
|
||||
.orderByAsc(UserDO::getId)
|
||||
);
|
||||
return mapperFacade.mapAsList(userDOList, UserListRes.class);
|
||||
return userDOList.stream().map(UserDO::toRes).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public UserInfoRes info(UserInfoReq req) {
|
||||
|
||||
@@ -3,8 +3,10 @@ package org.dromara.neutrinoproxy.server.service;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import org.dromara.neutrinoproxy.core.Constants;
|
||||
import org.dromara.neutrinoproxy.server.constant.EnableStatusEnum;
|
||||
import org.dromara.neutrinoproxy.server.constant.NetworkProtocolEnum;
|
||||
import org.dromara.neutrinoproxy.server.dal.LicenseMapper;
|
||||
import org.dromara.neutrinoproxy.server.dal.PortMappingMapper;
|
||||
import org.dromara.neutrinoproxy.server.dal.PortPoolMapper;
|
||||
@@ -43,6 +45,8 @@ import java.util.stream.Collectors;
|
||||
public class VisitorChannelService {
|
||||
@Inject("tcpServerBootstrap")
|
||||
private ServerBootstrap tcpServerBootstrap;
|
||||
@Inject("udpServerBootstrap")
|
||||
private Bootstrap udpServerBootstrap;
|
||||
@Inject
|
||||
private ProxyMutualService proxyMutualService;
|
||||
@Db
|
||||
@@ -207,7 +211,8 @@ public class VisitorChannelService {
|
||||
if (null != proxyChannel) {
|
||||
proxyChannel.close();
|
||||
}
|
||||
visitorChannel.close();
|
||||
// TODO 此处如果时UDP的visitorChannel,则不能close,后续重构考虑
|
||||
// visitorChannel.close();
|
||||
}
|
||||
ProxyUtil.removeProxyInfo(portMappingDO.getServerPort());
|
||||
}
|
||||
@@ -219,14 +224,20 @@ public class VisitorChannelService {
|
||||
|
||||
for (PortMappingDO portMapping : portMappingList) {
|
||||
if (EnableStatusEnum.DISABLE.getStatus().equals(portMapping.getEnable())) {
|
||||
// 端口映射被禁用了,忽略 TODO 端口被禁用了也需要处理
|
||||
// 端口映射被禁用了,忽略 TODO 映射没被禁用,但端口被禁用了也需要处理
|
||||
continue;
|
||||
}
|
||||
// TODO 此处切入,TCP/UDP代理
|
||||
try {
|
||||
proxyMutualService.bindServerPort(cmdChannelAttachInfo, portMapping.getServerPort());
|
||||
tcpServerBootstrap.bind(portMapping.getServerPort()).get();
|
||||
log.info("绑定用户端口: {}", portMapping.getServerPort());
|
||||
|
||||
NetworkProtocolEnum networkProtocolEnum = NetworkProtocolEnum.of(portMapping.getProtocal());
|
||||
if (networkProtocolEnum == NetworkProtocolEnum.UDP) {
|
||||
udpServerBootstrap.bind(portMapping.getServerPort()).get();
|
||||
log.info("bind UDP user port: {}", portMapping.getServerPort());
|
||||
} else {
|
||||
tcpServerBootstrap.bind(portMapping.getServerPort()).get();
|
||||
log.info("bind TCP user port: {}", portMapping.getServerPort());
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
// BindException表示该端口已经绑定过
|
||||
if (!(ex.getCause() instanceof BindException)) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.dromara.neutrinoproxy.server.service.bo;
|
||||
|
||||
import lombok.Data;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.report.HomeDataView;
|
||||
|
||||
/**
|
||||
* @author: aoshiguchen
|
||||
@@ -16,4 +17,18 @@ public class FlowBO {
|
||||
* 下行流量字节数
|
||||
*/
|
||||
private Long downFlowBytes;
|
||||
|
||||
public HomeDataView.TodayFlow todayFlow() {
|
||||
HomeDataView.TodayFlow todayFlow = new HomeDataView.TodayFlow();
|
||||
todayFlow.setUpFlowBytes(upFlowBytes);
|
||||
todayFlow.setDownFlowBytes(downFlowBytes);
|
||||
return todayFlow;
|
||||
}
|
||||
|
||||
public HomeDataView.TotalFlow totalFlow() {
|
||||
HomeDataView.TotalFlow totalFlow = new HomeDataView.TotalFlow();
|
||||
totalFlow.setUpFlowBytes(upFlowBytes);
|
||||
totalFlow.setDownFlowBytes(downFlowBytes);
|
||||
return totalFlow;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.dromara.neutrinoproxy.server.service.bo;
|
||||
|
||||
import lombok.Data;
|
||||
import org.dromara.neutrinoproxy.server.controller.res.report.HomeDataView;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@@ -23,4 +24,12 @@ public class SingleDayFlowBO {
|
||||
* 下行流量字节数
|
||||
*/
|
||||
private Long downFlowBytes;
|
||||
|
||||
public HomeDataView.SingleDayFlow toSingleDayFlow() {
|
||||
HomeDataView.SingleDayFlow singleDayFlow = new HomeDataView.SingleDayFlow();
|
||||
singleDayFlow.setDate(date);
|
||||
singleDayFlow.setUpFlowBytes(upFlowBytes);
|
||||
singleDayFlow.setDownFlowBytes(downFlowBytes);
|
||||
return singleDayFlow;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package org.dromara.neutrinoproxy.server.util;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
|
||||
/**
|
||||
* 检查端口是否被占用
|
||||
* 文章参考:https://blog.csdn.net/xingluxiaoseng/article/details/40148527
|
||||
*/
|
||||
public class PortAvailableUtil {
|
||||
|
||||
private static void bindPort(String host, int port) throws IOException {
|
||||
Socket s = new Socket();
|
||||
s.bind(new InetSocketAddress(host, port));
|
||||
s.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* 端口占用判断,若是端口被占用,则会抛出IOException异常,表示端口被占用
|
||||
* @param port
|
||||
* @return
|
||||
*/
|
||||
public static boolean isPortAvailable(int port) {
|
||||
try {
|
||||
bindPort("0.0.0.0", port);
|
||||
bindPort(InetAddress.getLocalHost().getHostAddress(), port);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("端口被占用:"+isPortAvailable(9527));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import com.google.common.collect.Sets;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dromara.neutrinoproxy.core.ChannelAttribute;
|
||||
import org.dromara.neutrinoproxy.core.Constants;
|
||||
import org.dromara.neutrinoproxy.server.constant.NetworkProtocolEnum;
|
||||
import org.dromara.neutrinoproxy.server.proxy.domain.CmdChannelAttachInfo;
|
||||
import org.dromara.neutrinoproxy.server.proxy.domain.ProxyAttachment;
|
||||
import org.dromara.neutrinoproxy.server.proxy.domain.ProxyMapping;
|
||||
@@ -201,18 +202,21 @@ public class ProxyUtil {
|
||||
* @param visitorId
|
||||
* @param visitorChannel
|
||||
*/
|
||||
public static void addVisitorChannelToCmdChannel(Channel cmdChannel, String visitorId, Channel visitorChannel, Integer serverPort) {
|
||||
public static void addVisitorChannelToCmdChannel(NetworkProtocolEnum protocol, Channel cmdChannel, String visitorId, Channel visitorChannel, Integer serverPort) {
|
||||
InetSocketAddress sa = (InetSocketAddress) visitorChannel.localAddress();
|
||||
String lanInfo = getClientLanInfoByServerPort(sa.getPort());
|
||||
CmdChannelAttachInfo cmdChannelAttachInfo = getAttachInfo(cmdChannel);
|
||||
|
||||
setAttachInfo(visitorChannel, new VisitorChannelAttachInfo()
|
||||
.setVisitorId(visitorId)
|
||||
.setLanInfo(lanInfo)
|
||||
.setServerPort(serverPort)
|
||||
.setLicenseId(cmdChannelAttachInfo.getLicenseId())
|
||||
.setIp(((InetSocketAddress)visitorChannel.remoteAddress()).getAddress().getHostAddress())
|
||||
);
|
||||
VisitorChannelAttachInfo attachInfo = new VisitorChannelAttachInfo()
|
||||
.setProtocol(protocol)
|
||||
.setVisitorId(visitorId)
|
||||
.setLanInfo(lanInfo)
|
||||
.setServerPort(serverPort)
|
||||
.setLicenseId(cmdChannelAttachInfo.getLicenseId());
|
||||
if (NetworkProtocolEnum.UDP != protocol) {
|
||||
attachInfo.setIp(((InetSocketAddress)visitorChannel.remoteAddress()).getAddress().getHostAddress());
|
||||
}
|
||||
setAttachInfo(visitorChannel, attachInfo);
|
||||
userChannelMapLock.writeLock().lock();
|
||||
try {
|
||||
cmdChannelAttachInfo.getVisitorChannelMap().put(visitorId, visitorChannel);
|
||||
|
||||
@@ -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:
|
||||
@@ -1,6 +1,25 @@
|
||||
server:
|
||||
# 服务端web端口,用于支持HTTP接口,管理后台页面访问
|
||||
port: ${WEB_PORT:8888}
|
||||
context-path: /neutrino-proxy-server
|
||||
solon:
|
||||
app:
|
||||
name: neutrino-proxy-server
|
||||
version: 2.0.1
|
||||
config:
|
||||
add: ./app.yml
|
||||
# 日志级别
|
||||
solon.logging.appender:
|
||||
console:
|
||||
pattern: "%d{yyyy-MM-dd HH:mm:ss.SSS} %highlight(%-5level) %magenta(${PID:-}) --- %-15([%15.15thread]) %-56(%cyan(%-40.40logger{39}%L)) : %msg%n"
|
||||
file:
|
||||
enable: true
|
||||
pattern: "%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level ${PID:-} --- %-15([%15.15thread]) %-56(%-40.40logger{39}%L) : %msg%n"
|
||||
name: "logs/${solon.app.name}"
|
||||
rolling: "logs/${solon.app.name}_%d{yyyy-MM-dd}_%i.log"
|
||||
solon.logging.logger:
|
||||
"root":
|
||||
level: info
|
||||
|
||||
neutrino:
|
||||
proxy:
|
||||
@@ -10,12 +29,9 @@ neutrino:
|
||||
length-field-length: 4
|
||||
initial-bytes-to-strip: 0
|
||||
length-adjustment: 0
|
||||
read-idle-time: 30
|
||||
write-idle-time: 5
|
||||
read-idle-time: 120
|
||||
write-idle-time: 20
|
||||
all-idle-time-seconds: 0
|
||||
logger:
|
||||
# 日志级别
|
||||
level: ${LOG_LEVEL:info}
|
||||
# 隧道相关配置-用于维持服务端与客户端的通信
|
||||
tunnel:
|
||||
# 线程池相关配置,用于技术调优,可忽略
|
||||
@@ -31,27 +47,36 @@ neutrino:
|
||||
jks-path: ${JKS_PATH:classpath:/test.jks}
|
||||
# 是否开启隧道传输报文日志(日志级别为debug时开启才有效)
|
||||
transfer-log-enable: ${TUNNEL_LOG:false}
|
||||
# 是否开启心跳日志
|
||||
heartbeat-log-enable: ${HEARTBEAT_LOG:false}
|
||||
server:
|
||||
# 线程池相关配置,用于技术调优,可忽略
|
||||
boss-thread-count: 5
|
||||
work-thread-count: 20
|
||||
# http代理端口,默认80
|
||||
http-proxy-port: ${HTTP_PROXY_PORT:80}
|
||||
# https代理端口,默认443 (需要配置域名、证书)
|
||||
https-proxy-port: ${HTTPS_PROXY_PORT:443}
|
||||
# 如果不配置,则不支持域名映射
|
||||
domain-name: ${DOMAIN_NAME:}
|
||||
# https证书配置
|
||||
key-store-password: ${HTTPS_STORE_PASS:}
|
||||
jks-path: ${HTTPS_JKS_PATH:}
|
||||
# 是否开启代理服务报文日志(日志级别为debug时开启才有效)
|
||||
transfer-log-enable: ${SERVER_LOG:false}
|
||||
tcp:
|
||||
# 线程池相关配置,用于技术调优,可忽略
|
||||
boss-thread-count: 5
|
||||
work-thread-count: 20
|
||||
# http代理端口,默认80
|
||||
http-proxy-port: ${HTTP_PROXY_PORT:80}
|
||||
# https代理端口,默认443 (需要配置域名、证书)
|
||||
https-proxy-port: ${HTTPS_PROXY_PORT:443}
|
||||
# 如果不配置,则不支持域名映射
|
||||
domain-name: ${DOMAIN_NAME:}
|
||||
# https证书配置
|
||||
key-store-password: ${HTTPS_STORE_PASS:}
|
||||
jks-path: ${HTTPS_JKS_PATH:}
|
||||
# 是否开启代理服务报文日志(日志级别为debug时开启才有效)
|
||||
transfer-log-enable: ${SERVER_LOG:false}
|
||||
udp:
|
||||
# 线程池相关配置,用于技术调优,可忽略
|
||||
boss-thread-count: 5
|
||||
work-thread-count: 20
|
||||
# 是否开启代理服务报文日志(日志级别为debug时开启才有效)
|
||||
transfer-log-enable: ${SERVER_LOG:false}
|
||||
data:
|
||||
db:
|
||||
# 数据库类型,目前支持sqlite、mysql、mariadb
|
||||
type: ${DB_TYPE:sqlite}
|
||||
# 数据库类型,目前支持h2、mysql、mariadb
|
||||
type: ${DB_TYPE:h2}
|
||||
# 数据库连接URL
|
||||
url: ${DB_URL:jdbc:sqlite:data.db}
|
||||
url: ${DB_URL:jdbc:h2:file:./data/db;MODE=MySQL;AUTO_SERVER=TRUE}
|
||||
# 数据库用户名
|
||||
username: ${DB_USER:}
|
||||
# 数据库密码
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<property name="LOG_FILE" value="./logs/neutrino-proxy-server.log"/>
|
||||
<property name="LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} %contextName [%thread] %-5level %logger{50} - %msg%n"/>
|
||||
<!-- <property name="ENCODE" value="utf8" />-->
|
||||
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||
<level>DEBUG</level>
|
||||
</filter>
|
||||
<encoder>
|
||||
<pattern>${LOG_PATTERN}</pattern>
|
||||
<!-- <charset>${ENCODE}</charset>-->
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${LOG_FILE}</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>${LOG_FILE}.%d{yyyy-MM-dd}.zip</fileNamePattern>
|
||||
<maxHistory>7</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${LOG_PATTERN}</pattern>
|
||||
<!-- <charset>${ENCODE}</charset>-->
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="DEBUG">
|
||||
<appender-ref ref="console"/>
|
||||
<appender-ref ref="file"/>
|
||||
</root>
|
||||
|
||||
<logger name="com.example.logback" level="warn"/>
|
||||
<logger name="io.netty" level="warn"/>
|
||||
</configuration>
|
||||
@@ -32,6 +32,9 @@
|
||||
possessor_type = 0
|
||||
OR ( possessor_type = 1 AND possessor_id = #{userId,jdbcType=INTEGER} )
|
||||
OR ( possessor_type = 2 AND possessor_id = #{licenseId,jdbcType=INTEGER} )
|
||||
)
|
||||
)
|
||||
<if test="keyword!=null and keyword!=''">
|
||||
AND `port` LIKE #{keyword}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -4,16 +4,16 @@
|
||||
|
||||
<select id="userFlowReportList" resultType="org.dromara.neutrinoproxy.server.controller.res.report.UserFlowReportRes">
|
||||
SELECT
|
||||
u.id AS 'userId',
|
||||
u.name AS 'userName',
|
||||
SUM(IFNULL(frm.write_bytes,0) + IFNULL(frd.write_bytes,0) + IFNULL(frm2.write_bytes,0)) AS 'upFlowBytes',
|
||||
SUM(IFNULL(frm.read_bytes,0) + IFNULL(frd.read_bytes,0) + IFNULL(frm2.read_bytes,0)) AS 'downFlowBytes',
|
||||
IFNULL(SUM(frm.write_bytes),0) monthWriteBytes,
|
||||
IFNULL(SUM(frm.read_bytes),0) monthReadBytes,
|
||||
IFNULL(SUM(frd.write_bytes),0) dayWriteBytes,
|
||||
IFNULL(SUM(frd.read_bytes),0) dayReadBytes,
|
||||
IFNULL(SUM(frm2.write_bytes),0) minuteWriteBytes,
|
||||
IFNULL(SUM(frm2.read_bytes),0) minuteReadBytes
|
||||
u.id AS userId,
|
||||
u.name AS userName,
|
||||
SUM(COALESCE(frm.write_bytes,0) + COALESCE(frd.write_bytes,0) + COALESCE(frm2.write_bytes,0)) AS upFlowBytes,
|
||||
SUM(COALESCE(frm.read_bytes,0) + COALESCE(frd.read_bytes,0) + COALESCE(frm2.read_bytes,0)) AS downFlowBytes,
|
||||
COALESCE(SUM(frm.write_bytes),0) monthWriteBytes,
|
||||
COALESCE(SUM(frm.read_bytes),0) monthReadBytes,
|
||||
COALESCE(SUM(frd.write_bytes),0) dayWriteBytes,
|
||||
COALESCE(SUM(frd.read_bytes),0) dayReadBytes,
|
||||
COALESCE(SUM(frm2.write_bytes),0) minuteWriteBytes,
|
||||
COALESCE(SUM(frm2.read_bytes),0) minuteReadBytes
|
||||
FROM `user` u
|
||||
LEFT JOIN (SELECT user_id,sum(write_bytes) write_bytes,sum(read_bytes) read_bytes from flow_report_month GROUP BY user_id) frm ON u.id = frm.user_id
|
||||
LEFT JOIN (SELECT user_id,sum(write_bytes) write_bytes,sum(read_bytes) read_bytes from flow_report_day
|
||||
@@ -32,18 +32,18 @@
|
||||
|
||||
<select id="licenseFLowReportList" resultType="org.dromara.neutrinoproxy.server.controller.res.report.LicenseFlowReportRes">
|
||||
SELECT
|
||||
l.id AS 'licenseId',
|
||||
l.name AS 'licenseName',
|
||||
u.id AS 'userId',
|
||||
u.name AS 'userName',
|
||||
SUM(IFNULL(frm.write_bytes,0) + IFNULL(frd.write_bytes,0) + IFNULL(frm2.write_bytes,0)) AS 'upFlowBytes',
|
||||
SUM(IFNULL(frm.read_bytes,0) + IFNULL(frd.read_bytes,0) + IFNULL(frm2.read_bytes,0)) AS 'downFlowBytes',
|
||||
IFNULL(SUM(frm.write_bytes),0) monthWriteBytes,
|
||||
IFNULL(SUM(frm.read_bytes),0) monthReadBytes,
|
||||
IFNULL(SUM(frd.write_bytes),0) dayWriteBytes,
|
||||
IFNULL(SUM(frd.read_bytes),0) dayReadBytes,
|
||||
IFNULL(SUM(frm2.write_bytes),0) minuteWriteBytes,
|
||||
IFNULL(SUM(frm2.read_bytes),0) minuteReadBytes
|
||||
l.id AS licenseId,
|
||||
l.name AS licenseName,
|
||||
u.id AS userId,
|
||||
u.name AS userName,
|
||||
SUM(COALESCE(frm.write_bytes,0) + COALESCE(frd.write_bytes,0) + COALESCE(frm2.write_bytes,0)) AS upFlowBytes,
|
||||
SUM(COALESCE(frm.read_bytes,0) + COALESCE(frd.read_bytes,0) + COALESCE(frm2.read_bytes,0)) AS downFlowBytes,
|
||||
COALESCE(SUM(frm.write_bytes),0) monthWriteBytes,
|
||||
COALESCE(SUM(frm.read_bytes),0) monthReadBytes,
|
||||
COALESCE(SUM(frd.write_bytes),0) dayWriteBytes,
|
||||
COALESCE(SUM(frd.read_bytes),0) dayReadBytes,
|
||||
COALESCE(SUM(frm2.write_bytes),0) minuteWriteBytes,
|
||||
COALESCE(SUM(frm2.read_bytes),0) minuteReadBytes
|
||||
FROM `license` l
|
||||
LEFT JOIN `user` u ON l.user_id = u.id
|
||||
LEFT JOIN (SELECT license_id,sum(write_bytes) write_bytes,sum(read_bytes) read_bytes from flow_report_month GROUP BY license_id) frm ON l.id = frm.license_id
|
||||
@@ -64,7 +64,7 @@
|
||||
<select id="userFlowMonthReportList" resultType="org.dromara.neutrinoproxy.server.controller.res.report.UserFlowMonthReportRes">
|
||||
SELECT
|
||||
T2.user_id,
|
||||
u.name AS 'userName',
|
||||
u.name AS userName,
|
||||
T2.date,
|
||||
T2.upFlowBytes,
|
||||
T2.downFlowBytes
|
||||
@@ -73,8 +73,8 @@
|
||||
SELECT
|
||||
frm.user_id,
|
||||
frm.date,
|
||||
IFNULL(SUM(frm.write_bytes),0) AS 'upFlowBytes',
|
||||
IFNULL(SUM(frm.read_bytes),0) AS 'downFlowBytes'
|
||||
COALESCE(SUM(frm.write_bytes),0) AS upFlowBytes,
|
||||
COALESCE(SUM(frm.read_bytes),0) AS downFlowBytes
|
||||
FROM flow_report_month frm
|
||||
GROUP BY frm.user_id,frm.date
|
||||
|
||||
@@ -82,16 +82,16 @@
|
||||
|
||||
SELECT
|
||||
T1.user_id,
|
||||
#{curMonthBeginDate} AS 'date',
|
||||
IFNULL(SUM(T1.upFlowBytes),0) AS 'upFlowBytes',
|
||||
IFNULL(SUM(T1.downFlowBytes),0) AS 'downFlowBytes'
|
||||
#{curMonthBeginDate} AS date,
|
||||
COALESCE(SUM(T1.upFlowBytes),0) AS upFlowBytes,
|
||||
COALESCE(SUM(T1.downFlowBytes),0) AS downFlowBytes
|
||||
FROM (
|
||||
|
||||
SELECT
|
||||
frd.user_id,
|
||||
frd.license_id,
|
||||
frd.write_bytes AS 'upFlowBytes',
|
||||
frd.read_bytes AS 'downFlowBytes',
|
||||
frd.write_bytes AS upFlowBytes,
|
||||
frd.read_bytes AS downFlowBytes,
|
||||
frd.date
|
||||
FROM flow_report_day frd
|
||||
WHERE frd.date >= #{curMonthBeginDate} AND frd.date <= #{curDayBeginDate}
|
||||
@@ -101,9 +101,9 @@
|
||||
SELECT
|
||||
frm.user_id,
|
||||
frm.license_id,
|
||||
IFNULL(SUM(frm.write_bytes),0) AS 'upFlowBytes',
|
||||
IFNULL(SUM(frm.read_bytes),0) AS 'downFlowBytes',
|
||||
#{curDayBeginDate} AS 'date'
|
||||
COALESCE(SUM(frm.write_bytes),0) AS upFlowBytes,
|
||||
COALESCE(SUM(frm.read_bytes),0) AS downFlowBytes,
|
||||
#{curDayBeginDate} AS date
|
||||
FROM flow_report_minute frm
|
||||
WHERE frm.date >= #{curDayBeginDate} AND frm.date <= #{curDate}
|
||||
GROUP BY frm.user_id,frm.license_id
|
||||
@@ -124,9 +124,9 @@
|
||||
<select id="licenseFLowMonthReportList" resultType="org.dromara.neutrinoproxy.server.controller.res.report.LicenseFlowMonthReportRes">
|
||||
SELECT
|
||||
T2.user_id,
|
||||
u.name AS 'userName',
|
||||
u.name AS userName,
|
||||
T2.license_id,
|
||||
l.`name` AS 'licenseName',
|
||||
l.`name` AS licenseName,
|
||||
T2.date,
|
||||
T2.upFlowBytes,
|
||||
T2.downFlowBytes
|
||||
@@ -136,8 +136,8 @@
|
||||
frm.user_id,
|
||||
frm.license_id,
|
||||
frm.date,
|
||||
IFNULL(SUM(frm.write_bytes),0) AS 'upFlowBytes',
|
||||
IFNULL(SUM(frm.read_bytes),0) AS 'downFlowBytes'
|
||||
COALESCE(SUM(frm.write_bytes),0) AS upFlowBytes,
|
||||
COALESCE(SUM(frm.read_bytes),0) AS downFlowBytes
|
||||
FROM flow_report_month frm
|
||||
GROUP BY frm.user_id,frm.license_id,frm.date
|
||||
|
||||
@@ -146,16 +146,16 @@
|
||||
SELECT
|
||||
T1.user_id,
|
||||
T1.license_id,
|
||||
#{curMonthBeginDate} AS 'date',
|
||||
IFNULL(SUM(T1.upFlowBytes),0) AS 'upFlowBytes',
|
||||
IFNULL(SUM(T1.downFlowBytes),0) AS 'downFlowBytes'
|
||||
#{curMonthBeginDate} AS date,
|
||||
COALESCE(SUM(T1.upFlowBytes),0) AS upFlowBytes,
|
||||
COALESCE(SUM(T1.downFlowBytes),0) AS downFlowBytes
|
||||
FROM (
|
||||
|
||||
SELECT
|
||||
frd.user_id,
|
||||
frd.license_id,
|
||||
frd.write_bytes AS 'upFlowBytes',
|
||||
frd.read_bytes AS 'downFlowBytes',
|
||||
frd.write_bytes AS upFlowBytes,
|
||||
frd.read_bytes AS downFlowBytes,
|
||||
frd.date
|
||||
FROM flow_report_day frd
|
||||
WHERE frd.date >= #{curMonthBeginDate} AND frd.date <= #{curDayBeginDate}
|
||||
@@ -165,9 +165,9 @@
|
||||
SELECT
|
||||
frm.user_id,
|
||||
frm.license_id,
|
||||
IFNULL(SUM(frm.write_bytes),0) AS 'upFlowBytes',
|
||||
IFNULL(SUM(frm.read_bytes),0) AS 'downFlowBytes',
|
||||
#{curDayBeginDate} AS 'date'
|
||||
COALESCE(SUM(frm.write_bytes),0) AS upFlowBytes,
|
||||
COALESCE(SUM(frm.read_bytes),0) AS downFlowBytes,
|
||||
#{curDayBeginDate} AS date
|
||||
FROM flow_report_minute frm
|
||||
WHERE frm.date >= #{curDayBeginDate} AND frm.date <= #{curDate}
|
||||
GROUP BY frm.user_id,frm.license_id
|
||||
@@ -191,35 +191,35 @@
|
||||
|
||||
<select id="homeTodayFlow" resultType="org.dromara.neutrinoproxy.server.service.bo.FlowBO">
|
||||
SELECT
|
||||
IFNULL(SUM(frm.write_bytes),0) AS 'upFlowBytes',
|
||||
IFNULL(SUM(frm.read_bytes),0) AS 'downFlowBytes'
|
||||
COALESCE(SUM(frm.write_bytes),0) AS upFlowBytes,
|
||||
COALESCE(SUM(frm.read_bytes),0) AS downFlowBytes
|
||||
FROM flow_report_minute frm
|
||||
WHERE frm.date >= #{curDayBeginDate} AND frm.date <= #{curDate}
|
||||
</select>
|
||||
|
||||
<select id="homeTotalFlow" resultType="org.dromara.neutrinoproxy.server.service.bo.FlowBO">
|
||||
SELECT
|
||||
IFNULL(SUM(T.upFlowBytes),0) AS 'upFlowBytes',
|
||||
IFNULL(SUM(T.downFlowBytes),0) AS 'downFlowBytes'
|
||||
COALESCE(SUM(T.upFlowBytes),0) AS upFlowBytes,
|
||||
COALESCE(SUM(T.downFlowBytes),0) AS downFlowBytes
|
||||
FROM (
|
||||
|
||||
SELECT
|
||||
IFNULL(SUM(frm.write_bytes),0) AS 'upFlowBytes',
|
||||
IFNULL(SUM(frm.read_bytes),0) AS 'downFlowBytes'
|
||||
COALESCE(SUM(frm.write_bytes),0) AS upFlowBytes,
|
||||
COALESCE(SUM(frm.read_bytes),0) AS downFlowBytes
|
||||
FROM flow_report_month frm
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
IFNULL(SUM(frd.write_bytes),0) AS 'upFlowBytes',
|
||||
IFNULL(SUM(frd.read_bytes),0) AS 'downFlowBytes'
|
||||
COALESCE(SUM(frd.write_bytes),0) AS upFlowBytes,
|
||||
COALESCE(SUM(frd.read_bytes),0) AS downFlowBytes
|
||||
FROM flow_report_day frd
|
||||
WHERE frd.date >= #{curMonthBeginDate} AND frd.date <= #{curDayBeginDate}
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
IFNULL(SUM(frm.write_bytes),0) AS 'upFlowBytes',
|
||||
IFNULL(SUM(frm.read_bytes),0) AS 'downFlowBytes'
|
||||
COALESCE(SUM(frm.write_bytes),0) AS upFlowBytes,
|
||||
COALESCE(SUM(frm.read_bytes),0) AS downFlowBytes
|
||||
FROM flow_report_minute frm
|
||||
WHERE frm.date >= #{curDayBeginDate} AND frm.date <= #{curDate}
|
||||
|
||||
@@ -233,8 +233,8 @@
|
||||
|
||||
SELECT
|
||||
frd.date,
|
||||
IFNULL(SUM(frd.write_bytes),0) AS 'upFlowBytes',
|
||||
IFNULL(SUM(frd.read_bytes),0) AS 'downFlowBytes'
|
||||
COALESCE(SUM(frd.write_bytes),0) AS upFlowBytes,
|
||||
COALESCE(SUM(frd.read_bytes),0) AS downFlowBytes
|
||||
FROM flow_report_day frd
|
||||
WHERE frd.date >= #{beginDate} AND frd.date <= #{curDayBeginDate}
|
||||
GROUP BY frd.date
|
||||
@@ -242,9 +242,9 @@
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
#{curDayBeginDate} AS 'date',
|
||||
IFNULL(SUM(frm.write_bytes),0) AS 'upFlowBytes',
|
||||
IFNULL(SUM(frm.read_bytes),0) AS 'downFlowBytes'
|
||||
#{curDayBeginDate} AS date,
|
||||
COALESCE(SUM(frm.write_bytes),0) AS upFlowBytes,
|
||||
COALESCE(SUM(frm.read_bytes),0) AS downFlowBytes
|
||||
FROM flow_report_minute frm
|
||||
WHERE frm.date >= #{curDayBeginDate} AND frm.date <= #{curDate}
|
||||
|
||||
|
||||
@@ -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>
|
||||
@@ -1,24 +1,24 @@
|
||||
#############################系统管理相关表#############################
|
||||
#用户表
|
||||
CREATE TABLE IF NOT EXISTS `user` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
`name` VARCHAR(50) NOT NULL,
|
||||
`login_name` VARCHAR(50) NOT NULL,
|
||||
`login_password` VARCHAR(255) NOT NULL,
|
||||
`enable` INTEGER(2) NOT NULL,
|
||||
`create_time` INTEGER(20) NOT NULL,
|
||||
`update_time` INTEGER(20) NOT NULL
|
||||
`create_time` TIMESTAMP NOT NULL,
|
||||
`update_time` TIMESTAMP NOT NULL
|
||||
);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS I_user_login_name ON `user` (login_name ASC);
|
||||
|
||||
#用户token表
|
||||
CREATE TABLE IF NOT EXISTS `user_token` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
`token` VARCHAR(50) NOT NULL,
|
||||
`user_id` INTEGER NOT NULL,
|
||||
`expiration_time` INTEGER NOT NULL,
|
||||
`create_time` INTEGER NOT NULL,
|
||||
`update_time` INTEGER NOT NULL
|
||||
`expiration_time` TIMESTAMP NOT NULL,
|
||||
`create_time` TIMESTAMP NOT NULL,
|
||||
`update_time` TIMESTAMP NOT NULL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS I_user_token_user_id ON user_token(user_id);
|
||||
CREATE INDEX IF NOT EXISTS I_user_token_token ON user_token(token);
|
||||
@@ -26,81 +26,119 @@ CREATE INDEX IF NOT EXISTS I_user_token_expiration_time ON user_token(expiration
|
||||
|
||||
#端口池
|
||||
CREATE TABLE IF NOT EXISTS `port_pool` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
`group_id` INTEGER NOT NULL DEFAULT 1,
|
||||
`port` INTEGER NOT NULL,
|
||||
`enable` INTEGER(2) NOT NULL,
|
||||
`update_time` INTEGER(20) NOT NULL,
|
||||
`create_time` INTEGER(20) NOT NULL
|
||||
`update_time` TIMESTAMP NOT NULL,
|
||||
`create_time` TIMESTAMP NOT NULL
|
||||
);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS I_port_pool_port ON port_pool (port ASC);
|
||||
|
||||
#端口分组
|
||||
CREATE TABLE IF NOT EXISTS `port_group` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
`name` VARCHAR(255) NOT NULL,
|
||||
`possessor_type` INTEGER NOT NULL DEFAULT '0',
|
||||
`possessor_id` INTEGER NOT NULL DEFAULT '-1',
|
||||
`enable` INTEGER NOT NULL,
|
||||
`create_time` datetime(3) NOT NULL,
|
||||
`update_time` datetime(3) NOT NULL
|
||||
`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` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
`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` INTEGER(20) NOT NULL,
|
||||
`update_time` INTEGER(20) NOT NULL
|
||||
`create_time` TIMESTAMP NOT NULL,
|
||||
`update_time` TIMESTAMP NOT NULL
|
||||
);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS I_license_key ON `license` (`key` ASC);
|
||||
|
||||
#端口映射表
|
||||
CREATE TABLE IF NOT EXISTS `port_mapping` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
`license_id` INTEGER(20) NOT NULL,
|
||||
`protocal` VARCHAR(10) NOT NULL DEFAULT 'TCP',
|
||||
`subdomain` VARCHAR(50) DEFAULT NULL,
|
||||
`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,
|
||||
`create_time` INTEGER(20) NOT NULL,
|
||||
`update_time` INTEGER(20) NOT NULL
|
||||
`security_group_id` INTEGER(20) NOT NULL DEFAULT 0,
|
||||
`create_time` TIMESTAMP NOT NULL,
|
||||
`update_time` TIMESTAMP NOT NULL
|
||||
);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS I_port_mapping_server_port ON port_mapping (server_port ASC);
|
||||
|
||||
#############################日志管理相关表#############################
|
||||
#用户登录记录表
|
||||
CREATE TABLE IF NOT EXISTS `user_login_record` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
`user_id` INTEGER NOT NULL,
|
||||
`ip` VARCHAR(50) NOT NULL,
|
||||
`token` VARCHAR(100) NOT NULL,
|
||||
`type` INTEGER(2) NOT NULL,
|
||||
`create_time` INTEGER(20) NOT NULL
|
||||
`create_time` TIMESTAMP NOT NULL
|
||||
);
|
||||
#客户端连接记录表
|
||||
CREATE TABLE IF NOT EXISTS `client_connect_record` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
`ip` VARCHAR(50) NOT NULL,
|
||||
`license_id` INTEGER(20) DEFAULT NULL,
|
||||
`type` INTEGER(2) NOT NULL,
|
||||
`msg` VARCHAR(512) DEFAULT NULL,
|
||||
`code` INTEGER(2) NOT NULL,
|
||||
`err` VARCHAR(512) DEFAULT NULL,
|
||||
`create_time` INTEGER(20) NOT NULL
|
||||
`create_time` TIMESTAMP NOT NULL
|
||||
);
|
||||
#############################调度管理相关表#############################
|
||||
#触发器信息表
|
||||
CREATE TABLE IF NOT EXISTS `job_info` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
`desc` VARCHAR(255) NOT NULL,
|
||||
`handler` VARCHAR(255) NOT NULL,
|
||||
`cron` VARCHAR(128) NOT NULL ,
|
||||
@@ -108,21 +146,21 @@ CREATE TABLE IF NOT EXISTS `job_info` (
|
||||
`alarm_email` VARCHAR(255) DEFAULT NULL,
|
||||
`alarm_ding` VARCHAR(255) DEFAULT NULL,
|
||||
`enable` INTEGER(2) NOT NULL,
|
||||
`create_time` INTEGER(20) NOT NULL,
|
||||
`update_time` INTEGER(20) NOT NULL
|
||||
`create_time` TIMESTAMP NOT NULL,
|
||||
`update_time` TIMESTAMP NOT NULL
|
||||
);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS I_job_info_handler ON `job_info` (`handler` ASC);
|
||||
|
||||
#触发器日志表
|
||||
CREATE TABLE IF NOT EXISTS `job_log` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
`job_id` INTEGER(20) NOT NULL,
|
||||
`handler` VARCHAR(255) NOT NULL,
|
||||
`param` VARCHAR(512) DEFAULT NULL,
|
||||
`code` INTEGER(20) NOT NULL,
|
||||
`msg` TEXT DEFAULT NULL,
|
||||
`alarm_status` INTEGER(2) NOT NULL DEFAULT '0',
|
||||
`create_time` INTEGER(20) NOT NULL
|
||||
`create_time` TIMESTAMP NOT NULL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS I_job_log_create_time ON job_log(create_time);
|
||||
CREATE INDEX IF NOT EXISTS I_job_log_code ON job_log(code);
|
||||
@@ -130,14 +168,14 @@ CREATE INDEX IF NOT EXISTS I_job_log_code ON job_log(code);
|
||||
#############################报表管理相关表#############################
|
||||
#流量统计报表-分钟(保留24小时)
|
||||
CREATE TABLE IF NOT EXISTS `flow_report_minute` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
`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,
|
||||
`date` 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` INTEGER(20) NOT NULL
|
||||
`create_time` TIMESTAMP NOT NULL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS I_flow_report_minute_create_time ON flow_report_minute(create_time);
|
||||
CREATE INDEX IF NOT EXISTS I_flow_report_minute_date ON flow_report_minute(`date`);
|
||||
@@ -146,14 +184,14 @@ CREATE INDEX IF NOT EXISTS I_flow_report_minute_license_id ON flow_report_minute
|
||||
|
||||
#流量统计报表-小时(保留60天)
|
||||
CREATE TABLE IF NOT EXISTS `flow_report_hour` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
`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,
|
||||
`date` 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` INTEGER(20) NOT NULL
|
||||
`create_time` TIMESTAMP NOT NULL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS I_flow_report_hour_create_time ON flow_report_hour(create_time);
|
||||
CREATE INDEX IF NOT EXISTS I_flow_report_hour_date ON flow_report_hour(`date`);
|
||||
@@ -162,14 +200,14 @@ CREATE INDEX IF NOT EXISTS I_flow_report_hour_license_id ON flow_report_hour(`li
|
||||
|
||||
#流量统计报表-天(保留1年)
|
||||
CREATE TABLE IF NOT EXISTS `flow_report_day` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
`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,
|
||||
`date` 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` INTEGER(20) NOT NULL
|
||||
`create_time` TIMESTAMP NOT NULL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS I_flow_report_day_create_time ON flow_report_day(create_time);
|
||||
CREATE INDEX IF NOT EXISTS I_flow_report_day_date ON flow_report_day(`date`);
|
||||
@@ -178,16 +216,16 @@ CREATE INDEX IF NOT EXISTS I_flow_report_day_license_id ON flow_report_day(`lice
|
||||
|
||||
#流量统计报表-月(全量保留)
|
||||
CREATE TABLE IF NOT EXISTS `flow_report_month` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
`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,
|
||||
`date` 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` INTEGER(20) NOT NULL
|
||||
`create_time` TIMESTAMP NOT NULL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS I_flow_report_month_create_time ON flow_report_month(create_time);
|
||||
CREATE INDEX IF NOT EXISTS I_flow_report_month_date ON flow_report_month(`date`);
|
||||
CREATE INDEX IF NOT EXISTS I_flow_report_month_user_id ON flow_report_month(`user_id`);
|
||||
CREATE INDEX IF NOT EXISTS I_flow_report_month_license_id ON flow_report_month(`license_id`);
|
||||
CREATE INDEX IF NOT EXISTS I_flow_report_month_license_id ON flow_report_month(`license_id`);
|
||||
@@ -1,13 +1,13 @@
|
||||
#job_qrtz_trigger_info
|
||||
INSERT INTO job_info(`id`, `desc`, `handler`, `cron`, `param`, `enable`, `create_time`, `update_time`) VALUES
|
||||
(1, '示例Job', 'DemoJob', '0/10 * * * * ?', '{"a":101}', 1, STRFTIME('%s000', 'NOW'), STRFTIME('%s000', 'NOW'));
|
||||
(1, '示例Job', 'DemoJob', '0/10 * * * * ?', '{"a":101}', 1, now(), now());
|
||||
INSERT INTO job_info(`id`, `desc`, `handler`, `cron`, `param`, `enable`, `create_time`, `update_time`) VALUES
|
||||
(2, '数据清理任务', 'DataCleanJob', '0 0 1 * * ?', '', 1, STRFTIME('%s000', 'NOW'), STRFTIME('%s000', 'NOW'));
|
||||
(2, '数据清理任务', 'DataCleanJob', '0 0 1 * * ?', '', 1, now(), now());
|
||||
INSERT INTO job_info(`id`, `desc`, `handler`, `cron`, `param`, `enable`, `create_time`, `update_time`) VALUES
|
||||
(3, '流量统计报表-分钟', 'FlowReportForMinuteJob', '0 */1 * * * ?', '', 1, STRFTIME('%s000', 'NOW'), STRFTIME('%s000', 'NOW'));
|
||||
(3, '流量统计报表-分钟', 'FlowReportForMinuteJob', '0 */1 * * * ?', '', 1, now(), now());
|
||||
INSERT INTO job_info(`id`, `desc`, `handler`, `cron`, `param`, `enable`, `create_time`, `update_time`) VALUES
|
||||
(4, '流量统计报表-小时', 'FlowReportForHourJob', '0 0 */1 * * ?', '', 1, STRFTIME('%s000', 'NOW'), STRFTIME('%s000', 'NOW'));
|
||||
(4, '流量统计报表-小时', 'FlowReportForHourJob', '0 0 */1 * * ?', '', 1, now(), now());
|
||||
INSERT INTO job_info(`id`, `desc`, `handler`, `cron`, `param`, `enable`, `create_time`, `update_time`) VALUES
|
||||
(5, '流量统计报表-天', 'FlowReportForDayJob', '0 0 1 * * ?', '', 1, STRFTIME('%s000', 'NOW'), STRFTIME('%s000', 'NOW'));
|
||||
(5, '流量统计报表-天', 'FlowReportForDayJob', '0 0 1 * * ?', '', 1, now(), now());
|
||||
INSERT INTO job_info(`id`, `desc`, `handler`, `cron`, `param`, `enable`, `create_time`, `update_time`) VALUES
|
||||
(6, '流量统计报表-月', 'FlowReportForMonthJob', '0 30 1 1 * ?', '', 1, STRFTIME('%s000', 'NOW'), STRFTIME('%s000', 'NOW'));
|
||||
(6, '流量统计报表-月', 'FlowReportForMonthJob', '0 30 1 1 * ?', '', 1, now(), now());
|
||||
@@ -1,3 +1,3 @@
|
||||
#license
|
||||
INSERT INTO license(`id`, `name`, `key`, `user_id`, `is_online`, `enable`, `create_time`, `update_time`) VALUES
|
||||
(1, '我的mac', 'b0a907332b474b25897c4dcb31fc7eb6', 1, 2, 1, STRFTIME('%s000', 'NOW'), STRFTIME('%s000', 'NOW'));
|
||||
(1, '我的mac', 'b0a907332b474b25897c4dcb31fc7eb6', 1, 2, 1, now(), now());
|
||||
@@ -1,3 +1,3 @@
|
||||
#port_group
|
||||
INSERT INTO `port_group`(`id`,`name`,`possessor_type`,`possessor_id`,`enable`,`create_time`,`update_time`) VALUES
|
||||
(1, '全局(默认)', 0, -1, 1, STRFTIME('%s000', 'NOW'), STRFTIME('%s000', 'NOW'));
|
||||
(1, '全局(默认)', 0, -1, 1, now(), now());
|
||||
@@ -1,7 +1,7 @@
|
||||
#port_mapping
|
||||
INSERT INTO port_mapping(`id`, `license_id`, `server_port`, `protocal`, `subdomain`,`client_ip`, `client_port`, `is_online`, `enable`,`description`,`create_time`, `update_time`) VALUES
|
||||
(1, 1, 9101, 'HTTP', 'test1', '127.0.0.1', 8080, 2, 1,'test1', STRFTIME('%s000', 'NOW'), STRFTIME('%s000', 'NOW'));
|
||||
(1, 1, 9101, 'HTTP', 'test1', '127.0.0.1', 8080, 2, 1,'test1', now(), now());
|
||||
INSERT INTO port_mapping(`id`, `license_id`, `server_port`, `protocal`, `subdomain`, `client_ip`, `client_port`, `is_online`, `enable`,`description`, `create_time`, `update_time`) VALUES
|
||||
(2, 1, 9102, 'TCP', '', '127.0.0.1', 3306, 2, 1,'test2', STRFTIME('%s000', 'NOW'), STRFTIME('%s000', 'NOW'));
|
||||
(2, 1, 9102, 'TCP', '', '127.0.0.1', 3306, 2, 1,'test2', now(), now());
|
||||
INSERT INTO port_mapping(`id`, `license_id`, `server_port`, `protocal`, `subdomain`, `client_ip`, `client_port`, `is_online`, `enable`,`description`, `create_time`, `update_time`) VALUES
|
||||
(3, 1, 9103, 'HTTP', 'test2', '127.0.0.1', 8081, 2, 1,'test3', STRFTIME('%s000', 'NOW'), STRFTIME('%s000', 'NOW'));
|
||||
(3, 1, 9103, 'HTTP', 'test2', '127.0.0.1', 8081, 2, 1,'test3', now(), now());
|
||||
@@ -1,41 +1,41 @@
|
||||
#端口池
|
||||
INSERT INTO port_pool(`id`, `group_id`, `port`, `enable`, `create_time`, `update_time`) VALUES
|
||||
(1, 1, 9101, 1, STRFTIME('%s000', 'NOW'), STRFTIME('%s000', 'NOW'));
|
||||
(1, 1, 9101, 1, now(), now());
|
||||
INSERT INTO port_pool(`id`, `group_id`, `port`, `enable`, `create_time`, `update_time`) VALUES
|
||||
(2, 1, 9102, 1, STRFTIME('%s000', 'NOW'), STRFTIME('%s000', 'NOW'));
|
||||
(2, 1, 9102, 1, now(), now());
|
||||
INSERT INTO port_pool(`id`, `group_id`, `port`, `enable`, `create_time`, `update_time`) VALUES
|
||||
(3, 1, 9103, 1, STRFTIME('%s000', 'NOW'), STRFTIME('%s000', 'NOW'));
|
||||
(3, 1, 9103, 1, now(), now());
|
||||
INSERT INTO port_pool(`id`, `group_id`, `port`, `enable`, `create_time`, `update_time`) VALUES
|
||||
(4, 1, 9104, 1, STRFTIME('%s000', 'NOW'), STRFTIME('%s000', 'NOW'));
|
||||
(4, 1, 9104, 1, now(), now());
|
||||
INSERT INTO port_pool(`id`, `group_id`, `port`, `enable`, `create_time`, `update_time`) VALUES
|
||||
(5, 1, 9105, 1, STRFTIME('%s000', 'NOW'), STRFTIME('%s000', 'NOW'));
|
||||
(5, 1, 9105, 1, now(), now());
|
||||
INSERT INTO port_pool(`id`, `group_id`, `port`, `enable`, `create_time`, `update_time`) VALUES
|
||||
(6, 1, 9106, 1, STRFTIME('%s000', 'NOW'), STRFTIME('%s000', 'NOW'));
|
||||
(6, 1, 9106, 1, now(), now());
|
||||
INSERT INTO port_pool(`id`, `group_id`, `port`, `enable`, `create_time`, `update_time`) VALUES
|
||||
(7, 1, 9107, 1, STRFTIME('%s000', 'NOW'), STRFTIME('%s000', 'NOW'));
|
||||
(7, 1, 9107, 1, now(), now());
|
||||
INSERT INTO port_pool(`id`, `group_id`, `port`, `enable`, `create_time`, `update_time`) VALUES
|
||||
(8, 1, 9108, 1, STRFTIME('%s000', 'NOW'), STRFTIME('%s000', 'NOW'));
|
||||
(8, 1, 9108, 1, now(), now());
|
||||
INSERT INTO port_pool(`id`, `group_id`, `port`, `enable`, `create_time`, `update_time`) VALUES
|
||||
(9, 1, 9109, 1, STRFTIME('%s000', 'NOW'), STRFTIME('%s000', 'NOW'));
|
||||
(9, 1, 9109, 1, now(), now());
|
||||
INSERT INTO port_pool(`id`, `group_id`, `port`, `enable`, `create_time`, `update_time`) VALUES
|
||||
(10, 1, 9110, 1, STRFTIME('%s000', 'NOW'), STRFTIME('%s000', 'NOW'));
|
||||
(10, 1, 9110, 1, now(), now());
|
||||
INSERT INTO port_pool(`id`, `group_id`, `port`, `enable`, `create_time`, `update_time`) VALUES
|
||||
(11, 1, 9111, 1, STRFTIME('%s000', 'NOW'), STRFTIME('%s000', 'NOW'));
|
||||
(11, 1, 9111, 1, now(), now());
|
||||
INSERT INTO port_pool(`id`, `group_id`, `port`, `enable`, `create_time`, `update_time`) VALUES
|
||||
(12, 1, 9112, 1, STRFTIME('%s000', 'NOW'), STRFTIME('%s000', 'NOW'));
|
||||
(12, 1, 9112, 1, now(), now());
|
||||
INSERT INTO port_pool(`id`, `group_id`, `port`, `enable`, `create_time`, `update_time`) VALUES
|
||||
(13, 1, 9113, 1, STRFTIME('%s000', 'NOW'), STRFTIME('%s000', 'NOW'));
|
||||
(13, 1, 9113, 1, now(), now());
|
||||
INSERT INTO port_pool(`id`, `group_id`, `port`, `enable`, `create_time`, `update_time`) VALUES
|
||||
(14, 1, 9114, 1, STRFTIME('%s000', 'NOW'), STRFTIME('%s000', 'NOW'));
|
||||
(14, 1, 9114, 1, now(), now());
|
||||
INSERT INTO port_pool(`id`, `group_id`, `port`, `enable`, `create_time`, `update_time`) VALUES
|
||||
(15, 1, 9115, 1, STRFTIME('%s000', 'NOW'), STRFTIME('%s000', 'NOW'));
|
||||
(15, 1, 9115, 1, now(), now());
|
||||
INSERT INTO port_pool(`id`, `group_id`, `port`, `enable`, `create_time`, `update_time`) VALUES
|
||||
(16, 1, 9116, 1, STRFTIME('%s000', 'NOW'), STRFTIME('%s000', 'NOW'));
|
||||
(16, 1, 9116, 1, now(), now());
|
||||
INSERT INTO port_pool(`id`, `group_id`, `port`, `enable`, `create_time`, `update_time`) VALUES
|
||||
(17, 1, 9117, 1, STRFTIME('%s000', 'NOW'), STRFTIME('%s000', 'NOW'));
|
||||
(17, 1, 9117, 1, now(), now());
|
||||
INSERT INTO port_pool(`id`, `group_id`, `port`, `enable`, `create_time`, `update_time`) VALUES
|
||||
(18, 1, 9118, 1, STRFTIME('%s000', 'NOW'), STRFTIME('%s000', 'NOW'));
|
||||
(18, 1, 9118, 1, now(), now());
|
||||
INSERT INTO port_pool(`id`, `group_id`, `port`, `enable`, `create_time`, `update_time`) VALUES
|
||||
(19, 1, 9119, 1, STRFTIME('%s000', 'NOW'), STRFTIME('%s000', 'NOW'));
|
||||
(19, 1, 9119, 1, now(), now());
|
||||
INSERT INTO port_pool(`id`, `group_id`, `port`, `enable`, `create_time`, `update_time`) VALUES
|
||||
(20, 1, 9120, 1, STRFTIME('%s000', 'NOW'), STRFTIME('%s000', 'NOW'));
|
||||
(20, 1, 9120, 1, now(), now());
|
||||
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE port_mapping ADD `proxy_responses` INTEGER(20) NOT NULL DEFAULT 0;
|
||||
ALTER TABLE port_mapping ADD `proxy_timeout_ms` INTEGER(20) NOT NULL DEFAULT 0;
|
||||
@@ -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;
|
||||
@@ -1,5 +1,5 @@
|
||||
#用户表 6613b92b77056faeb72068f184ed4c4f
|
||||
INSERT INTO `user`(`id`, `name`,`login_name`,`login_password`,`enable`,`create_time`, `update_time`) VALUES
|
||||
(1, '管理员', 'admin', 'e10adc3949ba59abbe56e057f20f883e', 1, STRFTIME('%s000', 'NOW'), STRFTIME('%s000', 'NOW'));
|
||||
(1, '管理员', 'admin', 'e10adc3949ba59abbe56e057f20f883e', 1, now(), now());
|
||||
INSERT INTO `user`(`id`, `name`,`login_name`,`login_password`,`enable`,`create_time`, `update_time`) VALUES
|
||||
(2, '游客', 'visitor', 'e10adc3949ba59abbe56e057f20f883e', 1, STRFTIME('%s000', 'NOW'), STRFTIME('%s000', 'NOW'));
|
||||
(2, '游客', 'visitor', 'e10adc3949ba59abbe56e057f20f883e', 1, now(), now());
|
||||
@@ -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,9 +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`),
|
||||
@@ -143,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 '创建时间',
|
||||
@@ -160,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 '创建时间',
|
||||
@@ -177,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 '创建时间',
|
||||
@@ -194,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 '创建时间',
|
||||
@@ -204,4 +241,4 @@ CREATE TABLE IF NOT EXISTS `flow_report_month` (
|
||||
KEY `I_flow_report_month_date` (`date`) USING BTREE,
|
||||
KEY `I_flow_report_month_user_id` (`user_id`),
|
||||
KEY `I_flow_report_month_license_id` (`license_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
@@ -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,9 +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`),
|
||||
@@ -143,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 '创建时间',
|
||||
@@ -160,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 '创建时间',
|
||||
@@ -177,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 '创建时间',
|
||||
@@ -194,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 '创建时间',
|
||||
@@ -204,4 +241,5 @@ CREATE TABLE IF NOT EXISTS `flow_report_month` (
|
||||
KEY `I_flow_report_month_date` (`date`) USING BTREE,
|
||||
KEY `I_flow_report_month_user_id` (`user_id`),
|
||||
KEY `I_flow_report_month_license_id` (`license_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE port_mapping ADD `proxy_responses` int NOT NULL DEFAULT 0 COMMENT '代理响应数据包数量';
|
||||
ALTER TABLE port_mapping ADD `proxy_timeout_ms` int NOT NULL DEFAULT 0 COMMENT '代理超时毫秒数';
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
@@ -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 {
|
||||
}
|
||||
@@ -30,7 +30,9 @@ module.exports = {
|
||||
{text: '后台操作指南', link: '/pages/793dcc/'},
|
||||
]
|
||||
},
|
||||
{text: '演示', link: '/pages/db78e2/'},
|
||||
{text: '案例', link: '/pages/5d571c/'},
|
||||
{text: '支持', link: '/pages/1ab20b/'},
|
||||
{text: '更新记录', link: '/pages/ff3519/'},
|
||||
{text: 'Gitee', link: 'https://gitee.com/dromara/neutrino-proxy'},
|
||||
],
|
||||
sidebarDepth: 2, // 侧边栏显示深度,默认1,最大2(显示到h3标题)
|
||||
|
||||
|
After Width: | Height: | Size: 4.4 KiB |
|
After Width: | Height: | Size: 48 KiB |
|
After Width: | Height: | Size: 53 KiB |
|
After Width: | Height: | Size: 60 KiB |
|
After Width: | Height: | Size: 38 KiB |
|
After Width: | Height: | Size: 4.8 KiB |
|
After Width: | Height: | Size: 301 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 103 KiB |
|
After Width: | Height: | Size: 6.3 KiB |
|
After Width: | Height: | Size: 6.3 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 53 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 9.7 KiB |
|
After Width: | Height: | Size: 176 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 33 KiB |
|
After Width: | Height: | Size: 456 KiB |
|
After Width: | Height: | Size: 7.4 KiB |
|
After Width: | Height: | Size: 38 KiB |
|
After Width: | Height: | Size: 6.5 KiB |
|
After Width: | Height: | Size: 11 KiB |
@@ -0,0 +1,11 @@
|
||||
<svg width="206" height="53" viewBox="0 0 206 53" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0_501_120)">
|
||||
<path d="M59.0087 36H54.5243V13.5938H59.0087V22.5625H67.9618V13.5938H72.4462V36H67.9618V27.0469H59.0087V36ZM82.5712 31.9062C82.7378 31.9583 82.9045 31.9948 83.0712 32.0156C83.2378 32.026 83.4045 32.0312 83.5712 32.0312C83.9878 32.0312 84.3889 31.974 84.7743 31.8594C85.1597 31.7448 85.5191 31.5833 85.8524 31.375C86.1962 31.1562 86.4983 30.8958 86.7587 30.5938C87.0295 30.2812 87.2483 29.9375 87.4149 29.5625L90.5399 32.7031C90.1441 33.2656 89.6858 33.7708 89.1649 34.2188C88.6545 34.6667 88.0972 35.0469 87.493 35.3594C86.8993 35.6719 86.2691 35.9062 85.6024 36.0625C84.9462 36.2292 84.2691 36.3125 83.5712 36.3125C82.3941 36.3125 81.2847 36.0938 80.243 35.6562C79.2118 35.2188 78.3055 34.6094 77.5243 33.8281C76.7535 33.0469 76.1441 32.1198 75.6962 31.0469C75.2483 29.9635 75.0243 28.776 75.0243 27.4844C75.0243 26.1615 75.2483 24.9531 75.6962 23.8594C76.1441 22.7656 76.7535 21.8333 77.5243 21.0625C78.3055 20.2917 79.2118 19.6927 80.243 19.2656C81.2847 18.8385 82.3941 18.625 83.5712 18.625C84.2691 18.625 84.9514 18.7083 85.618 18.875C86.2847 19.0417 86.9149 19.2812 87.5087 19.5938C88.1128 19.9062 88.6753 20.2917 89.1962 20.75C89.717 21.1979 90.1753 21.7031 90.5712 22.2656L82.5712 31.9062ZM84.7587 23.1094C84.5608 23.0365 84.3628 22.9896 84.1649 22.9688C83.9774 22.9479 83.7795 22.9375 83.5712 22.9375C82.9878 22.9375 82.4358 23.0469 81.9149 23.2656C81.4045 23.474 80.9566 23.776 80.5712 24.1719C80.1962 24.5677 79.8993 25.0469 79.6805 25.6094C79.4618 26.1615 79.3524 26.7865 79.3524 27.4844C79.3524 27.6406 79.3576 27.8177 79.368 28.0156C79.3889 28.2135 79.4149 28.4167 79.4462 28.625C79.4878 28.8229 79.5347 29.0156 79.5868 29.2031C79.6389 29.3906 79.7066 29.5573 79.7899 29.7031L84.7587 23.1094ZM96.993 36H92.7274V19.2656H93.7587L95.1649 21.25C95.8524 20.625 96.6337 20.1458 97.5087 19.8125C98.3837 19.4688 99.2899 19.2969 100.227 19.2969H103.993V23.5469H100.227C99.7795 23.5469 99.3576 23.6302 98.9618 23.7969C98.566 23.9635 98.2222 24.1927 97.9305 24.4844C97.6389 24.776 97.4097 25.1198 97.243 25.5156C97.0764 25.9115 96.993 26.3333 96.993 26.7812V36ZM114.368 36C113.337 36 112.368 35.8073 111.462 35.4219C110.556 35.026 109.759 34.4896 109.071 33.8125C108.394 33.125 107.858 32.3281 107.462 31.4219C107.076 30.5156 106.884 29.5469 106.884 28.5156V23.5469H104.806V19.2969H106.884V12.6094H111.134V19.2969H117.602V23.5469H111.134V28.5156C111.134 28.9635 111.217 29.3854 111.384 29.7812C111.55 30.1667 111.78 30.5052 112.071 30.7969C112.363 31.0885 112.707 31.3229 113.102 31.5C113.498 31.6667 113.92 31.75 114.368 31.75H117.602V36H114.368ZM133.071 36H119.118L126.165 23.5469H119.118V19.2969H133.071L126.024 31.75H133.071V36ZM153.821 29.2812C153.821 30.2083 153.644 31.0781 153.29 31.8906C152.936 32.7031 152.451 33.4167 151.837 34.0312C151.233 34.6354 150.524 35.1146 149.712 35.4688C148.899 35.8229 148.03 36 147.102 36H135.899V13.5938H147.102C148.03 13.5938 148.899 13.7708 149.712 14.125C150.524 14.4792 151.233 14.9635 151.837 15.5781C152.451 16.1823 152.936 16.8906 153.29 17.7031C153.644 18.5156 153.821 19.3854 153.821 20.3125C153.821 20.7292 153.764 21.1562 153.649 21.5938C153.535 22.0312 153.373 22.4531 153.165 22.8594C152.957 23.2656 152.707 23.6354 152.415 23.9688C152.123 24.3021 151.8 24.5781 151.446 24.7969C151.811 24.9948 152.139 25.2656 152.431 25.6094C152.722 25.9427 152.972 26.3125 153.181 26.7188C153.389 27.125 153.545 27.5521 153.649 28C153.764 28.4375 153.821 28.8646 153.821 29.2812ZM140.384 31.5156H147.102C147.415 31.5156 147.707 31.4583 147.977 31.3438C148.248 31.2292 148.483 31.0729 148.681 30.875C148.889 30.6667 149.05 30.4271 149.165 30.1562C149.28 29.8854 149.337 29.5938 149.337 29.2812C149.337 28.9688 149.28 28.6771 149.165 28.4062C149.05 28.1354 148.889 27.901 148.681 27.7031C148.483 27.4948 148.248 27.3333 147.977 27.2188C147.707 27.1042 147.415 27.0469 147.102 27.0469H140.384V31.5156ZM140.384 22.5625H147.102C147.415 22.5625 147.707 22.5052 147.977 22.3906C148.248 22.276 148.483 22.1198 148.681 21.9219C148.889 21.7135 149.05 21.474 149.165 21.2031C149.28 20.9219 149.337 20.625 149.337 20.3125C149.337 20 149.28 19.7083 149.165 19.4375C149.05 19.1667 148.889 18.9323 148.681 18.7344C148.483 18.526 148.248 18.3646 147.977 18.25C147.707 18.1354 147.415 18.0781 147.102 18.0781H140.384V22.5625ZM163.415 31.9062C163.582 31.9583 163.748 31.9948 163.915 32.0156C164.082 32.026 164.248 32.0312 164.415 32.0312C164.832 32.0312 165.233 31.974 165.618 31.8594C166.003 31.7448 166.363 31.5833 166.696 31.375C167.04 31.1562 167.342 30.8958 167.602 30.5938C167.873 30.2812 168.092 29.9375 168.259 29.5625L171.384 32.7031C170.988 33.2656 170.53 33.7708 170.009 34.2188C169.498 34.6667 168.941 35.0469 168.337 35.3594C167.743 35.6719 167.113 35.9062 166.446 36.0625C165.79 36.2292 165.113 36.3125 164.415 36.3125C163.238 36.3125 162.128 36.0938 161.087 35.6562C160.056 35.2188 159.149 34.6094 158.368 33.8281C157.597 33.0469 156.988 32.1198 156.54 31.0469C156.092 29.9635 155.868 28.776 155.868 27.4844C155.868 26.1615 156.092 24.9531 156.54 23.8594C156.988 22.7656 157.597 21.8333 158.368 21.0625C159.149 20.2917 160.056 19.6927 161.087 19.2656C162.128 18.8385 163.238 18.625 164.415 18.625C165.113 18.625 165.795 18.7083 166.462 18.875C167.128 19.0417 167.759 19.2812 168.352 19.5938C168.957 19.9062 169.519 20.2917 170.04 20.75C170.561 21.1979 171.019 21.7031 171.415 22.2656L163.415 31.9062ZM165.602 23.1094C165.405 23.0365 165.207 22.9896 165.009 22.9688C164.821 22.9479 164.623 22.9375 164.415 22.9375C163.832 22.9375 163.28 23.0469 162.759 23.2656C162.248 23.474 161.8 23.776 161.415 24.1719C161.04 24.5677 160.743 25.0469 160.524 25.6094C160.306 26.1615 160.196 26.7865 160.196 27.4844C160.196 27.6406 160.201 27.8177 160.212 28.0156C160.233 28.2135 160.259 28.4167 160.29 28.625C160.332 28.8229 160.378 29.0156 160.431 29.2031C160.483 29.3906 160.55 29.5573 160.634 29.7031L165.602 23.1094ZM189.649 36H188.618L186.962 33.7031C186.556 34.0677 186.123 34.4115 185.665 34.7344C185.217 35.0469 184.743 35.3229 184.243 35.5625C183.743 35.7917 183.227 35.974 182.696 36.1094C182.175 36.2448 181.644 36.3125 181.102 36.3125C179.925 36.3125 178.816 36.1146 177.774 35.7188C176.743 35.3229 175.837 34.75 175.056 34C174.285 33.2396 173.675 32.3125 173.227 31.2188C172.78 30.125 172.556 28.8802 172.556 27.4844C172.556 26.1823 172.78 24.9896 173.227 23.9062C173.675 22.8125 174.285 21.875 175.056 21.0938C175.837 20.3125 176.743 19.7083 177.774 19.2812C178.816 18.8438 179.925 18.625 181.102 18.625C181.644 18.625 182.181 18.6927 182.712 18.8281C183.243 18.9635 183.759 19.151 184.259 19.3906C184.759 19.6302 185.233 19.9115 185.681 20.2344C186.139 20.5573 186.566 20.9062 186.962 21.2812L188.618 19.2969H189.649V36ZM185.352 27.4844C185.352 26.901 185.238 26.3385 185.009 25.7969C184.79 25.2448 184.488 24.7604 184.102 24.3438C183.717 23.9167 183.264 23.5781 182.743 23.3281C182.233 23.0677 181.686 22.9375 181.102 22.9375C180.519 22.9375 179.967 23.0365 179.446 23.2344C178.936 23.4323 178.488 23.724 178.102 24.1094C177.727 24.4948 177.431 24.974 177.212 25.5469C176.993 26.1094 176.884 26.7552 176.884 27.4844C176.884 28.2135 176.993 28.8646 177.212 29.4375C177.431 30 177.727 30.474 178.102 30.8594C178.488 31.2448 178.936 31.5365 179.446 31.7344C179.967 31.9323 180.519 32.0312 181.102 32.0312C181.686 32.0312 182.233 31.9062 182.743 31.6562C183.264 31.3958 183.717 31.0573 184.102 30.6406C184.488 30.2135 184.79 29.7292 185.009 29.1875C185.238 28.6354 185.352 28.0677 185.352 27.4844ZM201.306 36C200.274 36 199.306 35.8073 198.399 35.4219C197.493 35.026 196.696 34.4896 196.009 33.8125C195.332 33.125 194.795 32.3281 194.399 31.4219C194.014 30.5156 193.821 29.5469 193.821 28.5156V23.5469H191.743V19.2969H193.821V12.6094H198.071V19.2969H204.54V23.5469H198.071V28.5156C198.071 28.9635 198.155 29.3854 198.321 29.7812C198.488 30.1667 198.717 30.5052 199.009 30.7969C199.3 31.0885 199.644 31.3229 200.04 31.5C200.436 31.6667 200.858 31.75 201.306 31.75H204.54V36H201.306Z" fill="#B421CC"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.8453 0C11.1261 0 0 10.745 0 24.001C0 33.826 6.11788 42.271 14.8744 45.982C14.804 44.308 14.862 42.293 15.304 40.47C15.7823 38.522 17.7077 27.5 17.7077 27.5C17.7077 27.5 17.7077 25.861 17.7077 23.595C17.7077 20.039 20.1176 21.819 22.7739 21.819L26.397 23C33.1256 23 43.995 23 43.995 23C43.995 23 34.1018 15.5 27.4322 15.5C19.8971 15.5 19.1508 15.5 19.1508 15.5C19.1508 17.594 13.9749 18 13.9749 18L11.9045 15.5L9.31658 14.5C9.31658 7.684 13.9956 8.069 25.7987 8.069C35.285 8.069 49.6884 14.5 43.995 23C43.995 23 34.3875 23 26.397 23C23.718 23 29.3327 31.09 28.4673 29.5C28.4673 29.5 28.9849 33 22.7739 37C22.248 38.85 18.7481 45.575 17.805 47.015C20.04 47.653 22.4012 48 24.8453 48C38.5655 48 49.6884 37.255 49.6884 24.001C49.6884 10.745 38.5655 0 24.8453 0Z" fill="#B421CC"/>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_501_120">
|
||||
<rect width="206" height="53" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 8.8 KiB |
|
After Width: | Height: | Size: 76 KiB |
|
After Width: | Height: | Size: 35 KiB |
|
After Width: | Height: | Size: 41 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 5.2 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 38 KiB |
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="380px" height="120px" viewBox="0 0 380 120" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>jpom-logo</title>
|
||||
<defs>
|
||||
<linearGradient x1="0.0077378419%" y1="0%" x2="99.9922622%" y2="100%" id="linearGradient-1">
|
||||
<stop stop-color="#5988FF" offset="0%"></stop>
|
||||
<stop stop-color="#0D58FF" offset="100%"></stop>
|
||||
</linearGradient>
|
||||
<path d="M97.0595063,0 C98.6792225,0 99.9922619,1.31303939 99.9922619,2.93275555 L99.9922619,83.9820475 C98.0456091,82.5565127 95.6960926,81.7868903 93.2832934,81.7844154 L92.9319967,81.7897766 C90.0097544,81.8790045 87.225876,83.0788415 85.1523588,85.1523588 C82.9959008,87.3088167 81.7844154,90.2336013 81.7844154,93.2832934 C81.7887374,95.7018607 82.5669783,98.0555651 84.0052619,100 L2.93275555,100 C1.31303939,100 0,98.6869606 0,97.0672444 L0,23.3072816 C0,21.6875654 1.31303939,20.374526 2.93275555,20.374526 L40.9038149,20.374526 C41.6822604,20.3724639 42.429417,20.6807875 42.979863,21.2312335 C43.530309,21.7816795 43.8386326,22.5288361 43.8365705,23.3072816 L43.8365705,78.9367794 L30.5114911,78.9367794 C29.733676,78.9367794 28.9877182,78.6277935 28.4377198,78.0777952 C27.8877214,77.5277968 27.5787356,76.781839 27.5787356,76.0040238 L27.5787356,34.4192525 C27.5787412,32.7982798 26.2669471,31.4830245 24.64598,31.4787588 L19.113209,31.4787588 C18.3340513,31.4787561 17.5869184,31.7888039 17.036697,32.3404771 C16.4864757,32.8921502 16.1783976,33.6400975 16.1804535,34.4192525 L16.1804535,73.9456782 C16.1783993,77.9092655 17.7520185,81.7111045 20.5546982,84.5137843 C23.357378,87.3164641 27.1592171,88.8900833 31.1228043,88.8880291 L68.8849338,88.8880291 C72.8478917,88.8880291 76.6485371,87.3137502 79.4507714,84.5115159 C82.2530058,81.7092815 83.8272847,77.9086361 83.8272847,73.9456782 L83.8272847,26.0543218 C83.8230153,17.8036584 77.1355972,11.1162403 68.8849338,11.1119709 L2.93275555,11.1119709 C1.31303939,11.1119709 0,9.79893152 0,8.17921535 L0,2.93275555 C0,1.31303939 1.31303939,0 2.93275555,0 Z M69.5271996,20.4054786 C71.1481666,20.4097443 72.4599551,21.7249996 72.4599551,23.3459723 L72.4599551,76.0427145 C72.4599551,76.8205297 72.1509693,77.5664875 71.6009709,78.1164859 C71.0509726,78.6664842 70.3050147,78.9754701 69.5271996,78.9754701 L59.1967809,78.9754701 C57.5758082,78.9754701 56.260553,77.6636816 56.2562872,76.0427145 L56.2562872,34.3573474 C56.2583431,33.5781924 55.950265,32.830245 55.4000437,32.2785719 C54.8498223,31.7268988 54.1026894,31.416851 53.3235317,31.4168537 L49.2842219,31.4168537 C47.6645058,31.4168537 46.3514664,30.1038143 46.3514664,28.4840981 L46.3514664,23.3459723 C46.3514664,21.7249996 47.6632549,20.4097443 49.2842219,20.4054786 Z" id="path-2"></path>
|
||||
<filter x="-6.5%" y="-5.5%" width="113.0%" height="113.0%" filterUnits="objectBoundingBox" id="filter-3">
|
||||
<feOffset dx="0" dy="1" in="SourceAlpha" result="shadowOffsetOuter1"></feOffset>
|
||||
<feGaussianBlur stdDeviation="2" in="shadowOffsetOuter1" result="shadowBlurOuter1"></feGaussianBlur>
|
||||
<feColorMatrix values="0 0 0 0 0.239215686 0 0 0 0 0.466666667 0 0 0 0 1 0 0 0 0.4 0" type="matrix" in="shadowBlurOuter1"></feColorMatrix>
|
||||
</filter>
|
||||
<linearGradient x1="0%" y1="41.21675%" x2="100%" y2="58.78325%" id="linearGradient-4">
|
||||
<stop stop-color="#5988FF" offset="0%"></stop>
|
||||
<stop stop-color="#0D58FF" offset="100%"></stop>
|
||||
</linearGradient>
|
||||
<path d="M321.177106,22 C326.648252,22 330.951915,23.8568225 334.001288,27.5645829 C337.018271,31.2329589 338.5054,36.5562047 338.5054,43.5075594 L338.5054,72.2764579 C338.5054,73.5037494 337.841444,74.4996824 336.640847,75.1857377 C335.575623,75.7944374 334.335668,76.0950324 332.937365,76.0950324 C331.544467,76.0950324 330.325067,75.8136323 329.292975,75.240248 C328.109924,74.5829978 327.466523,73.558321 327.466523,72.2764579 L327.466523,45.8401728 C327.466523,40.8955189 326.694202,37.2501639 325.194838,34.9111564 C323.764436,32.6797287 321.623311,31.5809935 318.650108,31.5809935 C316.79872,31.5809935 314.959692,32.2377892 313.114393,33.5771188 C311.238478,34.9386702 309.704728,36.7913184 308.510889,39.1483861 C307.319542,41.5005314 306.723542,44.0831986 306.723542,46.9092873 L306.723542,72.2764579 C306.723542,73.558321 306.08014,74.5829978 304.89709,75.240248 C303.864998,75.8136323 302.645598,76.0950324 301.2527,76.0950324 C299.859802,76.0950324 298.640401,75.8136323 297.60831,75.240248 C296.425259,74.5829978 295.781857,73.558321 295.781857,72.2764579 L295.781857,45.8401728 C295.781857,40.8955189 295.009536,37.2501639 293.510173,34.9111564 C292.080954,32.6815753 289.908011,31.5809935 286.868251,31.5809935 C285.088109,31.5809935 283.283388,32.2504868 281.43818,33.6195127 C279.556179,35.0158357 278.019002,36.8726239 276.823821,39.2016947 C275.633386,41.5215173 275.038877,44.0215023 275.038877,46.7149028 L275.038877,72.2764579 C275.038877,73.5037494 274.374922,74.4996824 273.174325,75.1857377 C272.111504,75.793064 270.90363,76.0950324 269.568035,76.0950324 C268.169731,76.0950324 266.929777,75.7944374 265.864552,75.1857377 C264.663955,74.4996824 264,73.5037494 264,72.2764579 L264,26.4989201 C264,25.2077738 264.668286,24.181477 265.88847,23.5278073 C266.948186,22.9601019 268.179114,22.6803456 269.568035,22.6803456 C270.71541,22.6803456 271.794876,22.969488 272.789139,23.5431017 C273.934643,24.2039694 274.552916,25.2264969 274.552916,26.4989201 L274.552,30.281 L274.790224,29.9647489 C276.112461,28.2407943 277.63116,26.7395118 279.345238,25.4631222 L279.777828,25.1487113 C282.731605,23.0535904 285.978736,22 289.492441,22 C293.59303,22 297.017667,23.0550649 299.730507,25.1766448 C301.838091,26.8248839 303.45357,29.0787041 304.580218,31.9217647 L304.664,32.141 L304.894304,31.758482 C306.256617,29.541499 308.04526,27.5894747 310.255056,25.9061867 L310.674327,25.5937203 C313.951412,23.204179 317.460734,22 321.177106,22 Z M231.214173,22.2721382 C235.842656,22.2721382 240.114809,23.2813081 244.017009,25.2996873 C247.949275,27.3336181 251.102191,30.4187296 253.463829,34.534728 C255.824475,38.648996 256.99819,43.6792053 256.99819,49.6112311 C256.99819,55.477913 255.824553,60.4910223 253.465574,64.636085 C251.105109,68.7837598 247.953791,71.9011925 244.023018,73.968237 C240.119404,76.0209992 235.845055,77.0475162 231.214173,77.0475162 C226.582371,77.0475162 222.323058,76.0205671 218.450763,73.9665673 C215.78895,72.5546487 213.481953,70.6522464 211.530874,68.2601777 C209.80805,70.6713158 207.747453,72.5853025 205.353205,73.9936837 C201.893057,76.0290653 198.056892,77.0475162 193.863464,77.0475162 C189.54284,77.0475162 185.913019,76.1613627 182.990636,74.373552 C181.090035,73.2108313 179.432511,71.7008619 178.019516,69.8490491 L177.854,69.627 L177.854825,92.1814255 C177.854825,93.3365234 177.266684,94.2866808 176.196546,94.966436 L175.990272,95.0907053 C174.927451,95.6980316 173.719578,96 172.383982,96 C170.985679,96 169.745724,95.699405 168.6805,95.0907053 C167.479903,94.40465 166.815948,93.408717 166.815948,92.1814255 L166.815948,26.7710583 C166.815948,25.479912 167.484234,24.4536152 168.704417,23.7999455 C169.764134,23.2322402 170.995062,22.9524838 172.383982,22.9524838 C173.531358,22.9524838 174.610823,23.2416263 175.605087,23.8152399 C176.750591,24.4761076 177.368863,25.4986352 177.368863,26.7710583 L177.368,30.16 L177.461941,30.0361727 C178.783959,28.309545 180.389965,26.8166359 182.276634,25.5604571 L182.685215,25.2949004 C185.864442,23.2779717 189.597959,22.2721382 193.863464,22.2721382 C198.128773,22.2721382 202.004283,23.3430028 205.46887,25.4828953 C207.771196,26.9049197 209.757739,28.7668286 211.429887,31.0693813 C213.399057,28.641774 215.743808,26.7167895 218.456791,25.3013201 C222.327675,23.2817281 226.584779,22.2721382 231.214173,22.2721382 Z M191.530851,31.6587473 C187.243462,31.6587473 183.896417,33.3099564 181.39759,36.6517607 C178.844201,40.0665344 177.563248,44.3106557 177.563248,49.4168467 C177.563248,55.109921 178.816344,59.5808448 181.296842,62.8575524 C183.727136,66.0679395 187.106609,67.6609071 191.530851,67.6609071 C195.643176,67.6609071 198.975743,66.1216499 201.603835,63.0102305 C203.930389,60.255805 205.247205,56.4902582 205.534777,51.6932527 L205.559596,51.2685058 L205.545125,50.8489568 C205.533272,50.4407123 205.527348,50.0281371 205.527348,49.6112311 C205.527348,49.189798 205.533269,48.7729418 205.545271,48.355724 L205.556796,48.0938945 L205.551214,47.9513662 C205.38458,44.9043393 204.749828,42.2339124 203.652128,39.9339693 C202.366962,37.2412414 200.654503,35.195383 198.511261,33.7766173 C196.374155,32.3619136 194.055203,31.6587473 191.530851,31.6587473 Z M231.214173,31.6587473 C226.836455,31.6587473 223.357717,33.2031872 220.700173,36.3137216 C218.430591,38.9701643 217.111936,42.5417911 216.759905,47.0508924 L216.700355,47.9290956 L216.714085,48.3122437 C216.725839,48.7404962 216.731714,49.1734918 216.731714,49.6112311 C216.731714,50.0470061 216.726182,50.47794 216.71489,50.911505 L216.700355,51.2251958 L216.724381,51.660711 C217.015654,56.4203676 218.347416,60.1767886 220.703261,62.9609692 C223.36111,66.1020631 226.838531,67.6609071 231.214173,67.6609071 C235.591349,67.6609071 239.086753,66.1007268 241.777295,62.9567219 C244.491519,59.7850452 245.862121,55.3498364 245.862121,49.6112311 C245.862121,43.8739162 244.492208,39.456332 241.78041,36.317958 C239.090148,33.2045095 235.593424,31.6587473 231.214173,31.6587473 Z M150.712743,4 C149.259053,4 147.963783,4.29606168 146.840427,4.89518486 C145.554497,5.58101431 144.853132,6.6564405 144.853132,8.01295896 L144.853132,50.3887689 C144.853132,54.9604969 144.458747,58.4784132 143.684829,60.9239931 C142.944236,63.264268 141.87171,64.8087043 140.491802,65.6090509 C139.040305,66.4509193 137.071912,66.8833693 134.578834,66.8833693 C133.004999,66.8833693 131.710962,66.6900075 130.699158,66.3141946 C129.625877,65.9155473 128.398225,65.3094909 127.020608,64.495445 C126.731999,64.3493116 126.45579,64.2036746 126.173893,64.0486339 L125.744519,63.8077828 C125.260149,63.5309997 124.711978,63.2569143 124.099443,62.9846766 C123.527077,62.7889863 123.145105,62.7041037 122.818575,62.7041037 C121.483129,62.7041037 120.469249,63.6183631 119.75338,65.2384268 L119.527332,65.7673253 C119.172059,66.6629279 119,67.5887714 119,68.5637149 C119,70.7152148 119.984373,72.4418969 121.873536,73.6494261 L122.114388,73.7976565 C125.574241,75.9689259 130.225662,77.0475162 136.036717,77.0475162 C140.933982,77.0475162 144.881961,76.1664222 147.872655,74.3788806 C150.905083,72.5663953 153.107534,69.6529168 154.47669,65.6823622 C155.813792,61.8047679 156.475162,56.6460815 156.475162,50.1943844 L156.475162,8.01295896 C156.475162,6.66509921 155.798106,5.59114857 154.548952,4.90196011 C153.45357,4.29761162 152.17012,4 150.712743,4 Z" id="path-5"></path>
|
||||
<filter x="-3.0%" y="-6.0%" width="105.9%" height="114.1%" filterUnits="objectBoundingBox" id="filter-6">
|
||||
<feOffset dx="0" dy="1" in="SourceAlpha" result="shadowOffsetOuter1"></feOffset>
|
||||
<feGaussianBlur stdDeviation="2" in="shadowOffsetOuter1" result="shadowBlurOuter1"></feGaussianBlur>
|
||||
<feColorMatrix values="0 0 0 0 0.239215686 0 0 0 0 0.466666667 0 0 0 0 1 0 0 0 0.4 0" type="matrix" in="shadowBlurOuter1"></feColorMatrix>
|
||||
</filter>
|
||||
</defs>
|
||||
<g id="jpom-logo" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="1" transform="translate(12.000000, 10.000000)" fill-rule="nonzero">
|
||||
<g id="2">
|
||||
<use fill="black" fill-opacity="1" filter="url(#filter-3)" xlink:href="#path-2"></use>
|
||||
<use fill="url(#linearGradient-1)" xlink:href="#path-2"></use>
|
||||
</g>
|
||||
<rect id="4" fill="#F74C00" x="345" y="64" width="12" height="12" rx="6"></rect>
|
||||
<g id="5">
|
||||
<use fill="black" fill-opacity="1" filter="url(#filter-6)" xlink:href="#path-5"></use>
|
||||
<use fill="url(#linearGradient-4)" xlink:href="#path-5"></use>
|
||||
</g>
|
||||
<rect id="3" fill="#F74C00" x="88" y="88" width="12" height="12" rx="6"></rect>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 29 KiB |
|
After Width: | Height: | Size: 7.6 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 73 KiB |
|
After Width: | Height: | Size: 48 KiB |
|
After Width: | Height: | Size: 37 KiB |
|
After Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 142 KiB |
|
After Width: | Height: | Size: 68 KiB |
|
After Width: | Height: | Size: 8.5 KiB |
|
After Width: | Height: | Size: 48 KiB |
|
After Width: | Height: | Size: 11 KiB |
@@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg id="_图层_1" data-name="图层 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 240">
|
||||
<defs>
|
||||
<style>
|
||||
.cls-1 {
|
||||
fill: #ff9045;
|
||||
}
|
||||
|
||||
.cls-2 {
|
||||
fill: #333;
|
||||
}
|
||||
|
||||
.cls-3 {
|
||||
fill: #0079dd;
|
||||
}
|
||||
|
||||
.cls-4 {
|
||||
fill: #595959;
|
||||
}
|
||||
</style>
|
||||
</defs>
|
||||
<g>
|
||||
<g>
|
||||
<circle class="cls-1" cx="145.28" cy="62.13" r="13.63"/>
|
||||
<path class="cls-1" d="M154.29,83.78h-18.09c-4.56,0-8.26,3.7-8.26,8.26v92.19c0,4.02,3.26,7.28,7.28,7.28h.07c4.02,0,7.28-3.26,7.28-7.28v-54.05c2.96,0,5.36,2.4,5.36,5.36v16.41c0,4.02,3.26,7.28,7.28,7.28h.07c4.02,0,7.28-3.26,7.28-7.28v-21.16s0-38.75,0-38.75c0-4.56-3.7-8.26-8.26-8.26Z"/>
|
||||
</g>
|
||||
<path class="cls-3" d="M117.19,125.56h-1.98c-3.07,0-5.56-2.49-5.56-5.56s2.49-5.56,5.56-5.56h1.98s.04,0,.06,0v-25.71c0-4.77-2.32-9.24-6.21-11.98L50.81,34.3c-4.86-3.42-11.55,.05-11.55,5.99V199.71c0,5.94,6.7,9.41,11.55,5.99l60.23-42.45c3.9-2.75,6.21-7.22,6.21-11.98v-25.71s-.04,0-.06,0Z"/>
|
||||
<path class="cls-3" d="M239.76,34.3l-60.23,42.45c-3.9,2.75-6.21,7.22-6.21,11.98v25.71s.04,0,.06,0h1.98c3.07,0,5.56,2.49,5.56,5.56s-2.49,5.56-5.56,5.56h-1.98s-.04,0-.06,0v25.71c0,4.77,2.32,9.24,6.21,11.98l60.23,42.45c4.86,3.42,11.55-.05,11.55-5.99V40.29c0-5.94-6.7-9.41-11.55-5.99Z"/>
|
||||
</g>
|
||||
<g>
|
||||
<g>
|
||||
<path class="cls-2" d="M344.63,60.54v-7.61h8.13v7.61h20.8c4.41,0,7.8,.88,10.16,2.64,3.06,2.31,4.58,5.45,4.58,9.43l-.04,32.47c0,3.86-.78,6.82-2.34,8.87-2.42,3.2-6.01,4.8-10.77,4.8h-22.4l.04,7.52-8.17-.04v-7.48h-20.54c-4.15,0-7.24-.59-9.25-1.77-3.66-2.13-5.49-6.18-5.49-12.15v-30.57c0-4.44,1.12-7.77,3.37-9.99,2.51-2.48,5.89-3.72,10.16-3.72h21.75Zm0,50.07v-41.94h-22.01c-2.05,0-3.47,.55-4.28,1.64-.58,.81-.87,2.08-.87,3.8v30.05c0,1.96,.07,3.13,.22,3.5,.72,1.99,2.31,2.98,4.76,2.98l22.18-.04Zm8.13,0l20.93,.04c4.32,.03,6.49-1.79,6.49-5.45v-30.48c0-2.48-.49-4.11-1.47-4.89-.92-.72-2.48-1.1-4.67-1.12l-21.27-.09v41.99Z"/>
|
||||
<path class="cls-2" d="M401.72,75.41v-8.78c2.13-1.73,3.62-3.34,4.45-4.84,1.12-1.93,2-4.94,2.64-9.04h8.13c-.46,2.19-.79,3.84-.99,4.93-.81,4.12-2.12,7.46-3.93,10.03-1.87,2.62-4.08,4.64-6.62,6.05-.81,.43-2.03,.98-3.67,1.64Zm0,20.67v-8.86c2.36-1.9,3.91-3.56,4.63-4.97,.89-1.67,1.7-4.63,2.42-8.86h8.17l-.91,4.15v48.86h-8.09v-33.77c-1.93,1.44-4.01,2.59-6.23,3.46Zm17.25,30.31v-8.47c1.35-.78,2.03-1.9,2.03-3.37v-10.59c0-2.6,.88-4.79,2.64-6.57,1.59-1.58,4.53-2.38,8.82-2.38h6.87c6.72,0,10.08,3.19,10.08,9.56v8.86c0,1.73,.23,2.87,.69,3.42,.26,.32,.72,.68,1.38,1.08v8.47c-2.88-.43-5.16-1.3-6.83-2.59-.87-.66-1.59-1.56-2.16-2.68-.81-1.53-1.21-3.07-1.21-4.63v-9.95c0-2.39-1.47-3.59-4.41-3.59h-3.5c-1.47,0-2.51,.32-3.11,.95-.81,.81-1.21,2.05-1.21,3.72v8.87c0,2.79-.88,5.07-2.64,6.83-1.39,1.41-3.86,2.44-7.44,3.07Zm.91-73.68h7.22v15.52c0,1.21,.23,2.02,.69,2.42,.52,.43,1.41,.65,2.68,.65h1.08v-18.59h7.74v18.59h1.12c1.07,0,1.84-.29,2.34-.86s.74-1.17,.74-1.77v-15.96h7.05v17.99c0,3.08-1.11,5.35-3.33,6.79-1.21,.78-3.37,1.17-6.49,1.17h-11.68c-3.2,0-5.59-.81-7.18-2.42-.69-.72-1.14-1.37-1.34-1.95-.43-1.21-.65-3.01-.65-5.4v-16.17Zm0,38.18v-7.22h30.66v7.22h-30.66Zm33.12,35.11v-7.74c2.36-.92,4.08-1.72,5.15-2.38,1.1-.69,2.62-1.92,4.58-3.67-2.02-3.83-3.39-7.16-4.11-9.99-.89-3.34-1.34-6.76-1.34-10.25v-14.87c-1.12,.75-2.45,1.37-3.98,1.86v-8.39c1.38-1.53,2.35-3.56,2.9-6.1,.63-3.08,1.08-7,1.34-11.76h7.26v4.89h17.08v8h-4.2v27.46c0,6.05-1.83,12.44-5.49,19.16,1.44,1.38,2.61,2.41,3.5,3.07,1.27,.89,3.33,1.89,6.18,2.98v7.74c-3.98-1.1-6.99-2.28-9.04-3.55-1.5-.89-3.27-2.29-5.32-4.19-3.08,2.54-5.49,4.24-7.22,5.1-1.53,.81-3.96,1.69-7.31,2.64Zm4.67-49.12h6.66l-.13,12.8c-.03,4.56,1.05,9.7,3.24,15.44,2.02-4.44,3.03-8.62,3.03-12.54v-26.98h-6.74c-1.15,4.24-2.38,7.18-3.68,8.82-.52,.69-1.31,1.51-2.38,2.47Z"/>
|
||||
<path class="cls-2" d="M494.58,91.89v-8h41.21l21.32-17.81c1.21-1.01,1.82-1.9,1.82-2.68,0-.46-.16-.89-.47-1.3-.66-.83-1.75-1.25-3.24-1.25h-56.56v-8h58.98c3.6,0,6.36,.68,8.26,2.03,2.36,1.67,3.55,3.99,3.55,6.96,0,2.56-1.04,4.97-3.11,7.22-1.21,1.3-2.8,2.75-4.76,4.37l-12.93,10.46h26.12v8h-29.45l.04,21.53c0,3.92-1.21,7.1-3.63,9.56-2.25,2.31-5.61,3.46-10.07,3.46h-16.73v-8.04h15.52c2.45,.03,4.12-.47,5.01-1.51,.81-.95,1.21-2.39,1.21-4.33v-20.71l-42.07,.04Z"/>
|
||||
<path class="cls-2" d="M587.86,86.78v-10.29c3-2.13,5.17-4.28,6.53-6.44,2.88-4.58,4.96-10.29,6.23-17.12h9.08c-1.24,6.26-2.96,11.93-5.15,17.04v56.38h-8.3v-44.88c-2.02,1.62-3.34,2.61-3.98,2.98-.61,.4-2.08,1.18-4.41,2.34Zm21.02-8.78v-8.13h19.46l-5.06-17.08h8.69l4.8,17.08h30.61v8.13h-28.32l5.1,18.81c1.01,3.72,2.31,7.28,3.89,10.68,1.47,3.14,3.66,5.69,6.57,7.65,3.29,2.22,6.69,3.33,10.2,3.33,.46,0,1.17-.04,2.12-.13v8.09c-4.7-.09-8.53-.68-11.5-1.77-5.51-2.07-9.71-5.65-12.63-10.72-1.87-3.23-3.72-7.91-5.53-14.05l-6.53-21.88h-21.88Zm40.99-16.78v-8h17.51v8h-17.51Z"/>
|
||||
<path class="cls-2" d="M680.84,124.06v-8h7.05v-24.95l-7.09,.04,.04-7.87h7.05v-20.41h-7.05v-8h22.4v8h-7.35v20.41h7.35v7.83h-7.35v24.95h7.35v8h-22.4Zm26.59,2.2v-8h22.92v-9.25h-20.76v-8h20.76v-7.05l-14.01-.04c-2.48,0-4.44-.88-5.88-2.64-.89-1.12-1.41-2.31-1.56-3.55-.09-.72-.13-1.7-.13-2.94v-23.44c0-2.91,.74-5.1,2.2-6.57,1.38-1.38,3.24-2.08,5.58-2.08h33.25c3.52,0,6.04,.72,7.57,2.16,1.33,1.27,1.99,3.17,1.99,5.71v25.47c0,2.42-.71,4.35-2.12,5.79-1.35,1.38-3.06,2.07-5.1,2.07l-13.79,.04v7.05h20.8v8h-20.8v9.25h22.4v8h-53.31Zm9.34-56.99h13.58v-8.56h-10.25c-1.21,0-2.11,.29-2.68,.86-.43,.43-.65,1.25-.65,2.47v5.23Zm13.58,16.56v-8.6h-13.58v4.71c0,1.56,.23,2.6,.69,3.11,.43,.52,1.24,.78,2.42,.78h10.46Zm8-16.56h13.19v-5.23c.03-2.28-1.41-3.42-4.32-3.42l-8.86,.09v8.56Zm0,16.56h9.64c1.41,0,2.35-.26,2.81-.78,.52-.58,.76-1.54,.74-2.9v-4.93h-13.19v8.6Z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path class="cls-4" d="M315.77,154.13l16.1,23.16h.12v-23.16h3.27v28.46h-3.35l-16.18-23.4h-.12v23.4h-3.27v-28.46h3.43Z"/>
|
||||
<path class="cls-4" d="M370.12,164.77c1.51,1.99,2.31,4.82,2.39,8.41h-16.26c.16,2.31,.76,4.11,1.87,5.38,1.12,1.28,2.67,1.91,4.63,1.91,1.67,0,3.07-.44,4.1-1.28,.88-.72,1.56-1.79,2.07-3.23h3.19c-.48,1.99-1.39,3.59-2.79,4.86-1.71,1.52-3.91,2.31-6.58,2.31-2.95,0-5.34-1-7.1-2.91-1.83-1.99-2.71-4.62-2.71-7.97,0-3.03,.84-5.58,2.59-7.61,1.75-2.15,4.11-3.23,7.1-3.23,3.31,0,5.82,1.12,7.49,3.35Zm-11.84,1.12c-1.12,1.2-1.76,2.79-1.95,4.82h12.88c-.4-4.42-2.59-6.62-6.5-6.62-1.83,0-3.31,.6-4.42,1.79Z"/>
|
||||
<path class="cls-4" d="M392.99,161.98v12.6c0,1.95,.4,3.43,1.24,4.38,.84,.96,2.19,1.48,4.07,1.48,1.35,0,2.59-.56,3.67-1.59,1.12-1.12,1.79-2.55,2.03-4.3v-12.56h3.19v20.61h-3.19v-3.19c-1.68,2.47-3.91,3.75-6.7,3.75-5.02,0-7.5-2.83-7.5-8.41v-12.76h3.19Z"/>
|
||||
<path class="cls-4" d="M431.17,161.98h5.1v2.67h-5.1v13.11c0,.76,.12,1.31,.44,1.63,.28,.32,.8,.52,1.51,.52h2.63v2.67h-3.11c-1.67,0-2.91-.44-3.63-1.31-.68-.8-1-1.95-1-3.51v-13.11h-4.15v-2.67h4.15v-5.34l3.15-1.31v6.66Z"/>
|
||||
<path class="cls-4" d="M465.24,161.9v3.19c-1.04-.32-2.07-.44-3.07-.44-1.59,0-2.95,.68-4.03,2.11-1.12,1.35-1.64,2.99-1.64,4.9v10.92h-3.15v-20.61h3.15v3.59c.56-1.19,1.28-2.15,2.15-2.83,1.08-.88,2.31-1.32,3.75-1.32,1.12,0,2.07,.16,2.83,.48Z"/>
|
||||
<path class="cls-4" d="M485.8,154.88c.48,.4,.72,.96,.72,1.68,0,.68-.24,1.24-.72,1.71-.48,.44-1.04,.68-1.71,.68s-1.24-.24-1.71-.68c-.48-.48-.68-1.04-.68-1.71,0-.72,.2-1.28,.68-1.68,.48-.48,1.04-.68,1.71-.68s1.24,.2,1.71,.68Zm-.12,7.1v20.61h-3.19v-20.61h3.19Z"/>
|
||||
<path class="cls-4" d="M522.54,169.91v12.67h-3.19v-12.44c0-4.03-1.83-6.02-5.42-6.02-1.43,0-2.67,.52-3.71,1.56-1.12,1.12-1.71,2.59-1.83,4.46v12.44h-3.19v-20.61h3.19v3.03c.72-1.16,1.64-2.03,2.75-2.63,1.12-.64,2.35-.96,3.71-.96,5.1,0,7.69,2.83,7.69,8.49Z"/>
|
||||
<path class="cls-4" d="M557.61,164.61c1.75,2.03,2.63,4.58,2.63,7.69s-.88,5.62-2.59,7.61c-1.87,2.15-4.35,3.23-7.41,3.23s-5.54-1.08-7.37-3.23c-1.75-1.99-2.63-4.54-2.63-7.61s.88-5.66,2.63-7.69c1.83-2.15,4.27-3.19,7.37-3.19s5.54,1.04,7.38,3.19Zm-12.48,1.99c-1.12,1.51-1.63,3.39-1.63,5.7s.52,4.15,1.63,5.66c1.2,1.68,2.91,2.51,5.1,2.51s3.87-.84,5.14-2.51c1.07-1.51,1.63-3.43,1.63-5.66s-.56-4.19-1.63-5.7c-1.28-1.68-2.99-2.51-5.14-2.51s-3.91,.84-5.1,2.51Z"/>
|
||||
<path class="cls-4" d="M616.79,154.13c6.54,0,9.8,2.79,9.8,8.37s-3.31,8.45-9.84,8.45h-8.33v11.64h-3.27v-28.46h11.64Zm-8.37,13.99h8.17c2.31,0,3.99-.48,5.1-1.39,1.07-.92,1.63-2.31,1.63-4.23s-.56-3.31-1.67-4.15c-1.12-.96-2.79-1.4-5.06-1.4h-8.17v11.16Z"/>
|
||||
<path class="cls-4" d="M655.76,161.9v3.19c-1.04-.32-2.07-.44-3.07-.44-1.59,0-2.95,.68-4.03,2.11-1.11,1.35-1.63,2.99-1.63,4.9v10.92h-3.15v-20.61h3.15v3.59c.56-1.19,1.28-2.15,2.15-2.83,1.07-.88,2.31-1.32,3.75-1.32,1.12,0,2.07,.16,2.83,.48Z"/>
|
||||
<path class="cls-4" d="M688.55,164.61c1.76,2.03,2.63,4.58,2.63,7.69s-.88,5.62-2.59,7.61c-1.87,2.15-4.34,3.23-7.41,3.23s-5.54-1.08-7.37-3.23c-1.75-1.99-2.63-4.54-2.63-7.61s.88-5.66,2.63-7.69c1.83-2.15,4.27-3.19,7.37-3.19s5.54,1.04,7.37,3.19Zm-12.48,1.99c-1.12,1.51-1.63,3.39-1.63,5.7s.52,4.15,1.63,5.66c1.2,1.68,2.91,2.51,5.1,2.51s3.87-.84,5.14-2.51c1.08-1.51,1.64-3.43,1.64-5.66s-.56-4.19-1.64-5.7c-1.28-1.68-2.99-2.51-5.14-2.51s-3.91,.84-5.1,2.51Z"/>
|
||||
<path class="cls-4" d="M711.23,161.98l5.34,7.33,5.3-7.33h3.75l-7.29,9.69,8.17,10.92h-3.79l-6.14-8.57-6.18,8.57h-3.79l8.17-10.92-7.29-9.69h3.75Z"/>
|
||||
<path class="cls-4" d="M743.9,161.98l6.3,16.26,6.1-16.26h3.51l-11.28,28.5h-3.47l3.55-8.37-8.17-20.13h3.47Z"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 9.0 KiB |
|
After Width: | Height: | Size: 48 KiB |
|
After Width: | Height: | Size: 9.3 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 8.4 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 213.97 125.78"><defs><style>.cls-1{fill:#231815;}</style></defs><title>资源 6</title><g id="图层_2" data-name="图层 2"><g id="图层_1-2" data-name="图层 1"><path class="cls-1" d="M103.07,10C104.83,4.87,101.58-.51,95.14,0A11.77,11.77,0,0,0,90,1.83C58.43,21,59.5,62.37,90.42,82.43A10.38,10.38,0,0,0,95,84.08c7.4.71,12-6.51,7.31-12a10.5,10.5,0,0,0-2.89-2.23c-23.85-13.2-24.7-41.33-.38-55.2A8.85,8.85,0,0,0,103.07,10Z"/><path class="cls-1" d="M124.06,14.2l10.52,6.9a8.84,8.84,0,0,0,1,.56c7.18,3.31,13.75-3.74,9.77-9.95A8.46,8.46,0,0,0,143,9.36L131.66,1.8A8.44,8.44,0,0,0,125.37.4c-4.29.82-6.12,4.75-4.94,9A8.54,8.54,0,0,0,124.06,14.2Z"/><path class="cls-1" d="M132,51.62V62.88a4.06,4.06,0,0,1-2,3.5l-5.34,3.14a7.59,7.59,0,0,0-4.13,8.69c.77,2.74,3.12,5,7.16,5.25a7.37,7.37,0,0,0,2.75-.43,35.87,35.87,0,0,0,13.38-8.55,9.57,9.57,0,0,0,2.76-6.75V42.06h0a6.78,6.78,0,0,0-6.78-6.78H132"/><path class="cls-1" d="M124.17,37.57V48.93a2.3,2.3,0,0,1-2.29,2.29h-7.11a8.48,8.48,0,0,1-7.79-5,7.39,7.39,0,0,1-.33-5.41,8.39,8.39,0,0,1,8-5.57h7.18A2.3,2.3,0,0,1,124.17,37.57Z"/><path class="cls-1" d="M11.91,100.28A2.38,2.38,0,0,0,9.31,97a3.89,3.89,0,0,0-1.68.59c-10.37,6.28-10,19.87.13,26.45a3.4,3.4,0,0,0,1.5.54c2.43.24,3.94-2.14,2.4-3.93a3.26,3.26,0,0,0-.95-.73c-7.82-4.33-8.1-13.57-.12-18.12A2.87,2.87,0,0,0,11.91,100.28Z"/><path class="cls-1" d="M18.8,101.68l3.46,2.26a3.37,3.37,0,0,0,.32.19c2.36,1.08,4.51-1.23,3.21-3.27a2.86,2.86,0,0,0-.78-.77L21.3,97.61a2.78,2.78,0,0,0-2.07-.46,2.18,2.18,0,0,0-1.62,2.95A2.81,2.81,0,0,0,18.8,101.68Z"/><path class="cls-1" d="M39.24,98.82V123a2.3,2.3,0,0,0,0,.37c.37,2.57,3.48,3.12,4.48.91a2.44,2.44,0,0,0,.22-1.07L44,98.69a2.78,2.78,0,0,0-.74-2,2.19,2.19,0,0,0-3.36.25A2.86,2.86,0,0,0,39.24,98.82Z"/><path class="cls-1" d="M71.05,108.91,71,123c0,.12,0,.25,0,.37.38,2.57,3.49,3.12,4.49.91a2.6,2.6,0,0,0,.22-1.07l.06-14.47a2.81,2.81,0,0,0-.73-2,2.2,2.2,0,0,0-3.37.25A2.85,2.85,0,0,0,71.05,108.91Z"/><path class="cls-1" d="M126.44,95.88l-10.13,0a2.42,2.42,0,0,0-.38,0c-2.57.37-3.12,3.49-.91,4.49a2.86,2.86,0,0,0,1.08.22l10.46.06a2.76,2.76,0,0,0,2-.74,2.18,2.18,0,0,0-.25-3.36A2.75,2.75,0,0,0,126.44,95.88Z"/><path class="cls-1" d="M126.44,121l-10.13,0-.38,0c-2.57.38-3.12,3.49-.91,4.49a2.86,2.86,0,0,0,1.08.22l10.46.06a2.8,2.8,0,0,0,2-.73,2.19,2.19,0,0,0-.25-3.37A2.81,2.81,0,0,0,126.44,121Z"/><path class="cls-1" d="M172.85,98.18a2.86,2.86,0,0,1-.91,1.92l-12.34,12v10.86a2.81,2.81,0,0,1-.68,1.86,2.19,2.19,0,0,1-3.36.25,2.85,2.85,0,0,1-.74-2l0-6.36,0-6.61,4.76-4.62,8.91-8.68a2.82,2.82,0,0,1,1.8-.81A2.19,2.19,0,0,1,172.85,98.18Z"/><path class="cls-1" d="M121.44,108.44h-5.13a2.42,2.42,0,0,0-.38,0c-2.57.37-3.12,3.48-.91,4.48a2.68,2.68,0,0,0,1.08.22l5.46.07a2.76,2.76,0,0,0,2-.74,2.18,2.18,0,0,0-.25-3.36A2.81,2.81,0,0,0,121.44,108.44Z"/><path class="cls-1" d="M211.18,95.79H201.05a2.3,2.3,0,0,0-.37,0c-2.57.37-3.12,3.48-.92,4.48a2.68,2.68,0,0,0,1.08.22l10.46.07a2.85,2.85,0,0,0,2-.74,2.19,2.19,0,0,0-.25-3.36A2.86,2.86,0,0,0,211.18,95.79Z"/><path class="cls-1" d="M211.18,120.93l-10.13,0a2.3,2.3,0,0,0-.37,0c-2.57.37-3.12,3.49-.92,4.49a2.86,2.86,0,0,0,1.08.22l10.46.06a2.8,2.8,0,0,0,2-.74,2.19,2.19,0,0,0-.25-3.36A2.8,2.8,0,0,0,211.18,120.93Z"/><path class="cls-1" d="M206.18,108.36l-5.13,0-.37,0c-2.57.38-3.12,3.49-.92,4.49a2.86,2.86,0,0,0,1.08.22l5.46.06a2.84,2.84,0,0,0,2-.73A2.2,2.2,0,0,0,208,109,2.85,2.85,0,0,0,206.18,108.36Z"/><path class="cls-1" d="M151.22,100.83l-3.88-3.36a2.37,2.37,0,0,0-.3-.23c-2.19-1.39-4.63.62-3.61,2.81a2.48,2.48,0,0,0,.67.87l4.1,3.61a2.83,2.83,0,0,0,2,.73,2.18,2.18,0,0,0,2-2.71A2.8,2.8,0,0,0,151.22,100.83Z"/><path class="cls-1" d="M61.45,100.75l24.13-.24.38,0c2.56-.4,3.07-3.52.86-4.49a2.67,2.67,0,0,0-1.08-.21L61.28,96a2.82,2.82,0,0,0-2,.76,2.19,2.19,0,0,0,.29,3.36A2.78,2.78,0,0,0,61.45,100.75Z"/><path class="cls-1" d="M102.73,98.84,103,123a2.42,2.42,0,0,0,0,.38c.4,2.56,3.52,3.08,4.5.86a2.67,2.67,0,0,0,.21-1.08l-.21-24.46a2.76,2.76,0,0,0-.76-2,2.18,2.18,0,0,0-3.35.28A2.81,2.81,0,0,0,102.73,98.84Z"/><path class="cls-1" d="M187.27,98.84l.24,24.13a2.43,2.43,0,0,0,0,.38c.4,2.56,3.52,3.08,4.49.86a2.67,2.67,0,0,0,.21-1.08L192,98.67a2.8,2.8,0,0,0-.76-2,2.19,2.19,0,0,0-3.36.28A2.8,2.8,0,0,0,187.27,98.84Z"/><path class="cls-1" d="M26.18,110.82v8.42a3.13,3.13,0,0,1-.91,2.22,11.64,11.64,0,0,1-4.39,2.8,2.3,2.3,0,0,1-.9.15,2.4,2.4,0,0,1-2.35-1.73A2.49,2.49,0,0,1,19,119.83l1.75-1a1.33,1.33,0,0,0,.65-1.15V114a.23.23,0,0,0,0-.14h-5.6a.86.86,0,0,1-.23,0,2.76,2.76,0,0,1-2.33-1.6,2.43,2.43,0,0,1-.1-1.78,2.74,2.74,0,0,1,2.43-1.82h8.6a2.18,2.18,0,0,1,1.41.64A2.26,2.26,0,0,1,26.18,110.82Z"/><path class="cls-1" d="M15.73,108.59h0Z"/><path class="cls-1" d="M15.52,113.8a.86.86,0,0,0,.23,0h-.23Z"/><path class="cls-1" d="M24.12,108.59h0Z"/></g></g></svg>
|
||||
|
After Width: | Height: | Size: 4.7 KiB |
|
After Width: | Height: | Size: 7.1 KiB |
|
After Width: | Height: | Size: 6.9 KiB |
|
After Width: | Height: | Size: 85 KiB |
|
After Width: | Height: | Size: 6.3 KiB |
|
After Width: | Height: | Size: 93 KiB |
|
After Width: | Height: | Size: 41 KiB |
|
After Width: | Height: | Size: 20 KiB |
@@ -0,0 +1,15 @@
|
||||
<svg width="1053" height="170" viewBox="0 0 1053 170" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M73.9973 35.0579C54.1616 69.8286 42.9756 83.2381 35.8964 77.1848C30.9901 72.9896 47.7987 41.7206 58.7276 21.3898C62.1781 14.9707 65.0426 9.64207 66.4524 6.60013C66.7845 5.88338 66.1105 5.51842 65.5618 6.11847C40.0106 34.0615 -21.3347 135.895 7.5775 162.983C8.93141 164.252 11.0512 163.631 11.7989 161.933L33.1473 113.459C34.035 111.443 36.5449 110.432 38.7533 111.201L48.8546 114.714C51.063 115.483 52.1337 117.739 51.246 119.755L31.2362 165.189C30.3407 167.223 31.8971 169.466 34.0878 169.095C74.8305 162.188 98.0507 93.0493 117.5 36.5C124 14.5 124 14.5 128 0C119.318 15.677 82.7367 82.7294 70.4985 81.4891C61.0082 80.5273 63.8387 71.85 70.8524 50.3486C72.2789 45.9755 73.8785 41.072 75.5826 35.595C75.865 34.6874 74.4765 34.218 73.9973 35.0579Z" fill="#FF5C00"/>
|
||||
<path d="M200.782 129.157H178.611L171.579 108.423H138.084L131.052 129.157H109L144.163 32.6779H165.5L200.782 129.157ZM154.533 60.2434L144.759 88.7678H164.904L155.249 60.2434H154.533Z" fill="black"/>
|
||||
<path d="M208.662 159V57.6067H228.806V66.1161H229.522C231.667 62.9201 234.409 60.4432 237.746 58.6854C241.084 56.8477 244.62 55.9288 248.355 55.9288C253.997 55.9288 258.924 57.4469 263.135 60.4832C267.426 63.4395 270.724 67.6742 273.029 73.1873C275.333 78.7004 276.485 85.1723 276.485 92.603C276.485 100.353 275.333 107.105 273.029 112.858C270.724 118.61 267.426 123.045 263.135 126.161C258.844 129.277 253.838 130.835 248.116 130.835C244.302 130.835 240.766 129.916 237.508 128.079C234.329 126.321 231.667 123.844 229.522 120.648H228.806V159H208.662ZM228.33 93.4419C228.33 99.035 229.561 103.509 232.025 106.865C234.488 110.141 237.746 111.779 241.799 111.779C246.09 111.779 249.507 110.141 252.05 106.865C254.593 103.509 255.864 99.035 255.864 93.4419C255.864 87.769 254.633 83.2946 252.169 80.0187C249.706 76.6629 246.408 74.985 242.276 74.985C238.064 74.985 234.687 76.6629 232.144 80.0187C229.601 83.2946 228.33 87.769 228.33 93.4419Z" fill="black"/>
|
||||
<path d="M306.184 130.835C299.907 130.835 294.702 129.037 290.569 125.442C286.517 121.767 284.49 116.733 284.49 110.341C284.49 105.387 285.881 101.032 288.662 97.2772C291.443 93.5218 295.377 90.6454 300.463 88.6479C305.628 86.5705 311.628 85.5318 318.462 85.5318H324.898V83.7341C324.898 80.2185 323.905 77.5418 321.918 75.7041C320.011 73.7865 317.309 72.8277 313.813 72.8277C308.807 72.8277 304.277 75.3046 300.224 80.2584L287.113 70.191C294.821 60.6829 304.595 55.9288 316.435 55.9288C322.077 55.9288 327.084 57.0874 331.454 59.4045C335.825 61.6417 339.202 64.7978 341.586 68.8727C343.97 72.9476 345.162 77.6617 345.162 83.015V129.157H324.898V121.007H324.183C322.753 124.203 320.448 126.64 317.27 128.318C314.091 129.996 310.396 130.835 306.184 130.835ZM312.502 114.176C316.078 114.176 319.018 113.377 321.322 111.779C323.706 110.101 324.898 107.824 324.898 104.948V102.071H320.488C315.323 102.071 311.469 102.591 308.926 103.629C306.383 104.668 305.111 106.426 305.111 108.903C305.111 110.421 305.747 111.699 307.019 112.738C308.37 113.697 310.197 114.176 312.502 114.176Z" fill="black"/>
|
||||
<path d="M391.139 130.835C383.829 130.835 377.471 129.317 372.068 126.281C366.744 123.245 362.611 118.93 359.671 113.337C356.811 107.664 355.38 101.032 355.38 93.4419C355.38 85.8514 356.811 79.2197 359.671 73.5468C362.611 67.8739 366.744 63.5194 372.068 60.4832C377.471 57.4469 383.829 55.9288 391.139 55.9288C397.656 55.9288 403.576 57.8464 408.9 61.6816C414.224 65.5169 418.118 70.7104 420.581 77.2622L401.867 84.3333C400.834 81.377 399.205 79.0999 396.98 77.5019C394.835 75.9039 392.451 75.1049 389.828 75.1049C385.617 75.1049 382.239 76.7828 379.696 80.1386C377.233 83.4145 376.001 87.8489 376.001 93.4419C376.001 99.035 377.233 103.469 379.696 106.745C382.239 110.021 385.617 111.659 389.828 111.659C392.451 111.659 394.835 110.86 396.98 109.262C399.205 107.584 400.834 105.307 401.867 102.431L420.581 109.502C418.118 116.054 414.224 121.247 408.9 125.082C403.576 128.918 397.656 130.835 391.139 130.835Z" fill="black"/>
|
||||
<path d="M430.993 129.157V32.6779H451.138V66.9551H451.734C453.8 63.5194 456.502 60.8427 459.839 58.9251C463.256 56.9276 467.15 55.9288 471.52 55.9288C478.593 55.9288 484.076 58.2459 487.97 62.8801C491.943 67.4345 493.93 73.9463 493.93 82.4157V129.157H473.785V87.0899C473.785 83.4145 472.871 80.5381 471.044 78.4607C469.216 76.3034 466.713 75.2247 463.534 75.2247C459.799 75.2247 456.78 76.4232 454.475 78.8202C452.25 81.1373 451.138 84.3333 451.138 88.4082V129.157H430.993Z" fill="black"/>
|
||||
<path d="M571.491 88.2884C571.491 93.3221 570.974 97.6367 569.941 101.232H525.361C526.871 109.861 531.719 114.176 539.903 114.176C542.764 114.176 545.347 113.337 547.651 111.659C549.956 109.981 551.783 107.664 553.134 104.708L569.703 111.899C567.319 117.891 563.505 122.566 558.26 125.921C553.095 129.197 546.936 130.835 539.784 130.835C532.632 130.835 526.355 129.357 520.951 126.401C515.547 123.365 511.376 119.09 508.435 113.577C505.575 107.984 504.144 101.472 504.144 94.0412C504.144 86.2909 505.575 79.5793 508.435 73.9064C511.296 68.1536 515.309 63.7191 520.474 60.603C525.719 57.4869 531.838 55.9288 538.831 55.9288C545.347 55.9288 551.068 57.2472 555.995 59.8839C560.922 62.5206 564.736 66.2759 567.438 71.1498C570.14 76.0237 571.491 81.7366 571.491 88.2884ZM550.989 84.573C550.989 80.9775 549.876 78.0612 547.651 75.824C545.506 73.5868 542.565 72.4682 538.831 72.4682C531.997 72.4682 527.626 76.5031 525.719 84.573H550.989Z" fill="black"/>
|
||||
<path d="M658.286 130.835C649.545 130.835 641.916 128.678 635.4 124.363C628.884 119.969 623.997 114.176 620.739 106.985L638.857 98.4757C640.526 102.79 643.069 106.066 646.486 108.303C649.903 110.541 653.876 111.659 658.405 111.659C663.094 111.659 666.829 110.78 669.61 109.022C672.391 107.265 673.782 104.988 673.782 102.191C673.782 100.194 673.265 98.5556 672.232 97.2772C671.199 95.9189 669.411 94.6804 666.868 93.5618C664.325 92.4432 660.63 91.2047 655.783 89.8464C649.426 88.0087 644.141 86.171 639.93 84.3333C635.718 82.4956 631.983 79.6592 628.725 75.824C625.546 71.9089 623.957 66.7553 623.957 60.3633C623.957 54.7703 625.507 49.7366 628.606 45.2622C631.784 40.7878 636.076 37.3121 641.479 34.8352C646.962 32.2784 653.002 31 659.597 31C676.205 31 688.165 38.5905 695.476 53.7715L677.596 62.5206C675.53 58.206 672.987 55.0899 669.967 53.1723C667.027 51.1748 663.491 50.176 659.359 50.176C655.386 50.176 652.048 51.0549 649.346 52.8127C646.644 54.5705 645.294 56.7278 645.294 59.2846C645.294 61.4419 645.85 63.1997 646.962 64.5581C648.075 65.8365 649.863 67.035 652.326 68.1536C654.869 69.1923 658.604 70.3908 663.531 71.7491C669.808 73.5069 675.053 75.3046 679.265 77.1423C683.476 78.9001 687.172 81.7366 690.35 85.6517C693.529 89.4869 695.118 94.6005 695.118 100.993C695.118 106.985 693.529 112.258 690.35 116.813C687.251 121.287 682.92 124.723 677.358 127.12C671.795 129.597 665.438 130.835 658.286 130.835Z" fill="black"/>
|
||||
<path d="M706.521 129.157V32.6779H726.665V66.9551H727.261C729.327 63.5194 732.029 60.8427 735.367 58.9251C738.784 56.9276 742.678 55.9288 747.048 55.9288C754.12 55.9288 759.604 58.2459 763.497 62.8801C767.471 67.4345 769.457 73.9463 769.457 82.4157V129.157H749.313V87.0899C749.313 83.4145 748.399 80.5381 746.571 78.4607C744.744 76.3034 742.24 75.2247 739.062 75.2247C735.327 75.2247 732.307 76.4232 730.003 78.8202C727.778 81.1373 726.665 84.3333 726.665 88.4082V129.157H706.521Z" fill="black"/>
|
||||
<path d="M847.018 88.2884C847.018 93.3221 846.502 97.6367 845.469 101.232H800.889C802.399 109.861 807.246 114.176 815.431 114.176C818.292 114.176 820.874 113.337 823.179 111.659C825.483 109.981 827.311 107.664 828.662 104.708L845.231 111.899C842.847 117.891 839.032 122.566 833.788 125.921C828.622 129.197 822.464 130.835 815.312 130.835C808.16 130.835 801.882 129.357 796.479 126.401C791.075 123.365 786.903 119.09 783.963 113.577C781.102 107.984 779.672 101.472 779.672 94.0412C779.672 86.2909 781.102 79.5793 783.963 73.9064C786.824 68.1536 790.837 63.7191 796.002 60.603C801.247 57.4869 807.365 55.9288 814.358 55.9288C820.874 55.9288 826.596 57.2472 831.523 59.8839C836.45 62.5206 840.264 66.2759 842.966 71.1498C845.668 76.0237 847.018 81.7366 847.018 88.2884ZM826.516 84.573C826.516 80.9775 825.404 78.0612 823.179 75.824C821.033 73.5868 818.093 72.4682 814.358 72.4682C807.524 72.4682 803.154 76.5031 801.247 84.573H826.516Z" fill="black"/>
|
||||
<path d="M857.962 129.157V57.6067H878.107V66.9551H878.703C880.769 63.5194 883.471 60.8427 886.808 58.9251C890.225 56.9276 894.119 55.9288 898.489 55.9288C905.562 55.9288 911.045 58.2459 914.939 62.8801C918.912 67.4345 920.899 73.9463 920.899 82.4157V129.157H900.754V87.0899C900.754 83.4145 899.84 80.5381 898.013 78.4607C896.185 76.3034 893.682 75.2247 890.503 75.2247C886.768 75.2247 883.749 76.4232 881.444 78.8202C879.219 81.1373 878.107 84.3333 878.107 88.4082V129.157H857.962Z" fill="black"/>
|
||||
<path d="M944.073 91.4045L909.625 32.6779H934.776L954.205 73.1873H954.92L974.349 32.6779H999.619L965.052 91.4045V129.157H944.073V91.4045Z" fill="black"/>
|
||||
<path d="M1053 57.6067V129.157H1032.86V120.049H1032.14C1030.15 123.484 1027.49 126.121 1024.15 127.959C1020.9 129.876 1017.08 130.835 1012.71 130.835C1005.64 130.835 1000.08 128.558 996.024 124.004C992.05 119.37 990.064 112.938 990.064 104.708V57.6067H1010.21V100.034C1010.21 103.629 1011.16 106.506 1013.07 108.663C1014.98 110.82 1017.48 111.899 1020.58 111.899C1024.31 111.899 1027.29 110.74 1029.52 108.423C1031.74 106.026 1032.86 102.83 1032.86 98.8352V57.6067H1053Z" fill="black"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 9.3 KiB |
|
After Width: | Height: | Size: 56 KiB |
|
After Width: | Height: | Size: 47 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 60 KiB |
|
After Width: | Height: | Size: 51 KiB |
|
After Width: | Height: | Size: 6.4 KiB |
|
After Width: | Height: | Size: 6.5 KiB |
|
After Width: | Height: | Size: 87 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 47 KiB |
|
After Width: | Height: | Size: 4.7 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 278 KiB |
|
After Width: | Height: | Size: 104 KiB |
@@ -0,0 +1,40 @@
|
||||
---
|
||||
title: 快速上手
|
||||
date: 2023-03-28 20:30:00
|
||||
permalink: /pages/793dcb
|
||||
article: false
|
||||
---
|
||||
|
||||
::: tip
|
||||
当前最新版本为2.0.0,如果从之前的版本升级而来,请注意以下变更
|
||||
|
||||
1、jdk版本升级为了jdk17,jar部署时请注意
|
||||
|
||||
2、去掉了默认的sqlite数据库,改为了h2。如果之前使用sqlite,请自行处理数据迁移
|
||||
|
||||
3、配置文件做了较大调整,请参照使用须知中的`服务端配置`、`客户端配置`进行更新
|
||||
:::
|
||||
|
||||
## 1、快速上手须知
|
||||
- 所谓快速上手,就是针对从来没用过的新手编写的、快速完成从安装部署到首次使用的最简化流程
|
||||
- 该流程中请严格按照说明步骤执行,不要靠猜测自作聪明的修改配置
|
||||
- 如果的确需要修改,请先把安装部署、使用须知、常见问题全部仔细读一遍
|
||||
- 快速上手中涉及到的配置,仅仅是快速体验所必须的配置,完整的配置请参照使用须知中的`服务端配置`、`客户端配置`
|
||||
|
||||
## 2、部署服务
|
||||
- 根据需要自行选择jar、docker、原生部署任意一种完成部署
|
||||
- 三种方式分别参见对应的文档
|
||||
- 任何一种部署方式,不要求客户端与服务端一致。如:服务端采用docker部署,客户端可以用docker部署、也可以用jar、原生部署
|
||||
- 管理后台说明
|
||||
- 服务端部署成功后,访问http://{服务端IP}:8888打开后台管理页面。使用默认的管理员帐号登录:admin/123456
|
||||
- 打开代理配置>License管理页面,可以看到系统已经自动为管理员初始化了一条License记录,复制该LicenseKey备用,后续客户端配置需要。
|
||||
- 客户端说明
|
||||
- 客户端启动后,查看服务端License管理,刷新页面,对应的License在线状态为`在线`,则表明客户端已正常连接。
|
||||
|
||||
## 3、代理验证
|
||||
- 本地启动被代理服务,如:redis、本地web项目、本地mysql等等,假设被代理服务端口为:8080
|
||||
- 先确保本地能正常访问被代理服务,如果本地都不能访问,不用想代理更不可能!!!
|
||||
- 服务端管理后台端口映射管理,使用默认的licesne创建一条端口映射,如:9101 -> 127.0.0.1:8080
|
||||
- 通过服务端IP+9101(上面License配置的端口映射重的服务端端口)访问本地被代理服务
|
||||
|
||||
访问成功,至此首次完整的内网穿透体验完成。开源不易,请速至[Gitee仓库](https://gitee.com/dromara/neutrino-proxy)一键三连🤝
|
||||
@@ -0,0 +1,55 @@
|
||||
---
|
||||
title: 使用jar部署
|
||||
date: 2023-10-26 13:50:45
|
||||
permalink: /pages/eebea1/
|
||||
---
|
||||
|
||||
## 1、环境准备
|
||||
- 首先确保已安装Java17运行环境
|
||||
- 打开[发行版页面](https://gitee.com/dromara/neutrino-proxy/releases),下载最新的release包:`neutrino-proxy-server-jar.zip`、`neutrino-proxy-client-jar.zip`
|
||||
|
||||
|
||||
## 2、部署服务端
|
||||
- 在服务器上新建部署目录:`/work/projects/neutrino-proxy-server`
|
||||
- 将`neutrino-proxy-server-jar.zip`上传至服务器部署目录,并解压
|
||||
- 执行命令`java -Dfile.encoding=utf-8 -jar neutrino-proxy-server.jar`启动服务端完成部署,默认使用h2数据库。
|
||||
- 若需要指定自己的mysql数据库,则需要在当前目录下的`app.yml`文件中,修改数据库配置如下:
|
||||
|
||||
```yml
|
||||
neutrino:
|
||||
data:
|
||||
db:
|
||||
type: mysql
|
||||
# 自己的数据库实例,创建一个空的名为'neutrino-proxy'的数据库即可,首次启动服务端会自动初始化
|
||||
url: jdbc:mysql://xxxx:3306/neutrino-proxy?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&useAffectedRows=true&useSSL=false
|
||||
driver-class: com.mysql.jdbc.Driver
|
||||
# 数据库帐号
|
||||
username: xxx
|
||||
# 数据库密码
|
||||
password: xxx
|
||||
```
|
||||
|
||||
- 可参照 https://gitee.com/dromara/neutrino-proxy/blob/master/scripts/unix/server_start.sh 使用shell脚本启动服务端。
|
||||
|
||||
## 3、部署客户端
|
||||
- 本地解压`neutrino-proxy-client-jar.zip`文件
|
||||
- 修改`app.yml`文件中的server-ip为服务器公网ip,并配置license-key,以下是相关的部分配置:
|
||||
```yml
|
||||
neutrino:
|
||||
proxy:
|
||||
tunnel:
|
||||
# ssl证书密钥(使用jjar包内自带的证书,则此处无需修改)
|
||||
key-store-password: 123456
|
||||
# ssl证书管理密钥(使用jjar包内自带的证书,则此处无需修改。自定义证书,则此处配置对应的路径)
|
||||
jks-path: classpath:/test.jks
|
||||
# 代理服务端IP
|
||||
server-ip: xxxx
|
||||
# 代理服务端IP, 若是非ssl端口,则ssl-enable需要配置为false
|
||||
server-port: 9002
|
||||
# 是否启用ssl
|
||||
ssl-enable: true
|
||||
# licenseKey,客户端凭证。此处需要配置刚刚从管理后台复制的LicenseKey
|
||||
license-key: xxxx
|
||||
```
|
||||
- 执行命令`java -jar neutrino-proxy-client.jar`启动客户端
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
---
|
||||
title: 使用docker容器化部署
|
||||
date: 2023-10-26 13:51:29
|
||||
permalink: /pages/5b9bef/
|
||||
---
|
||||
|
||||
## 1、 部署服务端
|
||||
### 使用默认h2数据库一键部署
|
||||
```shell
|
||||
docker run -it -p 9000-9200:9000-9200/tcp -p 8888:8888 \
|
||||
-d --restart=always --name neutrino-proxy \
|
||||
-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 \
|
||||
aoshiguchen/neutrino-proxy-server:latest
|
||||
```
|
||||
|
||||
### 指定自己的mysql数据库
|
||||
- 在服务器上创建目录:/root/neutrino-proxy/config
|
||||
- 在该目录下创建`app.yml`文本文件,并配置如下内容:
|
||||
```yml
|
||||
neutrino:
|
||||
data:
|
||||
db:
|
||||
type: mysql
|
||||
# 自己的数据库实例,创建一个空的名为'neutrino-proxy'的数据库即可,首次启动服务端会自动初始化
|
||||
url: jdbc:mysql://xxxx:3306/neutrino-proxy?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&useAffectedRows=true&useSSL=false
|
||||
driver-class: com.mysql.jdbc.Driver
|
||||
# 数据库帐号
|
||||
username: xxx
|
||||
# 数据库密码
|
||||
password: xxx
|
||||
```
|
||||
- 然后再执行上面的docker一键部署命令即可
|
||||
|
||||
## 2、部署客户端
|
||||
- 命令中的服务端ip、license请自行补充
|
||||
- 若是首次使用,请仔细阅读快速上手,以确定license从哪里取得
|
||||
```shell
|
||||
docker run -it -d --restart=always --name npclient -e SERVER_IP=xxxx -e LICENSE_KEY=xxxx \
|
||||
aoshiguchen/neutrino-proxy-client:latest
|
||||
```
|
||||
@@ -0,0 +1,61 @@
|
||||
---
|
||||
title: 原生部署
|
||||
date: 2023-10-26 13:51:44
|
||||
permalink: /pages/69699a/
|
||||
---
|
||||
|
||||
::: tip
|
||||
1、目前的原生部署包支持mac、linux、windows三个平台
|
||||
|
||||
2、这三个平台的部署包均由作者分别测试通过
|
||||
|
||||
3、尽管如此,仍然可能存在有的机器不支持的情况,可自行拉取仓库源码编译出目标平台可执行文件、或换成其它部署方式
|
||||
|
||||
4、若linux/mac下提示文件没有执行权限,可执行`chmod +x {文件路径}`解决
|
||||
|
||||
5、若mac下运行提示移到废纸篓,可执行`sudo xattr -rd com.apple.quarantine {文件路径}`解决
|
||||
:::
|
||||
|
||||
## 1、安装包下载
|
||||
- 打开[发行版页面](https://gitee.com/dromara/neutrino-proxy/releases),下载所需的最新的release包:
|
||||
- 比如服务器为linux则可下载`neutrino-proxy-server-ubuntu-20.04-native.zip`文件,客户端为windows则可下载`neutrino-proxy-client-windows-2022-native.zip`
|
||||
|
||||
## 2、部署服务端
|
||||
- 将服务端安装包上传至服务器,并解压
|
||||
- 服务端默认使用h2数据库,若需要改为mysql,则可修改安装包`app.yml`内的数据库配置,如下:
|
||||
```yml
|
||||
neutrino:
|
||||
data:
|
||||
db:
|
||||
type: mysql
|
||||
# 自己的数据库实例,创建一个空的名为'neutrino-proxy'的数据库即可,首次启动服务端会自动初始化
|
||||
url: jdbc:mysql://xxxx:3306/neutrino-proxy?useUnicode=true&allowMultiQueries=true&useAffectedRows=true&useSSL=false
|
||||
driver-class: com.mysql.jdbc.Driver
|
||||
# 数据库帐号
|
||||
username: xxx
|
||||
# 数据库密码
|
||||
password: xxx
|
||||
```
|
||||
- 然后直接启动服务端可执行程序即可
|
||||
|
||||
## 3、部署客户端
|
||||
- 本地解压客户端安装包
|
||||
- 修改`app.yml`文件中的server-ip为服务器公网ip,并配置license-key,以下是相关的部分配置:
|
||||
```yml
|
||||
neutrino:
|
||||
proxy:
|
||||
tunnel:
|
||||
# ssl证书密钥(使用jjar包内自带的证书,则此处无需修改)
|
||||
key-store-password: 123456
|
||||
# ssl证书管理密钥(使用jjar包内自带的证书,则此处无需修改。自定义证书,则此处配置对应的路径)
|
||||
jks-path: classpath:/test.jks
|
||||
# 代理服务端IP
|
||||
server-ip: xxxx
|
||||
# 代理服务端IP, 若是非ssl端口,则ssl-enable需要配置为false
|
||||
server-port: 9002
|
||||
# 是否启用ssl
|
||||
ssl-enable: true
|
||||
# licenseKey,客户端凭证。此处需要配置刚刚从管理后台复制的LicenseKey
|
||||
license-key: xxxx
|
||||
```
|
||||
- 然后直接启动客户端可执行程序即可
|
||||
@@ -1,118 +0,0 @@
|
||||
---
|
||||
title: 快速上手
|
||||
date: 2023-03-28 20:30:00
|
||||
permalink: /pages/793dcb
|
||||
article: false
|
||||
---
|
||||
|
||||
## 1、 部署服务端
|
||||
### 1.1、 Docker一键部署
|
||||
> 当前最新版本为1.8.4,下面的脚本中,可以使用:`registry.cn-hangzhou.aliyuncs.com/asgc/neutrino-proxy:1.8.4` 指定版本安装,推荐使用`latest`直接安装最新版。
|
||||
|
||||
#### 使用默认sqlite数据库
|
||||
```shell
|
||||
docker run -it -p 9000-9200:9000-9200/tcp -p 8888:8888 \
|
||||
-d --restart=always --name neutrino-proxy \
|
||||
registry.cn-hangzhou.aliyuncs.com/asgc/neutrino-proxy:latest
|
||||
```
|
||||
|
||||
#### 指定自己的mysql数据库
|
||||
- 在服务器上创建目录:/root/neutrino-proxy/config
|
||||
- 在该目录下创建`app.yml`文本文件,并配置如下内容:
|
||||
```yml
|
||||
neutrino:
|
||||
data:
|
||||
db:
|
||||
type: mysql
|
||||
# 自己的数据库实例,创建一个空的名为'neutrino-proxy'的数据库即可,首次启动服务端会自动初始化
|
||||
url: jdbc:mysql://xxxx:3306/neutrino-proxy?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&useAffectedRows=true&useSSL=false
|
||||
driver-class: com.mysql.jdbc.Driver
|
||||
# 数据库帐号
|
||||
username: xxx
|
||||
# 数据库密码
|
||||
password: xxx
|
||||
```
|
||||
- 然后执行如下命令:
|
||||
```shell
|
||||
docker run -it -p 9000-9200:9000-9200/tcp -p 8888:8888 \
|
||||
-v /root/neutrino-proxy/config:/root/neutrino-proxy/config \
|
||||
-d --restart=always --name neutrino \
|
||||
registry.cn-hangzhou.aliyuncs.com/asgc/neutrino-proxy:latest
|
||||
```
|
||||
|
||||
### 1.2、使用jar包自行部署
|
||||
- 首先确保服务器上已安装java8运行环境
|
||||
- 打开[发行版页面](https://gitee.com/dromara/neutrino-proxy/releases),下载最新的release包:`neutrino-proxy-server.jar`、`neutrino-proxy-admin.zip`
|
||||
- 在服务器上新建部署目录:`/work/projects/neutrino-proxy-server`
|
||||
- 将` neutrino-proxy-server.jar`、`neutrino-proxy-admin.zip`上传至服务器部署目录。
|
||||
- 解压`neutrino-proxy-admin.zip`文件
|
||||
- 执行命令`java -Dfile.encoding=utf-8 -jar neutrino-proxy-server.jar`启动服务端完成部署,默认使用sqlite数据库。
|
||||
- 若需要指定自己的mysql数据库,同样的需要在当前目录下新建`app.yml`文件,文件内容同上。执行命令`java -Dfile.encoding=utf-8 -jar neutrino-proxy-server.jar config=app.yml`启动服务端完成部署
|
||||
- 可参照 https://gitee.com/dromara/neutrino-proxy/blob/master/bin/server_start.sh 使用shell脚本启动服务端。
|
||||
|
||||
## 2、管理后台配置
|
||||
- 服务端部署成功后,访问`http://{服务端IP}:8888`打开后台管理页面。
|
||||
- 使用默认的管理员帐号登录:admin/123456
|
||||
- 打开`代理配置>License管理`页面,可以看到系统已经自动为管理员初始化了一条License记录,复制该`LicenseKey`备用,后续客户端配置需要。
|
||||
- 打开`代理配置>端口映射`页面,可以看到系统已经自动为初始化了几条端口映射。可根据需要自行添加、修改。这里我们以`9101 -> 127.0.0.1:8080`映射为例
|
||||
|
||||
## 3、启动客户端
|
||||
- 首先确保本地已安装java8运行环境
|
||||
- 打开[发行版页面](https://gitee.com/dromara/neutrino-proxy/releases),下载最新的release包:`neutrino-proxy-client.jar`
|
||||
- 在本地`neutrino-proxy-client.jar`同级别目录下新建`app.yml`文件,并配置如下内容:
|
||||
```yml
|
||||
neutrino:
|
||||
proxy:
|
||||
client:
|
||||
# ssl证书密钥(使用jjar包内自带的证书,则此处无需修改)
|
||||
key-store-password: 123456
|
||||
# ssl证书管理密钥(使用jjar包内自带的证书,则此处无需修改。自定义证书,则此处配置对应的路径)
|
||||
jks-path: classpath:/test.jks
|
||||
# 代理服务端IP
|
||||
server-ip: localhost
|
||||
# 代理服务端IP, 若是非ssl端口,则ssl-enable需要配置为false
|
||||
server-port: 9002
|
||||
# 是否启用ssl
|
||||
ssl-enable: true
|
||||
# licenseKey,客户端凭证。此处需要配置刚刚从管理后台复制的LicenseKey
|
||||
license-key: xxxx
|
||||
```
|
||||
- 执行命令`java -jar neutrino-proxy-client.jar config=app.yml`启动客户端
|
||||
- 查看服务端License管理,刷新页面,对应的License在线状态为`在线`,则表明客户端已正常连接。
|
||||
|
||||
## 4、代理验证
|
||||
- 本地启动被代理服务,如:redis、本地web项目、本地mysql等等
|
||||
- 先确保本地能正常访问被代理服务,如果本地都不能访问,不用想代理更不可能!!!
|
||||
- 通过服务端IP+9101(上面License配置的端口映射重的服务端端口)访问本地被代理服务
|
||||
|
||||
访问成功,至此首次完整的内网穿透体验完成。开源不易,请速至[Gitee仓库](https://gitee.com/dromara/neutrino-proxy)一键三连🤝
|
||||
|
||||
<!--
|
||||
## 4.开发&调试
|
||||
|
||||
::: tip
|
||||
1. 不建议在原默认vuepress项目上单独安装使用本主题包,而是clone我的整个项目再替换你自己的内容即可。
|
||||
2. 修改`config.js`配置后需要重新启动项目才会生效。
|
||||
3. 更多关于项目上手的问题,请查阅 [问答](/pages/9cc27d/)。
|
||||
:::
|
||||
|
||||
|
||||
## 版本升级
|
||||
|
||||
主题的版本会不定期更新,你只需更新npm主题包即可:
|
||||
```sh
|
||||
npm update vuepress-theme-vdoing
|
||||
```
|
||||
|
||||
::: tip
|
||||
1. 如更新后没起作用或报错,尝试把`node_modules`文件夹删除再`npm i`重新安装。
|
||||
2. 在.vuepress/config.js中,设置`theme: 'vdoing'`才是使用npm主题依赖包:
|
||||
```js
|
||||
// config.js
|
||||
module.exports = {
|
||||
theme: 'vdoing', // npm主题依赖包
|
||||
// theme: require.resolve('../../vdoing'), // 使用本地主题包
|
||||
}
|
||||
```
|
||||
:::
|
||||
-->
|
||||
@@ -1,65 +0,0 @@
|
||||
---
|
||||
title: 服务端配置
|
||||
date: 2023-05-27 11:41:44
|
||||
permalink: /pages/f2d0f1/
|
||||
---
|
||||
|
||||
::: tip
|
||||
|
||||
1.8.2版本,服务端配置格式有所调整。从1.8.2之前的版本升级到1.8.2之后的版本,需要注意
|
||||
|
||||
:::
|
||||
|
||||
|
||||
# 以下是最新的服务端配置格式(app.yml)
|
||||
```yml
|
||||
server:
|
||||
# 服务端web端口,用于支持HTTP接口,管理后台页面访问
|
||||
port: ${WEB_PORT:8888}
|
||||
|
||||
neutrino:
|
||||
proxy:
|
||||
logger:
|
||||
# 日志级别
|
||||
level: ${LOG_LEVEL:info}
|
||||
# 隧道相关配置-用于维持服务端与客户端的通信
|
||||
tunnel:
|
||||
# 线程池相关配置,用于技术调优,可忽略
|
||||
boss-thread-count: 2
|
||||
work-thread-count: 10
|
||||
# 隧道非SSL端口
|
||||
port: ${OPEN_PORT:9000}
|
||||
# 隧道SSL端口
|
||||
ssl-port: ${SSL_PORT:9002}
|
||||
# 隧道SSL证书配置
|
||||
key-store-password: ${STORE_PASS:123456}
|
||||
key-manager-password: ${MGR_PASS:123456}
|
||||
jks-path: ${JKS_PATH:classpath:/test.jks}
|
||||
# 是否开启隧道传输报文日志(日志级别为debug时开启才有效)
|
||||
transfer-log-enable: ${TUNNEL_LOG:false}
|
||||
server:
|
||||
# 线程池相关配置,用于技术调优,可忽略
|
||||
boss-thread-count: 5
|
||||
work-thread-count: 20
|
||||
# http代理端口,默认80
|
||||
http-proxy-port: ${HTTP_PROXY_PORT:80}
|
||||
# https代理端口,默认443 (需要配置域名、证书)
|
||||
https-proxy-port: ${HTTPS_PROXY_PORT:443}
|
||||
# 如果不配置,则不支持域名映射
|
||||
domain-name: ${DOMAIN_NAME:}
|
||||
# https证书配置
|
||||
key-store-password: ${HTTPS_STORE_PASS:}
|
||||
jks-path: ${HTTPS_JKS_PATH:}
|
||||
# 是否开启代理服务报文日志(日志级别为debug时开启才有效)
|
||||
transfer-log-enable: ${SERVER_LOG:false}
|
||||
data:
|
||||
db:
|
||||
# 数据库类型,目前支持sqlite、mysql、mariadb
|
||||
type: ${DB_TYPE:sqlite}
|
||||
# 数据库连接URL
|
||||
url: ${DB_URL:jdbc:sqlite:data.db}
|
||||
# 数据库用户名
|
||||
username: ${DB_USER:}
|
||||
# 数据库密码
|
||||
password: ${DB_PASSWORD:}
|
||||
```
|
||||
@@ -0,0 +1,75 @@
|
||||
---
|
||||
title: 服务端配置
|
||||
date: 2023-05-27 11:41:44
|
||||
permalink: /pages/f2d0f1/
|
||||
---
|
||||
|
||||
::: tip
|
||||
|
||||
1.9.0版本,服务端配置格式有所调整。从之前的版本升级的,需要注意
|
||||
|
||||
:::
|
||||
|
||||
|
||||
# 以下是最新的服务端配置格式(app.yml)
|
||||
```yml
|
||||
server:
|
||||
# 服务端web端口,用于支持HTTP接口,管理后台页面访问
|
||||
port: ${WEB_PORT:8888}
|
||||
# 日志级别
|
||||
solon.logging.logger:
|
||||
"root":
|
||||
level: info
|
||||
|
||||
neutrino:
|
||||
proxy:
|
||||
# 隧道相关配置-用于维持服务端与客户端的通信
|
||||
tunnel:
|
||||
# 线程池相关配置,用于技术调优,可忽略
|
||||
boss-thread-count: 2
|
||||
work-thread-count: 10
|
||||
# 隧道非SSL端口
|
||||
port: ${OPEN_PORT:9000}
|
||||
# 隧道SSL端口
|
||||
ssl-port: ${SSL_PORT:9002}
|
||||
# 隧道SSL证书配置
|
||||
key-store-password: ${STORE_PASS:123456}
|
||||
key-manager-password: ${MGR_PASS:123456}
|
||||
jks-path: ${JKS_PATH:classpath:/test.jks}
|
||||
# 是否开启隧道传输报文日志(日志级别为debug时开启才有效)
|
||||
transfer-log-enable: ${TUNNEL_LOG:false}
|
||||
# 是否开启心跳日志
|
||||
heartbeat-log-enable: ${HEARTBEAT_LOG:false}
|
||||
server:
|
||||
tcp:
|
||||
# 线程池相关配置,用于技术调优,可忽略
|
||||
boss-thread-count: 5
|
||||
work-thread-count: 20
|
||||
# http代理端口,默认80
|
||||
http-proxy-port: ${HTTP_PROXY_PORT:80}
|
||||
# https代理端口,默认443 (需要配置域名、证书)
|
||||
https-proxy-port: ${HTTPS_PROXY_PORT:443}
|
||||
# 如果不配置,则不支持域名映射
|
||||
domain-name: ${DOMAIN_NAME:}
|
||||
# https证书配置
|
||||
key-store-password: ${HTTPS_STORE_PASS:}
|
||||
jks-path: ${HTTPS_JKS_PATH:}
|
||||
# 是否开启代理服务报文日志(日志级别为debug时开启才有效)
|
||||
transfer-log-enable: ${SERVER_LOG:false}
|
||||
udp:
|
||||
# 线程池相关配置,用于技术调优,可忽略
|
||||
boss-thread-count: 5
|
||||
work-thread-count: 20
|
||||
# 是否开启代理服务报文日志(日志级别为debug时开启才有效)
|
||||
transfer-log-enable: ${SERVER_LOG:false}
|
||||
data:
|
||||
db:
|
||||
# 数据库类型,目前支持h2、mysql、mariadb
|
||||
type: ${DB_TYPE:h2}
|
||||
# 数据库连接URL
|
||||
url: ${DB_URL:jdbc:h2:file:./data/db;MODE=MySQL;AUTO_SERVER=TRUE}
|
||||
# 数据库用户名
|
||||
username: ${DB_USER:}
|
||||
# 数据库密码
|
||||
password: ${DB_PASSWORD:}
|
||||
```
|
||||
@@ -4,14 +4,22 @@ date: 2023-06-09 21:15:35
|
||||
permalink: /pages/50ce10/
|
||||
---
|
||||
|
||||
::: tip
|
||||
|
||||
1.9.0版本,客户端配置格式有所调整。从之前的版本升级的,需要注意
|
||||
|
||||
:::
|
||||
|
||||
# 以下是最新的客户端配置格式(app.yml)
|
||||
```yml
|
||||
# 日志级别
|
||||
solon.logging.logger:
|
||||
"root":
|
||||
level: info
|
||||
|
||||
neutrino:
|
||||
proxy:
|
||||
logger:
|
||||
# 日志级别
|
||||
level: ${LOG_LEVEL:info}
|
||||
client:
|
||||
tunnel:
|
||||
# 线程池相关配置,用于技术调优,可忽略
|
||||
thread-count: 50
|
||||
# 隧道SSL证书配置
|
||||
@@ -29,10 +37,21 @@ neutrino:
|
||||
client-id: ${CLIENT_ID:}
|
||||
# 是否开启隧道传输报文日志(日志级别为debug时开启才有效)
|
||||
transfer-log-enable: ${CLIENT_LOG:false}
|
||||
# 是否开启心跳日志
|
||||
heartbeat-log-enable: ${HEARTBEAT_LOG: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: ${CLIENT_LOG:false}
|
||||
```
|
||||
@@ -1,39 +0,0 @@
|
||||
---
|
||||
title: 项目结构
|
||||
date: 2020-05-11 13:54:56
|
||||
permalink: /pages/2f674a
|
||||
article: false
|
||||
---
|
||||
|
||||
# 主要目录、文件
|
||||
|
||||
```
|
||||
├── data.db (为配置mysql时,项目启动默认初始化生成的本地sqlite数据库文件)
|
||||
├── docs (项目相关的一些文档)
|
||||
├── neutrino-proxy-admin (管理后台前端项目,基于vue-element-admin)
|
||||
├── neutrino-proxy-client (基于netty的代理客户端,用于和服务端交互、转发内网数据)
|
||||
├── neutrino-proxy-core (代理相关的公共代码(协议、常量))
|
||||
├── neutrino-proxy-server (基于netty的代理服务端,用于和客户段交互,将客户端转发的内网数据转发至外网端口)
|
||||
└── todolist.MD (近期的开发计划)
|
||||
```
|
||||
|
||||
# 代理服务端 `neutrino-proxy-server`
|
||||
- base:基础的配置、初始化代码
|
||||
- constant:服务端常量、枚举定义
|
||||
- dal:持久层mapper、实体
|
||||
- job:定时任务执行入口
|
||||
- proxy:代理核心实现
|
||||
- service:基础业务
|
||||
- util:基础工具封装
|
||||
- resource/mapper:mybatis SQL文件
|
||||
- resource/sql:维护mysql/sqlite的初始化SQL、SQL变更记录
|
||||
- resource/app.yml:项目默认配置
|
||||
- resource/test.jks:默认的SSL证书
|
||||
|
||||
# 代理客户端 `neutrino-proxy-client`
|
||||
- config:基础配置
|
||||
- core:客户端代理核心入口
|
||||
- handler:客户端代理数据处理逻辑
|
||||
- util:基础工具封装
|
||||
- resource/app.yml:项目默认配置
|
||||
- resource/test.jks:默认的SSL证书
|
||||
@@ -1,13 +0,0 @@
|
||||
---
|
||||
title: 演示环境
|
||||
date: 2020-05-12 15:10:15
|
||||
permalink: /pages/db78e2
|
||||
article: false
|
||||
---
|
||||
|
||||
### 演示环境
|
||||
可使用分配好的游客license试用。服务器带宽较低,仅供学习使用!
|
||||
|
||||
管理后台地址:<a href="http://103.163.47.16:9527" target="_blank">http://103.163.47.16:9527</a>
|
||||
|
||||
游客账号:visitor/123456
|
||||
@@ -1,21 +0,0 @@
|
||||
---
|
||||
title: 2023年
|
||||
date: 2023-06-09 21:33:17
|
||||
permalink: /pages/cded59/
|
||||
---
|
||||
|
||||
| 日期 | 渠道 | 金额 |昵称| 备注 |
|
||||
|:-----------|:---|:---|:-|:--------|
|
||||
| 2023-06-09 |Gitee捐助| 10 |失败女神| 感谢您的开源项目! |
|
||||
| 2023-06-09 |Gitee捐助| 50 |Admin| 感谢您的开源项目! |
|
||||
| 2023-06-09 |微信红包| 50 |李阳| 开源无限好 |
|
||||
| 2023-06-09 |Gitee捐助| 50 |罗宾| 感谢您的开源项目!|
|
||||
| 2023-06-07 |Gitee捐助| 50 |罗宾| 感谢您的开源项目!|
|
||||
| 2023-06-03 |Gitee捐助| 50 |Admin| 感谢您的开源项目!|
|
||||
| 2023-05-29 |微信红包| 20 |TYY| |
|
||||
| 2023-05-29 |Gitee捐助| 10 |笑看| 感谢您的开源项目!|
|
||||
| 2023-05-26 |微信红包| 50 |至少还有满天星光照耀你| |
|
||||
| 2023-02-23 |Gitee捐助| 10 |Yohanes|感谢您的开源项目! |
|
||||
| 2023-02-23 |Gitee捐助| 20 |jam_lee|感谢您的开源项目!希望能支持域名映射|
|
||||
| 2023-02-10 |Gitee捐助| 5 |实习两年半|感谢您的开源项目!|
|
||||
| 2023-02-02 |Gitee捐助| 10 |阳光很暖|感谢您的开源项目!|
|
||||
@@ -0,0 +1,20 @@
|
||||
---
|
||||
title: 客户端连接服务端失败
|
||||
date: 2023-10-25 17:55:20
|
||||
permalink: /pages/31d253/
|
||||
---
|
||||
|
||||
## 1.1. 启动日志包含`not found license-key config`相关字样
|
||||
出现这种情况,说明客户端没获取到配置的license,可按如下检查:
|
||||
- 客户端是否有配置app.yml,app.yml中是否有配置`license-key`
|
||||
- 客户端启动参数是否指定app.yml配置,若未指定客户端不会加载任何jar外部的配置文件
|
||||
- 客户端启动参数指定的配置文件路径是否正确?如:`java -jar neutrino-proxy-client.jar config=app.yml`,代表`app.yml`文件与jar在同级别目录下,如果不在同级别目录,请使用绝对/相对路径指定
|
||||
- 除此之外license还可以用以下方法直接在启动参数中指定:
|
||||
- `java -jar -DLICENSE_KEY=xxxx -DSERVER_IP=x.x.x.x -DSERVER_PORT=9000 -DSSL_ENABLE=false neutrino-proxy-client.jar`
|
||||
- `java -jar neutrino-proxy-client.jar serverIp=x.x.x.x serverPort=9000 sslEnable=false licenseKey=xxxx`
|
||||
|
||||
## 1.2. 配置文件确定都已经配置,且启动参数正确指定了,但是没有出现`认证成功日志`
|
||||
- 确认客户端配置的`server-ip`,必须是服务端所在机器的ip,且保证客户端所在机器能正常ping通
|
||||
- 确认客户端配置的`server-port`与`ssl-enable`,默认情况应配置为9000、false或9002、true,除非服务端app.yml有改动隧道对外端口
|
||||
- 确认服务端对外的9000、9002端口是否已经放开
|
||||
- 服务端如果采用docker部署,需要确保容器的9000、9002端口映射到宿主机
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
title: 易混淆的2类证书
|
||||
date: 2023-10-25 17:56:59
|
||||
permalink: /pages/e4c3d7/
|
||||
---
|
||||
|
||||
## 2.1. HTTPS证书
|
||||
该证书用于服务端支持HTTPS,若需要在服务端`app.yml`中配置即可
|
||||
|
||||
## 2.2. 隧道SSL证书
|
||||
该证书用于对客户端-服务端之间的数据通信进行加密,因此客户端/服务端均需要配置该证书。可参考如下命令生成:
|
||||
```
|
||||
keytool -genkey -alias test1 -keyalg RSA -keysize 1024 -validity 3650 -keypass 123456 -storepass 123456 -keystore "./test.jks"
|
||||
```
|
||||
@@ -0,0 +1,16 @@
|
||||
---
|
||||
title: udp代理无效
|
||||
date: 2023-10-25 17:58:35
|
||||
permalink: /pages/7b990f/
|
||||
---
|
||||
|
||||
## 问题描述
|
||||
代理本地udp端口9231,公网访问代理端口无效,代理端口测试发送成功,但是本地服务没有收到,使用路由器的ddns功能也可以成功代理。
|
||||
## 解决方案
|
||||
+ 防火墙开放端口的时候一定要指定udp协议
|
||||
+ 还有如果想收到回复需要配置两个响应参数
|
||||
+ 响应数量根据实际响应数量配置,可以配置的大一些,但是不能比实际小
|
||||
+ 超时时间根据实际响应时间配置,比如正常响应时间是10s,这里就可以配置15000毫秒等
|
||||
<img :src="$withBase('/img/run-example/question_3_1.png')"></img>
|
||||
+ 相关链接:[1.9.0版本udp代理无效 · Issue #I83XOI · dromara/neutrino-proxy - Gitee.com](https://gitee.com/dromara/neutrino-proxy/issues/I83XOI)
|
||||
+ 贡献者:gitee:眉黛如画
|
||||
@@ -0,0 +1,19 @@
|
||||
---
|
||||
title: Vue项目出现Invalid Host header 的解决方案
|
||||
date: 2023-10-25 17:59:29
|
||||
permalink: /pages/441163/
|
||||
---
|
||||
|
||||
## 问题描述
|
||||
内网穿透 Vue项目出现Invalid Host header 的解决方案
|
||||
## 解决方案
|
||||
manifest.json中配置
|
||||
```
|
||||
"h5":{
|
||||
"devServer":{
|
||||
"disableHostCheck":true
|
||||
}
|
||||
},
|
||||
```
|
||||
+ 相关链接:[内网穿透 Vue项目出现Invalid Host header 的解决方案](https://blog.csdn.net/weixin_41549915/article/details/96132925)
|
||||
+ 贡献者:wx:明天会更好
|
||||
@@ -0,0 +1,39 @@
|
||||
---
|
||||
title: 个人赞赏
|
||||
date: 2023-10-26 13:08:02
|
||||
permalink: /pages/1ab20b/
|
||||
---
|
||||
|
||||
## 个人赞赏说明
|
||||
随着用户增加,需要协助解决的问题也多种多样,为了能给用户提供 `更优质`、`更准确` 的 疑难问题 解答我们推出赞赏咨询服务
|
||||
|
||||
| 赞赏金额 | 服务时长 | 服务说明 |
|
||||
|:-----|:-----|:----------------------|
|
||||
| 任意金额 | - | 您将获得赞助者列表的永久留名。 |
|
||||
| 30 | 一个月 | 您在群内反馈的问题将优先得到作者响应 |
|
||||
| 80 | 三个月 | 获得微信一对一的咨询服务 |
|
||||
| 180 | 三个月 | 获得官网首页特别赞助席位一个,一次远程协助 |
|
||||
| 更多金额 |-| 您将获得私人定制服务 |
|
||||
|
||||
> 注意1:服务项目是逐级叠加:如,您赞赏的金额是 80 员那么您将享受:任意金额、一个月、三个月的服务内容
|
||||
|
||||
> 注意2:二开问题不在个人赞赏支持服务范畴内,如需咨询二开问题或者二开方案请找作者协商
|
||||
|
||||
## 赞赏途径
|
||||
> 除4以外,赞赏后请及时通过官网首页微信二维码与作者取得联系
|
||||
|
||||
- 1、微信赞赏
|
||||
- 2、支付宝转账
|
||||
- 3、Gitee项目捐赠:[点击这里](https://gitee.com/dromara/neutrino-proxy)打开后拉到最底部点击捐赠
|
||||
- 4、微信好友转账
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td align="center">微信赞赏</td><td align="center">支付宝转账</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img width="300px" src="./a1.png"></td><td><img width="300px" src="./a2.png"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -36,8 +36,8 @@ permalink: /pages/a3f096/
|
||||
- 注释完备,尤其每个新增的方法应按照Java文档规范标明方法说明、参数说明、返回值说明等信息,必要时请添加单元测试,如果愿意,也可以加上你的大名。
|
||||
- 原则上,不允许自行添加第三方依赖库。若确有必要,请先和项目负责人沟通达成一致。
|
||||
- 对现有代码的优化,请在注释中说明原因。
|
||||
- 如果涉及到数据库的变更,则至少需要做到以下绩点:
|
||||
- sqlite、mysql下均测试通过
|
||||
- 如果涉及到数据库的变更,则至少需要做到以下几点:
|
||||
- h2、mysql下均测试通过
|
||||
- 在`./neutrino-proxy-server/src/main/resource/sql`下维护更新对应的表结构sql文件
|
||||
- 对于新增的表,维护必要的初始化数据
|
||||
- 在对应的mysql、sqlite的update目录下,维护SQL变更记录,确保SQL执行测试通过
|
||||
- 在对应的mysql、h2的update目录下,维护SQL变更记录,确保SQL执行测试通过
|
||||
@@ -0,0 +1,28 @@
|
||||
---
|
||||
title: 项目结构
|
||||
date: 2020-05-11 13:54:56
|
||||
permalink: /pages/2f674a
|
||||
article: false
|
||||
---
|
||||
|
||||
# 主要目录、文件
|
||||
|
||||
```
|
||||
├── assets (资源文件)
|
||||
├── docs (项目相关的一些文档)
|
||||
├── neutrino-proxy-admin (管理后台前端项目,基于vue-element-admin)
|
||||
├── neutrino-proxy-client (基于netty的代理客户端,用于和服务端交互、转发内网数据)
|
||||
├── neutrino-proxy-core (代理相关的公共代码(协议、常量))
|
||||
├── neutrino-proxy-server (基于netty的代理服务端,用于和客户段交互,将客户端转发的内网数据转发至外网端口)
|
||||
├── neutrino-proxy-vuepress (中微子代理官网文档)
|
||||
├── scripts (常用的编译、打包脚本)
|
||||
├── Milestone.md (里程碑事件节点)
|
||||
├── VLog.md (版本变更记录)
|
||||
└── todolist.MD (近期的开发计划)
|
||||
```
|
||||
|
||||
# 代码分支说明
|
||||
- dev:常规开发分支,日常的开发、Bug修复、提交PR都在此分支
|
||||
- feature/xxx:特征分支,一些试验性开发、提交PR都在此分支,xxx可自行取一个有意义的名称
|
||||
- release/xxx:发行版分支,作为阶段性成果、重大更新的版本固化分支。受保护,不允许任何提交。
|
||||
- master:主分支,定期同步最新代码,目前仅支持本人(傲世孤尘/雨韵诗泽)提交。
|
||||
@@ -0,0 +1,38 @@
|
||||
---
|
||||
title: 2023年
|
||||
date: 2023-06-09 21:33:17
|
||||
permalink: /pages/cded59/
|
||||
---
|
||||
|
||||
| 日期 | 渠道 | 金额 |昵称| 备注 |
|
||||
|:-----------|:---|:-----|:-|:-----------------|
|
||||
|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| 请大佬抽包烟 |
|
||||
| 2023-07-04 |微信红包| 50 |姫野永遠| |
|
||||
| 2023-06-29 |微信红包| 16.8 |迟迟🌱| 加油 |
|
||||
| 2023-06-27 |微信红包| 30 |Arno| |
|
||||
| 2023-06-25 |Gitee捐助| 10 |zhujue888| 感谢您的开源项目! |
|
||||
| 2023-06-16 |微信红包| 50 |小跟班| |
|
||||
| 2023-06-10 |Gitee捐助| 10 |失败女神| 感谢您的开源项目! |
|
||||
| 2023-06-09 |Gitee捐助| 50 |Admin| 感谢您的开源项目! |
|
||||
| 2023-06-09 |微信红包| 50 |李阳| 开源无限好 |
|
||||
| 2023-06-09 |Gitee捐助| 50 |罗宾| 感谢您的开源项目! |
|
||||
| 2023-06-07 |Gitee捐助| 50 |罗宾| 感谢您的开源项目! |
|
||||
| 2023-06-03 |Gitee捐助| 50 |Admin| 感谢您的开源项目! |
|
||||
| 2023-05-29 |微信红包| 20 |TYY| |
|
||||
| 2023-05-29 |Gitee捐助| 10 |笑看| 感谢您的开源项目! |
|
||||
| 2023-05-26 |微信红包| 50 |至少还有满天星光照耀你| |
|
||||
| 2023-02-23 |Gitee捐助| 10 |Yohanes| 感谢您的开源项目! |
|
||||
| 2023-02-23 |Gitee捐助| 20 |jam_lee| 感谢您的开源项目!希望能支持域名映射|
|
||||
| 2023-02-10 |Gitee捐助| 5 |实习两年半| 感谢您的开源项目! |
|
||||
| 2023-02-02 |Gitee捐助| 10 |阳光很暖| 感谢您的开源项目! |
|
||||
|
After Width: | Height: | Size: 418 KiB |
|
After Width: | Height: | Size: 296 KiB |
@@ -1,428 +0,0 @@
|
||||
---
|
||||
title: 案例
|
||||
date: 2020-05-14 11:39:45
|
||||
permalink: /pages/5d571c
|
||||
# sidebar: false
|
||||
article: false
|
||||
---
|
||||
## 特别用户
|
||||
::: cardImgList 3
|
||||
```yaml
|
||||
config:
|
||||
imgHeight: 140px
|
||||
|
||||
data:
|
||||
# - img: https://fastly.jsdelivr.net/gh/xugaoyi/image_store@master/blog/QQ20210729-233554@2x.22bdqeiem2sg.png
|
||||
# link: https://docs.openharmony.cn/pages/000000/
|
||||
# name: OpenHarmony
|
||||
# desc: 开放原子开源基金会
|
||||
# author: OpenHarmony
|
||||
# avatar: https://www.openharmony.cn/static/img/core-card-item2.a72a0d10.png
|
||||
- img: https://fastly.jsdelivr.net/gh/xugaoyi/image_store@master/blog/QQ20211215-144040.hgt2875r2zc.webp
|
||||
link: https://baomidou.com/
|
||||
name: MyBatis-Plus官网
|
||||
desc: 🚀为简化开发而生
|
||||
author: 青苗
|
||||
avatar: https://baomidou.com/img/logo.svg
|
||||
- img: https://fastly.jsdelivr.net/gh/xugaoyi/image_store@master/blog/QQ20210729-235804@2x.75e9lfd65t40.png
|
||||
link: https://docs.deepin.org
|
||||
name: Deepin 社区文档
|
||||
desc: Deepin 应用开发技术分享、DTK开发经验等
|
||||
author: Deepin
|
||||
avatar: https://fastly.jsdelivr.net/gh/xmuli/xmuliPic@pic/2021/deepin.png
|
||||
- img: https://ks3-cn-beijing.ksyuncs.com/vform-static/img/vform_website.png
|
||||
link: http://www.vform666.com
|
||||
name: VForm官网
|
||||
desc: 低代码表单优选方案,拖拽式设计,一键生成源码
|
||||
author: vformAdmin
|
||||
avatar: https://www.vform666.com/vform-logo.png
|
||||
- img: https://fastly.jsdelivr.net/gh/xugaoyi/blog-gitalk-comment@master/img/xxx.7feub7n1y0g0.png
|
||||
link: https://liteflow.yomahub.com
|
||||
name: LiteFlow官网
|
||||
desc: 轻量,快速,稳定可编排的组件式规则引擎
|
||||
author: 铂赛东
|
||||
avatar: https://portrait.gitee.com/uploads/avatars/user/367/1102362_bryan31_1578940308.png!avatar60
|
||||
- img: https://fastly.jsdelivr.net/gh/xugaoyi/blog-gitalk-comment@master/img/176866696-743faf44-4afd-4c12-9728-f982ea885836.2205nb3vf5mo.webp
|
||||
link: https://easy-es.cn/
|
||||
name: Easy-Es官网
|
||||
desc: 傻瓜级ElasticSearch搜索引擎ORM框架
|
||||
author: 老汉
|
||||
avatar: https://iknow.hs.net/9fa0407f-30ff-4d8b-82da-a4990e41a04b.png
|
||||
```
|
||||
:::
|
||||
|
||||
## 知识库兼博客
|
||||
::: cardImgList 4
|
||||
```yaml
|
||||
config:
|
||||
imgHeight: 140px
|
||||
|
||||
data:
|
||||
- img: https://fastly.jsdelivr.net/gh/xugaoyi/image_store/blog/20200530114033.png
|
||||
link: https://xugaoyi.com/
|
||||
name: Evan's blog
|
||||
desc: Web前端技术博客,积跬步以至千里,致敬每个爱学习的你。
|
||||
author: Evan Xu
|
||||
avatar: https://fastly.jsdelivr.net/gh/xugaoyi/image_store/blog/20200103123203.jpg
|
||||
- img: https://fastly.jsdelivr.net/gh/xugaoyi/image_store/blog/20200727170555.jpg
|
||||
link: https://miluluyo.github.io/vdoingBlog/
|
||||
name: 麋鹿鲁哟
|
||||
desc: 运气交给锦鲤,</br>你只管努力就好。 (●ˇ∀ˇ●)
|
||||
author: 麋鹿鲁哟
|
||||
avatar: https://fastly.jsdelivr.net/gh/xugaoyi/image_store/blog/20200122153807.jpg
|
||||
- img: https://i.loli.net/2020/07/26/BUCplirGIq9YTNA.png
|
||||
link: https://lingze.xyz/
|
||||
name: Lingze's blog
|
||||
desc: 少侠, 别来无恙?
|
||||
author: 令则
|
||||
avatar: https://i.loli.net/2020/07/11/XhqR7Idnk5LD8bC.jpg
|
||||
- img: https://fastly.jsdelivr.net/gh/xugaoyi/image_store@master/blog/QQ20210730-000829@2x.6pjgy10flk00.png
|
||||
link: https://www.xswsym.online/
|
||||
name: summer's blog
|
||||
desc: Devops运维技术博客,分享运维技术
|
||||
author: 夏苏文
|
||||
avatar: https://fastly.jsdelivr.net/gh/summerking1/image@main/tx.png
|
||||
- img: https://fastly.jsdelivr.net/gh/xugaoyi/image_store/blog/20201110221457.png
|
||||
link: https://gocifer.github.io
|
||||
name: Gocifer's DB & Blog
|
||||
desc: 一个中二少年,专注于计算机基础架构、云原生、网络、云计算的所学、所思、所行、所想。
|
||||
author: gocifer.jay
|
||||
avatar: https://gocifer.github.io/img/avatar/gocifer.png
|
||||
- img: https://dra-m.com/images/thumbnail.png
|
||||
link: https://dra-m.com/
|
||||
name: Dra-M
|
||||
desc: JAVA后端
|
||||
author: 莫小龙
|
||||
avatar: https://q1.qlogo.cn/g?b=qq&nk=975425198&s=640
|
||||
- img: https://fastly.jsdelivr.net/gh/xugaoyi/image_store/blog/20200905142134.png
|
||||
link: https://www.coder163.com/
|
||||
name: 跟着老侯玩编程
|
||||
desc: 一个乐于编程知识分享的站点
|
||||
author: 舞动的代码
|
||||
avatar: https://www.coder163.com/img/qun.png
|
||||
|
||||
- img: https://fastly.jsdelivr.net/gh/xugaoyi/image_store/blog/20210119213748.jpg
|
||||
link: https://haijunit.top/
|
||||
name: 学习笔记
|
||||
desc: 平时的技术积累|分享交流技术心得|温故而知新
|
||||
author: 爱做梦的奋斗青年
|
||||
avatar: https://haijunit.top/images/avatar.png
|
||||
- img: https://fastly.jsdelivr.net/gh/yxw839841231/images/studying-icu/20210120110320.png
|
||||
link: https://www.studying.icu/
|
||||
name: 研究院
|
||||
desc: 一万年太久,只争朝夕
|
||||
author: xwyang
|
||||
avatar: https://avatars1.githubusercontent.com/u/13757119?s=80&v=4
|
||||
- img: https://fastly.jsdelivr.net/gh/xugaoyi/image_store@master/blog/QQ20210704-230751@2x.3pw80u1fo6u0.png
|
||||
link: https://blog.kimen.com.cn/
|
||||
name: Kimen's Blog
|
||||
desc: 全沾攻城狮
|
||||
author: Kimen
|
||||
avatar: https://avatars.githubusercontent.com/u/25970284?s=460&u=69b419ad6de33eaa1d6b73d7f065f710076d6c55&v=4
|
||||
- img: https://fastly.jsdelivr.net/gh/xugaoyi/image_store@master/blog/QQ20211101-165045-(1).4b4axinii160.png
|
||||
link: https://lixianglong3210.gitee.io/xlong-vdoing/
|
||||
name: XLONG's blog
|
||||
desc: 蒸汽波、咖啡
|
||||
author: lixianglong3210
|
||||
avatar: http://www.lixianglong.cn/bg_store/img/avatar/default.jpg
|
||||
- img: https://fastly.jsdelivr.net/gh/Awrtiger/mirrorfile/img/web.png
|
||||
link: https://www.ool.cool/
|
||||
name: 偷吃了鸡蛋的梨
|
||||
desc: 捣鼓这,捣鼓那。
|
||||
author: Awrtiger
|
||||
avatar: https://fastly.jsdelivr.net/gh/Awrtiger/mirrorfile/img/avatar.jpg
|
||||
- img: https://image-1302577725.cos.ap-beijing.myqcloud.com/img/20210402183053.png
|
||||
link: https://f4de-bak.github.io/
|
||||
name: Xinghai's Blog
|
||||
desc: Web Security | Java Security
|
||||
author: Xinghai
|
||||
avatar: https://image-1302577725.cos.ap-beijing.myqcloud.com/img/20210328234543.jpg
|
||||
- img: https://fastly.jsdelivr.net/gh/xugaoyi/image_store@master/blog/eyjf.png
|
||||
link: https://wiki.eryajf.net
|
||||
name: 二丫讲梵
|
||||
desc: 学习,记录,分享。(运维生活编程)
|
||||
author: 二丫讲梵
|
||||
avatar: https://wiki.eryajf.net/img/logo.png
|
||||
- img: https://fastly.jsdelivr.net/gh/xugaoyi/image_store@master/blog/ss.2tev477ruza0.png
|
||||
link: https://masongsong.cn
|
||||
name: 松松的一尺三分地
|
||||
desc: 记录工作和学习中的所得
|
||||
author: masongsong
|
||||
avatar: https://fastly.jsdelivr.net/gh/MssText/learn@master/images/49203535.35emn5vryma0.png
|
||||
- img: https://fastly.jsdelivr.net/gh/Kele-Bingtang/static/user/20211218235045.png
|
||||
link: https://notes.youngkbt.cn/
|
||||
name: Young Kbt Blog
|
||||
desc: 记录学习Java, Web, 框架, 工具, 前端等相关知识, 记录生活和技术路程, 分享编程技巧。
|
||||
author: Ship Liu
|
||||
avatar: https://fastly.jsdelivr.net/gh/Kele-Bingtang/static/user/avatar2.png
|
||||
- img: https://fastly.jsdelivr.net/gh/xugaoyi/image_store@master/blog/123.57gcfayi85k0.webp
|
||||
link: https://blog.dragon1573.wang/
|
||||
name: 断桥烟雨の学习笔记
|
||||
desc: 学习爱我,我爱学习~
|
||||
author: べ断桥烟雨ミ
|
||||
avatar: https://avatars.githubusercontent.com/u/49941141
|
||||
- img: https://fastly.jsdelivr.net/gh/xugaoyi/blog-gitalk-comment@master/img/20220210094650.3q09d26tigc0.webp
|
||||
link: https://chuck6.github.io/blog/
|
||||
name: 梵一的博客
|
||||
desc: 个人博客和知识分享
|
||||
author: 梵一
|
||||
avatar: https://chuck6.github.io/blog/img/paizhao.jpg
|
||||
- img: https://fastly.jsdelivr.net/gh/niumoo/cdn-assets/2021/20220316145528.png
|
||||
link: https://www.wdbyte.com
|
||||
name: 未读代码
|
||||
desc: Java 开发知识库,分享原创文章
|
||||
author: 程序猿阿朗
|
||||
avatar: https://avatars.githubusercontent.com/u/26371673?v=4
|
||||
- img: https://fastly.jsdelivr.net/gh/simonzhangs/image-hosting@master/vue-plugin-example/blog.qg2buhe5h4g.webp
|
||||
link: https://simonzhangs.github.io/
|
||||
name: 松本松的博客儿
|
||||
desc: Web前端技术博客,积跬步以至千里。
|
||||
author: simonzhangs
|
||||
avatar: https://fastly.jsdelivr.net/gh/simonzhangs/image-hosting@master/20220319/image.4x708q9wzse0.webp
|
||||
- img: https://fastly.jsdelivr.net/gh/terwer/upload/img/image-20220422000045653.png
|
||||
link: http://terwergreen.com
|
||||
name: 远方的灯塔
|
||||
desc: 专注于服务端技术分享
|
||||
author: terwer
|
||||
avatar: https://fastly.jsdelivr.net/gh/terwer/upload/img/photo.jpg
|
||||
- img: https://fastly.jsdelivr.net/gh/nksuya/image_store@main/suyablog_home.5iou2ogjrm80.webp
|
||||
link: https://suyaspace.com/
|
||||
name: Suya's blog
|
||||
desc: 个人博客,分享技术文章,学习笔记,植物相关知识等。
|
||||
author: Suya
|
||||
avatar: https://fastly.jsdelivr.net/gh/nksuya/image_store@master/tech/avatar.2tycyyc1ebr4.jpg
|
||||
- img: https://fastly.jsdelivr.net/gh/xugaoyi/image_store2@master/img/QQ20220526-224620@2x.44o82ibj9qq0.png
|
||||
link: https://colorpanda.aifan.jp/
|
||||
name: ColorPanda
|
||||
desc: 日语中文英文学习网站
|
||||
author: ColorPanda
|
||||
avatar: https://fastly.jsdelivr.net/gh/xugaoyi/image_store2@master/img/image.3qr8m501tl20.png
|
||||
- img: https://fastly.jsdelivr.net/gh/xugaoyi/blog-gitalk-comment@master/img/asdf.23jsekfejla8.jpeg
|
||||
link: https://inannan423.github.io/
|
||||
name: Zihanio
|
||||
desc: Zihan的学习博客
|
||||
author: Zihan
|
||||
avatar: https://fastly.jsdelivr.net/gh/xugaoyi/blog-gitalk-comment@master/img/xxx.67b3ygadagk0.jpeg
|
||||
- img: https://user-images.githubusercontent.com/866409/175853573-28ded198-2348-4a82-8ddd-05088161e3fe.png
|
||||
link: https://xingcxb.com
|
||||
name: 不器小窝
|
||||
desc: 但知行好事,莫要问前程
|
||||
author: 不器
|
||||
avatar: https://avatars.githubusercontent.com/u/866409?v=4
|
||||
- img: https://cdn.staticaly.com/gh/xugaoyi/blog-gitalk-comment@master/img/QQ20220722-141037.22uk9ow7ary.png
|
||||
link: https://eryajf.github.io/vdoing-template/
|
||||
name: Vdoing主题博客模板
|
||||
desc: Vdoing主题博客模板
|
||||
author: eryajf
|
||||
avatar: https://cdn.staticaly.com/gh/xugaoyi/blog-gitalk-comment@master/img/33259379.277tur21ir40.jpeg
|
||||
- img: https://cdn.jsdelivr.net/gh/FireHH/github_img_repository/logo/微信截图_20220810164903.png
|
||||
link: https://javaessay.cn/
|
||||
name: Java essay
|
||||
desc: Java散文知识库,Spring全家桶,SpringCloud全家桶,高可用高并发架构,面试等
|
||||
author: Mr.Fire
|
||||
avatar: https://cdn.jsdelivr.net/gh/FireHH/github_img_repository/logo/huge.jpg
|
||||
- img: https://chendapeng.cn/images/about/blog_image.png
|
||||
link: https://chendapeng.cn
|
||||
name: 行百里er
|
||||
desc: Java,个人技术博客,后端开发,技术架构,分布式技术,Spring Cloud Alibaba,Elasticsearch,Redis,算法,数据结构,Git
|
||||
author: 行百里er
|
||||
avatar: https://chendapeng.cn/images/about/avatar.png
|
||||
- img: http://xyhwh-nav.cn/img/index.png
|
||||
link: http://xyhwh-nav.cn
|
||||
name: Captain
|
||||
desc: 学习技术,Java基础、面试知识点、项目经验总结和一些学习笔记
|
||||
author: Captain
|
||||
avatar: http://xyhwh-nav.cn/img/logo.png
|
||||
- img: https://xiaoxue-images.oss-cn-shenzhen.aliyuncs.com/blog/202212271108541.jpg
|
||||
link: https://blog.xueqimiao.com/
|
||||
name: 小薛博客
|
||||
desc: 小薛博客,专注IT技术分享,助力人人成为架构师
|
||||
author: xueqimiao
|
||||
avatar: https://xiaoxue-images.oss-cn-shenzhen.aliyuncs.com/blog/202212271110209.png
|
||||
- img: https://cdn.jsdelivr.net/gh/su-dd/cdn/博客/202301311644669.png
|
||||
link: https://blog.addai.cn/
|
||||
name: 呆呆的博客
|
||||
desc: 个人博客
|
||||
author: 呆呆
|
||||
avatar: https://cdn.addai.cn/博客/网站使用/呆呆.webp
|
||||
- img: https://raw.githubusercontent.com/jorgen-zhao/blog/master/images/snapshot.png
|
||||
link: https://jorgen.website
|
||||
name: Jorgen's blog
|
||||
desc: 🚀个人知识库兼博客🚀
|
||||
author: jorgen
|
||||
avatar: https://jorgen.website/img/avatar.jpg
|
||||
```
|
||||
:::
|
||||
|
||||
## 知识库
|
||||
::: cardImgList 4
|
||||
```yaml
|
||||
config:
|
||||
imgHeight: 150px
|
||||
|
||||
data:
|
||||
- img: https://fastly.jsdelivr.net/gh/xugaoyi/image_store/blog/20200530114035.png
|
||||
link: https://xugaoyi.github.io/vdoing-demo-repository/
|
||||
name: 知识库演示
|
||||
desc: Vdoing主题演示-知识库
|
||||
author: Evan Xu
|
||||
avatar: https://fastly.jsdelivr.net/gh/xugaoyi/image_store/blog/20200103123203.jpg
|
||||
- img: https://fastly.jsdelivr.net/gh/xugaoyi/image_store/blog/20201219205536.jpg
|
||||
link: https://wiki.router86.com/
|
||||
name: X86软路由和NAS
|
||||
desc: 记录X86软路由和NAS的一些知识
|
||||
author: MonoLogueChi
|
||||
avatar: https://blog.xxwhite.com/assets/img/avatar.jpg
|
||||
- img: https://fastly.jsdelivr.net/gh/xugaoyi/image_store/blog/20201219205318.jpg
|
||||
link: https://blog.northword.cn/dft-learning
|
||||
name: 计算模拟学习笔记
|
||||
desc: 《能源环境材料计算模拟方法》学习笔记,涉及密度泛函理论、第一性原理等和Materials Studio、VASP等的使用。
|
||||
author: Northword
|
||||
avatar: https://storage.live.com/items/28C1032A24A9C53B!25785?authkey=AHAx3GOYEKGqm8I
|
||||
- img: https://singerwimg-1300001977.cos.accelerate.myqcloud.com/20211008/WccSrJ0s.png
|
||||
link: https://repository.singerw.com
|
||||
name: Singerw's Repository
|
||||
desc: 技术的风花雪月之事,有个存档的地方,对于复盘,回忆,都是一个极好的方谭。
|
||||
author: Singerw
|
||||
avatar: https://singerwimg-1300001977.cos.accelerate.myqcloud.com/2021/09/20/76f29482ffc9b.png
|
||||
- img: https://fastly.jsdelivr.net/gh/xugaoyi/image_store@master/QQ20220113-114927.5oha7j06c580.webp
|
||||
link: https://hippox.cn
|
||||
name: hippo4j
|
||||
desc: 🔥 动态线程池框架,附带监控报警功能,轻量级的运维监控平台
|
||||
author: Acmenlt
|
||||
avatar: https://hippox.cn/img/web.png
|
||||
- img: https://pics.landcover100.com/pics/624e63f4c82b8.png
|
||||
link: https://www.gisrsdata.com
|
||||
name: 地信遥感数据汇
|
||||
desc: 解决目前地信遥感方向数据混杂,资源难以寻找的问题,构建一个地信遥感学习、讨论、交流的平台。
|
||||
author: 锐多宝
|
||||
avatar: https://pics.landcover100.com/pics/624e6469cbb8a.jpg
|
||||
- img: https://img.de7v.com/img/site-pic.jpg
|
||||
link: https://www.de7v.com
|
||||
name: De7v
|
||||
desc: 专注于安卓领域的技术传播
|
||||
author: wresource
|
||||
avatar: https://img.de7v.com/img/wresource.png
|
||||
- img: https://cdn.staticaly.com/gh/xugaoyi/blog-gitalk-comment@master/img/11123.1aljpnjyr074.png
|
||||
link: https://eryajf.github.io/HowToStartOpenSource/
|
||||
name: HowToStartOpenSource
|
||||
desc: GitHub开源项目维护协作指南
|
||||
author: eryajf
|
||||
avatar: https://cdn.staticaly.com/gh/xugaoyi/blog-gitalk-comment@master/img/33259379.277tur21ir40.jpeg
|
||||
```
|
||||
:::
|
||||
## 社区类
|
||||
:::cardImgList
|
||||
```yaml
|
||||
config:
|
||||
imgHeight: 150px
|
||||
|
||||
data:
|
||||
- img: https://fastly.jsdelivr.net/gh/xugaoyi/image_store/blog/20200921220111.png
|
||||
link: https://course.yiwiz.com/
|
||||
name: 奕维投资教程站
|
||||
desc: 股票投资
|
||||
author: 奕维
|
||||
avatar: https://course.yiwiz.com/img/logo.png
|
||||
```
|
||||
:::
|
||||
|
||||
## 博客类
|
||||
::: cardImgList
|
||||
```yaml
|
||||
config:
|
||||
imgHeight: 150px
|
||||
|
||||
data:
|
||||
- img: https://fastly.jsdelivr.net/gh/xugaoyi/image_store/blog/20200530114034.png
|
||||
link: https://xugaoyi.github.io/vdoing-demo-blog/
|
||||
name: Vdoing's blog
|
||||
desc: Vdoing主题演示-博客
|
||||
author: Evan Xu
|
||||
avatar: https://fastly.jsdelivr.net/gh/xugaoyi/image_store/blog/20200103123203.jpg
|
||||
- img: https://s4.ax1x.com/2022/02/25/bAjINF.png
|
||||
link: https://fangweilong.github.io/
|
||||
name: Teler的日常
|
||||
desc: 好好学习,天天向上
|
||||
author: Teler
|
||||
avatar: https://s4.ax1x.com/2022/02/25/bAva8J.jpg
|
||||
- img: https://user-images.githubusercontent.com/53399655/163007243-1b99b96b-cac3-49ca-9950-03a1e877a6d8.png
|
||||
link: https://xustudyxu.github.io/
|
||||
name: xustudyxu's Blog
|
||||
desc: 一起学习编程!
|
||||
author: xustudyxu
|
||||
avatar: https://xustudyxu.github.io/img/01.png
|
||||
```
|
||||
:::
|
||||
|
||||
## 文档类
|
||||
::: cardImgList 4
|
||||
```yaml
|
||||
config:
|
||||
imgHeight: 150px
|
||||
|
||||
data:
|
||||
- img: https://fastly.jsdelivr.net/gh/xugaoyi/image_store/blog/20200530114036.png
|
||||
link: https://xugaoyi.github.io/vuepress-theme-vdoing-doc/
|
||||
name: vdoing(本站)
|
||||
desc: 🚀一款简洁高效的VuePress 知识管理&博客 主题
|
||||
author: Evan Xu
|
||||
avatar: https://fastly.jsdelivr.net/gh/xugaoyi/image_store/blog/20200103123203.jpg
|
||||
- img: https://fastly.jsdelivr.net/gh/xugaoyi/image_store@master/blog/QQ20210925-124836@2x (1).6ogvf85maog0.png
|
||||
link: https://justauth.plus/
|
||||
name: JA Plus 开发者文档
|
||||
desc: 一款开源的登录认证中间件
|
||||
author: yadong,zhang
|
||||
avatar: https://portrait.gitee.com/uploads/avatars/user/261/784199_yadong.zhang_1578932767.png!avatar200
|
||||
- img: https://assets.imgradeone.com/docsdokimod-pv.png
|
||||
link: https://docs.dokimod.cn
|
||||
name: DokiMod 开发文档
|
||||
desc: 为 DDLC Mod 开发提供的完善文档
|
||||
author: imgradeone
|
||||
avatar: https://docs.dokimod.cn/logo_128x128.png
|
||||
# - img: http://yogoyun.oss-cn-beijing.aliyuncs.com/help/public/other/20200630125515.png
|
||||
# link: http://help.yogoyun.com/
|
||||
# name: 柚果云服务
|
||||
# desc: 智能商业应用程序服务商。
|
||||
# author: 柚果云服务
|
||||
# avatar: http://yogoyun.oss-cn-beijing.aliyuncs.com/admin/console/logo.png
|
||||
- img: https://jeesite.com/docs/img/docs.png
|
||||
link: http://docs.jeesite.com
|
||||
name: JeeSite 在线文档
|
||||
desc: JeeSite 快速开发平台 - 在线文档
|
||||
author: ThinkGem
|
||||
avatar: https://jeesite.com/docs/img/logo.png
|
||||
- img: https://fastly.jsdelivr.net/gh/dreamncn/picBed@master/uPic/2022_05_12_20_40_04_1652359204_1652359204449_9mVkaR.png
|
||||
link: https://cleanphp.ankio.net/
|
||||
name: CleanPHP
|
||||
desc: CleanPHP开发者文档
|
||||
author: ankio
|
||||
avatar: https://fastly.jsdelivr.net/gh/dreamncn/picBed@master/uPic/2022_04_04_19_48_51_1649072931_1649072931346_h4BGpQ.jpg
|
||||
- img: https://cdn.staticaly.com/gh/xugaoyi/blog-gitalk-comment@master/img/28284d.56bkx9qvhc00.webp
|
||||
link: https://jpom-docs.keepbx.cn/
|
||||
name: Jpom
|
||||
desc: 简而轻的低侵入式在线构建、自动部署、日常运维、项目监控软件
|
||||
author: 不忘初心
|
||||
avatar: https://jpom-docs.keepbx.cn/images/jpom_logo.png
|
||||
- img: https://wumei.live/kerwincui/document/raw/branch/master/images/img.png
|
||||
link: https://wumei.live/doc/
|
||||
name: 物美智能
|
||||
desc: 物美智能开源物联网平台,简单易用,可用于搭建物联网平台以及二次开发和学习。适用于智能家居、智慧办公、智慧社区、农业监测、水利监测、工业控制等。
|
||||
author: 随遇而安 / kerwincui
|
||||
avatar: https://portrait.gitee.com/uploads/avatars/user/611/1834441_kerwincui_1581523162.png!avatar200
|
||||
- img: https://pic.imgdb.cn/item/637c92ef16f2c2beb11293c7.jpg
|
||||
link: https://trace-recorder.xusc.cn
|
||||
name: trace-recorder官网
|
||||
desc: 简单的, 可伸缩的, 高性能的跟踪记录仪
|
||||
author: 蔡旺
|
||||
avatar: https://pic.imgdb.cn/item/637c933516f2c2beb112ed43.jpg
|
||||
```
|
||||
:::
|
||||
|
||||
</br></br>
|
||||
|
||||
## 申请加入案例
|
||||
|
||||
::: tip 你想在这个页面展示你的站点吗?
|
||||
欢迎使用Vdoing主题的小伙伴到 [**这里**](https://github.com/xugaoyi/vuepress-theme-vdoing/issues/new?assignees=&labels=&template=+join_case.md) 留下你的站点信息,你的站点将有机会出现在这个页面里~
|
||||
:::
|
||||
@@ -0,0 +1,21 @@
|
||||
---
|
||||
title: 企业登记案例
|
||||
date: 2020-05-14 11:39:45
|
||||
permalink: /pages/5d571c
|
||||
---
|
||||
|
||||
## 企业登记
|
||||
如果您所在的企业使用到了中微子代理,麻烦抽出宝贵的时间[点击这里](https://gitee.com/dromara/neutrino-proxy/issues/I6WC71)进行登记,这将会助力中微子代理走得更远。
|
||||
|
||||
## 案例展示
|
||||
|企业名称| logo | 官网地址 | 使用人数 |用途|
|
||||
|:-|:-----------------------------------------------------------------------------------------------------------|:-------------------------|:-----|:-|
|
||||
|北京吉威空间信息股份有限公司|  | http://www.geoway.com.cn | 10 |开发环境的session会话同步与开发环境的对接测试华为云与微信等云端回调接口|
|
||||
|悦邻供应链科技有限公司|| https://yinghecloud.com | 10 |开发及生产环境内网服务器VPN搭建,本地开发服务端口调试|
|
||||
|阿依瓦(北京)技术有限公司|| https://www.alva.com.cn | 50 |开发及生产环境内网服务器VPN搭建,本地开发服务端口调试,云端同步数据等|
|
||||
|常州裕景信息科技有限公司|| 无 | 5 |远程管理虚拟机,接口、数据库等功能调试|
|
||||
|湖北楚商联盟金融信息服务有限公司|| http://www.chually.cn | 10 |开发及生产环境内网服务器VPN搭建,本地开发服务端口调试,云端同步数据等|
|
||||
|中科元景智能(深圳)有限公司|| https://yjupi.com | 20 |本地开发连接测试环境及生产环境内网服务器,包含数据库、redis、模块服务等|
|
||||
|长沙小蜂科技有限公司|| 无 | 1~3人 |主要用于测试环境内网服务器,包含数据库,远程桌面等|
|
||||
|江西六湛科技|| http://www.liuzhankj.com | 12 |主要用于部署一些使用时长较短的项目|
|
||||
|杭州艾佳智能科技有限公司|| http://www.ajaiot.com | 12-16人 |公司部分设备是通过udp通信的,对接调试设备,搭建测试环境服务网关的时候需要|
|
||||
@@ -0,0 +1,15 @@
|
||||
---
|
||||
title: 2.x
|
||||
date: 2023-10-26 17:43:43
|
||||
permalink: /pages/ff3519/
|
||||
---
|
||||
|
||||
## 2.0.0
|
||||
- solon版本升级为`2.5.11`
|
||||
- jdk版本升级为17
|
||||
- 支持原生编译改造
|
||||
- 默认支持的数据库由sqlite改为h2
|
||||
- 升级须知:
|
||||
- jdk版本升级为了jdk17,jar部署时请注意
|
||||
- 去掉了默认的sqlite数据库,改为了h2。如果之前使用sqlite,请自行处理数据迁移
|
||||
- 配置文件做了较大调整,请参照官网使用须知中的`服务端配置`、`客户端配置`进行更新
|
||||
@@ -0,0 +1,72 @@
|
||||
---
|
||||
title: 1.x
|
||||
date: 2023-10-26 17:43:34
|
||||
permalink: /pages/dda8e5/
|
||||
---
|
||||
|
||||
## 1.9.0
|
||||
- 端口映射支持UDP协议
|
||||
- 端口映射HTTP(S)新增打开网页按钮,优先使用域名打开
|
||||
- 新增/编辑端口映射时端口占用检测功能屏蔽,解决docker下使用的各种问题
|
||||
|
||||
## 1.8.6
|
||||
- 端口映射选择端口支持分页
|
||||
- 新增/更新端口映射,增加端口占用检测(端口映射编辑时,如果端口号没有变动,则不验证。避免出现端口映射正在使用时,无法更新端口映射其他信息的问题)
|
||||
- 下拉搜索license,支持模糊搜索
|
||||
- license下拉用户搜索,支持模糊搜索
|
||||
- 端口映射HTTP(S)新增打开网页按钮
|
||||
- 客户端断开连接时,记录日志空指针异常问题修复
|
||||
|
||||
## 1.8.5
|
||||
- 后台端口池管理支持批量删除
|
||||
- 端口映射下拉选择端口支持搜索
|
||||
- 客户端/服务端配置增加心跳日志开关,有需要时开启,方便排查问题
|
||||
- 客户端/服务端读写超时逻辑微调
|
||||
|
||||
## 1.8.4
|
||||
- 增加对mariadb的支持
|
||||
- 服务端/客户端,支持配置文件、启动参数指定日志级别
|
||||
- 客户端支持配置文件指定重连间隔,是否开启无限重连
|
||||
|
||||
## 1.8.3
|
||||
- 客户端重连优化
|
||||
- 服务端验证客户端身份逻辑优化
|
||||
|
||||
## 1.8.2
|
||||
- 增加HTTPS的支持。
|
||||
|
||||
## 1.8.0
|
||||
- 端口映射支持选择协议
|
||||
- HTTP协议下映射支持配置子域名(前提是server端配置了域名)
|
||||
|
||||
## 1.7.1
|
||||
- 针对管理后台各页面的排序、搜索条件的优化
|
||||
- 增加端口池分组、相关的端口映射优化
|
||||
- 增加了报表管理模块:用户流量报表、license流量报表、用户流量月度明细、license流量月度明细
|
||||
- 完成首页图表展示:license统计、端口映射统计、今日流量统计、汇总流量统计、最近15日流量折线图
|
||||
|
||||
## 1.7.0
|
||||
- 底层框架更换为Solon + MybatisPlus
|
||||
|
||||
## 1.6.4
|
||||
- 支持代理服务端用户(删除/禁用)、端口池(删除/禁用/启用)、License(删除/禁用/启用)、端口映射(新增/删除/禁用/启用)实时生效
|
||||
- 启动参数优化
|
||||
- 服务端静态资源服务支持缓存、gzip压缩,提升响应速度
|
||||
|
||||
## 1.6.0
|
||||
- 新增日志管理模块,调度日志迁移至日志管理
|
||||
- 管理后台新增登录日志
|
||||
- 新增首页流量统计
|
||||
|
||||
## 1.5.0
|
||||
- 管理后台新增用户管理、License管理、端口映射、调度管理、客户端连接日志、调度日志
|
||||
- 支持默认sqlite数据库
|
||||
- 底层框架Aop、Banner、SqlMapper、Ioc、@Value注解、Yml配置加载、静态资源服务等优化
|
||||
- 底层框架新增@Async、@Singleton等注解
|
||||
- 新增AsgcCompiler、ApplicationEvent机制封装
|
||||
|
||||
## 1.0.0
|
||||
> 第一个基本可用版本
|
||||
- 基于自研底层应用框架、Netty
|
||||
- 纯配置实现、无管理后台
|
||||
- 支持TCP代理
|
||||
@@ -0,0 +1,24 @@
|
||||
---
|
||||
title: 里程碑
|
||||
date: 2023-10-26 17:41:26
|
||||
permalink: /pages/e406dd/
|
||||
---
|
||||
|
||||
- 2023-10-31 2.0.0版本发布,升级jdk版本至jdk17、支持原生编译、去掉sqlite改为默认H2数据库
|
||||
- 2023-09-25 中微子代理Gitee Star数突破1000
|
||||
- 2023-09-22 1.9.0版本发布,端口映射支持UDP协议
|
||||
- 2023-09-07 1.8.6版本发布,后台若干细节优化
|
||||
- 2023-07-04 1.8.5版本发布,后台若干细节优化、配置文件优化
|
||||
- 2023-06-08 1.8.4版本发布,增加对mariadb的支持、配置文件支持指定日志级别、重连参数
|
||||
- 2023-06-03 1.8.3版本发布,客户端重连优化、服务端验证客户端身份逻辑优化
|
||||
- 2023-05-27 1.8.2版本发布,增加HTTPS支持
|
||||
- 2023-04-03 1.8.0版本发布,端口映射支持选择协议,HTTP映射支持子域名
|
||||
- 2023-03-26 1.7.1版本发布,新增端口池分组、新增报表管理模块、首页图表优化
|
||||
- 2023-03-12 1.7.0版本发布,底层框架更换为Solon + MybatisPlus
|
||||
- 2023-02-23 1.6.4版本发布,管理后台增、删、改、禁用实时生效,启动参数、GZip优化
|
||||
- 2023-01-16 加入Dromara组织
|
||||
- 2023-01-08 中微子代理Gitee Star突破100
|
||||
- 2022-11-23 1.6.0版本发布,新增日志管理模块,新增首页流量统计
|
||||
- 2022-10-12 1.5.0版本发布,底层框架优化,新增管理后台
|
||||
- 2022-06-16 1.0.0版本发布,基于自研应用框架、纯配置无管理后台
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
---
|
||||
title: 最近更新
|
||||
date: 2020-05-25 12:01:52
|
||||
permalink: /pages/9cc27d
|
||||
# sidebar: false
|
||||
article: false
|
||||
---
|
||||
|
||||
# TODO
|
||||
|
||||
### 1.x剩余规划
|
||||
- [ ] 参考鹊桥,增加对域名的支持
|
||||
- [ ] 官网上线
|
||||
|
||||
#### Bug
|
||||
- windows环境下直接运行发布版的jar包,日志输出乱码
|
||||
- 代理mysql时,使用未开启远程访问的账号走代理访问mysql,代理客户端出现断开现象
|
||||
|
||||
### 2.x规划
|
||||
- 插件开发
|
||||
- [ ] neutrino-proxy-solon-plugin
|
||||
- [ ] neutrino-proxy-jetbrains-plugin
|
||||
- [ ] neutrino-proxy-starter (SpringBoot)
|
||||
- 基础优化
|
||||
- [ ] 支持批量端口映射
|
||||
- [ ] 代理协议规范化,方便后续更好扩展、支持不同语言客户端接入
|
||||
- 监控运维
|
||||
- [ ] 监控服务端状态
|
||||
- [ ] 支持调整服务端端口、证书
|
||||
- [ ] 服务端版本、协议版本、客户端版本管理
|
||||
- [ ] 服务端日志
|
||||
- client+计划启动
|
||||
- [ ] 安卓客户端
|
||||
- [ ] 基于electron-egg的多平台客户端
|
||||
|
||||
### 3.x规划
|
||||
- [ ] 支持针对用户限速、限流
|
||||
- [ ] 支持P2P穿透
|
||||
- [ ] 支持原生编译
|
||||
@@ -1,45 +0,0 @@
|
||||
---
|
||||
title: 如何贡献
|
||||
date: 2023-03-29 12:55:44
|
||||
permalink: /pages/69a632/
|
||||
---
|
||||
# 🎋代码分支说明
|
||||
- dev:常规开发分支,日常的开发、Bug修复、提交PR都在此分支
|
||||
- feature/xxx:特征分支,一些试验性开发、提交PR都在此分支,xxx可自行取一个有意义的名称
|
||||
- release/xxx:发行版分支,作为阶段性成果、重大更新的版本固化分支。受保护,不允许任何提交。
|
||||
- master:主分支,定期同步最新代码,目前仅支持本人(傲世孤尘/雨韵诗泽)提交。
|
||||
|
||||
|
||||
# ✊贡献的方式
|
||||
包括,但不限于以下形式:
|
||||
- 提交[issues](https://gitee.com/dromara/neutrino-proxy/issues)
|
||||
- 参与[issues](https://gitee.com/dromara/neutrino-proxy/issues)解决的必要性、解决方案的讨论、给出建设性的意见
|
||||
- 领取[issues](https://gitee.com/dromara/neutrino-proxy/issues) 并完成开发、提交PR
|
||||
- 为[本项目](https://gitee.com/dromara/neutrino-proxy)完善代码注释
|
||||
- 为[本项目](https://gitee.com/dromara/neutrino-proxy)增加测试代码
|
||||
- 为[本项目](https://gitee.com/dromara/neutrino-proxy)优化现有代码
|
||||
- 为[本项目](https://gitee.com/dromara/neutrino-proxy)优化操作体验
|
||||
- 通过公众号、博客、贴吧、论坛等形式分享/宣传中微子代理
|
||||
- 丰富项目文档,包括使用过程中踩过的坑、需要优化的点、具体问题的解决方法等
|
||||
|
||||
# 🧬贡献代码的步骤
|
||||
- 在Gitee或者Github上fork项目到自己的repo,fork,一定要把项目fork一份。
|
||||
- 把fork过去的项目也就是你的项目clone到你的本地
|
||||
- 同步feature/1.7.1最新代码
|
||||
- 修改代码
|
||||
- 开发完成后,不忙着提PR,再拉一遍最新代码,如果有冲突、解决冲突
|
||||
- commit后push到自己的库
|
||||
- 登录Gitee在你首页可以看到一个 pull request 按钮,点击它,填写一些说明信息,然后提交即可。
|
||||
- 等待维护者合并
|
||||
|
||||
# 📐PR的规范
|
||||
> 你可能发现有的代码并不符合这个规范,但我们后续都会朝着这个方向迈进。后续我们会逐步全面规范化,请先保证新提交的代码满足以下要求:
|
||||
|
||||
- 注释完备,尤其每个新增的方法应按照Java文档规范标明方法说明、参数说明、返回值说明等信息,必要时请添加单元测试,如果愿意,也可以加上你的大名。
|
||||
- 原则上,不允许自行添加第三方依赖库。若确有必要,请先和项目负责人沟通达成一致。
|
||||
- 对现有代码的优化,请在注释中说明原因。
|
||||
- 如果涉及到数据库的变更,则至少需要做到以下绩点:
|
||||
- sqlite、mysql下均测试通过
|
||||
- 在`./neutrino-proxy-server/src/main/resource/sql`下维护更新对应的表结构sql文件
|
||||
- 对于新增的表,维护必要的初始化数据
|
||||
- 在对应的mysql、sqlite的update目录下,维护SQL变更记录,确保SQL执行测试通过
|
||||
@@ -20,13 +20,13 @@ features: # 可选的
|
||||
- title: 端口映射
|
||||
details: 新增、编辑、删除、禁用实时生效。
|
||||
- title: Docker
|
||||
details: 服务端支持Docker一键部署。
|
||||
details: 服务端/客户端支持Docker一键部署。
|
||||
- title: 隧道SSL加密
|
||||
details: 隧道通信支持SSL,保护您的数据安全
|
||||
- title: HTTPS
|
||||
details: 支持HTTPS
|
||||
- title: 多客户端支持
|
||||
details: 暂未支持
|
||||
- title: 多种协议
|
||||
details: 支持TCP、HTTP、HTTPS、UDP
|
||||
- title: 原生部署
|
||||
details: 支持原生部署,更简单、性能更好的使用体验
|
||||
|
||||
# 文章列表显示方式: detailed 默认,显示详细版文章列表(包括作者、分类、标签、摘要、分页等)| simple => 显示简约版文章列表(仅标题和日期)| none 不显示文章列表
|
||||
postList: none
|
||||
@@ -137,166 +137,204 @@ postList: none
|
||||
或者加入我们的交流群:
|
||||
<div align="center">
|
||||
<img :src="$withBase('/img/qrcode/wxq.png')" class="no-zoom" style="width:200px;margin: 10px;">
|
||||
<p>中微子 微信群(添加我微信备注"进群")</p>
|
||||
<p>中微子 微信群(添加我微信备注"中微子进群")</p>
|
||||
</div>
|
||||
<br/>
|
||||
|
||||
<h2 id="🌈特别赞助"><a href="#🌈特别赞助" class="header-anchor">#</a> 🌈特别赞助</h2>
|
||||
<p align="center">等待有缘人赞助</p>
|
||||
<!-- <p align="center">等待有缘人赞助</p> -->
|
||||
|
||||
<div class="cardListContainer">
|
||||
<div class="card-list">
|
||||
<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>
|
||||
</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>
|
||||
|
||||
|
||||
<!--
|
||||
<div class="cardListContainer"><div class="card-list"><a href="https://datayi.cn/w/nPN4JJe9" target="_blank" class="card-item row-3" style="background-color:#102863;--random-color:#102863;color:#FFFFFF;"><img src="/images/friends/ad/postcat.png" class="no-zoom"> <div><p class="name">Postcat</p> <p class="desc">开源 API 管理工具,接口文档、接口测试、Mock...</p></div></a> <a href="https://gitee.com/dromara/MaxKey" target="_blank" class="card-item row-3" style="background-color:#9ed3e5;--random-color:#9ed3e5;color:#1f2328;"><img src="/images/friends/ad/maxkey.png" class="no-zoom"> <div><p class="name">MaxKey</p> <p class="desc"><br>业界领先的单点登录</p></div></a> <a href="https://www.xiaonuo.vip" target="_blank" class="card-item row-3" style="background-color:#1373CC;--random-color:#1373CC;color:#ffffff;"><img src="/images/friends/ad/snowy.png" class="no-zoom"> <div><p class="name">Snowy</p> <p class="desc">国内首个国密前后端分离快速开发平台,中国式工作流、独家双模式租户</p></div></a></div><div class="language-yaml line-numbers-mode"><pre class="language-yaml codecopy-enabled"><code><span class="token punctuation">-</span> <span class="token key atrule">name</span><span class="token punctuation">:</span> Postcat
|
||||
<span class="token key atrule">desc</span><span class="token punctuation">:</span> 开源 API 管理工具,接口文档、接口测试、Mock<span class="token punctuation">...</span>
|
||||
<span class="token key atrule">avatar</span><span class="token punctuation">:</span> /images/friends/ad/postcat.png
|
||||
<span class="token key atrule">link</span><span class="token punctuation">:</span> https<span class="token punctuation">:</span>//datayi.cn/w/nPN4JJe9
|
||||
<span class="token key atrule">bgColor</span><span class="token punctuation">:</span> <span class="token string">'#102863'</span>
|
||||
<span class="token key atrule">textColor</span><span class="token punctuation">:</span> <span class="token string">'#FFFFFF'</span>
|
||||
<span class="token punctuation">-</span> <span class="token key atrule">name</span><span class="token punctuation">:</span> MaxKey
|
||||
<span class="token key atrule">desc</span><span class="token punctuation">:</span> </br<span class="token punctuation">></span>业界领先的单点登录
|
||||
<span class="token key atrule">avatar</span><span class="token punctuation">:</span> /images/friends/ad/maxkey.png
|
||||
<span class="token key atrule">link</span><span class="token punctuation">:</span> https<span class="token punctuation">:</span>//gitee.com/dromara/MaxKey
|
||||
<span class="token key atrule">bgColor</span><span class="token punctuation">:</span> <span class="token string">'#9ed3e5'</span>
|
||||
<span class="token key atrule">textColor</span><span class="token punctuation">:</span> <span class="token string">'#1f2328'</span>
|
||||
<span class="token punctuation">-</span> <span class="token key atrule">name</span><span class="token punctuation">:</span> Snowy
|
||||
<span class="token key atrule">desc</span><span class="token punctuation">:</span> 国内首个国密前后端分离快速开发平台,中国式工作流、独家双模式租户
|
||||
<span class="token key atrule">avatar</span><span class="token punctuation">:</span> /images/friends/ad/snowy.png
|
||||
<span class="token key atrule">link</span><span class="token punctuation">:</span> https<span class="token punctuation">:</span>//www.xiaonuo.vip
|
||||
<span class="token key atrule">bgColor</span><span class="token punctuation">:</span> <span class="token string">'#1373CC'</span>
|
||||
<span class="token key atrule">textColor</span><span class="token punctuation">:</span> <span class="token string">'#ffffff'</span>
|
||||
</code><i class="code-copy" title="Copy to clipboard"><svg style="color:#aaa;font-size:14px" t="1572422231464" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3201" width="14" height="14"><path d="M866.461538 39.384615H354.461538c-43.323077 0-78.769231 35.446154-78.76923 78.769231v39.384616h472.615384c43.323077 0 78.769231 35.446154 78.769231 78.76923v551.384616h39.384615c43.323077 0 78.769231-35.446154 78.769231-78.769231V118.153846c0-43.323077-35.446154-78.769231-78.769231-78.769231z m-118.153846 275.692308c0-43.323077-35.446154-78.769231-78.76923-78.769231H157.538462c-43.323077 0-78.769231 35.446154-78.769231 78.769231v590.769231c0 43.323077 35.446154 78.769231 78.769231 78.769231h512c43.323077 0 78.769231-35.446154 78.76923-78.769231V315.076923z m-354.461538 137.846154c0 11.815385-7.876923 19.692308-19.692308 19.692308h-157.538461c-11.815385 0-19.692308-7.876923-19.692308-19.692308v-39.384615c0-11.815385 7.876923-19.692308 19.692308-19.692308h157.538461c11.815385 0 19.692308 7.876923 19.692308 19.692308v39.384615z m157.538461 315.076923c0 11.815385-7.876923 19.692308-19.692307 19.692308H216.615385c-11.815385 0-19.692308-7.876923-19.692308-19.692308v-39.384615c0-11.815385 7.876923-19.692308 19.692308-19.692308h315.076923c11.815385 0 19.692308 7.876923 19.692307 19.692308v39.384615z m78.769231-157.538462c0 11.815385-7.876923 19.692308-19.692308 19.692308H216.615385c-11.815385 0-19.692308-7.876923-19.692308-19.692308v-39.384615c0-11.815385 7.876923-19.692308 19.692308-19.692308h393.846153c11.815385 0 19.692308 7.876923 19.692308 19.692308v39.384615z" p-id="3202"></path></svg></i></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br></div></div></div>
|
||||
<div class="cardListContainer">
|
||||
<div class="card-list">
|
||||
<a href="https://datayi.cn/w/nPN4JJe9" target="_blank" class="card-item row-3" style="background-color:#102863;--random-color:#102863;color:#FFFFFF;">
|
||||
<img src="/images/friends/ad/postcat.png" class="no-zoom">
|
||||
<div><p class="name">Postcat</p> <p class="desc">开源 API 管理工具,接口文档、接口测试、Mock...</p></div>
|
||||
</a>
|
||||
<a href="https://gitee.com/dromara/MaxKey" target="_blank" class="card-item row-3" style="background-color:#9ed3e5;--random-color:#9ed3e5;color:#1f2328;">
|
||||
<img src="/images/friends/ad/maxkey.png" class="no-zoom">
|
||||
<div><p class="name">MaxKey</p> <p class="desc"><br>业界领先的单点登录</p></div>
|
||||
</a>
|
||||
<a href="https://www.xiaonuo.vip" target="_blank" class="card-item row-3" style="background-color:#1373CC;--random-color:#1373CC;color:#ffffff;">
|
||||
<img src="/images/friends/ad/snowy.png" class="no-zoom">
|
||||
<div><p class="name">Snowy</p> <p class="desc">国内首个国密前后端分离快速开发平台,中国式工作流、独家双模式租户</p></div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="language-yaml line-numbers-mode"><pre class="language-yaml codecopy-enabled">
|
||||
<code>
|
||||
<span class="token punctuation">-</span>
|
||||
<span class="token key atrule">name</span>
|
||||
<span class="token punctuation">:</span> Postcat
|
||||
<span class="token key atrule">desc</span>
|
||||
<span class="token punctuation">:</span>
|
||||
开源 API 管理工具,接口文档、接口测试、Mock<span class="token punctuation">...</span>
|
||||
<span class="token key atrule">avatar</span><span class="token punctuation">:</span> /images/friends/ad/postcat.png
|
||||
<span class="token key atrule">link</span><span class="token punctuation">:</span> https<span class="token punctuation">:</span>//datayi.cn/w/nPN4JJe9
|
||||
<span class="token key atrule">bgColor</span><span class="token punctuation">:</span> <span class="token string">'#102863'</span>
|
||||
<span class="token key atrule">textColor</span><span class="token punctuation">:</span> <span class="token string">'#FFFFFF'</span>
|
||||
<span class="token punctuation">-</span> <span class="token key atrule">name</span><span class="token punctuation">:</span> MaxKey
|
||||
<span class="token key atrule">desc</span><span class="token punctuation">:</span> </br<span class="token punctuation">></span>业界领先的单点登录
|
||||
<span class="token key atrule">avatar</span><span class="token punctuation">:</span> /images/friends/ad/maxkey.png
|
||||
<span class="token key atrule">link</span><span class="token punctuation">:</span> https<span class="token punctuation">:</span>//gitee.com/dromara/MaxKey
|
||||
<span class="token key atrule">bgColor</span><span class="token punctuation">:</span> <span class="token string">'#9ed3e5'</span>
|
||||
<span class="token key atrule">textColor</span><span class="token punctuation">:</span> <span class="token string">'#1f2328'</span>
|
||||
<span class="token punctuation">-</span> <span class="token key atrule">name</span><span class="token punctuation">:</span> Snowy
|
||||
<span class="token key atrule">desc</span><span class="token punctuation">:</span> 国内首个国密前后端分离快速开发平台,中国式工作流、独家双模式租户
|
||||
<span class="token key atrule">avatar</span><span class="token punctuation">:</span> /images/friends/ad/snowy.png
|
||||
<span class="token key atrule">link</span><span class="token punctuation">:</span> https<span class="token punctuation">:</span>//www.xiaonuo.vip
|
||||
<span class="token key atrule">bgColor</span><span class="token punctuation">:</span> <span class="token string">'#1373CC'</span>
|
||||
<span class="token key atrule">textColor</span><span class="token punctuation">:</span> <span class="token string">'#ffffff'</span>
|
||||
</code><i class="code-copy" title="Copy to clipboard"><svg style="color:#aaa;font-size:14px" t="1572422231464" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3201" width="14" height="14"><path d="M866.461538 39.384615H354.461538c-43.323077 0-78.769231 35.446154-78.76923 78.769231v39.384616h472.615384c43.323077 0 78.769231 35.446154 78.769231 78.76923v551.384616h39.384615c43.323077 0 78.769231-35.446154 78.769231-78.769231V118.153846c0-43.323077-35.446154-78.769231-78.769231-78.769231z m-118.153846 275.692308c0-43.323077-35.446154-78.769231-78.76923-78.769231H157.538462c-43.323077 0-78.769231 35.446154-78.769231 78.769231v590.769231c0 43.323077 35.446154 78.769231 78.769231 78.769231h512c43.323077 0 78.769231-35.446154 78.76923-78.769231V315.076923z m-354.461538 137.846154c0 11.815385-7.876923 19.692308-19.692308 19.692308h-157.538461c-11.815385 0-19.692308-7.876923-19.692308-19.692308v-39.384615c0-11.815385 7.876923-19.692308 19.692308-19.692308h157.538461c11.815385 0 19.692308 7.876923 19.692308 19.692308v39.384615z m157.538461 315.076923c0 11.815385-7.876923 19.692308-19.692307 19.692308H216.615385c-11.815385 0-19.692308-7.876923-19.692308-19.692308v-39.384615c0-11.815385 7.876923-19.692308 19.692308-19.692308h315.076923c11.815385 0 19.692308 7.876923 19.692307 19.692308v39.384615z m78.769231-157.538462c0 11.815385-7.876923 19.692308-19.692308 19.692308H216.615385c-11.815385 0-19.692308-7.876923-19.692308-19.692308v-39.384615c0-11.815385 7.876923-19.692308 19.692308-19.692308h393.846153c11.815385 0 19.692308 7.876923 19.692308 19.692308v39.384615z" p-id="3202"></path></svg></i></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br></div>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
|
||||
<h2 id="🤝-dromara-组织项目"><a href="#🤝-dromara-组织项目" class="header-anchor">#</a> 🤝 dromara 组织项目</h2>
|
||||
<p align="center"><b><a href="https://dromara.org/zh/projects/" target="_blank">为往圣继绝学,一个人或许能走的更快,但一群人会走的更远。</a></b></p>
|
||||
<p align="center"><b><a href="https://dromara.org/zh/projects/?from=neutrino-proxy" target="_blank">为往圣继绝学,一个人或许能走的更快,但一群人会走的更远。</a></b></p>
|
||||
<p>
|
||||
<a href="https://gitee.com/dromara/TLog" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="https://oss.dev33.cn/sa-token/link/tlog.png" msg="一个轻量级的分布式日志标记追踪神器,10分钟即可接入,自动对日志打标签完成微服务的链路追踪">
|
||||
<a href="https://gitee.com/dromara/TLog?from=neutrino-proxy" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="img/logo/tlog.png" msg="一个轻量级的分布式日志标记追踪神器,10分钟即可接入,自动对日志打标签完成微服务的链路追踪">
|
||||
</a>
|
||||
<a href="https://gitee.com/dromara/liteFlow" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="https://oss.dev33.cn/sa-token/link/liteflow.png" msg="轻量,快速,稳定,可编排的组件式流程引擎">
|
||||
<a href="https://gitee.com/dromara/liteFlow?from=neutrino-proxy" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="img/logo/liteflow.png" msg="轻量,快速,稳定,可编排的组件式流程引擎">
|
||||
</a>
|
||||
<a href="https://hutool.cn/" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="https://oss.dev33.cn/sa-token/link/hutool.jpg" msg="🍬小而全的Java工具类库,使Java拥有函数式语言般的优雅,让Java语言也可以“甜甜的”。">
|
||||
<a href="https://hutool.cn/?from=neutrino-proxy" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="img/logo/hutool.jpg" msg="🍬小而全的Java工具类库,使Java拥有函数式语言般的优雅,让Java语言也可以“甜甜的”。">
|
||||
</a>
|
||||
<a href="https://sa-token.cc/" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="https://oss.dev33.cn/sa-token/link/sa-token.png" msg="一个轻量级 java 权限认证框架,让鉴权变得简单、优雅!">
|
||||
<a href="https://sa-token.cc/?from=neutrino-proxy" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="img/logo/sa-token.png" msg="一个轻量级 java 权限认证框架,让鉴权变得简单、优雅!">
|
||||
</a>
|
||||
<a href="https://gitee.com/dromara/hmily" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="https://oss.dev33.cn/sa-token/link/hmily.png" msg="高性能一站式分布式事务解决方案。">
|
||||
<a href="https://gitee.com/dromara/hmily?from=neutrino-proxy" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="img/logo/hmily.png" msg="高性能一站式分布式事务解决方案。">
|
||||
</a>
|
||||
<a href="https://gitee.com/dromara/Raincat" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="https://oss.dev33.cn/sa-token/link/raincat.png" msg="强一致性分布式事务解决方案。">
|
||||
<a href="https://gitee.com/dromara/Raincat?from=neutrino-proxy" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="img/logo/raincat.png" msg="强一致性分布式事务解决方案。">
|
||||
</a>
|
||||
<a href="https://gitee.com/dromara/myth" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="https://oss.dev33.cn/sa-token/link/myth.png" msg="可靠消息分布式事务解决方案。">
|
||||
<a href="https://gitee.com/dromara/myth?from=neutrino-proxy" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="img/logo/myth.png" msg="可靠消息分布式事务解决方案。">
|
||||
</a>
|
||||
<a href="https://cubic.jiagoujishu.com/" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="https://oss.dev33.cn/sa-token/link/cubic.png" msg="一站式问题定位平台,以agent的方式无侵入接入应用,完整集成arthas功能模块,致力于应用级监控,帮助开发人员快速定位问题">
|
||||
<a href="https://cubic.jiagoujishu.com/?from=neutrino-proxy" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="img/logo/cubic.png" msg="一站式问题定位平台,以agent的方式无侵入接入应用,完整集成arthas功能模块,致力于应用级监控,帮助开发人员快速定位问题">
|
||||
</a>
|
||||
<a href="https://maxkey.top/" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="https://oss.dev33.cn/sa-token/link/maxkey.png" msg="业界领先的身份管理和认证产品">
|
||||
<a href="https://maxkey.top/?from=neutrino-proxy" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="img/logo/maxkey.png" msg="业界领先的身份管理和认证产品">
|
||||
</a>
|
||||
<a href="http://forest.dtflyx.com/" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="https://oss.dev33.cn/sa-token/link/forest-logo.png" msg="Forest能够帮助您使用更简单的方式编写Java的HTTP客户端" nf="">
|
||||
<a href="http://forest.dtflyx.com/?from=neutrino-proxy" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="img/logo/forest-logo.png" msg="Forest能够帮助您使用更简单的方式编写Java的HTTP客户端" nf="">
|
||||
</a>
|
||||
<a href="https://jpom.top/" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="https://oss.dev33.cn/sa-token/link/jpom.png" msg="一款简而轻的低侵入式在线构建、自动部署、日常运维、项目监控软件">
|
||||
<a href="https://jpom.top/?from=neutrino-proxy" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="img/logo/jpom.svg" msg="一款简而轻的低侵入式在线构建、自动部署、日常运维、项目监控软件">
|
||||
</a>
|
||||
<a href="https://su.usthe.com/" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="https://oss.dev33.cn/sa-token/link/sureness.png" msg="面向 REST API 的高性能认证鉴权框架">
|
||||
<a href="https://su.usthe.com/?from=neutrino-proxy" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="img/logo/sureness.png" msg="面向 REST API 的高性能认证鉴权框架">
|
||||
</a>
|
||||
<a href="https://easy-es.cn/" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="https://oss.dev33.cn/sa-token/link/easy-es2.png" msg="🚀傻瓜级ElasticSearch搜索引擎ORM框架">
|
||||
<a href="https://easy-es.cn/?from=neutrino-proxy" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="img/logo/easy-es2.png" msg="🚀傻瓜级ElasticSearch搜索引擎ORM框架">
|
||||
</a>
|
||||
<a href="https://gitee.com/dromara/northstar" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="https://oss.dev33.cn/sa-token/link/northstar_logo.png" msg="Northstar盈富量化交易平台">
|
||||
<a href="https://gitee.com/dromara/northstar?from=neutrino-proxy" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="img/logo/northstar_logo.png" msg="Northstar盈富量化交易平台">
|
||||
</a>
|
||||
<a href="https://hertzbeat.com/" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="https://oss.dev33.cn/sa-token/link/hertzbeat-brand.svg" msg="易用友好的云监控系统">
|
||||
<a href="https://hertzbeat.com/?from=neutrino-proxy" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="img/logo/hertzbeat-brand.svg" msg="易用友好的云监控系统">
|
||||
</a>
|
||||
<a href="https://dromara.gitee.io/fast-request/" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="https://oss.dev33.cn/sa-token/link/fast-request.gif" msg="Idea 版 Postman,为简化调试API而生">
|
||||
<a href="https://dromara.gitee.io/fast-request/?from=neutrino-proxy" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="img/logo/fast-request.gif" msg="Idea 版 Postman,为简化调试API而生">
|
||||
</a>
|
||||
<a href="https://www.jeesuite.com/" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="https://oss.dev33.cn/sa-token/link/mendmix.png" msg="开源分布式云原生架构一站式解决方案">
|
||||
<a href="https://www.jeesuite.com/?from=neutrino-proxy" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="img/logo/mendmix.png" msg="开源分布式云原生架构一站式解决方案">
|
||||
</a>
|
||||
<a href="https://gitee.com/dromara/koalas-rpc" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="https://oss.dev33.cn/sa-token/link/koalas-rpc2.png" msg="企业生产级百亿日PV高可用可拓展的RPC框架。">
|
||||
<a href="https://gitee.com/dromara/koalas-rpc?from=neutrino-proxy" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="img/logo/koalas-rpc2.png" msg="企业生产级百亿日PV高可用可拓展的RPC框架。">
|
||||
</a>
|
||||
<a href="https://async.sizegang.cn/" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="https://oss.dev33.cn/sa-token/link/gobrs-async.png" msg="🔥 配置极简功能强大的异步任务动态编排框架">
|
||||
<a href="https://async.sizegang.cn/?from=neutrino-proxy" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="img/logo/gobrs-async.png" msg="🔥 配置极简功能强大的异步任务动态编排框架">
|
||||
</a>
|
||||
<a href="https://dynamictp.cn/" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="https://oss.dev33.cn/sa-token/link/dynamic-tp.png" msg="🔥🔥🔥 基于配置中心的轻量级动态可监控线程池">
|
||||
<a href="https://dynamictp.cn/?from=neutrino-proxy" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="img/logo/dynamic-tp.png" msg="🔥🔥🔥 基于配置中心的轻量级动态可监控线程池">
|
||||
</a>
|
||||
<a href="https://www.x-easypdf.cn" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="https://oss.dev33.cn/sa-token/link/x-easypdf.png" msg="一个用搭积木的方式构建pdf的框架(基于pdfbox)">
|
||||
<a href="https://www.x-easypdf.cn?from=neutrino-proxy" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="img/logo/x-easypdf.png" msg="一个用搭积木的方式构建pdf的框架(基于pdfbox)">
|
||||
</a>
|
||||
<a href="http://dromara.gitee.io/image-combiner" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="https://oss.dev33.cn/sa-token/link/image-combiner.png" msg="一个专门用于图片合成的工具,没有很复杂的功能,简单实用,却不失强大">
|
||||
<a href="http://dromara.gitee.io/image-combiner?from=neutrino-proxy" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="img/logo/image-combiner.png" msg="一个专门用于图片合成的工具,没有很复杂的功能,简单实用,却不失强大">
|
||||
</a>
|
||||
<a href="https://www.herodotus.cn/" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="https://oss.dev33.cn/sa-token/link/dante-cloud2.png" msg="Dante-Cloud 是一款企业级微服务架构和服务能力开发平台。">
|
||||
<a href="https://www.herodotus.cn/?from=neutrino-proxy" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="img/logo/dante-cloud.jpg" msg="Dante-Cloud 是一款企业级微服务架构和服务能力开发平台。">
|
||||
</a>
|
||||
<a href="http://www.mtruning.club" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="https://oss.dev33.cn/sa-token/link/go-view.png" msg="低代码数据可视化开发平台">
|
||||
<a href="http://www.mtruning.club?from=neutrino-proxy" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="img/logo/go-view.png" msg="低代码数据可视化开发平台">
|
||||
</a>
|
||||
<a href="https://tangyh.top/" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="https://oss.dev33.cn/sa-token/link/lamp-cloud.png" msg="微服务中后台快速开发平台,支持租户(SaaS)模式、非租户模式">
|
||||
<a href="https://tangyh.top/?from=neutrino-proxy" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="img/logo/lamp-cloud.png" msg="微服务中后台快速开发平台,支持租户(SaaS)模式、非租户模式">
|
||||
</a>
|
||||
<a href="https://www.redisfront.com/" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="https://oss.dev33.cn/sa-token/link/redis-front.png" msg="RedisFront 是一款开源免费的跨平台 Redis 桌面客户端工具, 支持单机模式, 集群模式, 哨兵模式以及 SSH 隧道连接, 可轻松管理Redis缓存数据.">
|
||||
<a href="https://www.redisfront.com/?from=neutrino-proxy" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="img/logo/redis-front.png" msg="RedisFront 是一款开源免费的跨平台 Redis 桌面客户端工具, 支持单机模式, 集群模式, 哨兵模式以及 SSH 隧道连接, 可轻松管理Redis缓存数据.">
|
||||
</a>
|
||||
<a href="https://www.yuque.com/u34495/mivcfg" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="https://oss.dev33.cn/sa-token/link/electron-egg.png" msg="一个入门简单、跨平台、企业级桌面软件开发框架">
|
||||
<a href="https://www.yuque.com/u34495/mivcfg?from=neutrino-proxy" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="img/logo/electron-egg.png" msg="一个入门简单、跨平台、企业级桌面软件开发框架">
|
||||
</a>
|
||||
<a href="https://gitee.com/dromara/open-capacity-platform" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="https://oss.dev33.cn/sa-token/link/open-capacity-platform.jpg" msg="简称ocp是基于Spring Cloud的企业级微服务框架(用户权限管理,配置中心管理,应用管理,....)">
|
||||
<a href="https://gitee.com/dromara/open-capacity-platform?from=neutrino-proxy" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="img/logo/open-capacity-platform.jpg" msg="简称ocp是基于Spring Cloud的企业级微服务框架(用户权限管理,配置中心管理,应用管理,....)">
|
||||
</a>
|
||||
<a href="http://easy-trans.fhs-opensource.top/" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="https://oss.dev33.cn/sa-token/link/easy_trans.png" msg="Easy-Trans 一个注解搞定数据翻译,减少30%SQL代码量">
|
||||
<a href="http://easy-trans.fhs-opensource.top/?from=neutrino-proxy" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="img/logo/easy_trans.png" msg="Easy-Trans 一个注解搞定数据翻译,减少30%SQL代码量">
|
||||
</a>
|
||||
<a href="https://gitee.com/dromara/neutrino-proxy" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="https://oss.dev33.cn/sa-token/link/neutrino-proxy.svg" msg="一款基于 Netty 的、开源的内网穿透神器。">
|
||||
<a href="https://gitee.com/dromara/neutrino-proxy?from=neutrino-proxy" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="img/logo/neutrino-proxy.svg" msg="一款基于 Netty 的、开源的内网穿透神器。">
|
||||
</a>
|
||||
<a href="https://chatgpt.cn.obiscr.com/" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="https://oss.dev33.cn/sa-token/link/chatgpt.png" msg="一个支持在 JetBrains 系列 IDE 上运行的 ChatGPT 的插件。">
|
||||
<a href="https://chatgpt.cn.obiscr.com/?from=neutrino-proxy" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="img/logo/chatgpt.png" msg="一个支持在 JetBrains 系列 IDE 上运行的 ChatGPT 的插件。">
|
||||
</a>
|
||||
<a href="https://gitee.com/dromara/zyplayer-doc" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="https://oss.dev33.cn/sa-token/link/zyplayer-doc.png" msg="zyplayer-doc是一款适合团队和个人使用的WIKI文档管理工具,同时还包含数据库文档、Api接口文档。">
|
||||
<a href="https://gitee.com/dromara/zyplayer-doc?from=neutrino-proxy" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="img/logo/zyplayer-doc.png" msg="zyplayer-doc是一款适合团队和个人使用的WIKI文档管理工具,同时还包含数据库文档、Api接口文档。">
|
||||
</a>
|
||||
<a href="https://gitee.com/dromara/payment-spring-boot" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="https://oss.dev33.cn/sa-token/link/payment-spring-boot.png" msg="最全最好用的微信支付V3 Spring Boot 组件。">
|
||||
<a href="https://gitee.com/dromara/payment-spring-boot?from=neutrino-proxy" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="img/logo/payment-spring-boot.png" msg="最全最好用的微信支付V3 Spring Boot 组件。">
|
||||
</a>
|
||||
<a href="https://www.j2eefast.com/" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="https://oss.dev33.cn/sa-token/link/j2eefast.png" msg="J2eeFAST 是一个致力于中小企业 Java EE 企业级快速开发平台,我们永久开源!">
|
||||
<a href="https://www.j2eefast.com/?from=neutrino-proxy" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="img/logo/j2eefast.png" msg="J2eeFAST 是一个致力于中小企业 Java EE 企业级快速开发平台,我们永久开源!">
|
||||
</a>
|
||||
<a href="https://gitee.com/dromara/data-compare" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="https://oss.dev33.cn/sa-token/link/dataCompare.png" msg="数据库比对工具:hive 表数据比对,mysql、Doris 数据比对,实现自动化配置进行数据比对,避免频繁写sql 进行处理,低代码(Low-Code) 平台">
|
||||
<a href="https://gitee.com/dromara/data-compare?from=neutrino-proxy" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="img/logo/dataCompare.png" msg="数据库比对工具:hive 表数据比对,mysql、Doris 数据比对,实现自动化配置进行数据比对,避免频繁写sql 进行处理,低代码(Low-Code) 平台">
|
||||
</a>
|
||||
<a href="https://gitee.com/dromara/open-giteye-api" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="https://oss.dev33.cn/sa-token/link/open-giteye-api.svg" msg="giteye.net 是专为开源作者设计的数据图表服务工具类站点,提供了包括 Star 趋势图、贡献者列表、Gitee指数等数据图表服务。">
|
||||
<a href="https://gitee.com/dromara/open-giteye-api?from=neutrino-proxy" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="img/logo/open-giteye-api.svg" msg="giteye.net 是专为开源作者设计的数据图表服务工具类站点,提供了包括 Star 趋势图、贡献者列表、Gitee指数等数据图表服务。">
|
||||
</a>
|
||||
<a href="https://gitee.com/dromara/RuoYi-Vue-Plus" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="https://oss.dev33.cn/sa-token/link/RuoYi-Vue-Plus.png" msg="后台管理系统 重写 RuoYi-Vue 所有功能 集成 Sa-Token + Mybatis-Plus + Jackson + Xxl-Job + SpringDoc + Hutool + OSS 定期同步">
|
||||
<a href="https://gitee.com/dromara/RuoYi-Vue-Plus?from=neutrino-proxy" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="img/logo/RuoYi-Vue-Plus.png" msg="后台管理系统 重写 RuoYi-Vue 所有功能 集成 Sa-Token + Mybatis-Plus + Jackson + Xxl-Job + SpringDoc + Hutool + OSS 定期同步">
|
||||
</a>
|
||||
<a href="https://gitee.com/dromara/RuoYi-Cloud-Plus" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="https://oss.dev33.cn/sa-token/link/RuoYi-Cloud-Plus.png" msg="微服务管理系统 重写RuoYi-Cloud所有功能 整合 SpringCloudAlibaba Dubbo3.0 Sa-Token Mybatis-Plus MQ OSS ES Xxl-Job Docker 全方位升级 定期同步">
|
||||
<a href="https://gitee.com/dromara/RuoYi-Cloud-Plus?from=neutrino-proxy" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="img/logo/RuoYi-Cloud-Plus.png" msg="微服务管理系统 重写RuoYi-Cloud所有功能 整合 SpringCloudAlibaba Dubbo3.0 Sa-Token Mybatis-Plus MQ OSS ES Xxl-Job Docker 全方位升级 定期同步">
|
||||
</a>
|
||||
<a href="https://gitee.com/dromara/stream-query" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="https://oss.dev33.cn/sa-token/link/stream-query.png" msg="允许完全摆脱 Mapper 的 mybatis-plus 体验!封装 stream 和 lambda 操作进行数据返回处理。">
|
||||
<a href="https://gitee.com/dromara/stream-query?from=neutrino-proxy" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="img/logo/stream-query.png" msg="允许完全摆脱 Mapper 的 mybatis-plus 体验!封装 stream 和 lambda 操作进行数据返回处理。">
|
||||
</a>
|
||||
<a href="https://dromara.org/zh/projects/" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="https://oss.dev33.cn/sa-token/link/dromara.png" msg="让每一位开源爱好者,体会到开源的快乐。">
|
||||
<a href="https://dromara.org/zh/projects/?from=neutrino-proxy" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" src="img/logo/dromara.png" msg="让每一位开源爱好者,体会到开源的快乐。">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<h2>🤝 友情开源项目</h2>
|
||||
<p>
|
||||
<a href="https://gitee.com/noear/solon" target="_blank" class="friends-item" >
|
||||
<img class="no-zoom friends-item-img hover-alt" :src="$withBase('/img/logo/solon_logo_500_150.png')" msg="一个高效的应用开发框架:更快、更小、更简单。" />
|
||||
<a href="https://gitee.com/noear/solon?from=neutrino-proxy" target="_blank" class="friends-item" >
|
||||
<img class="no-zoom friends-item-img hover-alt" :src="$withBase('img/logo/solon_logo_500_150.png')" msg="一个高效的应用开发框架:更快、更小、更简单。" />
|
||||
</a>
|
||||
<a href="https://gitee.com/xiaonuobase/snowy" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" :src="$withBase('/img/logo/xiaonuo.png')" msg="国内首个国密前后端分离快速开发平台" />
|
||||
<a href="https://gitee.com/xiaonuobase/snowy?from=neutrino-proxy" target="_blank" class="friends-item">
|
||||
<img class="no-zoom friends-item-img hover-alt" :src="$withBase('img/logo/xiaonuo.png')" msg="国内首个国密前后端分离快速开发平台" />
|
||||
</a>
|
||||
</p>
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.noear</groupId>
|
||||
<artifactId>solon-parent</artifactId>
|
||||
<version>2.2.8</version>
|
||||
<version>2.5.12</version>
|
||||
<relativePath />
|
||||
</parent>
|
||||
|
||||
@@ -26,12 +26,13 @@
|
||||
<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.0-SNAPSHOT</revision>
|
||||
<revision>2.0.1-SNAPSHOT</revision>
|
||||
|
||||
<java.version>1.8</java.version>
|
||||
<native.version>0.9.28</native.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>
|
||||
<org.projectlombok.version>1.18.4</org.projectlombok.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
@@ -39,22 +40,7 @@
|
||||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-all</artifactId>
|
||||
<version>4.1.22.Final</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.25</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>1.2.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${org.projectlombok.version}</version>
|
||||
<version>4.1.100.Final</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.yaml</groupId>
|
||||
@@ -72,11 +58,6 @@
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.83</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
@@ -88,14 +69,14 @@
|
||||
<version>1.3.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.xerial</groupId>
|
||||
<artifactId>sqlite-jdbc</artifactId>
|
||||
<version>3.39.2.1</version>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<version>2.2.224</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>5.1.49</version>
|
||||
<version>8.0.33</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mariadb.jdbc</groupId>
|
||||
@@ -110,7 +91,7 @@
|
||||
<dependency>
|
||||
<groupId>org.dromara.solon-plugins</groupId>
|
||||
<artifactId>job-solon-plugin</artifactId>
|
||||
<version>0.0.4</version>
|
||||
<version>0.1.1</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>cn.hutool</groupId>
|
||||
@@ -118,43 +99,33 @@
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dromara.solon-plugins</groupId>
|
||||
<artifactId>orika-solon-plugin</artifactId>
|
||||
<version>0.0.4</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<groupId>org.noear</groupId>
|
||||
<artifactId>solon.logging.logback</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.noear</groupId>
|
||||
<artifactId>solon-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
@@ -176,7 +147,7 @@
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${org.projectlombok.version}</version>
|
||||
<version>${lombok.version}</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
@@ -209,5 +180,83 @@
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>tencent</id>
|
||||
<url>https://mirrors.cloud.tencent.com/nexus/repository/maven-public/</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>sonatype-nexus-snapshots</id>
|
||||
<name>Sonatype Nexus Snapshots</name>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>sonatype-nexus-snapshots</id>
|
||||
<name>Sonatype Nexus Snapshots</name>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>native</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.noear</groupId>
|
||||
<artifactId>solon-maven-plugin</artifactId>
|
||||
<version>${solon.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>process-aot</id>
|
||||
<goals>
|
||||
<goal>process-aot</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-utils</artifactId>
|
||||
<version>3.5.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.graalvm.buildtools</groupId>
|
||||
<artifactId>native-maven-plugin</artifactId>
|
||||
<version>${native.version}</version>
|
||||
<!-- 使用graalvm提供的可达性元数据,很多第三方库就直接可以构建成可执行文件了 -->
|
||||
<configuration>
|
||||
<metadataRepository>
|
||||
<enabled>true</enabled>
|
||||
</metadataRepository>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>add-reachability-metadata</id>
|
||||
<goals>
|
||||
<goal>add-reachability-metadata</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
|
||||
|
||||
@@ -41,4 +41,12 @@ npm run build:$env
|
||||
#拷贝
|
||||
cd ..
|
||||
cp -rf ./neutrino-proxy-admin/dist $adminDeployDir/
|
||||
cp -rf ./neutrino-proxy-admin/dist/ $giteePagesDir
|
||||
cp -rf ./neutrino-proxy-admin/dist/ $giteePagesDir
|
||||
cd $serverDeployDir
|
||||
zip -r neutrino-proxy-admin.zip "neutrino-proxy-admin/"
|
||||
|
||||
#拷贝到neutrino-proxy-server项目静态资源目录下
|
||||
cd ../..
|
||||
rm -rf ./neutrino-proxy-server/src/main/resources/static
|
||||
mkdir -p neutrino-proxy-server/src/main/resources/static
|
||||
cp -rf ./neutrino-proxy-admin/dist/ ./neutrino-proxy-server/src/main/resources/static
|
||||
|
||||
@@ -41,4 +41,12 @@ npm run build:$env
|
||||
#拷贝
|
||||
cd ..
|
||||
cp -rf ./neutrino-proxy-admin/dist $adminDeployDir/
|
||||
cp -rf ./neutrino-proxy-admin/dist/ $giteePagesDir
|
||||
cp -rf ./neutrino-proxy-admin/dist/ $giteePagesDir
|
||||
cd $serverDeployDir
|
||||
zip -r neutrino-proxy-admin.zip "neutrino-proxy-admin/"
|
||||
|
||||
#拷贝到neutrino-proxy-server项目静态资源目录下
|
||||
cd ../..
|
||||
rm -rf ./neutrino-proxy-server/src/main/resources/static
|
||||
mkdir -p neutrino-proxy-server/src/main/resources/static
|
||||
cp -rf ./neutrino-proxy-admin/dist/ ./neutrino-proxy-server/src/main/resources/static
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
#!/bin/sh
|
||||
# 中微子代理客户端编译打包脚本,基础参数请自行修改
|
||||
|
||||
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home
|
||||
export MAVANE_HOME=/Users/yangwen/my/service/maven/apache-maven-3.8.1
|
||||
export PATH=:$PATH:$JAVA_HOME/bin:$MAVANE_HOME/bin
|
||||
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
|
||||
|
||||
deployDir="deploy"
|
||||
clientDeployDir=$deployDir"/client"
|
||||
@@ -11,14 +12,20 @@ clientDeployDir=$deployDir"/client"
|
||||
#切到项目根目录
|
||||
cd ../..
|
||||
#初始化文件夹
|
||||
if [ ! -d "$deployDir" ];then
|
||||
mkdir $deployDir
|
||||
fi
|
||||
if [ ! -d "$clientDeployDir" ];then
|
||||
mkdir $clientDeployDir
|
||||
fi
|
||||
mkdir -p $clientDeployDir
|
||||
rm -rf $clientDeployDir/neutrino-proxy-client.jar
|
||||
rm -rf $clientDeployDir/neutrino-proxy-client-jar
|
||||
rm -rf $clientDeployDir/neutrino-proxy-client-jar.zip
|
||||
|
||||
#客户端打包
|
||||
mvn clean install -U -pl neutrino-proxy-client -am -Dmaven.test.skip=true
|
||||
# 拷贝到deploy目录下
|
||||
cp ./neutrino-proxy-client/target/neutrino-proxy-client.jar $clientDeployDir/neutrino-proxy-client.jar
|
||||
|
||||
#打zip包,用于发版
|
||||
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-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
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
#!/bin/sh
|
||||
|
||||
# 镜像版本,每次更新版本时需要调整
|
||||
ImageVer=2.0.0
|
||||
ImageName=neutrino-proxy-client
|
||||
DockerFilePath=$PWD/../../neutrino-proxy-client
|
||||
|
||||
##初始化文件夹
|
||||
#deployDir=$PWD/../../"deploy"
|
||||
#clientDeployDir=$deployDir"/client"
|
||||
#if [ ! -d "$deployDir" ];then
|
||||
# mkdir $deployDir
|
||||
#fi
|
||||
#if [ ! -d "$clientDeployDir" ];then
|
||||
# mkdir $clientDeployDir
|
||||
#fi
|
||||
#rm -rf $clientDeployDir/$ImageName.tar
|
||||
|
||||
#echo '打包jar...'
|
||||
#sh ./client_build.sh
|
||||
|
||||
# 删除老的本地镜像
|
||||
docker rmi -f $(docker images | grep $ImageName | awk '{print $3}')
|
||||
# 构建镜像
|
||||
docker build -t $ImageName:$ImageVer -t $ImageName:latest $DockerFilePath
|
||||
# 保存镜像到本地
|
||||
#docker save -o $clientDeployDir/$ImageName.tar $ImageName:$ImageVer
|
||||
|
||||
# docker run -it -e LICENSE_KEY=b0a907332b474b25897c4dcb31fc7eb6 -e SERVER_IP=host.docker.internal --name np-client neutrino-proxy-client:2.0.0
|
||||
@@ -0,0 +1,52 @@
|
||||
#!/bin/sh
|
||||
# 中微子代理客户端编译打包脚本,基础参数请自行修改
|
||||
|
||||
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
|
||||
|
||||
deployDir="deploy"
|
||||
clientDeployDir=$deployDir"/client"
|
||||
machine=macos
|
||||
|
||||
#切到项目根目录
|
||||
cd ../..
|
||||
#初始化文件夹
|
||||
mkdir -p $clientDeployDir
|
||||
|
||||
# 删除原来的编译文件
|
||||
rm -rf $clientDeployDir/neutrino-proxy-client.jar
|
||||
rm -rf $clientDeployDir/neutrino-proxy-client
|
||||
rm -rf $clientDeployDir/neutrino-proxy-client-jar
|
||||
rm -rf $clientDeployDir/neutrino-proxy-client-jar.zip
|
||||
rm -rf $clientDeployDir/neutrino-proxy-client-${machine}-native
|
||||
rm -rf $clientDeployDir/neutrino-proxy-client-${machine}-native.zip
|
||||
|
||||
#客户端打包
|
||||
mvn clean install -U -pl neutrino-proxy-client -am -Dmaven.test.skip=true
|
||||
cd neutrino-proxy-client
|
||||
mvn clean native:compile -P native -DskipTests
|
||||
cd ..
|
||||
|
||||
# 给执行权限
|
||||
chmod +x ./neutrino-proxy-client/target/neutrino-proxy-client
|
||||
|
||||
# 拷贝到deploy目录下
|
||||
cp ./neutrino-proxy-client/target/neutrino-proxy-client.jar $clientDeployDir/neutrino-proxy-client.jar
|
||||
cp ./neutrino-proxy-client/target/neutrino-proxy-client $clientDeployDir/neutrino-proxy-client
|
||||
|
||||
#打zip包,用于发版
|
||||
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-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-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
|
||||
@@ -1,8 +1,8 @@
|
||||
#!/bin/sh
|
||||
# 中微子代理客户端启动脚本,基础参数请自行修改
|
||||
|
||||
JAVA_OPS="-server -Xms256m -Xmx512m -XX:PermSize=128M -XX:MaxPermSize=256M -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/work/$NAME/heapError/"
|
||||
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home
|
||||
JAVA_OPS="-server -Xms256m -Xmx512m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/work/$NAME/heapError/"
|
||||
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,9 +1,10 @@
|
||||
!/bin/sh
|
||||
# 中微子代理客户端编译打包脚本,基础参数请自行修改
|
||||
#!/bin/sh
|
||||
# 中微子代理服务端编译打包脚本,基础参数请自行修改
|
||||
|
||||
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home
|
||||
export MAVANE_HOME=/Users/yangwen/my/service/maven/apache-maven-3.8.1
|
||||
export PATH=:$PATH:$JAVA_HOME/bin:$MAVANE_HOME/bin
|
||||
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
|
||||
|
||||
deployDir="deploy"
|
||||
serverDeployDir=$deployDir"/server"
|
||||
@@ -11,15 +12,20 @@ serverDeployDir=$deployDir"/server"
|
||||
#切到项目根目录
|
||||
cd ../..
|
||||
#初始化文件夹
|
||||
if [ ! -d "$deployDir" ];then
|
||||
mkdir $deployDir
|
||||
fi
|
||||
if [ ! -d "$serverDeployDir" ];then
|
||||
mkdir $serverDeployDir
|
||||
fi
|
||||
mkdir -p $serverDeployDir
|
||||
rm -rf $serverDeployDir/neutrino-proxy-server.jar
|
||||
rm -rf $serverDeployDir/neutrino-proxy-server-jar
|
||||
rm -rf $serverDeployDir/neutrino-proxy-server-jar.zip
|
||||
|
||||
#客户端打包
|
||||
#服务端打包
|
||||
mvn clean install -U -pl neutrino-proxy-server -am -Dmaven.test.skip=true
|
||||
# 拷贝到deploy目录下
|
||||
cp ./neutrino-proxy-server/target/neutrino-proxy-server.jar $serverDeployDir/neutrino-proxy-server.jar
|
||||
|
||||
#打zip包,用于发版
|
||||
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-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,17 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
# 镜像版本,每次更新版本时需要调整
|
||||
ImageVer=1.0.0
|
||||
ImageVer=2.0.0
|
||||
ImageName=neutrino-proxy
|
||||
DockerFilePath=$PWD/../..
|
||||
DockerFilePath=$PWD/../../neutrino-proxy-server
|
||||
|
||||
#echo '打包jar...'
|
||||
sh ./server_build.sh
|
||||
#echo '打包管理后台...'
|
||||
sh ./admin_build_docker.sh
|
||||
#echo '打包jar...'
|
||||
sh ./server_build.sh
|
||||
|
||||
# 删除老的本地镜像
|
||||
docker rmi -f $(docker images | grep $ImageName | awk '{print $3}')
|
||||
# 构建镜像
|
||||
docker build -t $ImageName:$ImageVer -t $ImageName:latest $DockerFilePath
|
||||
|
||||
# docker run -it -p 9000-9200:9000-9200/tcp -p 8888:8888 --name np-server neutrino-proxy:2.0.0
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
#!/bin/sh
|
||||
# 中微子代理服务端编译打包脚本,基础参数请自行修改
|
||||
|
||||
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
|
||||
|
||||
deployDir="deploy"
|
||||
serverDeployDir=$deployDir"/server"
|
||||
machine=macos
|
||||
|
||||
#切到项目根目录
|
||||
cd ../..
|
||||
#初始化文件夹
|
||||
mkdir -p $serverDeployDir
|
||||
|
||||
# 删除原来的编译文件
|
||||
rm -rf $serverDeployDir/neutrino-proxy-server.jar
|
||||
rm -rf $serverDeployDir/neutrino-proxy-server
|
||||
rm -rf $serverDeployDir/neutrino-proxy-server-jar
|
||||
rm -rf $serverDeployDir/neutrino-proxy-server-jar.zip
|
||||
rm -rf $serverDeployDir/neutrino-proxy-server-${machine}-native
|
||||
rm -rf $serverDeployDir/neutrino-proxy-server-${machine}-native.zip
|
||||
|
||||
# 不需要每次都重新编译一次前端代码,如果前端代码有变更,编译前需要手动执行`admin_build_docker.sh`
|
||||
##前端页面打包
|
||||
#rm -rf ./neutrino-proxy-server/src/main/resources/static
|
||||
#cd ./scripts/unix
|
||||
#sh admin_build_docker.sh
|
||||
#cd ../..
|
||||
#mkdir -p neutrino-proxy-server/src/main/resources/static
|
||||
#cp -rf ./neutrino-proxy-admin/dist/ ./neutrino-proxy-server/src/main/resources/static
|
||||
|
||||
#服务端打包
|
||||
mvn clean install -U -pl neutrino-proxy-server -am -Dmaven.test.skip=true
|
||||
cd neutrino-proxy-server
|
||||
mvn clean native:compile -P native -DskipTests
|
||||
cd ..
|
||||
|
||||
# 给执行权限
|
||||
chmod +x ./neutrino-proxy-server/target/neutrino-proxy-server
|
||||
|
||||
# 拷贝到deploy目录下
|
||||
cp ./neutrino-proxy-server/target/neutrino-proxy-server.jar $serverDeployDir/neutrino-proxy-server.jar
|
||||
cp ./neutrino-proxy-server/target/neutrino-proxy-server $serverDeployDir/neutrino-proxy-server
|
||||
|
||||
#打zip包,用于发版
|
||||
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-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-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
|
||||
@@ -1,8 +1,8 @@
|
||||
#!/bin/sh
|
||||
# 中微子代理服务端启动脚本,基础参数请自行修改
|
||||
|
||||
JAVA_OPS="-server -Xms256m -Xmx1024m -XX:PermSize=128M -XX:MaxPermSize=256M -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/work/$NAME/heapError/"
|
||||
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home
|
||||
JAVA_OPS="-server -Xms256m -Xmx1024m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/work/$NAME/heapError/"
|
||||
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'
|
||||
@@ -1,30 +1,21 @@
|
||||
# 1.x规划
|
||||
- Bug
|
||||
- 优化
|
||||
- 心跳日志开关
|
||||
- 客户端启动无限重连开关
|
||||
- UDP支持
|
||||
- 官网文档完善
|
||||
- 常见问题汇总
|
||||
- HTTPS配置说明
|
||||
- 协议重构
|
||||
- 代码重构
|
||||
- [x] 适配mariadb
|
||||
|
||||
# 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
|
||||
- 监控运维
|
||||
- [ ] 监控服务端状态
|
||||
- [ ] 支持调整服务端端口、证书
|
||||
@@ -32,11 +23,14 @@
|
||||
- [ ] 服务端日志
|
||||
- [ ] 支持持管理后台动态调整日志级别。
|
||||
- [ ] 动态调整转发、报文、心跳输出
|
||||
- client+计划启动
|
||||
- [ ] 安卓客户端
|
||||
- [ ] 基于electron-egg的多平台客户端
|
||||
|
||||
# 3.x规划
|
||||
- [ ] 支持针对用户限速、限流
|
||||
- [ ] 支持P2P穿透
|
||||
- [ ] 支持原生编译
|
||||
- 插件开发
|
||||
- [ ] neutrino-proxy-solon-plugin
|
||||
- [ ] neutrino-proxy-jetbrains-plugin
|
||||
- [ ] neutrino-proxy-starter (SpringBoot)
|
||||
- client+计划启动
|
||||
- [ ] 安卓客户端
|
||||
- [ ] 基于electron-egg的多平台客户端
|
||||
|
||||