Compare commits

..
184 Commits
Author SHA1 Message Date
aoshiguchen 6389c8bf43 更新版本号 2026-01-28 09:30:44 +08:00
aoshiguchen c478d8ba80 新增水位线配置. 2026-01-26 18:17:55 +08:00
aoshiguchen a93646619e 新增水位线配置 2026-01-26 18:04:09 +08:00
aoshiguchen f83f9e45a4 增加日志 2026-01-26 15:44:27 +08:00
aoshiguchen 2104f829ef 增加cache大小检查接口 2026-01-20 11:46:07 +08:00
aoshiguchen 456ac900e9 针对HTTP代理附加对象的优化 2026-01-20 10:54:12 +08:00
aoshiguchen 72d79b5ccf 删除无用的缓存:license -> 服务端口映射 2026-01-20 10:17:03 +08:00
aoshiguchen 2ae5259670 代码优化. 2026-01-20 10:10:58 +08:00
aoshiguchen 0c5c7908ae 代码优化 2026-01-19 14:39:13 +08:00
aoshiguchen 7282e32ac5 代码优化 2026-01-16 13:19:53 +08:00
aoshiguchen 810661d5f4 连接关闭、异常处理优化 2026-01-15 15:17:27 +08:00
aoshiguchen 7dc605ab7c solon版本从3.4.1退回2.7.6 2025-11-23 13:46:48 +08:00
aoshiguchen 150c69d37c 解决通过mc基岩 udp代理,同一个代理端口只能有一个人连接的问题 2025-11-23 13:06:30 +08:00
aoshiguchen 9cbcf4de2e 异常日志调整 2025-11-19 17:05:34 +08:00
aoshiguchen f124557686 官网更新 2025-11-19 14:22:17 +08:00
aoshiguchen 4a7df310f1 更新docker-compose脚本 2025-11-11 10:06:38 +08:00
aoshiguchen e0aaccc949 新增注释 2025-11-01 22:57:04 +08:00
aoshiguchen da4b030234 udp代理优化 2025-10-27 11:50:33 +08:00
aoshiguchen 7e7a1546b3 日志调整 2025-10-27 10:45:52 +08:00
aoshiguchen b001247088 更新里程碑记录 2025-10-17 14:39:25 +08:00
aoshiguchen b83e40051e 更新里程碑记录 2025-10-14 09:47:30 +08:00
傲世孤尘 a58902f984 !67 solon 升为 3.4.1
Merge pull request !67 from 西东/dev
2025-07-28 02:45:26 +00:00
noear 9188a41ad6 solon 升为 3.4.1 2025-07-26 08:19:24 +08:00
aoshiguchen e88671c880 更新README 2025-07-18 16:33:39 +08:00
aoshiguchen 82773034c6 端口映射列表展示优化,多域名时鼠标悬浮自动下拉,点击自动复制 2025-05-30 22:26:59 +08:00
aoshiguchen 2e33f9ff1a tmp 2025-05-25 10:30:27 +08:00
aoshiguchen 23f3ec1ba2 tmp... 2025-05-25 10:20:34 +08:00
aoshiguchen 666f071e37 tmp... 2025-05-25 10:19:09 +08:00
aoshiguchen bd56ce094a 优化https多级主域名存在包含关系时的匹配机制 2025-05-24 23:40:02 +08:00
aoshiguchen a7ee52dbf1 升级版本为2.0.3 2025-05-24 21:53:54 +08:00
aoshiguchen 95764cdfb0 workflow 2025-05-24 21:04:37 +08:00
aoshiguchen 22ff47dbe6 workflow. 2025-05-24 20:58:24 +08:00
aoshiguchen 391d664710 workflow. 2025-05-24 20:54:47 +08:00
aoshiguchen f26ed2d12e workflow.. 2025-05-24 20:48:07 +08:00
aoshiguchen aa02b7b3c2 workflow 2025-05-24 20:43:21 +08:00
aoshiguchen 344bf11b88 workflow. 2025-05-24 20:40:23 +08:00
aoshiguchen f9ab82cd80 workflow 2025-05-24 20:33:11 +08:00
aoshiguchen e97aacee8f workflow. 2025-05-24 20:17:43 +08:00
aoshiguchen 59acada928 workflow 2025-05-24 20:12:27 +08:00
aoshiguchen 498ffeed46 更新打包脚本 2025-05-24 20:08:28 +08:00
aoshiguchen 0164e71f37 解决http请求拆包情况下域名映射失效的问题 2025-05-24 18:53:54 +08:00
aoshiguchen 65abda93fb 更新配置,解决docker部署时无法通过环境变量指定db配置的问题 2025-03-06 13:04:08 +08:00
傲世孤尘 9c818e5fcf !66 修复【License流量报表】 SQL报错
Merge pull request !66 from 晚安,地球/master-fix-License流量报表SQL报错
2025-01-06 05:48:41 +00:00
baiyun_xuyan a8c05a9e5e fix:gitee@ issues/IBD933 【License流量报表】 SQL报错 2024-12-26 00:34:50 +08:00
aoshiguchen 01ac42f269 官网里程碑更新 2024-12-23 17:00:26 +08:00
aoshiguchen d4f77524cf 官网新增通过宝塔面板部署说明 2024-12-20 16:48:22 +08:00
aoshiguchen d22b8df0ac 测试. 2024-12-19 10:24:52 +08:00
aoshiguchen c96d91c17c 测试.. 2024-12-19 10:23:22 +08:00
aoshiguchen af9cf5d260 Merge branch 'master' into dev 2024-12-19 10:12:03 +08:00
aoshiguchen 6eb31879ab 测试。 2024-12-19 10:11:37 +08:00
aoshiguchen 8cf89e86d5 更新官网. 2024-12-18 22:17:28 +08:00
aoshiguchen 43aec0d8de Merge branch 'dev'
# Conflicts:
#	neutrino-proxy-vuepress/docs/01.使用教程/01.安装部署/01.快速上手.md
2024-12-18 22:10:00 +08:00
aoshiguchen d343231351 更新官网 2024-12-18 22:09:38 +08:00
aoshiguchen 83519299f8 Merge branch 'dev' 2024-12-18 22:09:02 +08:00
aoshiguchen 87c2ff846a 更新官网 2024-12-18 22:08:43 +08:00
aoshiguchen 02af8df384 更新官网. 2024-12-18 21:48:46 +08:00
aoshiguchen 81d8a41842 更新官网.. 2024-12-18 21:47:06 +08:00
aoshiguchen f2999fa384 更新官网. 2024-12-18 21:42:53 +08:00
aoshiguchen 37ff5abb28 更新官网 2024-12-18 21:27:18 +08:00
aoshiguchen 4b4bcd2829 更新workflow 2024-12-18 21:23:04 +08:00
aoshiguchen adc8cb3f66 test13 2024-12-18 21:19:09 +08:00
aoshiguchen 81c3e3f219 test12 2024-12-18 21:14:24 +08:00
aoshiguchen 587359d40e test11 2024-12-18 21:07:01 +08:00
傲世孤尘 cedef6589f update pipeline-docs-build.yml 2024-12-18 13:03:34 +00:00
aoshiguchen 9a1f0c65ce test10 2024-12-18 20:53:27 +08:00
aoshiguchen 031eeae706 test9 2024-12-18 20:51:45 +08:00
傲世孤尘 32366a06f5 update pipeline-docs-build.yml 2024-12-18 12:50:59 +00:00
aoshiguchen 4873fc5084 test8 2024-12-18 20:44:49 +08:00
aoshiguchen fda50fb383 test7 2024-12-18 20:38:05 +08:00
aoshiguchen 65da4cdc53 test6 2024-12-18 20:29:03 +08:00
aoshiguchen 7b8e92b402 test5 2024-12-18 20:20:07 +08:00
aoshiguchen c5d736eafd test4 2024-12-18 20:15:21 +08:00
aoshiguchen 85e5e72363 test3 2024-12-18 20:02:04 +08:00
aoshiguchen 216bbb449f test2 2024-12-18 19:45:19 +08:00
aoshiguchen 1378e808f8 test1 2024-12-18 19:37:11 +08:00
傲世孤尘 8a23c83c83 create pipeline-docs-build.yml 2024-12-18 11:35:50 +00:00
aoshiguchen 2936a934d2 更新官网. 2024-12-07 15:23:19 +08:00
aoshiguchen 98e9a9c663 更新官网 2024-12-07 15:18:59 +08:00
aoshiguchen a8fec7caef 新增发版文章 2024-12-07 15:13:54 +08:00
aoshiguchen 64c155ad68 更新官网文档 2024-12-07 14:58:40 +08:00
aoshiguchen b260602810 更新README. 2024-12-07 11:31:57 +08:00
aoshiguchen ca2e7e5254 http代理优化,解决多个主域名存在上下级关系时,域名映射不能正常使用的问题 2024-11-22 22:22:39 +08:00
aoshiguchen 00eb14c3be 新增/更新域名 校验逻辑调整 2024-11-22 22:01:03 +08:00
aoshiguchen df7aec109d 更新官网常见问题列表 2024-11-09 15:33:29 +08:00
aoshiguchen 59ce5cfe85 更新官网赞赏列表 2024-11-09 15:25:16 +08:00
aoshiguchen d6ff43c7a6 更新VLog 2024-11-09 15:16:31 +08:00
aoshiguchen 9d226ab23b 配置调整 2024-11-09 14:30:49 +08:00
aoshiguchen 50afac643e 启动输出调整. 2024-11-04 16:37:23 +08:00
aoshiguchen 249dd5ec12 更新scripts 2024-11-03 16:58:54 +08:00
aoshiguchen 7c82dce6a6 解决admin编译报错 2024-11-03 16:50:34 +08:00
zCans 55c62c9281 端口映射:新增编辑优化 2024-11-02 17:36:12 +08:00
aoshiguchen b01226b5c5 调整端口映射中client ip的长度 2024-10-30 08:52:26 +08:00
aoshiguchen e2f64ce407 域名管理,校验正则优化 2024-10-27 19:10:37 +08:00
aoshiguchen c2cf34e6c8 去除文件头版权描述 2024-10-27 18:46:01 +08:00
aoshiguchen 1a326397f6 去除文件头版权描述 2024-10-26 15:15:19 +08:00
aoshiguchen e6e0639a92 更新README.md 2024-10-26 14:55:43 +08:00
aoshiguchen 8e26e5b36c Merge remote-tracking branch 'origin/master' into dev 2024-10-25 21:44:59 +08:00
aoshiguchen 0006a33a5d 新增docker-compose脚本 2024-10-25 21:39:12 +08:00
aoshiguchen 98ab8fd3d0 新增启动信息输出. 2024-10-25 16:43:31 +08:00
aoshiguchen 131a8120ca 新增启动信息输出 2024-10-16 18:04:45 +08:00
傲世孤尘 14b03c5d51 !65 对域名映射相关功能的重构
Merge pull request !65 from Mirac/dev-multi-domain
2024-10-10 13:06:43 +00:00
suxiang e207b81d3b 2.0.2版本文档维护 2024-09-22 14:02:43 +08:00
suxiang 8761a4e93e 2.0.2版本文档维护 2024-09-22 11:55:47 +08:00
suxiang 19f4ad915e 文档维护 2024-09-22 11:49:34 +08:00
suxiang 38a1304dab 文档维护 2024-09-22 11:48:46 +08:00
suxiang 4d35c8ffef optimizer: 域名管理支持多级域名 & fix:修改子域名,输入相同子域名引起的报错。优化前端交互内容显示。 2024-09-21 17:48:17 +08:00
suxiang 930ad52b3e 文档维护 2024-09-19 18:53:18 +08:00
suxiang 214804b365 删除无用接口 2024-09-18 22:48:15 +08:00
suxiang 2243118206 optimizer: native打包支持新版本域名映射 2024-09-18 22:47:09 +08:00
suxiang 29ab0118ff 文档维护 2024-09-18 22:45:46 +08:00
suxiang 402aeb1e40 fix: 修复了用户没有创建域名时,无法修改HTTP(S)映射 2024-09-18 22:45:28 +08:00
suxiang 8bbd8d000d fix: 修复禁用域名后,已建立的通道仍然可以访问的问题 2024-09-18 22:43:34 +08:00
suxiang 2950e123b0 内容维护 2024-09-18 18:33:26 +08:00
suxiang 132e4cf053 fix: 修复项目初始化问题 2024-09-18 18:32:52 +08:00
suxiang 5b2ccbe5c3 fix: 修复域名的 SSL 上下文初始化错误 2024-09-18 13:53:52 +08:00
suxiang fa5030277f HTTP(S)代理端口检测,不配置则不支持HTTP(S)域名映射 2024-09-18 13:25:49 +08:00
suxiang b6224c42e7 维护表结构 2024-09-18 12:44:48 +08:00
suxiang b08bef691f optimizer: 服务器证书维护新增删除 2024-09-17 14:57:57 +08:00
suxiang ee08bc6ed3 配置文件维护 2024-09-17 14:56:45 +08:00
suxiang bc7046305c fix: 修复不存在域名时查询保存问题 2024-09-17 10:55:27 +08:00
suxiang cdec03d031 配置文件维护 2024-09-17 10:54:53 +08:00
suxiang c36a89ba30 optimizer: 更新域名映射接口返回值和前端页面显示 2024-09-14 17:38:15 +08:00
suxiang 87857ef55a fix: 修复了页面按钮UI显示问题 2024-09-13 10:31:38 +08:00
suxiang eafa89a35e 补充注释 2024-09-11 15:19:13 +08:00
suxiang 30f6dc38f7 修复:添加或更新Http端口映射不指定域名引起的报错 2024-09-10 23:18:42 +08:00
suxiang 9476ee4bcd 更新详细注释 2024-09-10 23:16:23 +08:00
suxiang 243605481a 域名映射功能重构:支持多域名HTTPS映射和SSL证书自动切换 2024-08-27 22:30:05 +08:00
suxiang 5aac309f47 域名映射功能重构:支持多域名HTTP映射 2024-08-25 17:21:00 +08:00
suxiang c8f025290c 更新前端域名状态更新接口 2024-08-25 16:24:57 +08:00
suxiang 4b52d7fafe 维护域名端口映射中间表建表唯一索引 2024-08-24 20:02:17 +08:00
aoshiguchen ac901a551b 更新README 2024-08-10 09:51:46 +08:00
aoshiguchen 4db6a15113 官网新增GitCode跳转、更新赞赏记录 2024-08-09 08:05:22 +08:00
suxiang cb095575c0 更改端口映射查询域名相关接口 2024-08-08 23:36:30 +08:00
suxiang b10eb48a45 支持多域名映射 2024-08-08 23:34:23 +08:00
suxiang fe9da42442 更新域名管理功能:添加根据域名状态获取所有域名接口 2024-08-08 20:32:42 +08:00
suxiang c28ce07a6d 更新端口映射前端页面:支持多域名添加和编辑 2024-08-08 20:32:05 +08:00
suxiang d1fde2e21d 维护表结构 2024-08-08 20:31:02 +08:00
suxiang 4a016d8102 更新域名管理功能:添加SSL证书状态字段,支持强制HTTPS设置 2024-07-23 14:26:47 +08:00
suxiang 1145467c11 域名管理:更新域名状态&设置默认域名 2024-07-23 12:08:14 +08:00
suxiang 571152b58a 更新域名状态 2024-07-23 12:07:12 +08:00
suxiang f70eb85419 add TODO: jks密码不为空仍无法通过验证 2024-07-22 23:23:40 +08:00
suxiang 6b5597514d 域名管理服务端初步设计:支持域名搜索、添加、修改 2024-07-22 23:21:05 +08:00
suxiang dcb59975da 维护数据库表结构 2024-07-22 23:20:51 +08:00
suxiang 8c455e5024 域名管理前端页面初步设计:支持域名搜索、添加、修改 2024-07-22 23:20:15 +08:00
aoshiguchen 2955ad1a26 更新solon依赖版本 2024-05-08 18:45:20 +08:00
aoshiguchen aa298c61b6 更新打包脚本 2024-05-08 14:21:33 +08:00
aoshiguchen 63bcd32a2a 新增win下的服务端打包脚本. 2024-05-08 13:37:14 +08:00
aoshiguchen 179904c3fe 新增win下的admin打包脚本. 2024-05-08 13:16:49 +08:00
aoshiguchen 00e37e0a27 新增win下的客户端native打包脚本. 2024-05-08 11:57:50 +08:00
aoshiguchen 5838481358 新增win下的客户端native打包脚本. 2024-05-08 10:59:38 +08:00
aoshiguchen 88baeb3f33 新增win下的客户端native打包脚本 2024-05-07 22:31:07 +08:00
aoshiguchen 2fc1754161 新增win下的客户端native打包脚本. 2024-05-07 22:17:18 +08:00
aoshiguchen dd27a6609d Merge remote-tracking branch 'origin/dev' into dev 2024-05-07 18:36:27 +08:00
aoshiguchen d8d4fbf6a6 新增win下的客户端native打包脚本 2024-05-07 18:36:04 +08:00
aoshiguchen c7c7afa8af 更新README 2024-05-06 17:35:20 +08:00
aoshiguchen fe9dc46796 更新官网打包脚本 2024-05-06 17:26:41 +08:00
aoshiguchen 21c5dcb053 Merge remote-tracking branch 'origin/master' into dev 2024-05-06 15:14:46 +08:00
傲世孤尘 482214529e !61 update README.md.
Merge pull request !61 from WuName/N/A
2024-05-06 07:12:59 +00:00
WuName 5998fb8785 update README.md.
发现readme的jdk还是17,修改为21

Signed-off-by: WuName <[email protected]>
2024-05-05 02:11:54 +00:00
aoshiguchen 6411b8759d 更新赞助列表、首页特别赞助 2024-04-16 20:06:44 +08:00
aoshiguchen da173f2005 Revert "解决后台分页查询的已知问题" 2024-04-09 12:00:36 +08:00
aoshiguchen c427213dfb 服务端解决native下清理日志报错的问题 2024-03-15 18:31:31 +08:00
aoshiguchen bf6b1767b3 解决客户端docker环境变量指定参数不生效的问题 2024-02-19 18:19:44 +08:00
aoshiguchen 223ab4a447 修正文档中的错误 2024-01-09 10:29:03 +08:00
aoshiguchen b91910b61c 解决分页后点击搜索,页面上页码显示错误的问题 2024-01-04 21:58:33 +08:00
aoshiguchen b01864e362 更新官网赞赏列表. 2023-12-29 13:32:03 +08:00
aoshiguchen a5df904f9a 更新官网赞赏列表. 2023-12-27 17:23:56 +08:00
aoshiguchen 3d250b6833 更新官网赞赏列表 2023-12-26 14:11:20 +08:00
aoshiguchen 889817e484 解决native编译后,端口池批量删除报错的问题 2023-12-26 12:45:50 +08:00
aoshiguchen 665ec3a708 更新官网赞助列表 2023-12-21 17:56:15 +08:00
aoshiguchen fe5c2fe3ef 代码优化.解决映射域名访问因ipv6报错的问题. 2023-12-21 16:15:11 +08:00
aoshiguchen 744335b433 代码优化.解决映射域名访问因ipv6报错的问题 2023-12-21 16:07:30 +08:00
aoshiguchen 66e803d14e Merge branch 'dev' 2023-12-20 17:05:55 +08:00
aoshiguchen 8b84d281e7 . 2023-12-20 17:05:45 +08:00
aoshiguchen b5d30e227c 新增2.0.1发版文章. 2023-12-20 10:05:38 +08:00
aoshiguchen 88790c7f36 新增2.0.1发版文章 2023-12-19 18:01:29 +08:00
aoshiguchen c30755c663 更新官网安装部署文档 2023-12-19 15:44:37 +08:00
aoshiguchen 2e81bfbe2c 更新官网里程碑 2023-12-19 15:26:41 +08:00
aoshiguchen f49898b9b0 更新官网管理后台文档. 2023-12-19 14:56:12 +08:00
aoshiguchen 74d36fc5d1 更新官网赞赏列表 2023-12-19 14:13:33 +08:00
aoshiguchen fb5980e577 新增运行示例截图 2023-12-19 14:07:58 +08:00
aoshiguchen b9277d142c 更新官网首页 2023-12-19 11:32:44 +08:00
aoshiguchen 81b0a28e2c 更新官网里程碑、版本记录 2023-12-19 11:09:17 +08:00
aoshiguchen 59d47e6bf1 更新revision 2023-12-19 10:46:33 +08:00
285 changed files with 4661 additions and 2916 deletions
+3 -3
View File
@@ -13,7 +13,7 @@ jobs:
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']
os: ['ubuntu-latest']
name: build - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
# https://github.com/softprops/action-gh-release/issues/236#issuecomment-1150530128
@@ -39,7 +39,7 @@ jobs:
distribution: 'graalvm' # New 'distribution' option
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Cache local Maven repository
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
@@ -84,7 +84,7 @@ jobs:
filename: neutrino-proxy-client-${{ env.OS }}-${{ env.VERSION }}-native.zip
# 上传构建产物
- name: Upload artifact
uses: actions/upload-artifact@v3.0.0
uses: actions/upload-artifact@v4.3.1
with:
name: neutrino-proxy-server-client-${{ env.OS }}-${{ env.VERSION }}
path: |
+2 -2
View File
@@ -38,7 +38,7 @@ jobs:
distribution: 'graalvm' # New 'distribution' option
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Cache local Maven repository
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
@@ -83,7 +83,7 @@ jobs:
filename: neutrino-proxy-client-${{ env.OS }}-${{ env.VERSION }}-native.zip
# 上传构建产物
- name: Upload artifact
uses: actions/upload-artifact@v3.0.0
uses: actions/upload-artifact@v4.3.1
with:
name: neutrino-proxy-server-client-${{ env.OS }}-${{ env.VERSION }}
path: |
+1
View File
@@ -54,6 +54,7 @@ hs_err_pid*
**/memo/**
neutrino-proxy-vuepress/deploy
neutrino-proxy-vuepress/deploy.sh
.NEUTRINO_PROXY_CLIENT_ID
logs
+74
View File
@@ -0,0 +1,74 @@
version: '1.0'
name: pipeline-docs-build
displayName: 官网静态资源构建
triggers:
trigger: auto
push:
branches:
precise:
- master
paths:
include:
- neutrino-proxy-vuepress.*
variables:
global:
- git_token
- username
commit_name: aoshiguchen
commit_email: [email protected]
repo_url: https://gitee.com/dromara/neutrino-proxy.git
target_branch: site
stages:
- name: stage-build
displayName: 构建
strategy: naturally
trigger: auto
executor:
- asgc
steps:
- step: build@nodejs
name: build_nodejs
displayName: Nodejs 构建
nodeVersion: 14.16.0
commands:
- '# 切换到工作目录'
- ''
- cd ./neutrino-proxy-vuepress
- '# 设置NPM源,提升安装速度'
- npm config set registry https://registry.npmmirror.com
- ''
- '# 执行编译命令'
- npm install && npm run build
- ''
- '# 初始化git仓库'
- cd docs/.vuepress/dist
- git init
- ''
- '# 设置Git信息'
- GIT_REPO_URL=$repo_url
- GIT_USERNAME=$username
- GIT_NAME=$commit_name
- GIT_EMAIL=$commit_email
- GIT_TOKEN=$git_token
- echo "https://${GIT_USERNAME}:${GIT_TOKEN}@${GIT_REPO_URL#https://}" > ~/.git-credentials
- git config --global credential.helper store
- git remote add origin ${GIT_REPO_URL}
- git config user.name ${GIT_NAME}
- git config user.email ${GIT_EMAIL}
- ''
- '# 将构建产物推送到目标分支'
- git add -A
- '# git commit -m $GITEE_COMMIT_MESSAGE'
- git commit -m "update"
- git checkout -b $target_branch
- git push -f origin $target_branch
artifacts:
- name: BUILD_ARTIFACT
path:
- ./neutrino-proxy-vuepress/docs/.vuepress/dist
caches:
- ~/.npm
- ~/.yarn
notify: []
strategy:
retry: '0'
+2
View File
@@ -14,3 +14,5 @@
- 2023-09-07 1.8.6版本发布,后台若干细节优化
- 2023-09-22 1.9.0版本发布,端口映射支持UDP协议
- 2023-09-25 中微子代理Gitee Star数突破1000
- 2023-10-31 2.0.0版本发布,升级jdk版本至jdk17、支持原生编译、去掉sqlite改为默认H2数据库
- 2023-12-21 2.0.1版本发布,jdk版本升级到21,支持安全组(黑/白名单IP限制)、限速
+20 -9
View File
@@ -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-jdk17-downloads.html">
<img src="https://img.shields.io/badge/JDK-17+-red.svg" />
<a target="_blank" href="https://www.oracle.com/java/technologies/javase/javase-jdk21-downloads.html">
<img src="https://img.shields.io/badge/JDK-21+-red.svg" />
</a>
<a href="./LICENSE">
<img src="https://img.shields.io/badge/license-MIT-red" alt="license MIT">
@@ -16,9 +16,8 @@
- 中微子代理(neutrino-proxy)是一个基于netty的、开源的java内网穿透项目。
- 技术栈:Solon、MybatisPlus、Netty
- 遵循MIT许可,因此您可以对它进行复制、修改、传播并用于任何个人或商业行为。
- 官网地址1https://neutrino-proxy.dromara.org
- 官网地址2https://dromara.gitee.io/neutrino-proxy
- 快速上手请[点击这里](https://dromara.gitee.io/neutrino-proxy/pages/793dcb)
- 官网地址:https://neutrino-proxy-docs.asgc.fun
- 快速上手请[点击这里](https://neutrino-proxy.dromara.org/neutrino-proxy/pages/793dcb/)
# 2、名称由来
中微子,是轻子的一种,是组成自然界的最基本的粒子之一。它十分微小、不带电,可自由穿过地球,以接近光速运动,与其他物质的相互作用十分微弱,号称宇宙间的“隐身人”。
@@ -27,21 +26,30 @@
因此以中微子命名,寓意着中微子代理拥有中微子"安全"、"快速"、"穿透力强"的特点。
# 3、运行示例
# 3、部署方式
- 1、[使用宝塔面板](https://neutrino-proxy.dromara.org/pages/9e0fde/)
- 2、[使用jar文件](https://neutrino-proxy.dromara.org/pages/eebea1/)
- 3、[使用Docker](https://neutrino-proxy.dromara.org/pages/5b9bef/)
- 4、[原生部署](https://neutrino-proxy.dromara.org/pages/69699a/)
- 5、[使用Docker-Compose](https://neutrino-proxy.dromara.org/pages/2d4123/)
# 4、运行示例
![首页](assets/run-example/home.png)
![用户管理](assets/run-example/user-manager1.png)
![端口池管理](assets/run-example/port-pool1.png)
![License管理](assets/run-example/license1.png)
![端口映射管理](assets/run-example/port-mapping1.png)
# 4、代理示意图
# 5、代理示意图
![代理流程](assets/design/neutrino-proxy-process.jpg)
# 5、联系我们
# 6、联系我们
- 微信: yuyunshize
- GitCodehttps://gitcode.com/dromara/neutrino-proxy
- Gitee: https://gitee.com/asgc/neutrino-proxy
- Github仓库:https://github.com/dromara/neutrino-proxy
# 6、贡献者列表
# 7、贡献者列表
<p>
<a href="https://gitee.com/zcans" target="_blank">
<img src="assets/developer/zcans.png" width="11%">
@@ -91,6 +99,9 @@
<a href="https://gitee.com/nichenxyx" target="_blank">
<img src="assets/developer/NichenFly.jpg" width="11%">
</a>
<a href="https://gitee.com/miracrl" target="_blank">
<img src="assets/developer/miracrl.png" width="11%">
</a>
</p>
# ❤️ 感谢
+15
View File
@@ -79,3 +79,18 @@
- 支持对用户、license限速
- 修复HTTP(S)映射时使用tcp端口访问正常,使用域名访问偶现一直loading的问题
- 修复HTTP(S)映射时使用映射的域名上传文件时,连接中断的问题
## 2.0.2
- 部分细节优化
- 解决客户端docker方式部署环境变量指定参数不生效的问题
- 服务端解决服务端native下,清理日志定时任务报错的问题
- 解决后台分页查询的已知问题
- 端口映射中的客户端ip字段加长,解决配置阿里云数据库域名字段不够的问题
- 管理后台新增域名管理
- [x] 支持设置一个默认域名
- [x] 删除、修改、禁用实时生效
- [x] 支持维护https证书
- 端口映射支持支持绑定多个子域名
- 选择择不同的主域名、子域名变更实时生效
## 2.0.3
- 解决http请求拆包情况下域名映射失效的问题
Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 262 KiB

After

Width:  |  Height:  |  Size: 243 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB

+1 -1
View File
@@ -20,7 +20,7 @@
> 从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://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镜像部署,则更新镜像重启即可
## 项目简介
Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

+62
View File
@@ -0,0 +1,62 @@
# NeutrinoProxy2.0.1发布,新增IP访问拦截+限速支持
## 项目简介
- [中微子代理(neutrino-proxy)](https://gitee.com/asgc/neutrino-proxy) 是一款基于Solon、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、安全组:支持黑/白名单IP访问限制
- 11、限速:支持对License、端口映射限制上传/下载速度
- 12、采用最为宽松的MIT协议,免去你的后顾之忧
## 本次更新内容
- jdk版本升级为21
- 新增安全组模块,支持黑名单、白名单限制
- 支持对用户、license限速
- 修复HTTP(S)映射时使用tcp端口访问正常,使用域名访问偶现一直loading的问题
- 修复HTTP(S)映射时使用映射的域名上传文件时,连接中断的问题
## 安装使用说明
- 快速上手:https://neutrino-proxy.dromara.org/neutrino-proxy/pages/793dcb/
- 升级须知:
- jdk版本升级为了jdk21,jar部署时请注意
- 涉及到表结构变更,执行增量SQLhttps://gitee.com/dromara/neutrino-proxy/blob/master/neutrino-proxy-server/src/main/resources/sql/mysql/update/UPDATE-20231215.SQL
## 运行示例
#### License限速
<img src="./license2.png" width="100%"/>
#### 端口映射限速
<img src="./port-mapping2.png" width="100%"/>
#### 安全组
<img src="./security-group1.png" width="100%"/>
<img src="./security-rule1.png" width="100%"/>
## 联系我们
笔者时间、能力有限,且开源项目非一朝一夕之事,存在众多问题亦在所难免。使用、学习过程中有任何问题欢迎大家与我联系。
对项目有什么想法或者建议,可以加我微信拉交流群,或者创建[issues](https://gitee.com/dromara/neutrino-proxy/issues),一起完善项目
- 微信号:yuyunshize
- Email: aoshiguchen@dromara.org
- 微信二维码(添加时请备注"中微子进群"):
<img src="MyWeChatQRCode.jpeg" width="100%"/>
Binary file not shown.

After

Width:  |  Height:  |  Size: 175 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

+81
View File
@@ -0,0 +1,81 @@
# NeutrinoProxy2.0.2发布,端口映射支持绑定多个域名
## 项目简介
- [中微子代理(neutrino-proxy)](https://gitee.com/dromara/neutrino-proxy) 是一款基于Solon、Netty的内网穿透神器。该项目采用最为宽松的MIT协议,因此您可以对它进行复制、修改、传播并用于任何个人或商业行为。
- 市面上基于内网穿透的常见产品有:花生壳、TeamView、cpolar等。
- 常见的使用场景:
- 本地开发调试第三方回调
- 本地开发异地接口连调
- 远程登录内网windows机器
- 将本地服务映射到外网,用于演示
- GitCodehttps://gitcode.com/dromara/neutrino-proxy
- Gitee仓库:https://gitee.com/dromara/neutrino-proxy
- Github仓库:https://github.com/dromara/neutrino-proxy
- 官网地址: https://neutrino-proxy.dromara.org
## 主要特点:
- 1、流量监控:首页图表、报表管理多维度流量监控。全方位掌握实时、历史代理数据。
- 2、用户/License:支持多用户、多客户端使用。后台禁用实时生效。
- 3、端口池:对外端口统一管理,支持用户、License独占端口。
- 4、端口映射:新增、编辑、删除、禁用实时生效。
- 5、Docker:服务端/客户端支持Docker一键部署。
- 6、SSL证书:隧道通信支持SSL加密,保护您的数据安全。
- 7、域名映射:支持绑定多个子域名,方便本地调试三方回调
- 8、多种协议:支持代理TCP、HTTP、HTTPS、UDP协议
- 9、原生部署:支持编译为原生可执行文件,更低部署门槛、更少内存占用
- 10、安全组:支持黑/白名单IP访问限制
- 11、限速:支持对License、端口映射限制上传/下载速度
- 12、采用最为宽松的MIT协议,免去你的后顾之忧
## 本次更新内容
- bug修复
- 解决安全组在ipv6场景下误拦截导致域名映射访问不通的问题
- 解决native编译后,端口池批量删除报错的问题
- 解决客户端docker方式部署环境变量指定参数不生效的问题
- 服务端解决native下清理日志定时任务报错的问题
- 解决后台分页查询的已知问题
- 端口映射中的客户端ip字段加长一点,解决配置阿里云数据库域名字段不够的问题
- 解决服务端native部署时,访问后台用户列表,日志警告“you should use: nativeMetadata.registerField(field) at aot runtime”的问题
- 新增功能
- 新增后台域名管理,⽀持新增、修改、删除、禁⽤主域名,支持添加多级域名。
- 域名管理支持上传域名对应的SSL证书、⽀持设置强制HTTPS、⽀持域名映射⾃动加载对应的服务器证书。
- 端口映射支持选择切换不同的主域名,⽀持绑定多个⼦域名,单个端⼝⽀持绑定多个不同的主域名。
## 安装使用说明
- 快速上手:https://neutrino-proxy.dromara.org/neutrino-proxy/pages/793dcb/
- 支持的部署方式
- 1、jar
- 2、docker
- 3、native
- windows
- linux
- mac
- 4、docker-compose
- 升级须知:
- **域名和SSL证书的配置由配置文件配置改为后台域名管理页面配置。**
- 去掉了配置文件声明服务器端域名和证书的方式,改为通过页面进行管理,请注意自行进行数据迁移。
- 数据库新增`域名表``域名映射中间表`,修改了`端口映射表`,涉及到表结构变更,执行[增量SQL](https://gitee.com/dromara/neutrino-proxy/blob/master/neutrino-proxy-server/src/main/resources/sql/mysql/update/UPDATE-20240808.SQL)
## 运行示例
#### License限速
<img src="./license2.png" width="100%"/>
#### 端口映射限速
<img src="./port-mapping2.png" width="100%"/>
#### 端口映射绑定多个域名
<img src="./port-mapping3.png" width="100%"/>
#### 安全组
<img src="./security-group1.png" width="100%"/>
<img src="./security-rule1.png" width="100%"/>
## 联系我们
笔者时间、能力有限,且开源项目非一朝一夕之事,存在众多问题亦在所难免。使用、学习过程中有任何问题欢迎大家与我联系。
对项目有什么想法或者建议,可以加我微信拉交流群,或者创建[issues](https://gitee.com/dromara/neutrino-proxy/issues),一起完善项目
- 微信号:yuyunshize
- Email: aoshiguchen@dromara.org
- 微信二维码(添加时请备注"中微子进群"):
<img src="MyWeChatQRCode.jpeg" width="100%"/>
Binary file not shown.

After

Width:  |  Height:  |  Size: 175 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB

+2 -2
View File
@@ -31,7 +31,7 @@
- 原则上,不允许自行添加第三方依赖库。若确有必要,请先和项目负责人沟通达成一致。
- 对现有代码的优化,请在注释中说明原因。
- 如果涉及到数据库的变更,则至少需要做到以下绩点:
- sqlite、mysql下均测试通过
- h2、mysql下均测试通过
-`./neutrino-proxy-server/src/main/resource/sql`下维护更新对应的表结构sql文件
- 对于新增的表,维护必要的初始化数据
- 在对应的mysql、sqlite的update目录下,维护SQL变更记录,确保SQL执行测试通过
- 在对应的mysql、h2的update目录下,维护SQL变更记录,确保SQL执行测试通过
+1 -1
View File
@@ -37,7 +37,7 @@ registry.cn-hangzhou.aliyuncs.com/asgc/neutrino-proxy:1.7.1
- 在服务器上新建部署目录:`/work/projects/neutrino-proxy-server`
-` neutrino-proxy-server.jar``neutrino-proxy-admin.zip`上传至服务器部署目录。
- 解压`neutrino-proxy-admin.zip`文件
- 执行命令`java -jar neutrino-proxy-server.jar`启动服务端完成部署,默认使用sqlite数据库。
- 执行命令`java -jar neutrino-proxy-server.jar`启动服务端完成部署,默认使用h2数据库。
- 若需要指定自己的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脚本启动服务端。
+1
View File
@@ -8,6 +8,7 @@
# 代理配置
- License管理:License是客户端连接服务端的唯一合法凭证。一个License同时只能被一个客户端使用,一个License可以维护多条端口映射
- 端口映射:服务端IP+端口 -> 客户端IP+端口的四元组映射(因目前服务端单节点只有一个公网IP,所以不体现出来),是内网穿透的基本单元。
- 域名管理:用于统一管理服务器主域名和证书,支持多域名。
# 系统管理
- 用户管理:支持多用户,一个用户可持有多个License。由于项目目前主推个人版,所以暂是没有权限这一套,管理员之外的所有用户都属于游客。对于绝大多数操作,游客仅有只读权限。
+66
View File
@@ -7,3 +7,69 @@ export function domainNameBindInfo(query) {
params: query
})
}
export function fetchList(query) {
return request({
url: '/domain/page',
method: 'get',
params: query
})
}
export function fetchAvailableDomainList(query) {
return request({
url: '/domain/all',
method: 'get',
params: query
})
}
export function updateEnableStatus(id, enable, domain) {
return request({
url: '/domain/update/enable-status',
method: 'post',
data: {
id: id,
enable: enable,
domain: domain,
}
})
}
export function createDomain(data) {
return request({
url: '/domain/create',
method: 'post',
data
})
}
export function updateDomain(data) {
return request({
url: '/domain/update',
method: 'post',
data
})
}
export function deleteDomain(id) {
return request({
url: '/domain/delete',
method: 'post',
params: {
id: id
}
})
}
export function updateDefaultStatus(id, isDefault) {
return request({
url: '/domain/update/default-status',
method: 'post',
data: {
id: id,
isDefault: isDefault
}
})
}
@@ -50,7 +50,7 @@
:hide-on-single-pageInfo="false"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-pageInfo="PaginationData.currentPage"
:current-page="PaginationData.currentPage"
:pageInfo-sizes="[10, 20, 50, 100]"
:pageInfo-size="PaginationData.pageSize"
layout="total, sizes, prev, pager, next, jumper"
+2
View File
@@ -55,6 +55,7 @@ export default {
proxy: '代理配置',
license: 'License管理',
portMapping: '端口映射',
domainManagement: '域名管理',
jobManager: '调度管理',
jobLog: '调度日志',
log: '日志管理',
@@ -128,6 +129,7 @@ export default {
deleteBatch: '批量删除',
cancel: '取 消',
confirm: '确 定',
domain: '域名',
userId: '用户ID',
userName: '用户名',
name: '名称',
+3 -2
View File
@@ -61,7 +61,8 @@ export const asyncRouterMap = [
},
children: [
{ path: 'license', component: _import('proxy/license'), name: 'license', meta: { title: 'license' }},
{ path: 'portMapping', component: _import('proxy/portMapping'), name: 'portMapping', meta: { title: 'portMapping' }}
{ path: 'portMapping', component: _import('proxy/portMapping'), name: 'portMapping', meta: { title: 'portMapping' }},
{ path: 'domainManagement', component: _import('proxy/domain'), name: 'domainManagement', meta: { title: 'domainManagement' }}
]
},
{
@@ -78,7 +79,7 @@ export const asyncRouterMap = [
{ 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: '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' }}
]
@@ -51,7 +51,7 @@
</el-table-column>
</el-table>
<div class="pagination-container">
<el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-pageInfo.sync="listQuery.current"
<el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.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>
@@ -46,7 +46,7 @@
</el-table-column>-->
</el-table>
<div class="pagination-container">
<el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-pageInfo.sync="listQuery.current"
<el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.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>
@@ -31,7 +31,7 @@
</el-table-column>
</el-table>
<div class="pagination-container">
<el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-pageInfo.sync="listQuery.current"
<el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.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>
@@ -0,0 +1,467 @@
<template>
<div class="app-container calendar-list-container">
<div class="filter-container" style="display:flex">
<el-select v-model="listQuery.userId" placeholder="请选择用户" filterable clearable style="margin-right:10px;width: 120px;">
<el-option v-for="item in userList" :key="item.id" :label="item.name" :value="item.id"/>
</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" :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.userName')" width="150">
<template slot-scope="scope">
<span>{{scope.row.userName}}</span>
</template>
</el-table-column>
<el-table-column align="center" :label="$t('table.domain')" width="300">
<template slot-scope="scope">
<span>{{scope.row.domain}}</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>
</template>
</el-table-column>
<el-table-column class-name="status-col" :label="$t('SSL证书状态')" width="110">
<template slot-scope="scope">
<el-tag :type="scope.row.sslStatus | statusFilter">{{scope.row.sslStatus | sslStatusName}}</el-tag>
</template>
</el-table-column>
<el-table-column class-name="status-col" :label="$t('默认域名')" width="100">
<template slot-scope="scope">
<el-tag :type="scope.row.isDefault | statusFilter">{{scope.row.isDefault | httpStatusName}}</el-tag>
</template>
</el-table-column>
<el-table-column class-name="status-col" :label="$t('强制HTTPS')" width="100">
<template slot-scope="scope">
<el-tag :type="scope.row.forceHttps | statusFilter">{{scope.row.forceHttps | httpStatusName}}</el-tag>
</template>
</el-table-column>
<el-table-column class-name="status-col" :label="$t('table.enableStatus')" width="100">
<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="330" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button v-if="scope.row.isDefault !='1' && scope.row.enable == '1'" size="mini" type="primary" @click="handleDefaultStatus(scope.row)">{{$t('默认')}}</el-button>
<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 size="mini" type="danger" @click="handleDelete(scope.row,'deleted')">{{$t('table.delete')}}</el-button>-->
<ButtonPopover @handleCommitClick="handleDelete2(scope.row)" style="margin-left: 10px"/>
</template>
</el-table-column>
</el-table>
<div class="pagination-container">
<el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.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="left" label-width="120px" style='width: 400px; margin-left:50px;'>
<el-form-item :label="$t('主域名')" prop="domain">
<el-input v-model="temp.domain"></el-input>
</el-form-item>
<el-form-item :label="$t('强制HTTPS')" prop="userId">
<el-select style="width: 280px" class="filter-item" v-model="temp.forceHttps" placeholder="请选择">
<el-option label="开启" :value="1"></el-option>
<el-option label="关闭" :value="2"></el-option>
</el-select>
</el-form-item>
<el-form-item :label="$t('JKS文件上传')" prop="file">
<el-upload
ref="upload"
class="upload-demo"
action=""
:http-request="httpRequest"
:file-list="this.fileList"
:auto-upload="false"
:multiple="false"
accept=".jks"
:limit="1"
:on-change="handleChange"
>
<el-button slot="trigger" size="small" type="primary">选择文件</el-button>
</el-upload>
</el-form-item>
<el-form-item v-if="passWordInputStatus" :label="$t('JKS密码')" prop="filePassword">
<el-input type="password" v-model="temp.keyStorePassword"></el-input>
</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 { fetchList, updateEnableStatus, createDomain, updateDomain, deleteDomain, updateDefaultStatus } from '@/api/domain'
import { userList } from '@/api/user'
import waves from '@/directive/waves' // 水波纹指令
import { parseTime } from '@/utils'
import ButtonPopover from '../../components/Button/buttonPopover'
const calendarTypeOptions = [
{ key: 'CN', display_name: 'China' },
{ key: 'US', display_name: 'USA' },
{ key: 'JP', display_name: 'Japan' },
{ key: 'EU', display_name: 'Eurozone' }
]
// arr to obj ,such as { CN : "China", US : "USA" }
const calendarTypeKeyValue = calendarTypeOptions.reduce((acc, cur) => {
acc[cur.key] = cur.display_name
return acc
}, {})
export default {
name: 'complexTable',
directives: {
waves
},
components: {
ButtonPopover
},
data() {
return {
fileList: [],
tableKey: 0,
list: null,
total: null,
listLoading: true,
listQuery: {
current: 1,
size: 10,
enable: undefined,
userId: null
},
importanceOptions: [1, 2, 3],
calendarTypeOptions,
userList: [],
sortOptions: [{ label: 'ID Ascending', key: '+id' }, { label: 'ID Descending', key: '-id' }],
statusOptions: ['published', 'draft', 'deleted'],
showReviewer: false,
temp: {
id: undefined,
importance: 1,
remark: '',
timestamp: new Date(),
title: '',
type: '',
status: 'published',
domain: '',
jks: undefined,
keyStorePassword: '',
forceHttps: ''
},
dialogFormVisible: false,
dialogStatus: '',
passWordInputStatus: false,
textMap: {
update: '编辑',
create: '新建'
},
dialogPvVisible: false,
pvData: [],
rules: {
domain: [
{ required: true, message: '主域名不能为空', trigger: 'blur' },
{ validator: this.validateDomain, trigger: 'blur' }
],
file: [
{ required: false, message: '请选择文件', trigger: 'blur' }
],
filePassword: [
{ required: false, message: '密码不能为空', trigger: 'blur' }
]// TODO required改为true后,密码不为空,仍不能通过
},
downloadLoading: false,
selectObj: {
statusOptions: [{ label: '启用', value: 1 }, { label: '禁用', value: 2 }],
onlineOptions: [{ label: '在线', value: 1 }, { label: '离线', value: 2 }]
}
}
},
filters: {
statusName(status) {
const statusMap = {
1: '启用',
2: '禁用'
}
return statusMap[status]
},
sslStatusName(status) {
const statusMap = {
1: '已上传',
2: '未上传',
3: '已验证'
}
return statusMap[status]
},
httpStatusName(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() {
this.getDataList()
},
methods: {
httpRequest(param) {
this.temp.jks = param.file
},
validateDomain(rule, value, callback) {
// 匹配多级域名,例如:sub.example.com, sub.sub.example.com
const domainPattern = /^(?:[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?\.)+[A-Za-z]{2,6}$/
if (!value) {
callback(new Error('主域名不能为空'));
} else if (!domainPattern.test(value)) {
callback(new Error('请输入正确的域名格式'));
} else {
callback();
}
},
handleChange(file) {
this.fileList = [file]
this.passWordInputStatus = true
},
getList() {
this.listLoading = true
fetchList(this.listQuery).then(response => {
this.list = response.data.data.records
this.total = response.data.data.total
this.listLoading = false
})
},
getUserList() {
userList().then(response => {
this.userList = response.data.data
})
},
getDataList() {
const loginName = this.$store.state.user.loginName
userList().then(response => {
this.userList = response.data.data
const curUser = this.userList.find((val) => val.loginName === loginName)
if (curUser) {
this.listQuery.userId = curUser.id
}
this.getList()
})
},
handleFilter() {
this.listQuery.current = 1
this.getList()
},
handleSizeChange(val) {
this.listQuery.size = val
this.getList()
},
handleCurrentChange(val) {
this.listQuery.current = val
this.getList()
},
handleDefaultStatus(row) {
updateDefaultStatus(row.id, 1).then(response => {
if (response.data.code === 0) {
this.$notify({
title: '成功',
message: '操作成功',
type: 'success'
})
this.getList()
}
this.getList()
})
},
handleModifyStatus(row, enable) {
console.log('route', this.$route)
updateEnableStatus(row.id, enable, row.domain).then(response => {
if (response.data.data.code === 0) {
this.$message({
message: '操作成功',
type: 'success'
})
}
this.getList()
})
},
resetTemp() {
this.passWordInputStatus = false
this.fileList = []
this.temp = {
domain: undefined,
jks: undefined,
keyStorePassword: undefined,
forceHttps: undefined
}
},
handleCreate() {
this.resetTemp()
this.dialogStatus = 'create'
this.dialogFormVisible = true
this.$nextTick(() => {
this.$refs['dataForm'].clearValidate()
})
},
createData() {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
this.$refs.upload.submit()
const formData = this.objectToFormData(this.temp)
createDomain(formData).then(response => {
if (response.data.code === 0) {
this.dialogFormVisible = false
this.$notify({
title: '成功',
message: '创建成功',
type: 'success',
duration: 2000
})
this.getList()
}
})
}
})
},
handleUpdate(row) {
this.resetTemp()
this.temp = Object.assign({}, row) // copy obj
this.dialogStatus = 'update'
this.dialogFormVisible = true
this.$nextTick(() => {
this.$refs['dataForm'].clearValidate()
})
},
updateData() {
this.$refs['dataForm'].validate((valid) => {
console.log(this.temp)
if (valid) {
this.$refs.upload.submit()
const tempData = Object.assign({}, this.temp)
const formData = this.objectToFormData(tempData)
updateDomain(formData).then(response => {
if (response.data.code === 0) {
this.dialogFormVisible = false
this.$notify({
title: '成功',
message: '创建成功',
type: 'success',
duration: 2000
})
this.getList()
}
})
}
})
},
objectToFormData(obj) {
const formData = new FormData()
Object.keys(obj).forEach(key => {
if (obj[key] !== undefined) {
formData.append(key, obj[key])
}
})
return formData
},
handleDelete(row) {
this.$confirm('确定要删除吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
deleteDomain(row.id).then(response => {
if (response.data.code === 0) {
this.$notify({
title: '成功',
message: '删除成功',
type: 'success',
duration: 2000
})
this.getList()
}
})
}).catch(() => {})
},
handleDelete2(row) {
deleteDomain(row.id).then(response => {
if (response.data.code === 0) {
this.$notify({
title: '成功',
message: '删除成功',
type: 'success',
duration: 2000
})
this.getList()
}
})
},
handleDownload() {
this.downloadLoading = true
import('@/vendor/Export2Excel').then(excel => {
const tHeader = ['timestamp', 'title', 'type', 'importance', 'status']
const filterVal = ['timestamp', 'title', 'type', 'importance', 'status']
const data = this.formatJson(filterVal, this.list)
excel.export_json_to_excel(tHeader, data, 'table-list')
this.downloadLoading = false
})
},
formatJson(filterVal, jsonData) {
return jsonData.map(v => filterVal.map(j => {
if (j === 'timestamp') {
return parseTime(v[j])
} else {
return v[j]
}
}))
}
}
}
</script>
@@ -1,13 +1,13 @@
<template>
<div class="app-container calendar-list-container">
<div class="filter-container">
<el-select v-model="listQuery.userId" placeholder="请选择用户" filterable clearable>
<el-select v-model="listQuery.userId" placeholder="请选择用户" filterable clearable style="margin-right:10px;width: 120px;">
<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>
<el-select v-model="listQuery.isOnline" placeholder="请选择在线状态" clearable style="width:145px;margin-right:10px">
<el-option v-for="item in selectObj.onlineOptions" :key="item.value" :label="item.label" :value="item.value"/>
</el-select>
<el-select v-model="listQuery.enable" placeholder="请选择启用状态" clearable>
<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>
@@ -74,7 +74,7 @@
</el-table>
<div class="pagination-container">
<el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-pageInfo.sync="listQuery.current"
<el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.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>
@@ -49,9 +49,20 @@
<span>{{ scope.row.protocal }}</span>
</template>
</el-table-column>
<el-table-column align="center" :label="$t('table.domainName')" width="180">
<el-table-column align="center" :label="$t('table.domainName')" width="190">
<template slot-scope="scope">
<span>{{ scope.row.domain }}</span>
<el-dropdown v-if="scope.row.allFullDomainList" @command="handleCopy">
<span class="el-dropdown-link">
{{ scope.row.allFullDomainList[0] }}<i v-if="scope.row.allFullDomainList.length > 1" class="el-icon-arrow-down el-icon--right"></i>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item v-for="(domain, index) in scope.row.allFullDomainList" :command="domain">{{ domain }}</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
<div v-if="!scope.row.allFullDomainList">-</div>
<!-- <div v-if="scope.row.allFullDomainList" v-for="(domain, index) in scope.row.allFullDomainList" :key="index">-->
<!-- <span>{{ domain }}</span>-->
<!-- </div>-->
</template>
</el-table-column>
<el-table-column align="center" :label="$t('table.serverPort')" width="80">
@@ -114,88 +125,112 @@
<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"
:current-page.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="left" label-width="120px"
style='width: 400px; margin-left:50px;'>
<!-- <el-form-item :label="$t('License')" prop="licenseId">-->
<!-- <el-select style="width: 280px;" class="filter-item" v-model="temp.licenseId" placeholder="请选择" :disabled="dialogStatus=='update'">-->
<!-- <el-option v-for="item in licenseList" :key="item.id" :label="item.name" :value="item.id">-->
<!-- </el-option>-->
<!-- </el-select>-->
<!-- </el-form-item>-->
<el-form-item :label="$t('License')" prop="licenseId">
<DropdownTable v-model="temp.licenseId" :name.sync="temp.licenseName" :tableData="licenseAuthList"
@selectedData="selectedFeeItem" placeholder="请选择" :width="280" :disabled="dialogStatus === 'update'" />
<!-- <DropdownTable
:columns="countryColumns"
:data="licenseList"
v-model="temp.licenseId"
:value="temp.licenseName"
@rowClick="selectedFeeItem"
disabled
:disabled="dialogStatus==='update'"
style="width: 280px"
/>-->
</el-form-item>
<el-form-item :label="$t('协议')" prop="protocal">
<el-select style="width: 280px;" class="filter-item" v-model="temp.protocal" placeholder="请选择">
<el-option v-for="item in protocalList" :key="item.name" :label="item.name" :value="item.name"
:disabled="!item.enable">
</el-option>
</el-select>
</el-form-item>
<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>
</el-form-item>
<el-form-item :label="$t('客户端端口')" prop="clientPort">
<el-input v-model="temp.clientPort"></el-input>
</el-form-item>
<el-form-item :label="$t('域名')" prop="subdomain" v-if="(temp.protocal === 'HTTP' || temp.protocal === 'HTTP(S)') && domainName && domainName != ''">
<el-input v-model="temp.subdomain">
<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>
</el-form>
<el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible" width="800px">
<div style="height: 500px; overflow-y: auto;">
<el-form :rules="rules" ref="dataForm" :model="temp" label-position="right" label-width="150px" inline>
<!-- <el-form-item :label="$t('License')" prop="licenseId">-->
<!-- <el-select style="width: 187px;" class="filter-item" v-model="temp.licenseId" placeholder="请选择" :disabled="dialogStatus=='update'">-->
<!-- <el-option v-for="item in licenseList" :key="item.id" :label="item.name" :value="item.id">-->
<!-- </el-option>-->
<!-- </el-select>-->
<!-- </el-form-item>-->
<el-form-item :label="$t('License')" prop="licenseId">
<DropdownTable v-model="temp.licenseId" :name.sync="temp.licenseName" :tableData="licenseAuthList"
@selectedData="selectedFeeItem" placeholder="请选择" :width="280" :disabled="dialogStatus === 'update'" />
<!-- <DropdownTable
:columns="countryColumns"
:data="licenseList"
v-model="temp.licenseId"
:value="temp.licenseName"
@rowClick="selectedFeeItem"
disabled
:disabled="dialogStatus==='update'"
style="width: 280px"
/>-->
</el-form-item>
<el-form-item :label="$t('协议')" prop="protocal">
<el-select style="width: 187px;" class="filter-item" v-model="temp.protocal" placeholder="请选择">
<el-option v-for="item in protocalList" :key="item.name" :label="item.name" :value="item.name"
:disabled="!item.enable">
</el-option>
</el-select>
</el-form-item>
<el-form-item :label="$t('服务端端口')" prop="serverPort" >
<load-select style="width: 187px;" 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>
</el-form-item>
<el-form-item :label="$t('客户端端口')" prop="clientPort">
<el-input v-model="temp.clientPort"></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: 187px;" 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" style="width: 540px;"></el-input>
</el-form-item>
<el-form-item :label="$t('域名')" prop="domainMappings" v-if="(temp.protocal === 'HTTP' || temp.protocal === 'HTTP(S)') && domainList != null && domainList.length > 0" >
<div class="my-tag">
<el-tag
:key="index"
v-for="(domain, index) in temp.domainMappings"
closable
:disable-transitions="false"
@close="removeDomainMapping(index)"
class="my-tag_item"
>
<el-input v-model="domain.subdomain" class="my-input"></el-input>
<el-select v-model="domain.domainId" placeholder="请选择主域名" class="my-select">
<el-option v-for="tmp in domainList" :key="tmp.id" :label="'.'+tmp.domain" :value="tmp.id"></el-option>
</el-select>
</el-tag>
<el-button v-if="!temp.domainMappings.length || temp.domainMappings[temp.domainMappings.length - 1].subdomain" class="button-new-tag" size="small" @click="addDomainMapping">+ 添加域名</el-button>
</div>
<!--<div v-for="(domain, index) in temp.domainMappings" :key="index" class="domain-mapping">
<el-input v-model="domain.subdomain">
<template slot="append">
<el-select v-model="domain.domainId" placeholder="请选择主域名" style="width: 187px;">
<el-option v-for="tmp in domainList" :key="tmp.id" :label="'.'+tmp.domain" :value="tmp.id"></el-option>
</el-select>
<el-button type="danger" @click="removeDomainMapping(index)" style="margin-left: 10px;">删除</el-button>
</template>
</el-input>
</div>
<el-button type="primary" @click="addDomainMapping" style="margin-top: 10px;">添加域名</el-button>-->
</el-form-item>
</el-form>
</div>
<div slot="footer" class="dialog-footer">
<el-button @click="
dialogFormVisible = false">{{ $t('table.cancel') }}</el-button>
@@ -225,13 +260,13 @@ import { availablePortList, portAvailable } from '@/api/portPool'
import { licenseList, licenseAuthList } from '@/api/license'
import { protocalList } from '@/api/protocal'
import { userList } from '@/api/user'
import { domainNameBindInfo } from '@/api/domain'
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";
import {fetchAvailableDomainList} from "../../api/domain";
const calendarTypeOptions = [
{ key: 'CN', display_name: 'China' },
@@ -297,7 +332,7 @@ export default {
protocalList: [],
licenseAuthList: [],
serverPortList: [],
domainName: '',
domainList: [{ 'name': 'link.com', 'id': '1' }],
showReviewer: false,
temp: {
id: undefined,
@@ -308,7 +343,8 @@ export default {
clientPort: undefined,
protocal: undefined,
proxyResponses: undefined,
proxyTimeoutMs: undefined
proxyTimeoutMs: undefined,
domainMappings: []
},
selectObj: {
statusOptions: [{ label: '启用', value: 1 }, { label: '禁用', value: 2 }],
@@ -323,6 +359,27 @@ export default {
dialogPvVisible: false,
pvData: [],
rules: {
domainMappings: [
{
validator: (rule, value, callback) => {
if (value && value.length > 0) {
for (let i = 0; i < value.length; i++) {
if (!value[i].subdomain || !value[i].domainId) {
return callback(new Error(`子域名和主域名都不能为空`))
}
}
const set = new Set()
value.forEach(i => {
const row = this.domainList.find(d => d.id === i.domainId)
set.add(i.subdomain + '.' + row.domain)
})
if (set.size !== value.length) return callback(new Error(`域名不能重复`))
}
callback() // 验证通过
},
trigger: ''
}
],
licenseId: [{ required: true, message: '请选择License', trigger: 'blur,change' }],
serverPort: [{ required: true, message: '请输入服务端端口', trigger: 'blur' },
// { validator: isPortAvailable, trigger: 'change' }
@@ -372,18 +429,71 @@ export default {
}
},
created() {
this.getDomainNameBindInfo()
this.getDataList()
this.getLicenseList()
this.getLicenseAuthList()
this.getProtocalList()
this.fetchSecurityGroupList()
this.getAvailableDomainList()
},
methods: {
handleCopy(text) {
navigator.clipboard.writeText(text).then(() => {
this.$message.success('复制成功')
}).catch(() => {
this.$message.error('复制失败')
})
},
// 添加新的域名映射
addDomainMapping() {
let defaultDomainId = this.domainList[0].id
this.domainList.forEach(item => {
if (item.isDefault === 1) {
defaultDomainId = item.id
}
})
this.temp.domainMappings.push({
subdomain: undefined,
domain: undefined,
domainId: defaultDomainId
});
console.log(this.list)
},
// 删除指定的域名映射
removeDomainMapping(index) {
this.temp.domainMappings.splice(index, 1);
},
getList() {
this.listLoading = true
fetchList(this.listQuery).then(response => {
this.list = response.data.data.records
this.list = response.data.data.records.map(item => {
// 初始化 domainMappings 字段
item.domainMappings = [];
// 检查是否存在 subdomain 和 domain 字段
if (item.fullDomainMappings && Array.isArray(item.fullDomainMappings)) {
let allFullDomainList = []
for (const fullDomainMapping of item.fullDomainMappings) {
item.domainMappings.push({
id: fullDomainMapping.id || '',
subdomain: fullDomainMapping.subdomain || '', // 使用 || '' 保证字段非空
domainId: fullDomainMapping.domainNameId || '',
domain: fullDomainMapping.domain || ''
});
// 拼接完整的域名
let fullDomain = null;
if (fullDomainMapping.forceHttps == 1) {
fullDomain = `https://` + `${fullDomainMapping.subdomain}.${fullDomainMapping.domain}`;
} else {
fullDomain = `http://` + `${fullDomainMapping.subdomain}.${fullDomainMapping.domain}`;
}
// 将拼接后的域名添加到
allFullDomainList.push(fullDomain);
}
item.allFullDomainList = allFullDomainList
}
return item;
});
// console.log(this.list)
this.total = response.data.data.total
this.listLoading = false
})
@@ -406,15 +516,15 @@ export default {
}
})
},
getDomainNameBindInfo() {
domainNameBindInfo().then(response => {
this.domainName = response.data.data
})
},
getAvailablePortList(licenseId) {
this.loadServerPortQuery.licenseId = licenseId;
this.serverPortList = []; //清掉数据
},
getAvailableDomainList() {
fetchAvailableDomainList({}).then(response => {
this.domainList = response.data.data
})
},
getAllUserList() {
userList().then(response => {
this.userList = response.data.data
@@ -469,9 +579,10 @@ export default {
clientPort: undefined,
userId: undefined,
proxyResponses: undefined,
proxyTimeoutMs: undefined
}
this.serverPortList = []
proxyTimeoutMs: undefined,
domainMappings: []
};
this.serverPortList = [];
this.loadServerPortQuery.licenseId = null;
this.more = true;
},
@@ -486,6 +597,7 @@ export default {
createData() {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
// console.log(this.temp)
createUserPortMapping(this.temp).then(response => {
if (response.data.code === 0) {
this.dialogFormVisible = false
@@ -503,13 +615,16 @@ export default {
},
handleOpenWebPage(row) {
let url = location.protocol + '//' + location.hostname + ':' + row.serverPort
if (row.domain) {
url = location.protocol + '//' + row.domain
if (row.allFullDomainList && row.allFullDomainList.length > 0) {
url = row.allFullDomainList[0]
}
open(url)
},
handleUpdate(row) {
this.temp = Object.assign({}, row) // copy obj
this.resetTemp()
console.log(this.temp)
this.temp = JSON.parse(JSON.stringify(row))
console.log(this.temp)
if (row.securityGroupId === 0) {
this.temp.securityGroupId = null
}
@@ -636,3 +751,42 @@ export default {
}
}
</script>
<style scoped lang="scss">
.my-tag {
width: 570px;
&_item {
height: 36px;
line-height: 35px;
padding: 0 7px;
.my-input, .my-select {
width: auto;
/deep/ input {
height: 32px;
line-height: 32px;
}
}
.my-input {
/deep/ input {
width: 120px;
padding: 0 6px;
}
}
.my-select {
/deep/ input {
width: 110px;
border-width: 0!important;
background: #ecf5ff!important;
}
}
&:first-child {
margin-right: 8px;
}
& + & {
margin-right: 8px;
margin-bottom: 6px;
}
}
}
</style>
@@ -44,7 +44,7 @@
</el-table-column>
</el-table>
<div class="pagination-container">
<el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-pageInfo.sync="listQuery.current"
<el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.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>
@@ -41,7 +41,7 @@
</el-table-column>
</el-table>
<div class="pagination-container">
<el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-pageInfo.sync="listQuery.current"
<el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.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>
@@ -36,7 +36,7 @@
</el-table-column>
</el-table>
<div class="pagination-container">
<el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-pageInfo.sync="listQuery.current"
<el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.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>
@@ -37,7 +37,7 @@
</el-table-column>
</el-table>
<div class="pagination-container">
<el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-pageInfo.sync="listQuery.current"
<el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.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>
@@ -51,7 +51,7 @@
</el-table-column>
</el-table>
<div class="pagination-container">
<el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-pageInfo.sync="listQuery.current"
<el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.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>
@@ -58,7 +58,7 @@
<div class="pagination-container">
<el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
:current-pageInfo.sync="listQuery.current"
:current-page.sync="listQuery.current"
:pageInfo-sizes="[10,20,30, 50]" :pageInfo-size="listQuery.size"
layout="total, sizes, prev, pager, next, jumper" :total="total">
</el-pagination>
@@ -55,7 +55,7 @@
</el-table>
<div class="pagination-container">
<el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-pageInfo.sync="listQuery.current"
<el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.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>
@@ -28,7 +28,7 @@
<div class="pagination-container">
<el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
:current-pageInfo.sync="listQuery.current"
:current-page.sync="listQuery.current"
:pageInfo-sizes="[10,20,30, 50]" :pageInfo-size="listQuery.size"
layout="total, sizes, prev, pager, next, jumper" :total="total">
</el-pagination>
@@ -80,7 +80,7 @@
<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"
:current-page.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>
@@ -176,7 +176,7 @@
<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"
:current-page.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>
@@ -81,7 +81,7 @@
<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"
:current-page.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>
@@ -50,7 +50,7 @@
</el-table>
<div class="pagination-container">
<el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-pageInfo.sync="listQuery.current"
<el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.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>
@@ -28,8 +28,6 @@ public class ProxyClient {
setAlias("neutrino.proxy.tunnel.jks-path", "jksPath");
setAlias("neutrino.proxy.tunnel.key-store-password", "keyStorePassword");
setAlias("neutrino.proxy.tunnel.license-key", "licenseKey");
log.info("NeutrinoProxy Client {}", app.cfg().get("solon.app.version"));
});
}
@@ -0,0 +1,35 @@
package org.dromara.neutrinoproxy.client.config;
import lombok.extern.slf4j.Slf4j;
import org.noear.solon.Solon;
import org.noear.solon.annotation.Component;
import org.noear.solon.core.event.AppLoadEndEvent;
import org.noear.solon.core.event.EventListener;
import org.noear.solon.core.runtime.NativeDetector;
/**
* 启动成功后信息输出
* @author: aoshiguchen
* @date: 2024/10/16
*/
@Slf4j
@Component
public class AppLoadEndExecutor implements EventListener<AppLoadEndEvent> {
@Override
public void onEvent(AppLoadEndEvent appLoadEndEvent) throws Throwable {
// aot 阶段,不执行
if (NativeDetector.isAotRuntime()) {
return;
}
System.out.printf("""
---------------------------------------------------------------
Neutrino Proxy Client %s
Gitee: https://gitee.com/dromara/neutrino-proxy
GitHub: https://github.com/dromara/neutrino-proxy
GitCode: https://gitcode.com/dromara/neutrino-proxy
---------------------------------------------------------------
%n""", Solon.app().cfg().get("solon.app.version"));
}
}
@@ -1,6 +1,10 @@
package org.dromara.neutrinoproxy.client.config;
import cn.hutool.core.util.StrUtil;
import io.netty.channel.WriteBufferWaterMark;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.dromara.neutrinoproxy.client.util.StringUtil;
import org.noear.solon.annotation.Component;
import org.noear.solon.annotation.Inject;
@@ -9,6 +13,7 @@ import org.noear.solon.annotation.Inject;
* @author: aoshiguchen
* @date: 2022/6/16
*/
@Slf4j
@Data
@Component
public class ProxyConfig {
@@ -29,6 +34,8 @@ public class ProxyConfig {
private Integer readIdleTime;
private Integer writeIdleTime;
private Integer allIdleTimeSeconds;
// 水位线
private String waterMark;
}
@Data
@@ -71,4 +78,38 @@ public class ProxyConfig {
private String puppetPortRange;
private Boolean transferLogEnable;
}
private WriteBufferWaterMark waterMark;
private boolean isParseWaterMark = false;
public synchronized WriteBufferWaterMark getWaterMark() {
if (isParseWaterMark) {
return waterMark;
}
isParseWaterMark = true;
if (null == protocol || StrUtil.isBlank(protocol.getWaterMark())) {
return null;
}
String[] tmp = protocol.getWaterMark().split("/");
if (tmp.length != 2) {
log.info("[配置解析] 水位线配置参数格式有误! config={}", protocol.getWaterMark());
return null;
}
String lowStr = tmp[0].trim();
String highStr = tmp[1].trim();
if (!StringUtil.isBytesDesc(lowStr) || !StringUtil.isBytesDesc(highStr)) {
log.info("[配置解析] 水位线配置参数格式有误! config={}", protocol.getWaterMark());
return null;
}
Long low = StringUtil.parseBytes(lowStr);
Long high = StringUtil.parseBytes(highStr);
if (null == low || null == high || low >= high) {
log.info("[配置解析] 水位线配置参数格式或大小有误! config={}", protocol.getWaterMark());
return null;
}
waterMark = new WriteBufferWaterMark(low.intValue(), high.intValue());
log.info("[配置解析] 水位线配置 config={},low={},high={}", protocol.getWaterMark(), low.intValue(), high.intValue());
return waterMark;
}
}
@@ -1,8 +1,6 @@
package org.dromara.neutrinoproxy.client.config;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelOption;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.*;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioDatagramChannel;
@@ -16,7 +14,6 @@ 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;
import io.netty.channel.ChannelHandlerContext;
import org.noear.solon.Solon;
import org.noear.solon.annotation.Bean;
import org.noear.solon.annotation.Configuration;
@@ -108,6 +105,12 @@ public class ProxyConfiguration implements LifecycleBean {
Bootstrap bootstrap = new Bootstrap();
bootstrap.group(tunnelWorkGroup);
bootstrap.channel(NioSocketChannel.class);
WriteBufferWaterMark waterMark = proxyConfig.getWaterMark();
if (null != waterMark) {
bootstrap.option(ChannelOption.WRITE_BUFFER_WATER_MARK, waterMark);
}
bootstrap.remoteAddress(InetSocketAddress.createUnresolved(proxyConfig.getTunnel().getServerIp(), proxyConfig.getTunnel().getServerPort()));
bootstrap.handler(new ChannelInitializer<SocketChannel>() {
@@ -165,6 +168,12 @@ public class ProxyConfiguration implements LifecycleBean {
Bootstrap bootstrap = new Bootstrap();
bootstrap.group(tcpRealServerWorkGroup);
bootstrap.channel(NioSocketChannel.class);
WriteBufferWaterMark waterMark = proxyConfig.getWaterMark();
if (null != waterMark) {
bootstrap.option(ChannelOption.WRITE_BUFFER_WATER_MARK, waterMark);
}
bootstrap.handler(new ChannelInitializer<SocketChannel>() {
@Override
@@ -1,5 +1,6 @@
package org.dromara.neutrinoproxy.client.core;
import io.netty.handler.codec.DecoderException;
import org.dromara.neutrinoproxy.client.config.ProxyConfig;
import org.dromara.neutrinoproxy.client.util.ProxyUtil;
import org.dromara.neutrinoproxy.core.Constants;
@@ -13,6 +14,9 @@ import io.netty.handler.timeout.IdleStateEvent;
import lombok.extern.slf4j.Slf4j;
import org.noear.solon.Solon;
import java.io.IOException;
import java.net.SocketException;
/**
* 处理与服务端之间的数据传输
* @author: aoshiguchen
@@ -58,8 +62,29 @@ public class CmdChannelHandler extends SimpleChannelInboundHandler<ProxyMessage>
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
log.error("[CMD Channel]Client CmdChannel Error channelId:{}", ctx.channel().id().asLongText(), cause);
ctx.close();
// 对于网络IO异常(致命异常),关闭channel以防止资源泄漏
// 对于其他异常(可能是可恢复的业务异常),只记录日志
if (cause instanceof IOException) {
// IOException及其子类(包括SocketException)都是致命的网络异常
if (cause instanceof SocketException && cause.getMessage() != null && cause.getMessage().contains("Connection reset")) {
// Connection reset是常见的客户端断开,使用debug级别
log.debug("[Cmd Channel] Client connection reset: {}", cause.getMessage());
} else {
log.error("[Cmd Channel] IO Error", cause);
}
if (ctx.channel().isActive()) {
ctx.channel().close();
}
} else if(cause instanceof DecoderException) {
// 协议解析错误,为防止数据污染,立即关闭
log.debug("[Cmd Channel] decoder error: {}", cause.getMessage());
if (ctx.channel().isActive()) {
ctx.channel().close();
}
} else {
// 其他异常只记录日志,不关闭channel,让Netty自己处理
log.error("[Cmd Channel] error", cause);
}
}
@Override
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.client.core;
import java.util.concurrent.ThreadFactory;
@@ -1,25 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.client.core;
import io.netty.channel.Channel;
@@ -1,36 +1,16 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.client.core;
import io.netty.buffer.Unpooled;
import io.netty.channel.*;
import io.netty.handler.codec.DecoderException;
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 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 java.io.IOException;
import java.net.SocketException;
/**
* 处理与被代理客户端的数据传输
@@ -77,9 +57,10 @@ public class RealServerChannelHandler extends SimpleChannelInboundHandler<ByteBu
Channel realServerChannel = ctx.channel();
String visitorId = ProxyUtil.getVisitorIdByRealServerChannel(realServerChannel);
ProxyUtil.removeRealServerChannel(visitorId);
Channel channel = realServerChannel.attr(Constants.NEXT_CHANNEL).get();
if (channel != null) {
channel.writeAndFlush(ProxyMessage.buildDisconnectMessage(visitorId));
Channel proxyChannel = realServerChannel.attr(Constants.NEXT_CHANNEL).get();
if (proxyChannel != null && proxyChannel.isActive()) {
// channel.writeAndFlush(ProxyMessage.buildDisconnectMessage(visitorId));
proxyChannel.writeAndFlush(Unpooled.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE);
}
super.channelInactive(ctx);
@@ -98,6 +79,28 @@ public class RealServerChannelHandler extends SimpleChannelInboundHandler<ByteBu
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
log.error("Client ProxyChannel Error", cause);
// 对于网络IO异常(致命异常),关闭channel以防止资源泄漏
// 对于其他异常(可能是可恢复的业务异常),只记录日志
if (cause instanceof IOException) {
// IOException及其子类(包括SocketException)都是致命的网络异常
if (cause instanceof SocketException && cause.getMessage() != null && cause.getMessage().contains("Connection reset")) {
// Connection reset是常见的客户端断开,使用debug级别
log.debug("[Real Server Channel] Client connection reset: {}", cause.getMessage());
} else {
log.error("[Real Server Channel] IO Error", cause);
}
if (ctx.channel().isActive()) {
ctx.channel().close();
}
} else if(cause instanceof DecoderException) {
// 协议解析错误,为防止数据污染,立即关闭
log.debug("[Real Server Channel] decoder error: {}", cause.getMessage());
if (ctx.channel().isActive()) {
ctx.channel().close();
}
} else {
// 其他异常只记录日志,不关闭channel,让Netty自己处理
log.error("[Real Server Channel] error", cause);
}
}
}
@@ -1,9 +1,8 @@
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.buffer.Unpooled;
import io.netty.channel.*;
import io.netty.handler.codec.DecoderException;
import io.netty.handler.timeout.IdleStateEvent;
import lombok.extern.slf4j.Slf4j;
import org.dromara.neutrinoproxy.client.util.ProxyUtil;
@@ -12,6 +11,9 @@ import org.dromara.neutrinoproxy.core.ProxyMessage;
import org.dromara.neutrinoproxy.core.dispatcher.Dispatcher;
import org.noear.solon.Solon;
import java.io.IOException;
import java.net.SocketException;
/**
* 处理与服务端之间的数据传输
* @author: aoshiguchen
@@ -43,18 +45,43 @@ public class TcpProxyChannelHandler extends SimpleChannelInboundHandler<ProxyMes
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
// 数据传输连接
Channel realServerChannel = ctx.channel().attr(Constants.NEXT_CHANNEL).get();
if (realServerChannel != null && realServerChannel.isActive()) {
realServerChannel.close();
if (null != realServerChannel && realServerChannel.isActive()) {
// realServerChannel.close();
realServerChannel.writeAndFlush(Unpooled.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE);
}
ProxyUtil.returnTcpProxyChanel(ctx.channel());
ctx.channel().attr(Constants.NEXT_CHANNEL).remove();
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();
// 对于网络IO异常(致命异常),关闭channel以防止资源泄漏
// 对于其他异常(可能是可恢复的业务异常),只记录日志
if (cause instanceof IOException) {
// IOException及其子类(包括SocketException)都是致命的网络异常
if (cause instanceof SocketException && cause.getMessage() != null && cause.getMessage().contains("Connection reset")) {
// Connection reset是常见的客户端断开,使用debug级别
log.debug("[TCP Proxy Channel] Client connection reset: {}", cause.getMessage());
} else {
log.error("[TCP Proxy Channel] IO Error", cause);
}
if (ctx.channel().isActive()) {
ctx.channel().close();
}
} else if(cause instanceof DecoderException) {
// 协议解析错误,为防止数据污染,立即关闭
log.debug("[TCP Proxy Channel] decoder error: {}", cause.getMessage());
if (ctx.channel().isActive()) {
ctx.channel().close();
}
} else {
// 其他异常只记录日志,不关闭channel,让Netty自己处理
log.error("[TCP Proxy Channel] error", cause);
}
}
@Override
@@ -1,9 +1,8 @@
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.buffer.Unpooled;
import io.netty.channel.*;
import io.netty.handler.codec.DecoderException;
import io.netty.handler.timeout.IdleStateEvent;
import lombok.extern.slf4j.Slf4j;
import org.dromara.neutrinoproxy.client.util.ProxyUtil;
@@ -12,6 +11,9 @@ import org.dromara.neutrinoproxy.core.ProxyMessage;
import org.dromara.neutrinoproxy.core.dispatcher.Dispatcher;
import org.noear.solon.Solon;
import java.io.IOException;
import java.net.SocketException;
/**
* 处理与服务端之间的数据传输
* @author: aoshiguchen
@@ -44,17 +46,40 @@ public class UdpProxyChannelHandler extends SimpleChannelInboundHandler<ProxyMes
// 数据传输连接
Channel realServerChannel = ctx.channel().attr(Constants.NEXT_CHANNEL).get();
if (realServerChannel != null && realServerChannel.isActive()) {
realServerChannel.close();
// realServerChannel.close();
realServerChannel.writeAndFlush(Unpooled.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE);
}
ProxyUtil.removeTcpProxyChanel(ctx.channel());
ProxyUtil.returnUdpProxyChanel(ctx.channel());
ProxyUtil.removeUdpProxyChanel(ctx.channel());
super.channelInactive(ctx);
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
log.error("[UDP Proxy Channel]Client ProxyChannel Error channelId:{}", ctx.channel().id().asLongText(), cause);
ctx.close();
// 对于网络IO异常(致命异常),关闭channel以防止资源泄漏
// 对于其他异常(可能是可恢复的业务异常),只记录日志
if (cause instanceof IOException) {
// IOException及其子类(包括SocketException)都是致命的网络异常
if (cause instanceof SocketException && cause.getMessage() != null && cause.getMessage().contains("Connection reset")) {
// Connection reset是常见的客户端断开,使用debug级别
log.debug("[UDP Proxy Channel] Client connection reset: {}", cause.getMessage());
} else {
log.error("[UDP Proxy Channel] IO Error", cause);
}
if (ctx.channel().isActive()) {
ctx.channel().close();
}
} else if(cause instanceof DecoderException) {
// 协议解析错误,为防止数据污染,立即关闭
log.debug("[UDP Proxy Channel] decoder error: {}", cause.getMessage());
if (ctx.channel().isActive()) {
ctx.channel().close();
}
} else {
// 其他异常只记录日志,不关闭channel,让Netty自己处理
log.error("[UDP Proxy Channel] error", cause);
}
}
@Override
@@ -63,16 +88,18 @@ public class UdpProxyChannelHandler extends SimpleChannelInboundHandler<ProxyMes
IdleStateEvent event = (IdleStateEvent)evt;
switch (event.state()) {
case READER_IDLE:
// 读超时,断开连接
log.info("[UDP Proxy Channel]Read timeout");
ctx.channel().close();
if (ctx.channel().isWritable()) {
// 读超时,断开连接
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("[UDP Proxy Channel]ReadWrite timeout");
ctx.close();
// log.debug("[UDP Proxy Channel]ReadWrite timeout");
// ctx.close();
break;
}
}
@@ -3,12 +3,16 @@ package org.dromara.neutrinoproxy.client.core;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.channel.socket.DatagramPacket;
import io.netty.handler.codec.DecoderException;
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.io.IOException;
import java.net.InetSocketAddress;
import java.net.SocketException;
import java.util.Date;
/**
* @author: aoshiguchen
@@ -36,6 +40,47 @@ public class UdpRealServerHandler extends SimpleChannelInboundHandler<DatagramPa
);
udpChannelBindInfo.getLockChannel().setResponseCount(udpChannelBindInfo.getLockChannel().getResponseCount() + 1);
udpChannelBindInfo.getLockChannel().setLastActiveTime(new Date());
}
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
// 对于网络IO异常(致命异常),关闭channel以防止资源泄漏
// 对于其他异常(可能是可恢复的业务异常),只记录日志
if (cause instanceof IOException) {
// IOException及其子类(包括SocketException)都是致命的网络异常
if (cause instanceof SocketException && cause.getMessage() != null && cause.getMessage().contains("Connection reset")) {
// Connection reset是常见的客户端断开,使用debug级别
log.debug("[UDP RealServer Channel] Client connection reset: {}", cause.getMessage());
} else {
log.error("[UDP RealServer Channel] IO Error", cause);
}
if (ctx.channel().isActive()) {
ctx.channel().close();
}
} else if(cause instanceof DecoderException) {
// 协议解析错误,为防止数据污染,立即关闭
log.debug("[UDP RealServer Channel] decoder error: {}", cause.getMessage());
if (ctx.channel().isActive()) {
ctx.channel().close();
}
} else {
// 其他异常只记录日志,不关闭channel,让Netty自己处理
log.error("[UDP RealServer Channel] error", cause);
}
}
// @Override
// public void channelInactive(ChannelHandlerContext ctx) throws Exception {
// // 数据传输连接
// Channel realServerChannel = ctx.channel().attr(org.dromara.neutrinoproxy.core.Constants.NEXT_CHANNEL).get();
// if (realServerChannel != null && realServerChannel.isActive()) {
// // realServerChannel.close();
// realServerChannel.writeAndFlush(Unpooled.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE);
// }
//
// ProxyUtil.removeUdpProxyChanel(ctx.channel());
// super.channelInactive(ctx);
// }
}
@@ -1,14 +1,10 @@
package org.dromara.neutrinoproxy.client.handler;
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 io.netty.buffer.Unpooled;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import org.noear.solon.annotation.Component;
@@ -23,12 +19,12 @@ public class ProxyMessageDisconnectHandler implements ProxyMessageHandler {
@Override
public void handle(ChannelHandlerContext ctx, ProxyMessage proxyMessage) {
Channel realServerChannel = ctx.channel().attr(Constants.NEXT_CHANNEL).get();
if (null != realServerChannel) {
ctx.channel().attr(Constants.NEXT_CHANNEL).remove();
ProxyUtil.returnTcpProxyChanel(ctx.channel());
realServerChannel.writeAndFlush(Unpooled.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE);
}
// Channel realServerChannel = ctx.channel().attr(Constants.NEXT_CHANNEL).get();
// if (null != realServerChannel) {
// ctx.channel().attr(Constants.NEXT_CHANNEL).remove();
// ProxyUtil.returnTcpProxyChanel(ctx.channel());
// realServerChannel.writeAndFlush(Unpooled.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE);
// }
ctx.close();
}
@@ -23,6 +23,8 @@ public class LockChannel {
private long proxyTimeoutMs;
// 被获取的时间
private Date takeTime;
// 已经响应的次数
// 最后一次活跃的时间(最后发生读写的时间),每次发送或响应需要重置
private Date lastActiveTime;
// 已经响应的次数(相对于最后一次发送的时,每次发送后需要重置)
private int responseCount;
}
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.client.util;
import io.netty.channel.ChannelHandler;
@@ -201,8 +180,7 @@ public class ProxyUtil {
}
public static ChannelHandler createSslHandler(ProxyConfig proxyConfig) {
try {
InputStream jksInputStream = FileUtil.getInputStream(proxyConfig.getTunnel().getJksPath());
try (InputStream jksInputStream = FileUtil.getInputStream(proxyConfig.getTunnel().getJksPath())) {
SSLContext clientContext = SSLContext.getInstance("TLS");
final KeyStore ks = KeyStore.getInstance("JKS");
@@ -0,0 +1,75 @@
package org.dromara.neutrinoproxy.client.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;
}
}
@@ -133,28 +133,40 @@ public class UdpServerUtil {
* @return
*/
public static synchronized Channel takeChannel(ProxyMessage.UdpBaseInfo info, Channel tunnelChannel) {
if (info.getProxyResponses() <= 0 || info.getProxyTimeoutMs() <= 0) {
Channel realServerChannel = tunnelChannel.attr(org.dromara.neutrinoproxy.core.Constants.NEXT_CHANNEL).get();
if (null != realServerChannel) {
UdpChannelBindInfo udpChannelBindInfo = realServerChannel.attr(Constants.UDP_CHANNEL_BIND_KEY).get();
// 每次发送前重置
udpChannelBindInfo.getLockChannel().setResponseCount(0);
udpChannelBindInfo.getLockChannel().setLastActiveTime(new Date());
return realServerChannel;
}
// 响应数量为零、超时时间<=0,则不需要响应(注意:响应数量为-1 则不限制响应数量)
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);
realServerChannel = portToChannelMap.get(port);
if (null == realServerChannel) {
realServerChannel = bindPort(port);
portToChannelMap.put(port, realServerChannel);
}
// 添加到锁定队列
LockChannel lockChannel = new LockChannel()
.setPort(port)
.setChannel(channel)
.setChannel(realServerChannel)
.setProxyResponses(info.getProxyResponses())
.setProxyTimeoutMs(info.getProxyTimeoutMs())
.setTakeTime(new Date())
.setLastActiveTime(new Date())
.setResponseCount(0);
lockChannelList.add(lockChannel);
channel.attr(Constants.UDP_CHANNEL_BIND_KEY).set(new UdpChannelBindInfo()
realServerChannel.attr(Constants.UDP_CHANNEL_BIND_KEY).set(new UdpChannelBindInfo()
.setTunnelChannel(tunnelChannel)
.setVisitorId(info.getVisitorId())
.setVisitorIp(info.getVisitorIp())
@@ -164,7 +176,12 @@ public class UdpServerUtil {
.setTargetPort(info.getTargetPort())
.setLockChannel(lockChannel)
);
return channel;
// 连接绑定
realServerChannel.attr(org.dromara.neutrinoproxy.core.Constants.NEXT_CHANNEL).set(tunnelChannel);
tunnelChannel.attr(org.dromara.neutrinoproxy.core.Constants.NEXT_CHANNEL).set(realServerChannel);
return realServerChannel;
}
/**
@@ -177,8 +194,8 @@ public class UdpServerUtil {
Iterator<LockChannel> iter = lockChannelList.iterator();
if (iter.hasNext()) {
LockChannel lockChannel = iter.next();
if (lockChannel.getResponseCount() >= lockChannel.getProxyResponses() ||
System.currentTimeMillis() - lockChannel.getTakeTime().getTime() >= lockChannel.getProxyTimeoutMs()
if ((lockChannel.getProxyResponses() > 0 && lockChannel.getResponseCount() >= lockChannel.getProxyResponses()) ||
System.currentTimeMillis() - lockChannel.getLastActiveTime().getTime() > lockChannel.getProxyTimeoutMs()
) {
iter.remove();
UdpChannelBindInfo udpChannelBindInfo = lockChannel.getChannel().attr(Constants.UDP_CHANNEL_BIND_KEY).get();
@@ -186,6 +203,17 @@ public class UdpServerUtil {
closeChannel(udpChannelBindInfo.getTunnelChannel());
lockChannel.getChannel().attr(Constants.UDP_CHANNEL_BIND_KEY).set(null);
udpServerFreePortPool.offer(lockChannel.getPort());
// 连接解绑
Channel realServerChannel = lockChannel.getChannel();
Channel tunnelChannel = realServerChannel.attr(org.dromara.neutrinoproxy.core.Constants.NEXT_CHANNEL).get();
if (null != realServerChannel) {
realServerChannel.attr(org.dromara.neutrinoproxy.core.Constants.NEXT_CHANNEL).set(null);
}
if (null != tunnelChannel) {
tunnelChannel.attr(org.dromara.neutrinoproxy.core.Constants.NEXT_CHANNEL).set(null);
}
log.debug("[udp channel]release udp channel port:{}", lockChannel.getPort());
}
}
@@ -4,6 +4,9 @@ solon.logging.logger:
neutrino:
proxy:
protocol:
# 高低水位线,如:32KB/64KB、32KB/1MB、1MB/5MB
# water-mark: 1MB/8MB
tunnel:
# 线程池相关配置,用于技术调优,可忽略
thread-count: 50
@@ -11,13 +14,13 @@ neutrino:
key-store-password: 123456
jks-path: classpath:/test.jks
# 服务端IP
server-ip: localhost
server-ip: ${SERVER_IP:localhost}
# 服务端端口(对应服务端app.yml中的tunnel.port、tunnel.ssl-port)
server-port: 9002
server-port: ${SERVER_PORT:9002}
# 是否启用SSL(注意:该配置必须和server-port对应上)
ssl-enable: true
ssl-enable: ${SSL_ENABLE:true}
# 客户端连接唯一凭证
license-key:
license-key: ${LICENSE_KEY:}
# 客户端唯一身份标识(可忽略,若不设置首次启动会自动生成)
client-id:
# 是否开启隧道传输报文日志(日志级别为debug时开启才有效)
@@ -3,7 +3,7 @@ solon:
add: ./app.yml
app:
name: neutrino-proxy-client
version: 2.0.1
version: 2.0.4
# 日志级别
solon.logging.appender:
console:
@@ -31,6 +31,8 @@ neutrino:
read-idle-time: 120
write-idle-time: 20
all-idle-time-seconds: 0
# 高低水位线,如:32KB/64KB、32KB/1MB、1MB/5MB
# water-mark: 1MB/8MB
tunnel:
# 线程池相关配置,用于技术调优,可忽略
thread-count: 50
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.core;
import java.util.HashMap;
@@ -1,31 +1,10 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.core;
import io.netty.channel.Channel;
import io.netty.util.AttributeKey;
import java.net.InetSocketAddress;
import java.util.function.BiConsumer;
/**
*
@@ -55,6 +34,8 @@ public interface Constants {
AttributeKey<Boolean> FLOW_LIMITER_FLAG = AttributeKey.newInstance("flowLimiterFlag");
AttributeKey<ProxyAttachment> PROXY_CONNECT_ATTACHMENT = AttributeKey.newInstance("proxyConnectAttachment");;
int HEADER_SIZE = 4;
int TYPE_SIZE = 1;
@@ -73,4 +54,20 @@ public interface Constants {
String ERROR = "ERROR";
String PORT_MAPPING_SYNC = "PORT_MAPPING_SYNC";
}
class ProxyAttachment {
private byte[] bytes;
private BiConsumer<Channel, byte[]> executor;
public ProxyAttachment(byte[] bytes, BiConsumer<Channel, byte[]> executor) {
this.bytes = bytes;
this.executor = executor;
}
public void execute(Channel channel) {
if (null != executor && null != channel && channel.isActive()) {
this.executor.accept(channel, bytes);
}
}
}
}
@@ -1,25 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.core;
import io.netty.channel.ChannelHandlerContext;
@@ -1,25 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.core;
import lombok.Data;
@@ -1,25 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.core;
import lombok.AllArgsConstructor;
@@ -1,25 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.core;
import lombok.Data;
@@ -1,25 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.core;
import io.netty.buffer.ByteBuf;
@@ -1,25 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.core;
import io.netty.buffer.ByteBuf;
@@ -1,25 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.core.base;
/**
@@ -1,5 +1,3 @@
package org.dromara.neutrinoproxy.core.base;
/**
@@ -1,25 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.core.dispatcher;
/**
@@ -1,25 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.core.dispatcher;
/**
@@ -1,25 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.core.dispatcher;
import java.lang.annotation.*;
@@ -1,4 +1,3 @@
package org.dromara.neutrinoproxy.core.type;
/**
@@ -37,8 +37,17 @@ public class HttpUtil {
* @return
*/
public static String getHeaderValue(String httpContent, String header) {
if (!httpContent.contains("\r\n\r\n")) {
return null;
}
String headerContent = httpContent.split("\r\n\r\n")[0];
if (!headerContent.contains("\r\n")) {
return null;
}
String[] lines = headerContent.split("\r\n");
if (lines.length == 0) {
return null;
}
String firstLine = lines[0];
if (!(firstLine.endsWith("HTTP/1.1") || firstLine.endsWith("HTTP/1.0"))) {
return null;
@@ -2,10 +2,12 @@ package org.dromara.neutrinoproxy.core.util;
import cn.hutool.core.net.Ipv4Util;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import java.net.InetSocketAddress;
@Slf4j
public class IpUtil extends org.noear.solon.core.util.IpUtil {
public static String getRemoteIp(ChannelHandlerContext ctx) {
@@ -27,7 +29,8 @@ public class IpUtil extends org.noear.solon.core.util.IpUtil {
if (StringUtils.isEmpty(ip)) {
ip = HttpUtil.getHeaderValue(httpContent, "X-Real-IP");
}
if (StringUtils.isNotEmpty(ip) && !Ipv4Util.isInnerIP(ip)) {
if (StringUtils.isNotEmpty(ip)) {
log.debug("obtain http header ip{}", ip);
return ip;
}
return null;
@@ -25,7 +25,6 @@ public class ProxyServer {
if (Utils.isNotEmpty(loglevel)) {
app.cfg().put("solon.logging.logger.root.level", loglevel);
}
log.info("NeutrinoProxy Server {}", app.cfg().get("solon.app.version"));
});
}
}
@@ -0,0 +1,38 @@
package org.dromara.neutrinoproxy.server.base;
import lombok.extern.slf4j.Slf4j;
import org.noear.solon.Solon;
import org.noear.solon.annotation.Component;
import org.noear.solon.core.event.AppLoadEndEvent;
import org.noear.solon.core.event.EventListener;
import org.noear.solon.core.runtime.NativeDetector;
/**
* 启动成功后信息输出
* @author: aoshiguchen
* @date: 2024/10/16
*/
@Slf4j
@Component
public class AppLoadEndExecutor implements EventListener<AppLoadEndEvent> {
@Override
public void onEvent(AppLoadEndEvent appLoadEndEvent) throws Throwable {
// aot 阶段,不执行
if (NativeDetector.isAotRuntime()) {
return;
}
System.out.printf("""
---------------------------------------------------------------
Neutrino Proxy Server %s
admin: http://localhost:%s
account: admin/123456
Gitee: https://gitee.com/dromara/neutrino-proxy
GitHub: https://github.com/dromara/neutrino-proxy
GitCode: https://gitcode.com/dromara/neutrino-proxy
---------------------------------------------------------------
%n""", Solon.app().cfg().get("solon.app.version"),
Solon.app().cfg().get("server.port"));
}
}
@@ -1,9 +1,13 @@
package org.dromara.neutrinoproxy.server.base;
import org.apache.ibatis.type.SimpleTypeRegistry;
import org.dromara.neutrinoproxy.server.base.proxy.ProxyConfig;
import org.dromara.neutrinoproxy.server.base.rest.ResponseBody;
import org.dromara.neutrinoproxy.server.controller.req.proxy.PortMappingCreateReq;
import org.dromara.neutrinoproxy.server.controller.req.proxy.PortMappingUpdateReq;
import org.dromara.neutrinoproxy.server.controller.res.report.HomeDataView;
import org.dromara.neutrinoproxy.server.dal.*;
import org.dromara.neutrinoproxy.server.proxy.enhance.SslContextManager;
import org.dromara.neutrinoproxy.server.service.*;
import org.dromara.solonplugins.job.JobBean;
import org.noear.solon.annotation.Component;
@@ -37,7 +41,8 @@ public class NeutrinoServerRuntimeNativeRegistrar implements RuntimeNativeRegist
metadata.registerLambdaSerialization(UserLoginRecordService.class);
metadata.registerLambdaSerialization(UserService.class);
metadata.registerLambdaSerialization(SecurityGroupService.class);
metadata.registerLambdaSerialization(DomainService.class);
metadata.registerLambdaSerialization(SslContextManager.class);
metadata.registerLambdaSerialization(LicenseMapper.class);
metadata.registerLambdaSerialization(ClientConnectRecordMapper.class);
@@ -46,14 +51,21 @@ public class NeutrinoServerRuntimeNativeRegistrar implements RuntimeNativeRegist
metadata.registerLambdaSerialization(FlowReportMinuteMapper.class);
metadata.registerLambdaSerialization(FlowReportMonthMapper.class);
metadata.registerLambdaSerialization(JobInfoMapper.class);
metadata.registerLambdaSerialization(JobLogMapper.class);
metadata.registerLambdaSerialization(PortMappingMapper.class);
metadata.registerLambdaSerialization(PortGroupMapper.class);
metadata.registerLambdaSerialization(ReportMapper.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.registerLambdaSerialization(DomainMapper.class);
metadata.registerLambdaSerialization(DomainPortMappingMapper.class);
metadata.registerReflection(PortMappingUpdateReq.DomainMapping.class, MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.INVOKE_DECLARED_METHODS);
metadata.registerReflection(PortMappingCreateReq.DomainMapping.class, MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.INVOKE_DECLARED_METHODS);
metadata.registerReflection(HomeDataView.class, MemberCategory.DECLARED_FIELDS);
metadata.registerReflection(HomeDataView.Last7dFlow.class, MemberCategory.DECLARED_FIELDS);
@@ -75,6 +87,8 @@ public class NeutrinoServerRuntimeNativeRegistrar implements RuntimeNativeRegist
metadata.registerReflection(JobBean.class, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS);
// 解决mybatis调用deleteBatchIds报错“java.lang.ClassNotFoundException: Cannot find class: org.apache.ibatis.type.SimpleTypeRegistry”
metadata.registerReflection(SimpleTypeRegistry.class, MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.INVOKE_DECLARED_METHODS);
}
}
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.base.db;
import cn.hutool.core.collection.CollectionUtil;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.base.db;
import org.dromara.neutrinoproxy.server.constant.DbTypeEnum;
@@ -1,6 +1,10 @@
package org.dromara.neutrinoproxy.server.base.proxy;
import cn.hutool.core.util.StrUtil;
import io.netty.channel.WriteBufferWaterMark;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.dromara.neutrinoproxy.server.util.StringUtil;
import org.noear.solon.annotation.Component;
import org.noear.solon.annotation.Inject;
@@ -9,6 +13,7 @@ import org.noear.solon.annotation.Inject;
* @author: aoshiguchen
* @date: 2022/6/16
*/
@Slf4j
@Data
@Component
public class ProxyConfig {
@@ -38,6 +43,8 @@ public class ProxyConfig {
private Integer readIdleTime;
private Integer writeIdleTime;
private Integer allIdleTimeSeconds;
// 水位线
private String waterMark;
}
@Data
@@ -63,7 +70,6 @@ public class ProxyConfig {
public static class Tcp {
private Integer bossThreadCount;
private Integer workThreadCount;
private String domainName;
private Integer httpProxyPort;
private Integer httpsProxyPort;
private String keyStorePassword;
@@ -77,4 +83,37 @@ public class ProxyConfig {
private Integer workThreadCount;
private Boolean transferLogEnable;
}
private WriteBufferWaterMark waterMark;
private boolean isParseWaterMark = false;
public synchronized WriteBufferWaterMark getWaterMark() {
if (isParseWaterMark) {
return waterMark;
}
isParseWaterMark = true;
if (null == protocol || StrUtil.isBlank(protocol.getWaterMark())) {
return null;
}
String[] tmp = protocol.getWaterMark().split("/");
if (tmp.length != 2) {
log.info("[配置解析] 水位线配置参数格式有误! config={}", protocol.getWaterMark());
return null;
}
String lowStr = tmp[0].trim();
String highStr = tmp[1].trim();
if (!StringUtil.isBytesDesc(lowStr) || !StringUtil.isBytesDesc(highStr)) {
log.info("[配置解析] 水位线配置参数格式有误! config={}", protocol.getWaterMark());
return null;
}
Long low = StringUtil.parseBytes(lowStr);
Long high = StringUtil.parseBytes(highStr);
if (null == low || null == high || low >= high) {
log.info("[配置解析] 水位线配置参数格式或大小有误! config={}", protocol.getWaterMark());
return null;
}
waterMark = new WriteBufferWaterMark(low.intValue(), high.intValue());
log.info("[配置解析] 水位线配置 config={},low={},high={}", protocol.getWaterMark(), low.intValue(), high.intValue());
return waterMark;
}
}
@@ -1,10 +1,9 @@
package org.dromara.neutrinoproxy.server.base.proxy;
import cn.hutool.core.util.StrUtil;
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.*;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioDatagramChannel;
import io.netty.channel.socket.nio.NioServerSocketChannel;
@@ -15,14 +14,13 @@ 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.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.dromara.neutrinoproxy.server.util.ProxyUtil;
import org.noear.solon.Solon;
import org.noear.solon.annotation.Bean;
import org.noear.solon.annotation.Configuration;
@@ -47,6 +45,8 @@ public class ProxyConfiguration implements LifecycleBean {
null : ProxyDataTypeEnum.of((int)proxyMessage.getType()).getName());
Solon.context().wrapAndPut(Dispatcher.class, dispatcher);
ProxyUtil.init();
}
@Bean("tcpServerBossGroup")
@@ -67,6 +67,11 @@ public class ProxyConfiguration implements LifecycleBean {
@Inject ProxyConfig proxyConfig
) {
ServerBootstrap bootstrap = new ServerBootstrap();
WriteBufferWaterMark waterMark = proxyConfig.getWaterMark();
if (null != waterMark) {
bootstrap.childOption(ChannelOption.WRITE_BUFFER_WATER_MARK, waterMark);
}
bootstrap.group(tcpServerBossGroup, tcpServerWorkerGroup)
.channel(NioServerSocketChannel.class)
.childHandler(new ChannelInitializer<SocketChannel>() {
@@ -75,7 +80,7 @@ public class ProxyConfiguration implements LifecycleBean {
if (null != proxyConfig.getServer().getTcp().getTransferLogEnable() && proxyConfig.getServer().getTcp().getTransferLogEnable()) {
ch.pipeline().addFirst(new LoggingHandler(TcpVisitorChannelHandler.class));
}
ch.pipeline().addFirst(new BytesMetricsHandler());
// 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());
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.base.rest;
import java.lang.annotation.ElementType;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.base.rest;
import lombok.Data;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.base.rest;
import org.dromara.neutrinoproxy.server.constant.ExceptionConstant;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.base.rest;
import org.dromara.neutrinoproxy.server.dal.entity.UserDO;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.base.rest;
import org.dromara.neutrinoproxy.server.dal.entity.UserDO;
@@ -8,7 +8,6 @@ import org.dromara.neutrinoproxy.server.dal.entity.UserDO;
import org.dromara.neutrinoproxy.server.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.dromara.neutrinoproxy.server.base.rest.*;
import org.noear.solon.Solon;
import org.noear.solon.annotation.Component;
import org.noear.solon.core.handle.Action;
@@ -23,7 +23,7 @@ public class GlobalExceptionFilter implements Filter {
try {
chain.doFilter(ctx);
} catch (Throwable e) {
log.error("global error", e);
log.debug("global error", e);
if (e instanceof ServiceException) {
ServiceException serviceException = (ServiceException) e;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.constant;
import lombok.AllArgsConstructor;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.constant;
import lombok.AllArgsConstructor;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.constant;
import lombok.AllArgsConstructor;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.constant;
import lombok.AllArgsConstructor;
@@ -0,0 +1,19 @@
package org.dromara.neutrinoproxy.server.constant;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 默认域名状态枚举
* @author Mirac
* @date 21/7/2024
*/
@Getter
@AllArgsConstructor
public enum DefaultDomainStatusEnum {
ENABLE(1, "默认域名"),
DISABLE(2, "关闭");
private Integer status;
private String desc;
}
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.constant;
import lombok.AllArgsConstructor;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.constant;
import lombok.AllArgsConstructor;
@@ -59,8 +38,6 @@ public enum ExceptionConstant {
PORT_MAPPING_NOT_EXIST(14000, "端口映射记录不存在"),
PORT_CANNOT_REPEAT_MAPPING(14001, "服务端口[{}]不能重复映射"),
AN_UNSUPPORTED_PROTOCOL(14002, "不支持的协议[{}]"),
PORT_MAPPING_SUBDONAME_CONNOT_REPEAT(14003, "子域名不能重复使用!"),
// 调度管理(15000)
JOB_INFO_NOT_EXIST(15000, "调度管理记录不存在"),
SYSTEM_ERROR(500, "系统异常"),
@@ -72,7 +49,12 @@ public enum ExceptionConstant {
// 安全组管理(17000)
SECURITY_GROUP_NOT_EXIST(17000, "安全组不存在"),
SECURITY_RULE_NOT_EXIST(17001, "安全规则不存在"),
// 域名映射管理(18000)
DOMAIN_NAME_CANNOT_REPEAT(18000, "域名不能重复"),
DOMAIN_NAME_NOT_EXIST(18001, "域名不存在"),
DOMAIN_NAME_IS_DISABLE(18002, "当前域名[{}]被禁用"),
SUDOMAIN_NAME_CANNOT_REPEAT(18003, "子域名不能重复"),
DOMAIN_NAME_IS_USED(18002, "当前域名正在使用"),
;
private int code;
@@ -0,0 +1,29 @@
package org.dromara.neutrinoproxy.server.constant;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* 仅Https状态枚举
* @author Mirac
* @date 21/7/2024
*/
@Getter
@AllArgsConstructor
public enum HttpsStatusEnum {
ONLY_HTTPS(1, "仅HTTPS"),
DISABLE_ONLY_HTTPS(2, "关闭仅HTTPS");
private static Map<Integer, HttpsStatusEnum> CACHE = Stream.of(HttpsStatusEnum.values()).collect(Collectors.toMap(HttpsStatusEnum::getStatus, Function.identity()));
private Integer status;
private String desc;
public static HttpsStatusEnum of(Integer status) {
return CACHE.get(status);
}
}
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.constant;
import lombok.AllArgsConstructor;
@@ -0,0 +1,25 @@
package org.dromara.neutrinoproxy.server.constant;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* 仅Https状态枚举
* @author Mirac
* @date 21/7/2024
*/
@Getter
@AllArgsConstructor
public enum SslStatusEnum {
UPLOADED(1, "已上传"),
NOT_UPLOADED(2, "未上传"),
CERTIFIED(3, "已认证");//预留,用于证书验证
private Integer status;
private String desc;
}
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.constant;
import lombok.AllArgsConstructor;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller;
import org.dromara.neutrinoproxy.server.base.page.PageInfo;
@@ -0,0 +1,91 @@
package org.dromara.neutrinoproxy.server.controller;
import cn.hutool.core.util.StrUtil;
import org.dromara.neutrinoproxy.server.base.page.PageInfo;
import org.dromara.neutrinoproxy.server.base.page.PageQuery;
import org.dromara.neutrinoproxy.server.base.rest.Authorization;
import org.dromara.neutrinoproxy.server.controller.req.proxy.*;
import org.dromara.neutrinoproxy.server.controller.res.proxy.DomainListRes;
import org.dromara.neutrinoproxy.server.controller.res.proxy.DomainUpdateDefaultStatusRes;
import org.dromara.neutrinoproxy.server.controller.res.proxy.DomainUpdateEnableStatusRes;
import org.dromara.neutrinoproxy.server.util.ParamCheckUtil;
import org.noear.solon.annotation.*;
import org.dromara.neutrinoproxy.server.service.DomainService;
import org.noear.solon.core.handle.Context;
import org.noear.solon.core.handle.UploadedFile;
import org.noear.solon.lang.Nullable;
import javax.sound.midi.Soundbank;
import java.io.IOException;
import java.util.List;
/**
* @author Mirac
* @date 21/7/2024
*/
@Mapping("/domain")
@Controller
public class DomainController {
@Inject
private DomainService domainService;
@Get
@Mapping("/page")
public PageInfo<DomainListRes> page(PageQuery pageQuery, DomainListReq req) {
return domainService.page(pageQuery, req);
}
@Get
@Mapping("/all")
public List<DomainListRes> all(DomainListReq req) {
ParamCheckUtil.checkNotNull(req, "req");
return domainService.all(req);
}
@Post
@Mapping(path = "/create")
@Authorization(onlyAdmin = true)
public void create(DomainCreateReq req, UploadedFile jks) throws IOException {
ParamCheckUtil.checkNotNull(req, "req");
ParamCheckUtil.checkNotEmpty(req.getDomain(), "domain");
domainService.create(req, jks);
}
@Post
@Mapping(path = "/update")
@Authorization(onlyAdmin = true)
public void update(DomainUpdateReq req, UploadedFile jks) throws IOException {
ParamCheckUtil.checkNotNull(req, "req");
ParamCheckUtil.checkNotEmpty(req.getDomain(), "domain");
domainService.update(req, jks);
}
@Post
@Mapping(path = "/update/enable-status")
@Authorization(onlyAdmin = true)
public DomainUpdateEnableStatusRes updateEnableStatus(DomainUpdateEnableStatusReq req){
ParamCheckUtil.checkNotNull(req, "req");
ParamCheckUtil.checkNotNull(req.getId(), "id");
ParamCheckUtil.checkNotNull(req.getEnable(), "enable");
return domainService.updateEnableStatus(req);
}
@Post
@Mapping(path = "/delete")
@Authorization(onlyAdmin = true)
public void delete(DomainDeleteReq req) {
ParamCheckUtil.checkNotNull(req, "req");
ParamCheckUtil.checkNotNull(req.getId(), "id");
domainService.delete(req.getId());
}
@Post
@Mapping(path = "/update/default-status")
@Authorization(onlyAdmin = true)
public DomainUpdateDefaultStatusRes updateDefaultStatus(DomainUpdateDefaultStatusReq req){
ParamCheckUtil.checkNotNull(req, "req");
ParamCheckUtil.checkNotNull(req.getId(), "id");
ParamCheckUtil.checkNotNull(req.getIsDefault(), "isDefault");
return domainService.updateDefaultStatus(req.getId(), req.getIsDefault());
}
}
@@ -1,27 +0,0 @@
package org.dromara.neutrinoproxy.server.controller;
import lombok.extern.slf4j.Slf4j;
import org.dromara.neutrinoproxy.server.base.proxy.ProxyConfig;
import org.noear.solon.annotation.Controller;
import org.noear.solon.annotation.Get;
import org.noear.solon.annotation.Inject;
import org.noear.solon.annotation.Mapping;
/**
* @author: aoshiguchen
* @date: 2023/4/2
*/
@Slf4j
@Mapping("/domain-name")
@Controller
public class DomainNameController {
@Inject
private ProxyConfig proxyConfig;
@Get
@Mapping("/bind-info")
public String bindInfo () {
return proxyConfig.getServer().getTcp().getDomainName();
}
}
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller;
import org.dromara.neutrinoproxy.server.base.rest.Authorization;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller;
import org.dromara.neutrinoproxy.server.base.page.PageInfo;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller;
import org.dromara.neutrinoproxy.server.base.page.PageInfo;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller;
import org.dromara.neutrinoproxy.server.base.page.PageInfo;
@@ -30,7 +30,6 @@ public class PortMappingController {
@Mapping("/page")
public PageInfo<PortMappingListRes> page(PageQuery pageQuery, PortMappingListReq req) {
ParamCheckUtil.checkNotNull(pageQuery, "pageQuery");
return portMappingService.page(pageQuery, req);
}
@@ -53,7 +52,7 @@ public class PortMappingController {
ParamCheckUtil.checkNotNull(networkProtocolEnum, ExceptionConstant.AN_UNSUPPORTED_PROTOCOL, req.getProtocal());
if (networkProtocolEnum != NetworkProtocolEnum.HTTP) {
// 目前仅HTTP支持绑定域名
req.setSubdomain(null);
req.setDomainMappings(null);
}
req.setProtocal(networkProtocolEnum.getDesc());
if (null == req.getProxyResponses()) {
@@ -88,7 +87,7 @@ public class PortMappingController {
ParamCheckUtil.checkNotNull(networkProtocolEnum, ExceptionConstant.AN_UNSUPPORTED_PROTOCOL, req.getProtocal());
if (networkProtocolEnum != NetworkProtocolEnum.HTTP) {
// 目前仅HTTP支持绑定域名
req.setSubdomain(null);
req.setDomainMappings(null);
}
req.setProtocal(networkProtocolEnum.getDesc());
if (null == req.getProxyResponses()) {
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller;
import org.dromara.neutrinoproxy.server.base.page.PageInfo;
@@ -0,0 +1,26 @@
package org.dromara.neutrinoproxy.server.controller;
import org.dromara.neutrinoproxy.server.base.rest.Authorization;
import org.dromara.neutrinoproxy.server.controller.res.stats.StatsInfoRes;
import org.dromara.neutrinoproxy.server.util.ProxyUtil;
import org.noear.solon.annotation.Controller;
import org.noear.solon.annotation.Get;
import org.noear.solon.annotation.Mapping;
/**
*
* @author: wen.y
* @date: 2026/1/20
*/
@Mapping("/stats")
@Controller
public class StatsController {
@Authorization(login = false)
@Get
@Mapping("/info")
public StatsInfoRes info() {
return new StatsInfoRes().setCacheInfo(ProxyUtil.getCacheInfo());
}
}
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller;
import org.dromara.neutrinoproxy.server.base.page.PageInfo;
@@ -28,13 +7,11 @@ import org.dromara.neutrinoproxy.server.base.rest.SystemContextHolder;
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.res.system.*;
import org.dromara.neutrinoproxy.server.dal.UserMapper;
import org.dromara.neutrinoproxy.server.dal.entity.UserDO;
import org.dromara.neutrinoproxy.server.service.UserService;
import org.dromara.neutrinoproxy.server.util.Md5Util;
import org.dromara.neutrinoproxy.server.util.ParamCheckUtil;
import org.dromara.neutrinoproxy.server.controller.req.system.*;
import org.noear.solon.annotation.*;
import java.util.List;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller;
import org.dromara.neutrinoproxy.server.base.page.PageInfo;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.req.log;
import lombok.Data;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.req.log;
import lombok.Data;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.req.log;
import lombok.Data;
@@ -0,0 +1,25 @@
package org.dromara.neutrinoproxy.server.controller.req.proxy;
import lombok.Data;
/**
* @author Mirac
* @date 21/7/2024
*/
@Data
public class DomainCreateReq {
/**
* 主域名
*/
private String domain;
/**
* KeyStore密码
*/
private String keyStorePassword;
/**
* 强制Https
*/
private Integer forceHttps;
}
@@ -0,0 +1,15 @@
package org.dromara.neutrinoproxy.server.controller.req.proxy;
import lombok.Data;
/**
* @author Mirac
* @date 23/7/2024
*/
@Data
public class DomainDeleteReq {
/**
* id
*/
private Integer id;
}
@@ -0,0 +1,21 @@
package org.dromara.neutrinoproxy.server.controller.req.proxy;
import lombok.Data;
import org.dromara.neutrinoproxy.server.constant.EnableStatusEnum;
/**
* @author Mirac
* @date 21/7/2024
*/
@Data
public class DomainListReq {
/**
* 用户ID
*/
private Integer userId;
/**
* 启用状态
* {@link EnableStatusEnum}
*/
private Integer enable;
}
@@ -0,0 +1,22 @@
package org.dromara.neutrinoproxy.server.controller.req.proxy;
import lombok.Data;
import org.dromara.neutrinoproxy.server.constant.DefaultDomainStatusEnum;
/**
* @author Mirac
* @date 23/7/2024
*/
@Data
public class DomainUpdateDefaultStatusReq {
/**
* id
*/
private Integer id;
/**
* 启用状态 {@link DefaultDomainStatusEnum}
*/
private Integer isDefault;
}
@@ -0,0 +1,26 @@
package org.dromara.neutrinoproxy.server.controller.req.proxy;
import lombok.Data;
/**
* @author Mirac
* @date 23/7/2024
*/
@Data
public class DomainUpdateEnableStatusReq {
/**
* id
*/
private Integer id;
/**
* 启用状态
*/
private Integer enable;
/**
* 域名
*/
private String domain;
}
@@ -0,0 +1,30 @@
package org.dromara.neutrinoproxy.server.controller.req.proxy;
import lombok.Data;
/**
* @author Mirac
* @date 21/7/2024
*/
@Data
public class DomainUpdateReq {
/**
* id
*/
private Integer id;
/**
* 主域名
*/
private String domain;
/**
* KeyStore密码
*/
private String keyStorePassword;
/**
* 强制Https
*/
private Integer forceHttps;
}
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.req.proxy;
import lombok.Data;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.req.proxy;
import lombok.Data;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.req.proxy;
import lombok.Data;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.req.proxy;
import lombok.Data;
@@ -1,28 +1,9 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.req.proxy;
import lombok.Data;
import java.util.List;
/**
* 端口映射创建请求
* @author: aoshiguchen
@@ -38,10 +19,6 @@ public class PortMappingCreateReq {
* 协议
*/
private String protocal;
/**
* 子域名
*/
private String subdomain;
/**
* 服务端端口
*/
@@ -80,4 +57,15 @@ public class PortMappingCreateReq {
* 描述
*/
private String description;
/**
* 域名映射列表
*/
private List<DomainMapping> domainMappings;
@Data
public class DomainMapping {
private Integer domainId;
private String subdomain;
}
}
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.req.proxy;
import lombok.Data;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.req.proxy;
import org.dromara.neutrinoproxy.server.constant.EnableStatusEnum;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.req.proxy;
import lombok.Data;
@@ -1,28 +1,9 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.req.proxy;
import lombok.Data;
import java.util.List;
/**
* 端口映射更新请求
* @author: aoshiguchen
@@ -42,10 +23,6 @@ public class PortMappingUpdateReq {
* 协议
*/
private String protocal;
/**
* 子域名
*/
private String subdomain;
/**
* 服务端端口
*/
@@ -84,4 +61,16 @@ public class PortMappingUpdateReq {
* 描述
*/
private String description;
/**
* 域名映射列表
*/
private List<DomainMapping> domainMappings;
@Data
public class DomainMapping {
private Integer id;
private Integer domainId;
private String subdomain;
}
}
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.req.system;
import lombok.Data;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.req.system;
import lombok.Data;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.req.system;
import lombok.Data;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.req.system;
import lombok.Data;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.req.system;
import lombok.Data;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.req.system;
import lombok.Data;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.req.system;
import lombok.Data;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.req.system;
import lombok.Data;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.req.system;
import lombok.Data;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.req.system;
import lombok.Data;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.req.system;
import lombok.Data;
@@ -1,31 +1,18 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.req.system;
import lombok.Data;
/**
* 用户列表请求
* @author: aoshiguchen
* @date: 2022/8/14
*/
@Data
public class UserListReq {
/**
* 用户名
*/
private String name;
}
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.req.system;
import lombok.Data;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.req.system;
import lombok.Data;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.req.system;
import lombok.Data;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.res.log;
import lombok.Data;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.res.log;
import lombok.Data;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.res.log;
import lombok.Data;
@@ -0,0 +1,72 @@
package org.dromara.neutrinoproxy.server.controller.res.proxy;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import lombok.experimental.Accessors;
import org.dromara.neutrinoproxy.server.constant.DefaultDomainStatusEnum;
import org.dromara.neutrinoproxy.server.constant.EnableStatusEnum;
import org.dromara.neutrinoproxy.server.constant.HttpsStatusEnum;
import org.dromara.neutrinoproxy.server.constant.SslStatusEnum;
import java.util.Date;
/**
* @author Mirac
* @date 21/7/2024
*/
@Accessors(chain = true)
@Data
public class DomainListRes {
@TableId(type = IdType.AUTO)
private Integer id;
/**
* 主域名
*/
private String domain;
/**
* 用户ID
*/
private Integer userId;
/**
* 用户名
*/
private String userName;
/**
* 是否是默认域名(1 2)
* {@link DefaultDomainStatusEnum}
*/
private Integer isDefault;
/**
* 强制使用HTTPS(1 2)
* {@link HttpsStatusEnum}
*/
private Integer forceHttps;
/**
* 启用状态
* {@link EnableStatusEnum}
*/
private Integer enable;
/**
* SSLStatusEnum
* {@link SslStatusEnum}
*/
private Integer sslStatus;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
}
@@ -0,0 +1,8 @@
package org.dromara.neutrinoproxy.server.controller.res.proxy;
/**
* @author Mirac
* @date 23/7/2024
*/
public class DomainUpdateDefaultStatusRes {
}
@@ -0,0 +1,8 @@
package org.dromara.neutrinoproxy.server.controller.res.proxy;
/**
* @author Mirac
* @date 23/7/2024
*/
public class DomainUpdateEnableStatusRes {
}
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.res.proxy;
import lombok.Data;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.res.proxy;
import org.dromara.neutrinoproxy.server.constant.EnableStatusEnum;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.res.proxy;
/**
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.res.proxy;
/**
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.res.proxy;
import lombok.Data;
@@ -1,31 +1,12 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.res.proxy;
import lombok.Data;
import org.dromara.neutrinoproxy.server.constant.EnableStatusEnum;
import org.dromara.neutrinoproxy.server.constant.OnlineStatusEnum;
import lombok.Data;
import org.dromara.neutrinoproxy.server.service.bo.FullDomainNameBO;
import java.util.Date;
import java.util.List;
/**
* 端口映射列表响应
@@ -43,14 +24,10 @@ public class PortMappingListRes {
* 协议
*/
private String protocal;
/**
* 子域名
*/
private String subdomain;
/**
* 域名
*/
private String domain;
/**
* 完整域名映射
*/
private List<FullDomainNameBO> fullDomainMappings;
/**
* license名称
*/
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.res.proxy;
import lombok.Data;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.res.proxy;
import lombok.Data;
@@ -0,0 +1,31 @@
package org.dromara.neutrinoproxy.server.controller.res.stats;
import lombok.Data;
import lombok.experimental.Accessors;
/**
*
* @author: wen.y
* @date: 2026/1/20
*/
@Accessors(chain = true)
@Data
public class StatsInfoRes {
private CacheInfo cacheInfo;
@Data
public static class CacheInfo {
private Integer proxyInfoMapSize;
private Integer serverPortToCmdChannelMapSize;
private Integer licenseToCmdChannelMapSize;
private Integer serverPortToVisitorChannelMapSize;
private Integer proxyConnectAttachmentMapSize;
private Integer fullDomainToServerPortMapSize;
private Integer domainToDomainNameIdMapSize;
private Integer licenseIdToClientIdMapSize;
private Integer visitorIdToSocketAddressMapSize;
private Integer socketAddressToVisitorIdMapSize;
private Integer visitorIdToTunnelChannelMapSize;
}
}
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.res.system;
import lombok.Data;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.res.system;
import lombok.Data;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.res.system;
import lombok.Data;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.res.system;
import lombok.Data;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.res.system;
import lombok.Data;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.res.system;
import lombok.Data;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.res.system;
import lombok.Data;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.res.system;
import lombok.Data;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.res.system;
import lombok.Data;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.res.system;
/**
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.res.system;
import lombok.Data;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.res.system;
import lombok.Data;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.res.system;
/**
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.controller.res.system;
/**
@@ -0,0 +1,61 @@
package org.dromara.neutrinoproxy.server.dal;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.dromara.neutrinoproxy.server.dal.entity.DomainNameDO;
import org.dromara.neutrinoproxy.server.service.bo.FullDomainNameBO;
import java.util.Date;
import java.util.List;
import java.util.Set;
@Mapper
public interface DomainMapper extends BaseMapper<DomainNameDO> {
default DomainNameDO checkRepeat(String domain, Set<Integer> excludeIds) {
// 查询与输入域名相关的域名列表
List<DomainNameDO> domainList = this.selectList(new LambdaQueryWrapper<DomainNameDO>()
.notIn(excludeIds != null, DomainNameDO::getId, excludeIds)
);
// 遍历数据库中的域名检查是否存在重复包括子域名
for (DomainNameDO domainNameDO : domainList) {
String existingDomain = domainNameDO.getDomain();
// 完全相等的情况
if (existingDomain.equals(domain)) {
return domainNameDO;
}
// // 是子域名关系
// if (isSubdomainOrEqual(existingDomain, domain)) {
// return domainNameDO;
// }
}
// 如果没有找到重复的返回 null
return null;
}
// 辅助方法判断 domain1 是否是 domain2 的子域名或者两者相等
private boolean isSubdomainOrEqual(String domain1, String domain2) {
// 判断是否是子域名关系例如 "proxy.asgc.fun" "asgc.fun" 的子域名
return domain1.endsWith("." + domain2) || domain2.endsWith("." + domain1);
}
default void updateEnableStatus(Integer id, Integer enable, Date updateTime) {
this.update(Wrappers.<DomainNameDO>lambdaUpdate()
.eq(DomainNameDO::getId, id)
.set(DomainNameDO::getEnable, enable)
.set(DomainNameDO::getUpdateTime, updateTime)
);
}
List<FullDomainNameBO> selectFullDomainNameListByPortMappingIds(@Param("ids") Set<Integer> ids);
List<FullDomainNameBO> selectFullDomainNameListByDomainNameIds(@Param("ids") Set<Integer> ids);
List<FullDomainNameBO> selectFullDomainNameList();
}
@@ -0,0 +1,41 @@
package org.dromara.neutrinoproxy.server.dal;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.apache.ibatis.annotations.Mapper;
import org.dromara.neutrinoproxy.server.dal.entity.DomainPortMappingDO;
import java.util.List;
/**
* @author: Mirac
* @date: 2024/8/24
*/
@Mapper
public interface DomainPortMappingMapper extends BaseMapper<DomainPortMappingDO> {
default Boolean checkRepeatBySubdomain(String subdomain, Integer domainNameId, Integer id) {
return StringUtils.isEmpty(subdomain)? Boolean.FALSE : this.selectCount(new LambdaQueryWrapper<DomainPortMappingDO>()
.eq(DomainPortMappingDO::getSubdomain, subdomain)
.eq(DomainPortMappingDO::getDomainNameId, domainNameId)
.ne(id != null, DomainPortMappingDO::getId, id)
.last("limit 1")
).intValue() > 0;
}
default List<DomainPortMappingDO> findByPortMappingId(Integer portMappingId) {
return this.selectList(Wrappers.<DomainPortMappingDO>lambdaQuery()
.eq(DomainPortMappingDO::getPortMappingId, portMappingId));
}
default void deleteByDomainNameId(Integer doomainNameId) {
this.delete(Wrappers.<DomainPortMappingDO>lambdaQuery()
.eq(DomainPortMappingDO::getDomainNameId, doomainNameId));
}
default boolean checkUsed(Integer domainNameId) {
return this.exists(Wrappers.<DomainPortMappingDO>lambdaQuery()
.eq(DomainPortMappingDO::getDomainNameId, domainNameId));
}
}
@@ -11,6 +11,7 @@ import org.dromara.neutrinoproxy.server.controller.req.proxy.PortMappingListReq;
import org.dromara.neutrinoproxy.server.dal.entity.PortMappingDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.dromara.neutrinoproxy.server.service.bo.FullDomainNameBO;
import java.util.Date;
import java.util.List;
@@ -44,18 +45,6 @@ public interface PortMappingMapper extends BaseMapper<PortMappingDO> {
);
}
/**
* 校验子域名是否重复
* @param subdomain
* @return
*/
default Boolean checkRepeatBySubdomain(String subdomain, Set<Integer> excludeIds) {
return StringUtils.isEmpty(subdomain)? Boolean.FALSE : this.selectCount(new LambdaQueryWrapper<PortMappingDO>()
.eq(PortMappingDO::getSubdomain, subdomain)
.notIn(!CollectionUtil.isEmpty(excludeIds), PortMappingDO::getId, excludeIds)
).intValue() > 0;
}
default List<PortMappingDO> findEnableListByLicenseId(Integer licenseId) {
return this.selectList(new LambdaQueryWrapper<PortMappingDO>()
.eq(PortMappingDO::getLicenseId, licenseId)
@@ -0,0 +1,104 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
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;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.Accessors;
import org.dromara.neutrinoproxy.server.constant.*;
import org.dromara.neutrinoproxy.server.controller.res.proxy.DomainListRes;
import org.dromara.neutrinoproxy.server.controller.res.proxy.PortMappingListRes;
import java.util.Date;
/**
* 域名
* @author: Mirac
* @date: 2024/7/21
*/
@ToString
@Accessors(chain = true)
@Data
@TableName("domain_name")
public class DomainNameDO {
@TableId(type = IdType.AUTO)
private Integer id;
/**
* 主域名
*/
private String domain;
/**
* 用户ID
*/
private Integer userId;
/**
* SSL证书文件内容
*/
private byte[] jks;
/**
* KeyStore密码
*/
private String keyStorePassword;
/**
* 是否是默认域名(1 2)
* {@link DefaultDomainStatusEnum}
*/
private Integer isDefault;
/**
* 强制使用HTTPS(1 2)
* {@link HttpsStatusEnum}
*/
private Integer forceHttps;
/**
* 启用状态
* {@link EnableStatusEnum}
*/
private Integer enable;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
public DomainListRes toRes() {
DomainListRes res = new DomainListRes();
BeanUtil.copyProperties(this, res);
res.setSslStatus(this.getJks() == null ? SslStatusEnum.NOT_UPLOADED.getStatus() : SslStatusEnum.UPLOADED.getStatus());
return res;
}
}
@@ -0,0 +1,64 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
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;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.Accessors;
import org.dromara.neutrinoproxy.server.constant.EnableStatusEnum;
import org.dromara.neutrinoproxy.server.constant.OnlineStatusEnum;
import org.dromara.neutrinoproxy.server.controller.res.proxy.PortMappingListRes;
import java.util.Date;
/**
* @author: Mirac
* @date: 2024/8/24
*/
@ToString
@Accessors(chain = true)
@Data
@TableName("domain_port_mapping")
public class DomainPortMappingDO {
/**
* 主键
*/
@TableId(type = IdType.AUTO)
private Integer id;
/**
* 端口映射id
*/
private Integer portMappingId;
/**
* 域名id
*/
private Integer domainNameId;
/**
* 子域名
*/
private String subdomain;
}
@@ -54,10 +54,6 @@ public class PortMappingDO {
* 协议
*/
private String protocal;
/**
* 子域名
*/
private String subdomain;
/**
* 服务端端口
*/
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.job;
import cn.hutool.core.collection.CollectionUtil;
@@ -1,25 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.proxy.core;
import org.dromara.neutrinoproxy.server.proxy.domain.MetricsCollector;
@@ -1,27 +1,6 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.proxy.core;
import io.netty.handler.codec.DecoderException;
import org.dromara.neutrinoproxy.core.Constants;
import org.dromara.neutrinoproxy.core.ProxyMessage;
import org.dromara.neutrinoproxy.core.dispatcher.Dispatcher;
@@ -39,7 +18,9 @@ import io.netty.handler.timeout.IdleStateEvent;
import lombok.extern.slf4j.Slf4j;
import org.noear.solon.Solon;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.SocketException;
import java.util.Date;
/**
@@ -73,6 +54,7 @@ public class ProxyTunnelChannelHandler extends SimpleChannelInboundHandler<Proxy
Channel visitorChannel = ctx.channel().attr(Constants.NEXT_CHANNEL).get();
if (visitorChannel != null) {
visitorChannel.config().setOption(ChannelOption.AUTO_READ, ctx.channel().isWritable());
// visitorChannel.config().setAutoRead(ctx.channel().isWritable());
}
super.channelWritabilityChanged(ctx);
@@ -80,6 +62,13 @@ public class ProxyTunnelChannelHandler extends SimpleChannelInboundHandler<Proxy
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
{
// udp情况下不能使用visitorChannel上的visitorId因为所有的用户都是走的同一个VisitorChannel
String visitorId = ctx.channel().attr(Constants.VISITOR_ID).get();
// 删除Udp的SocketAddress
ProxyUtil.removeSocketAddressByVisitorId(visitorId);
}
Channel visitorChannel = ctx.channel().attr(Constants.NEXT_CHANNEL).get();
if (null != visitorChannel) {
Integer licenseId = ctx.channel().attr(Constants.LICENSE_ID).get();
@@ -96,7 +85,7 @@ public class ProxyTunnelChannelHandler extends SimpleChannelInboundHandler<Proxy
if (visitorChannel.isActive() && null == isUdp) {
// 数据发送完成后再关闭连接解决http1.0数据传输问题
visitorChannel.writeAndFlush(Unpooled.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE);
visitorChannel.close();
// visitorChannel.close();
}
} else {
CmdChannelAttachInfo cmdChannelAttachInfo = ProxyUtil.getAttachInfo(ctx.channel());
@@ -126,11 +115,29 @@ 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();
// }
log.error("[Tunnel Channel] error", cause);
// 对于网络IO异常致命异常关闭channel以防止资源泄漏
// 对于其他异常可能是可恢复的业务异常只记录日志
if (cause instanceof IOException) {
// IOException及其子类包括SocketException都是致命的网络异常
if (cause instanceof SocketException && cause.getMessage() != null && cause.getMessage().contains("Connection reset")) {
// Connection reset是常见的客户端断开使用debug级别
log.debug("[Tunnel Channel] Connection reset: {}", cause.getMessage());
} else {
log.error("[Tunnel Channel] IO error", cause);
}
if (ctx.channel().isActive()) {
ctx.channel().close();
}
} else if(cause instanceof DecoderException) {
// 协议解析错误为防止数据污染立即关闭
log.debug("[Tunnel Channel] decoder error: {}", cause.getMessage());
if (ctx.channel().isActive()) {
ctx.channel().close();
}
} else {
// 其他异常只记录日志不关闭channel让Netty自己处理
log.error("[Tunnel Channel] error", cause);
}
}
@Override
@@ -1,5 +1,7 @@
package org.dromara.neutrinoproxy.server.proxy.core;
import io.netty.channel.ChannelOption;
import io.netty.channel.WriteBufferWaterMark;
import io.netty.handler.logging.LoggingHandler;
import org.dromara.neutrinoproxy.core.ProxyMessageDecoder;
import org.dromara.neutrinoproxy.core.ProxyMessageEncoder;
@@ -54,6 +56,12 @@ public class ProxyTunnelServer implements EventListener<AppLoadEndEvent> {
*/
private void startProxyServer() {
ServerBootstrap bootstrap = new ServerBootstrap();
WriteBufferWaterMark waterMark = proxyConfig.getWaterMark();
if (null != waterMark) {
bootstrap.childOption(ChannelOption.WRITE_BUFFER_WATER_MARK, waterMark);
}
bootstrap.group(serverBossGroup, serverWorkerGroup).channel(NioServerSocketChannel.class).childHandler(new ChannelInitializer<SocketChannel>() {
@Override
@@ -91,8 +99,7 @@ public class ProxyTunnelServer implements EventListener<AppLoadEndEvent> {
}
private ChannelHandler createSslHandler() {
try {
InputStream jksInputStream = FileUtil.getInputStream(proxyConfig.getTunnel().getJksPath());
try (InputStream jksInputStream = FileUtil.getInputStream(proxyConfig.getTunnel().getJksPath())) {
SSLContext serverContext = SSLContext.getInstance("TLS");
final KeyStore ks = KeyStore.getInstance("JKS");
@@ -2,10 +2,9 @@ package org.dromara.neutrinoproxy.server.proxy.core;
import cn.hutool.core.util.StrUtil;
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOption;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.buffer.Unpooled;
import io.netty.channel.*;
import io.netty.handler.codec.DecoderException;
import lombok.extern.slf4j.Slf4j;
import org.dromara.neutrinoproxy.core.Constants;
import org.dromara.neutrinoproxy.core.ProxyMessage;
@@ -15,7 +14,9 @@ import org.dromara.neutrinoproxy.server.service.FlowReportService;
import org.dromara.neutrinoproxy.server.util.ProxyUtil;
import org.noear.solon.Solon;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.SocketException;
/**
*
@@ -27,9 +28,29 @@ public class TcpVisitorChannelHandler extends SimpleChannelInboundHandler<ByteBu
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
// 当出现异常就关闭连接
ctx.close();
log.error("VisitorChannel error", cause);
// 对于网络IO异常致命异常关闭channel以防止资源泄漏
// 对于其他异常可能是可恢复的业务异常只记录日志
if (cause instanceof IOException) {
// IOException及其子类包括SocketException都是致命的网络异常
if (cause instanceof SocketException && cause.getMessage() != null && cause.getMessage().contains("Connection reset")) {
// Connection reset是常见的客户端断开使用debug级别
log.debug("[TCP Visitor Channel] connection reset: {}", cause.getMessage());
} else {
log.error("[TCP Visitor Channel] IO error", cause);
}
if (ctx.channel().isActive()) {
ctx.channel().close();
}
} else if(cause instanceof DecoderException) {
// 协议解析错误为防止数据污染立即关闭
log.debug("[TCP Visitor Channel] decoder error: {}", cause.getMessage());
if (ctx.channel().isActive()) {
ctx.channel().close();
}
} else {
// 其他异常只记录日志不关闭channel让Netty自己处理
log.error("[TCP Visitor Channel] error", cause);
}
}
@Override
@@ -95,11 +116,7 @@ public class TcpVisitorChannelHandler extends SimpleChannelInboundHandler<ByteBu
InetSocketAddress sa = (InetSocketAddress) visitorChannel.localAddress();
Channel cmdChannel = ProxyUtil.getCmdChannelByServerPort(sa.getPort());
if (null == cmdChannel) {
// 该端口还没有代理客户端
ctx.channel().close();
} else {
if (null != cmdChannel) {
// 用户连接断开从控制连接中移除
String visitorId = ProxyUtil.getVisitorIdByChannel(visitorChannel);
ProxyUtil.removeVisitorChannelFromCmdChannel(cmdChannel, visitorId);
@@ -116,6 +133,8 @@ public class TcpVisitorChannelHandler extends SimpleChannelInboundHandler<ByteBu
proxyChannel.config().setOption(ChannelOption.AUTO_READ, true);
// 通知客户端用户连接已经断开
proxyChannel.writeAndFlush(ProxyMessage.buildDisconnectMessage(visitorId));
proxyChannel.writeAndFlush(Unpooled.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE);
}
}
@@ -138,6 +157,7 @@ public class TcpVisitorChannelHandler extends SimpleChannelInboundHandler<ByteBu
Channel proxyChannel = visitorChannel.attr(Constants.NEXT_CHANNEL).get();
if (null != proxyChannel) {
proxyChannel.config().setOption(ChannelOption.AUTO_READ, visitorChannel.isWritable());
// proxyChannel.config().setAutoRead(visitorChannel.isWritable());
}
}
@@ -10,7 +10,6 @@ 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;
@@ -33,8 +32,13 @@ public class UdpVisitorChannelHandler extends SimpleChannelInboundHandler<Datagr
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();
Constants.ProxyAttachment proxyAttachment = new Constants.ProxyAttachment(bytes, (channel, buf) -> {
String visitorId = ProxyUtil.getVisitorIdBySocketAddress(datagramPacket.sender());
if (StrUtil.isBlank(visitorId)) {
return;
}
Channel proxyChannel = ProxyUtil.getTunnelChannelByVisitorId(visitorId);
// Channel proxyChannel = channel.attr(Constants.NEXT_CHANNEL).get();
if (null == proxyChannel) {
// // 该端口还没有代理客户端
@@ -49,7 +53,6 @@ public class UdpVisitorChannelHandler extends SimpleChannelInboundHandler<Datagr
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())
@@ -65,10 +68,11 @@ public class UdpVisitorChannelHandler extends SimpleChannelInboundHandler<Datagr
Solon.context().getBean(FlowReportService.class).addWriteByte(visitorChannelAttachInfo.getLicenseId(), bytes.length);
});
Channel proxyChannel = ctx.channel().attr(Constants.NEXT_CHANNEL).get();
if (null != proxyChannel && proxyChannel.isActive()) {
String visitorId = ProxyUtil.getVisitorIdBySocketAddress(datagramPacket.sender());
Channel proxyChannel = ProxyUtil.getTunnelChannelByVisitorId(visitorId);
if (StrUtil.isNotBlank(visitorId) && null != proxyChannel && proxyChannel.isActive()) {
// UDP代理隧道已就绪直接转发
proxyAttachment.execute();
proxyAttachment.execute(ctx.channel());
return;
}
@@ -95,8 +99,10 @@ public class UdpVisitorChannelHandler extends SimpleChannelInboundHandler<Datagr
// // 用户连接到代理服务器时设置用户连接不可读等待代理后端服务器连接成功后再改变为可读状态
// visitorChannel.config().setOption(ChannelOption.AUTO_READ, false);
// TODO UDP此处叫visitor似有不妥与TCP不同,2.x重构思考
String visitorId = ProxyUtil.newVisitorId();
// UDP场景下一个visitorId并不对应一个visitorChannel所有visitor共用一个visitorChannel
visitorId = ProxyUtil.newVisitorId();
// 设置udp发送方的地址
ProxyUtil.setVisitorIdToSocketAddressMap(visitorId, datagramPacket.sender());
// 此处需要和tcp分开
ProxyUtil.addVisitorChannelToCmdChannel(NetworkProtocolEnum.UDP, cmdChannel, visitorId, visitorChannel, sa.getPort());
ProxyUtil.addProxyConnectAttachment(visitorId, proxyAttachment);
@@ -105,6 +111,7 @@ public class UdpVisitorChannelHandler extends SimpleChannelInboundHandler<Datagr
.setServerPort(sa.getPort())
.setTargetIp(targetIp)
.setTargetPort(targetPort)
// connect消息没有传超时时间响应数量导致客户端日志输出的超时时间响应数量都是0
));
}
@@ -113,12 +120,32 @@ public class UdpVisitorChannelHandler extends SimpleChannelInboundHandler<Datagr
super.channelActive(ctx);
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
// 当出现异常就关闭连接
ctx.close();
log.error("[UDP Visitor Channel]VisitorChannel error", cause);
}
// @Override
// public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
// // 对于网络IO异常致命异常关闭channel以防止资源泄漏
// // 对于其他异常可能是可恢复的业务异常只记录日志
// if (cause instanceof IOException) {
// // IOException及其子类包括SocketException都是致命的网络异常
// if (cause instanceof SocketException && cause.getMessage() != null && cause.getMessage().contains("Connection reset")) {
// // Connection reset是常见的客户端断开使用debug级别
// log.debug("[UDP Visitor Channel] Connection reset: {}", cause.getMessage());
// } else {
// log.error("[UDP Visitor Channel] IO error", cause);
// }
// if (ctx.channel().isActive()) {
// ctx.channel().close();
// }
// } else if(cause instanceof DecoderException) {
// // 协议解析错误为防止数据污染立即关闭
// log.debug("[UDP Visitor Channel] decoder error: {}", cause.getMessage());
// if (ctx.channel().isActive()) {
// ctx.channel().close();
// }
// } else {
// // 其他异常只记录日志不关闭channel让Netty自己处理
// log.error("[UDP Visitor Channel] error", cause);
// }
// }
@Override
public void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception {
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.proxy.domain;
import io.netty.channel.Channel;
@@ -1,25 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.proxy.domain;
import java.util.ArrayList;
@@ -1,29 +1,28 @@
package org.dromara.neutrinoproxy.server.proxy.domain;
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import java.util.function.BiConsumer;
/**
* 代理连接附件
* @author: aoshiguchen
* @date: 2023/4/2
*/
public class ProxyAttachment {
private Channel channel;
private byte[] bytes;
private BiConsumer<Channel, byte[]> executor;
public ProxyAttachment(Channel channel, byte[] bytes, BiConsumer<Channel, byte[]> executor) {
this.channel = channel;
this.bytes = bytes;
this.executor = executor;
}
public void execute() {
if (null != executor) {
this.executor.accept(channel, bytes);
}
}
}
//package org.dromara.neutrinoproxy.server.proxy.domain;
//
//import io.netty.channel.Channel;
//
//import java.util.function.BiConsumer;
//
///**
// * 代理连接附件
// * @author: aoshiguchen
// * @date: 2023/4/2
// */
//public class ProxyAttachment {
// private Channel channel;
// private byte[] bytes;
// private BiConsumer<Channel, byte[]> executor;
//
// public ProxyAttachment(Channel channel, byte[] bytes, BiConsumer<Channel, byte[]> executor) {
// this.channel = channel;
// this.bytes = bytes;
// this.executor = executor;
// }
//
// public void execute() {
// if (null != executor) {
// this.executor.accept(channel, bytes);
// }
// }
//}
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.proxy.domain;
import lombok.Data;
@@ -1,16 +1,13 @@
package org.dromara.neutrinoproxy.server.proxy.enhance;
import cn.hutool.core.util.StrUtil;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.*;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.handler.logging.LoggingHandler;
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;
@@ -30,8 +27,8 @@ public class HttpProxy implements EventListener<AppLoadEndEvent> {
private ProxyConfig proxyConfig;
@Override
public void onEvent(AppLoadEndEvent appLoadEndEvent) throws Throwable {
if (StrUtil.isBlank(proxyConfig.getServer().getTcp().getDomainName()) || null == proxyConfig.getServer().getTcp().getHttpProxyPort()) {
log.info("no config domain name,nonsupport http proxy.");
if (null == proxyConfig.getServer().getTcp().getHttpProxyPort()) {
log.info("no config http proxy port, nonsupport http proxy.");
return;
}
this.start();
@@ -47,8 +44,8 @@ public class HttpProxy implements EventListener<AppLoadEndEvent> {
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 HttpVisitorSecurityChannelHandler(proxyConfig.getServer().getTcp().getDomainName()));
// ch.pipeline().addFirst(new BytesMetricsHandler());
ch.pipeline().addLast(new HttpVisitorSecurityChannelHandler(false));
ch.pipeline().addLast("flowLimiter",new VisitorFlowLimiterChannelHandler());
ch.pipeline().addLast(new HttpVisitorChannelHandler());
}
@@ -1,22 +1,22 @@
package org.dromara.neutrinoproxy.server.proxy.enhance;
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 io.netty.buffer.Unpooled;
import io.netty.channel.*;
import io.netty.handler.codec.DecoderException;
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;
import org.dromara.neutrinoproxy.server.util.ProxyUtil;
import org.noear.solon.Solon;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.SocketException;
/**
* @author: aoshiguchen
@@ -30,7 +30,7 @@ public class HttpVisitorChannelHandler extends SimpleChannelInboundHandler<ByteB
byte[] bytes = new byte[byteBuf.readableBytes()];
byteBuf.readBytes(bytes);
byteBuf.resetReaderIndex();
ProxyAttachment proxyAttachment = new ProxyAttachment(ctx.channel(), bytes, (channel, buf) -> {
Constants.ProxyAttachment proxyAttachment = new Constants.ProxyAttachment(bytes, (channel, buf) -> {
Channel proxyChannel = channel.attr(Constants.NEXT_CHANNEL).get();
if (null == proxyChannel) {
// 该端口还没有代理客户端
@@ -47,7 +47,7 @@ public class HttpVisitorChannelHandler extends SimpleChannelInboundHandler<ByteB
String visitorId = ProxyUtil.getVisitorIdByChannel(ctx.channel());
if (StringUtils.isNotBlank(visitorId)) {
proxyAttachment.execute();
proxyAttachment.execute(ctx.channel());
return;
}
@@ -70,7 +70,8 @@ public class HttpVisitorChannelHandler extends SimpleChannelInboundHandler<ByteB
visitorId = ProxyUtil.newVisitorId();
ProxyUtil.addVisitorChannelToCmdChannel(NetworkProtocolEnum.HTTP, cmdChannel, visitorId, ctx.channel(), serverPort);
ProxyUtil.addProxyConnectAttachment(visitorId, proxyAttachment);
// ProxyUtil.addProxyConnectAttachment(visitorId, proxyAttachment);
ctx.channel().attr(Constants.PROXY_CONNECT_ATTACHMENT).set(proxyAttachment);
cmdChannel.writeAndFlush(ProxyMessage.buildConnectMessage(visitorId).setData(lanInfo.getBytes()));
}
@@ -82,11 +83,7 @@ public class HttpVisitorChannelHandler extends SimpleChannelInboundHandler<ByteB
InetSocketAddress sa = (InetSocketAddress) visitorChannel.localAddress();
Channel cmdChannel = ProxyUtil.getCmdChannelByServerPort(sa.getPort());
if (cmdChannel == null) {
// 该端口还没有代理客户端
ctx.channel().close();
} else {
if (null != cmdChannel) {
// 用户连接断开从控制连接中移除
String visitorId = ProxyUtil.getVisitorIdByChannel(visitorChannel);
ProxyUtil.removeVisitorChannelFromCmdChannel(cmdChannel, visitorId);
@@ -103,6 +100,8 @@ public class HttpVisitorChannelHandler extends SimpleChannelInboundHandler<ByteB
proxyChannel.config().setOption(ChannelOption.AUTO_READ, true);
// 通知客户端用户连接已经断开
proxyChannel.writeAndFlush(ProxyMessage.buildDisconnectMessage(visitorId));
proxyChannel.writeAndFlush(Unpooled.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE);
}
}
@@ -116,8 +115,29 @@ public class HttpVisitorChannelHandler extends SimpleChannelInboundHandler<ByteB
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
// 当出现异常就关闭连接
ctx.close();
// 对于网络IO异常致命异常关闭channel以防止资源泄漏
// 对于其他异常可能是可恢复的业务异常只记录日志
if (cause instanceof IOException) {
// IOException及其子类包括SocketException都是致命的网络异常
if (cause instanceof SocketException && cause.getMessage() != null && cause.getMessage().contains("Connection reset")) {
// Connection reset是常见的客户端断开使用debug级别
log.debug("[HTTP Visitor Channel] Connection reset: {}", cause.getMessage());
} else {
log.error("[HTTP Visitor Channel] IO error", cause);
}
if (ctx.channel().isActive()) {
ctx.channel().close();
}
} else if(cause instanceof DecoderException) {
// 协议解析错误为防止数据污染立即关闭
log.debug("[HTTP Visitor Channel] decoder error: {}", cause.getMessage());
if (ctx.channel().isActive()) {
ctx.channel().close();
}
} else {
// 其他异常只记录日志不关闭channel让Netty自己处理
log.error("[HTTP Visitor Channel] error", cause);
}
}
@Override
@@ -1,19 +1,15 @@
package org.dromara.neutrinoproxy.server.proxy.enhance;
import cn.hutool.core.util.StrUtil;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.*;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.handler.logging.LoggingHandler;
import io.netty.handler.ssl.SslHandler;
import io.netty.handler.ssl.SniHandler;
import io.netty.handler.ssl.SslContext;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
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;
@@ -21,10 +17,6 @@ import org.noear.solon.annotation.Inject;
import org.noear.solon.core.event.AppLoadEndEvent;
import org.noear.solon.core.event.EventListener;
import javax.net.ssl.*;
import java.io.InputStream;
import java.security.KeyStore;
/**
* HTTPS代理
* @author: aoshiguchen
@@ -35,11 +27,13 @@ import java.security.KeyStore;
public class HttpsProxy implements EventListener<AppLoadEndEvent> {
@Inject
private ProxyConfig proxyConfig;
@Inject
private SslContextManager sslContextManager;
@Override
public void onEvent(AppLoadEndEvent appLoadEndEvent) throws Throwable {
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.");
public void onEvent(AppLoadEndEvent appLoadEndEvent) {
if (null == proxyConfig.getServer().getTcp().getHttpsProxyPort()) {
log.info("no config https proxy port, nonsupport http proxy.");
return;
}
this.start();
@@ -55,9 +49,9 @@ public class HttpsProxy implements EventListener<AppLoadEndEvent> {
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 HttpVisitorSecurityChannelHandler(proxyConfig.getServer().getTcp().getDomainName()));
ch.pipeline().addLast(createSniHandler());
// ch.pipeline().addFirst(new BytesMetricsHandler());
ch.pipeline().addLast(new HttpVisitorSecurityChannelHandler(true));
ch.pipeline().addLast("flowLimiter",new VisitorFlowLimiterChannelHandler());
ch.pipeline().addLast(new HttpVisitorChannelHandler());
}
@@ -69,26 +63,19 @@ public class HttpsProxy implements EventListener<AppLoadEndEvent> {
}
}
private ChannelHandler createSslHandler() {
public SniHandler createSniHandler() {
try {
InputStream jksInputStream = FileUtil.getInputStream(proxyConfig.getServer().getTcp().getJksPath());
SSLContext serverContext = SSLContext.getInstance("TLS");
final KeyStore ks = KeyStore.getInstance("JKS");
ks.load(jksInputStream, proxyConfig.getServer().getTcp().getKeyStorePassword().toCharArray());
final KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
kmf.init(ks, proxyConfig.getServer().getTcp().getKeyStorePassword().toCharArray());
TrustManager[] trustManagers = null;
serverContext.init(kmf.getKeyManagers(), trustManagers, null);
SSLEngine sslEngine = serverContext.createSSLEngine();
sslEngine.setUseClientMode(false);
sslEngine.setNeedClientAuth(false);
return new SslHandler(sslEngine);
return new SniHandler(domainName -> {
SslContext sslContext = sslContextManager.getSslContextByFullDomain(domainName);
if (sslContext != null) {
return sslContext;
} else {
log.info("No SSL context available for domain: {}", domainName);
return null;
}
});
} catch (Exception e) {
log.error("create SSL handler failed", e);
log.info("create SSL handler failed", e);
e.printStackTrace();
}
return null;
@@ -0,0 +1,126 @@
package org.dromara.neutrinoproxy.server.proxy.enhance;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.netty.handler.ssl.ClientAuth;
import io.netty.handler.ssl.SslContext;
import io.netty.handler.ssl.SslContextBuilder;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.solon.annotation.Db;
import org.dromara.neutrinoproxy.server.base.db.DBInitialize;
import org.dromara.neutrinoproxy.server.dal.DomainMapper;
import org.dromara.neutrinoproxy.server.dal.entity.DomainNameDO;
import org.dromara.neutrinoproxy.server.util.ProxyUtil;
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 javax.net.ssl.KeyManagerFactory;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.security.KeyStore;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
/**
* 域名到SSL上下文
* @author: Mirac
* @date: 2024/8/25
*/
@Slf4j
@Component
@Data
public class SslContextManager implements EventListener<AppLoadEndEvent> {
@Db
private DomainMapper domainMapper;
@Inject
private DBInitialize dbInitialize;
// 初始化时加载所有域名的 SSL 上下文
@Init
public void init() throws Throwable {
// aot 阶段不初始化
if (NativeDetector.isAotRuntime()) {
return;
}
try {
initializeSslContexts();
} catch (Exception e) {
log.error("initialize SSL handler failed", e);
throw e;
}
}
@Override
public void onEvent(AppLoadEndEvent appLoadEndEvent) throws Throwable {
}
// 维护域名到 SslContext 的映射
private final ConcurrentHashMap<String, SslContext> domainSslContexts = new ConcurrentHashMap<>();
// 初始化所有域名的 SSL 上下文
private void initializeSslContexts() throws Exception {
List<DomainNameDO> domainNameDOS = domainMapper.selectList(Wrappers.<DomainNameDO>lambdaQuery()
.isNotNull(DomainNameDO::getDomain)
.isNotNull(DomainNameDO::getJks)
.isNotNull(DomainNameDO::getKeyStorePassword));
for (DomainNameDO domainNameDO : domainNameDOS) {
if (domainNameDO.getDomain() != null && domainNameDO.getKeyStorePassword() != null && domainNameDO.getJks() != null) {
String domain = domainNameDO.getDomain();
byte[] jks = domainNameDO.getJks();// 假设数据库中存储了每个域名对应的 JKS 路径
String keyStorePassword = domainNameDO.getKeyStorePassword();
SslContext sslContext = loadSslContextFromJks(jks, keyStorePassword);
domainSslContexts.put(domain, sslContext);
}
}
}
// 动态添加新的域名和证书
public void addDomainAndCert(String domain, byte[] jks, String keyStorePassword) throws Exception {
SslContext sslContext = loadSslContextFromJks(jks, keyStorePassword);
domainSslContexts.put(domain, sslContext);
}
// 使用 JKS 文件加载 SSL 上下文禁用客户端认证并设置为服务器模式
private SslContext loadSslContextFromJks(byte[] jks, String keyStorePassword) throws Exception {
InputStream jksInputStream = new ByteArrayInputStream(jks);
// 初始化 KeyStore
KeyStore keyStore = KeyStore.getInstance("JKS");
keyStore.load(jksInputStream, keyStorePassword.toCharArray());
// 初始化 KeyManagerFactory
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
kmf.init(keyStore, keyStorePassword.toCharArray());
// 创建 SslContext 并禁用客户端认证
return SslContextBuilder.forServer(kmf)
.clientAuth(ClientAuth.NONE) // 禁用客户端认证
.build();
}
public SslContext getSslContextByDomain(String domain) {
return domainSslContexts.get(domain);
}
public void removeSslContextByDomain(String domain) {
domainSslContexts.remove(domain);
}
public SslContext getSslContextByFullDomain(String fullDomain) {
String domain = ProxyUtil.getDomainNameByFullDomain(fullDomain);
if (StrUtil.isBlank(domain)) {
return null;
}
return domainSslContexts.get(domain);
}
}
@@ -1,25 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.proxy.handler;
import cn.hutool.core.util.StrUtil;
@@ -7,7 +7,6 @@ import org.dromara.neutrinoproxy.core.dispatcher.Match;
import org.dromara.neutrinoproxy.server.constant.EnableStatusEnum;
import org.dromara.neutrinoproxy.server.dal.entity.LicenseDO;
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;
@@ -76,8 +75,11 @@ public class ProxyMessageConnectHandler implements ProxyMessageHandler {
Channel visitorChannel = ProxyUtil.getVisitorChannel(cmdChannel, visitorId);
if (null == visitorChannel) {
ctx.channel().writeAndFlush(ProxyMessage.buildErrMessage(ExceptionEnum.CONNECT_FAILED, "server errorvisitor channel not found!"));
ctx.channel().close();
return;
}
ctx.channel().attr(Constants.VISITOR_ID).set(visitorId);
ctx.channel().attr(Constants.LICENSE_ID).set(licenseDO.getId());
ctx.channel().attr(Constants.NEXT_CHANNEL).set(visitorChannel);
@@ -86,13 +88,24 @@ public class ProxyMessageConnectHandler implements ProxyMessageHandler {
// 代理客户端与后端服务器连接成功修改用户连接为可读状态
visitorChannel.config().setOption(ChannelOption.AUTO_READ, true);
// 获取代理附加对象
ProxyAttachment proxyAttachment = ProxyUtil.getProxyConnectAttachment(visitorId);
if (null != proxyAttachment) {
// 及时释放
ProxyUtil.remoteProxyConnectAttachment(visitorId);
proxyAttachment.execute();
}
// 获取代理附加对象
Constants.ProxyAttachment proxyAttachment = visitorChannel.attr(Constants.PROXY_CONNECT_ATTACHMENT).get();
if (null != proxyAttachment) {
// 转发来自visitor的首次代理数据
proxyAttachment.execute(visitorChannel);
// 此处时TCP代理不一定有代理附加对象不能因为没有而直接释放visitorChannel
}
// // 获取代理附加对象
// ProxyAttachment proxyAttachment = ProxyUtil.getProxyConnectAttachment(visitorId);
// if (null != proxyAttachment) {
// // 及时释放
// ProxyUtil.remoteProxyConnectAttachment(visitorId);
// proxyAttachment.execute();
// }
}
@Override
@@ -38,6 +38,8 @@ public class ProxyMessageTransferHandler implements ProxyMessageHandler {
ctx.channel().config().setAutoRead(true);
}
}
// TODO Netty默认的高水位通常只有64KB在SCP/SFTP场景下可能很快就填满了
// 而visitorChannel.writeAndFlush(buf);是异步的有可能写入数据极快而visitorChannel的isWritable还没来得及变成false此处就会写入大量数据把缓冲撑爆
ByteBuf buf = ctx.alloc().buffer(proxyMessage.getData().length);
buf.writeBytes(proxyMessage.getData());
visitorChannel.writeAndFlush(buf);
@@ -14,7 +14,6 @@ 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;
@@ -87,16 +86,18 @@ public class UdpProxyMessageConnectHandler implements ProxyMessageHandler {
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());
// 所有udb visitor共用一个visitorChannel设置这个没啥用
// visitorChannel.attr(Constants.NEXT_CHANNEL).set(ctx.channel());
ProxyUtil.setVisitorIdToTunnelChannelMap(udpBaseInfo.getVisitorId(), ctx.channel());
visitorChannel.attr(Constants.IS_UDP_KEY).set(Boolean.TRUE);
// // 代理客户端与后端服务器连接成功修改用户连接为可读状态
// visitorChannel.config().setOption(ChannelOption.AUTO_READ, true);
// 获取代理附加对象
ProxyAttachment proxyAttachment = ProxyUtil.getProxyConnectAttachment(udpBaseInfo.getVisitorId());
Constants.ProxyAttachment proxyAttachment = ProxyUtil.getProxyConnectAttachment(udpBaseInfo.getVisitorId());
if (null != proxyAttachment) {
// 及时释放
ProxyUtil.remoteProxyConnectAttachment(udpBaseInfo.getVisitorId());
proxyAttachment.execute();
proxyAttachment.execute(visitorChannel);
}
}
@@ -31,33 +31,31 @@ public class UdpProxyMessageTransferHandler implements ProxyMessageHandler {
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 (null == visitorChannel) {
return;
}
if (!visitorChannel.isWritable()) {
//自己不可写通道可以读让通道关闭读
//自己可写通道不可以读让通道打开读
if (ctx.channel().config().isAutoRead()) {
ctx.channel().config().setAutoRead(false);
}
} else {
if (ctx.channel().config().isAutoRead()) {
ctx.channel().config().setAutoRead(true);
}
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));
}
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);
}
// 增加流量计数(TODO 如果UDP映射服务端端口修改这个似乎不准)
Integer licenseId = visitorChannel.attr(Constants.LICENSE_ID).get();
if (null != licenseId) {
Solon.context().getBean(FlowReportService.class).addReadByte(licenseId, proxyMessage.getData().length);
}
}
@@ -1,19 +1,27 @@
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 io.netty.buffer.Unpooled;
import io.netty.channel.*;
import io.netty.handler.codec.DecoderException;
import io.netty.util.CharsetUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.checkerframework.checker.i18nformatter.qual.I18nFormat;
import org.dromara.neutrinoproxy.core.Constants;
import org.dromara.neutrinoproxy.core.ProxyMessage;
import org.dromara.neutrinoproxy.core.util.HttpUtil;
import org.dromara.neutrinoproxy.core.util.IpUtil;
import org.dromara.neutrinoproxy.server.service.DomainService;
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;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.SocketException;
/**
* @author: aoshiguchen
* @date: 2023/12/14
@@ -22,55 +30,70 @@ import org.noear.solon.Solon;
public class HttpVisitorSecurityChannelHandler extends ChannelInboundHandlerAdapter {
private final SecurityGroupService securityGroupService = Solon.context().getBean(SecurityGroupService.class);
private final PortMappingService portMappingService = Solon.context().getBean(PortMappingService.class);
private final DomainService domainService = Solon.context().getBean(DomainService.class);
/**
* 域名
*/
private String domainName;
private Boolean isHttps;
public HttpVisitorSecurityChannelHandler(String domainName) {
this.domainName = domainName;
// 拼接收到的 ByteBuf 内容
private ByteBuf cumulationBuf = Unpooled.buffer();
// private boolean initialized = false;
public HttpVisitorSecurityChannelHandler(Boolean isHttps) {
this.isHttps = isHttps;
}
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
// 未配置域名则不支持通过域名访问
if (StrUtil.isBlank(domainName)) {
// if (initialized) {
// // 已经初始化直接透传
// ctx.fireChannelRead(msg);
// return;
// }
// 累加数据包
ByteBuf buf = (ByteBuf) msg;
cumulationBuf.writeBytes(buf);
String dataStr = cumulationBuf.toString(CharsetUtil.UTF_8);
int headerEndIndex = dataStr.indexOf("\r\n\r\n");
if (-1 == headerEndIndex) {
// 请求头还没读完继续等
return;
}
// 获取Host请求头
String headerPart = dataStr.substring(0, headerEndIndex + 4);
String host = HttpUtil.getHostIgnorePort(headerPart); //test1.asgc.fun
log.debug("HttpProxy host: {}", host);
if (StringUtils.isBlank(host)) {
ctx.channel().close();
return;
}
// 判断域名是否被禁用或删除
Integer domainNameId = ProxyUtil.getDomainNameIdByFullDomain(host);
if (domainNameId == null) {
ctx.channel().close();
return;
}
// 域名映射强制https验证
if (!isHttps && domainService.isOnlyHttps(domainNameId)) {
ctx.channel().close();
return;
}
ByteBuf buf = (ByteBuf) msg;
Integer serverPort = ctx.channel().attr(Constants.SERVER_PORT).get();
if (null == serverPort) {
// 获取Host请求头
byte[] bytes = new byte[buf.readableBytes()];
buf.readBytes(bytes);
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
serverPort = ProxyUtil.getServerPortBySubdomain(subdomain);
// channel没有服务器端口信息尝试根据完整域名拿到服务端端口
serverPort = ProxyUtil.getServerPortByFullDomain(host);
if (null == serverPort) {
ctx.channel().close();
return;
}
// 判断IP是否在该端口绑定的安全组允许的规则内
String ip = IpUtil.getRealRemoteIp(httpContent);
String ip = IpUtil.getRealRemoteIp(headerPart);
if (ip == null) {
ip = IpUtil.getRemoteIp(ctx);
}
@@ -84,9 +107,71 @@ public class HttpVisitorSecurityChannelHandler extends ChannelInboundHandlerAdap
ctx.channel().attr(Constants.SERVER_PORT).set(serverPort);
}
// 从此之后所有的 in 都是直接透传
// 否则若请求体过长数据包被拆分为多个后续的数据包都无法解析出host导致转发数据不完整
ctx.pipeline().remove(this);
// 继续传播
buf.resetReaderIndex();
ctx.fireChannelRead(buf);
ctx.fireChannelRead(cumulationBuf);
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
// 对于网络IO异常致命异常关闭channel以防止资源泄漏
// 对于其他异常可能是可恢复的业务异常只记录日志
if (cause instanceof IOException) {
// IOException及其子类包括SocketException都是致命的网络异常
if (cause instanceof SocketException && cause.getMessage() != null && cause.getMessage().contains("Connection reset")) {
// Connection reset是常见的客户端断开使用debug级别
log.debug("[HTTP Visitor Security Channel] Connection reset: {}", cause.getMessage());
} else {
log.error("[HTTP Visitor Security Channel] IO error", cause);
}
if (ctx.channel().isActive()) {
ctx.channel().close();
}
} else if(cause instanceof DecoderException) {
// 协议解析错误为防止数据污染立即关闭
log.debug("[HTTP Visitor Security Channel] decoder error: {}", cause.getMessage());
if (ctx.channel().isActive()) {
ctx.channel().close();
}
} else {
// 其他异常只记录日志不关闭channel让Netty自己处理
log.error("[HTTP Visitor Security Channel] error", cause);
}
}
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
// 通知代理客户端
Channel visitorChannel = ctx.channel();
InetSocketAddress sa = (InetSocketAddress) visitorChannel.localAddress();
Channel cmdChannel = ProxyUtil.getCmdChannelByServerPort(sa.getPort());
if (null != cmdChannel) {
// 用户连接断开从控制连接中移除
String visitorId = ProxyUtil.getVisitorIdByChannel(visitorChannel);
ProxyUtil.removeVisitorChannelFromCmdChannel(cmdChannel, visitorId);
// 删除代理附加对象
ProxyUtil.remoteProxyConnectAttachment(visitorId);
Channel proxyChannel = visitorChannel.attr(Constants.NEXT_CHANNEL).get();
if (proxyChannel != null && proxyChannel.isActive()) {
proxyChannel.attr(Constants.NEXT_CHANNEL).remove();
proxyChannel.attr(Constants.LICENSE_ID).remove();
proxyChannel.attr(Constants.VISITOR_ID).remove();
proxyChannel.config().setOption(ChannelOption.AUTO_READ, true);
// 通知客户端用户连接已经断开
proxyChannel.writeAndFlush(ProxyMessage.buildDisconnectMessage(visitorId));
proxyChannel.writeAndFlush(Unpooled.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE);
}
}
super.channelInactive(ctx);
}
}
@@ -1,18 +1,22 @@
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 io.netty.buffer.Unpooled;
import io.netty.channel.*;
import io.netty.handler.codec.DecoderException;
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.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;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.SocketException;
/**
* @author: aoshiguchen
@@ -65,4 +69,64 @@ public class TcpVisitorSecurityChannelHandler extends ChannelInboundHandlerAdapt
ctx.fireChannelActive();
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
// 对于网络IO异常致命异常关闭channel以防止资源泄漏
// 对于其他异常可能是可恢复的业务异常只记录日志
if (cause instanceof IOException) {
// IOException及其子类包括SocketException都是致命的网络异常
if (cause instanceof SocketException && cause.getMessage() != null && cause.getMessage().contains("Connection reset")) {
// Connection reset是常见的客户端断开使用debug级别
log.debug("[TCP Visitor Security Channel] Connection reset: {}", cause.getMessage());
} else {
log.error("[TCP Visitor Security Channel] IO error", cause);
}
if (ctx.channel().isActive()) {
ctx.channel().close();
}
} else if(cause instanceof DecoderException) {
// 协议解析错误为防止数据污染立即关闭
log.debug("[TCP Visitor Security Channel] decoder error: {}", cause.getMessage());
if (ctx.channel().isActive()) {
ctx.channel().close();
}
} else {
// 其他异常只记录日志不关闭channel让Netty自己处理
log.error("[TCP Visitor Security Channel] error", cause);
}
}
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
// 通知代理客户端
Channel visitorChannel = ctx.channel();
InetSocketAddress sa = (InetSocketAddress) visitorChannel.localAddress();
Channel cmdChannel = ProxyUtil.getCmdChannelByServerPort(sa.getPort());
if (null != cmdChannel) {
// 用户连接断开从控制连接中移除
String visitorId = ProxyUtil.getVisitorIdByChannel(visitorChannel);
ProxyUtil.removeVisitorChannelFromCmdChannel(cmdChannel, visitorId);
// 删除代理附加对象
ProxyUtil.remoteProxyConnectAttachment(visitorId);
Channel proxyChannel = visitorChannel.attr(Constants.NEXT_CHANNEL).get();
if (proxyChannel != null && proxyChannel.isActive()) {
proxyChannel.attr(Constants.NEXT_CHANNEL).remove();
proxyChannel.attr(Constants.LICENSE_ID).remove();
proxyChannel.attr(Constants.VISITOR_ID).remove();
proxyChannel.config().setOption(ChannelOption.AUTO_READ, true);
// 通知客户端用户连接已经断开
proxyChannel.writeAndFlush(ProxyMessage.buildDisconnectMessage(visitorId));
proxyChannel.writeAndFlush(Unpooled.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE);
}
}
super.channelInactive(ctx);
}
}
@@ -1,16 +1,20 @@
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.buffer.Unpooled;
import io.netty.channel.*;
import io.netty.channel.socket.DatagramPacket;
import io.netty.handler.codec.DecoderException;
import lombok.extern.slf4j.Slf4j;
import org.dromara.neutrinoproxy.core.Constants;
import org.dromara.neutrinoproxy.core.ProxyMessage;
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;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.SocketException;
/**
* @author: aoshiguchen
@@ -36,4 +40,64 @@ public class UdpVisitorSecurityChannelHandler extends ChannelInboundHandlerAdapt
ctx.channel().attr(Constants.SERVER_PORT).set(sa.getPort());
ctx.fireChannelRead(msg);
}
// @Override
// public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
// // 对于网络IO异常致命异常关闭channel以防止资源泄漏
// // 对于其他异常可能是可恢复的业务异常只记录日志
// if (cause instanceof IOException) {
// // IOException及其子类包括SocketException都是致命的网络异常
// if (cause instanceof SocketException && cause.getMessage() != null && cause.getMessage().contains("Connection reset")) {
// // Connection reset是常见的客户端断开使用debug级别
// log.debug("[UDP Visitor Security Channel] Connection reset: {}", cause.getMessage());
// } else {
// log.error("[UDP Visitor Security Channel] IO error", cause);
// }
// if (ctx.channel().isActive()) {
// ctx.channel().close();
// }
// } else if(cause instanceof DecoderException) {
// // 协议解析错误为防止数据污染立即关闭
// log.debug("[UDP Visitor Security Channel] decoder error: {}", cause.getMessage());
// if (ctx.channel().isActive()) {
// ctx.channel().close();
// }
// } else {
// // 其他异常只记录日志不关闭channel让Netty自己处理
// log.error("[UDP Visitor Security Channel] error", cause);
// }
// }
// @Override
// public void channelInactive(ChannelHandlerContext ctx) throws Exception {
//
// // 通知代理客户端
// Channel visitorChannel = ctx.channel();
// InetSocketAddress sa = (InetSocketAddress) visitorChannel.localAddress();
// Channel cmdChannel = ProxyUtil.getCmdChannelByServerPort(sa.getPort());
//
// if (null != cmdChannel) {
// // 用户连接断开从控制连接中移除
// String visitorId = ProxyUtil.getVisitorIdByChannel(visitorChannel);
// ProxyUtil.removeVisitorChannelFromCmdChannel(cmdChannel, visitorId);
//
// // 删除代理附加对象
// ProxyUtil.remoteProxyConnectAttachment(visitorId);
//
// Channel proxyChannel = visitorChannel.attr(Constants.NEXT_CHANNEL).get();
// if (proxyChannel != null && proxyChannel.isActive()) {
// proxyChannel.attr(Constants.NEXT_CHANNEL).remove();
// proxyChannel.attr(Constants.LICENSE_ID).remove();
// proxyChannel.attr(Constants.VISITOR_ID).remove();
//
// proxyChannel.config().setOption(ChannelOption.AUTO_READ, true);
// // 通知客户端用户连接已经断开
// proxyChannel.writeAndFlush(ProxyMessage.buildDisconnectMessage(visitorId));
//
// proxyChannel.writeAndFlush(Unpooled.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE);
// }
// }
//
// super.channelInactive(ctx);
// }
}
@@ -1,16 +1,14 @@
package org.dromara.neutrinoproxy.server.proxy.security;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.*;
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
@@ -47,4 +45,63 @@ public class VisitorFlowLimiterChannelHandler extends ChannelInboundHandlerAdapt
ctx.fireChannelRead(msg);
}
// @Override
// public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
// // 对于网络IO异常致命异常关闭channel以防止资源泄漏
// // 对于其他异常可能是可恢复的业务异常只记录日志
// if (cause instanceof IOException) {
// // IOException及其子类包括SocketException都是致命的网络异常
// if (cause instanceof SocketException && cause.getMessage() != null && cause.getMessage().contains("Connection reset")) {
// // Connection reset是常见的客户端断开使用debug级别
// log.debug("[Visitor FlowLimit Channel] Connection reset: {}", cause.getMessage());
// } else {
// log.error("[Visitor FlowLimit Channel] IO error", cause);
// }
// if (ctx.channel().isActive()) {
// ctx.channel().close();
// }
// } else if(cause instanceof DecoderException) {
// // 协议解析错误为防止数据污染立即关闭
// log.debug("[Visitor FlowLimit Channel] decoder error: {}", cause.getMessage());
// if (ctx.channel().isActive()) {
// ctx.channel().close();
// }
// } else {
// // 其他异常只记录日志不关闭channel让Netty自己处理
// log.error("[Visitor FlowLimit Channel] error", cause);
// }
// }
// @Override
// public void channelInactive(ChannelHandlerContext ctx) throws Exception {
//
// // 通知代理客户端
// Channel visitorChannel = ctx.channel();
// InetSocketAddress sa = (InetSocketAddress) visitorChannel.localAddress();
// Channel cmdChannel = ProxyUtil.getCmdChannelByServerPort(sa.getPort());
//
// if (null != cmdChannel) {
// // 用户连接断开从控制连接中移除
// String visitorId = ProxyUtil.getVisitorIdByChannel(visitorChannel);
// ProxyUtil.removeVisitorChannelFromCmdChannel(cmdChannel, visitorId);
//
// // 删除代理附加对象
// ProxyUtil.remoteProxyConnectAttachment(visitorId);
//
// Channel proxyChannel = visitorChannel.attr(Constants.NEXT_CHANNEL).get();
// if (proxyChannel != null && proxyChannel.isActive()) {
// proxyChannel.attr(Constants.NEXT_CHANNEL).remove();
// proxyChannel.attr(Constants.LICENSE_ID).remove();
// proxyChannel.attr(Constants.VISITOR_ID).remove();
//
// proxyChannel.config().setOption(ChannelOption.AUTO_READ, true);
// // 通知客户端用户连接已经断开
// proxyChannel.writeAndFlush(ProxyMessage.buildDisconnectMessage(visitorId));
//
// proxyChannel.writeAndFlush(Unpooled.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE);
// }
// }
//
// super.channelInactive(ctx);
// }
}
@@ -0,0 +1,301 @@
package org.dromara.neutrinoproxy.server.service;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.text.StrPool;
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.Wrappers;
import com.baomidou.mybatisplus.solon.plugins.pagination.Page;
import com.google.common.collect.Sets;
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.*;
import org.dromara.neutrinoproxy.server.controller.req.proxy.DomainCreateReq;
import org.dromara.neutrinoproxy.server.controller.req.proxy.DomainListReq;
import org.dromara.neutrinoproxy.server.controller.req.proxy.DomainUpdateEnableStatusReq;
import org.dromara.neutrinoproxy.server.controller.req.proxy.DomainUpdateReq;
import org.dromara.neutrinoproxy.server.controller.res.proxy.DomainListRes;
import org.dromara.neutrinoproxy.server.controller.res.proxy.DomainUpdateDefaultStatusRes;
import org.dromara.neutrinoproxy.server.controller.res.proxy.DomainUpdateEnableStatusRes;
import org.dromara.neutrinoproxy.server.dal.DomainMapper;
import org.dromara.neutrinoproxy.server.dal.DomainPortMappingMapper;
import org.dromara.neutrinoproxy.server.dal.PortMappingMapper;
import org.dromara.neutrinoproxy.server.dal.UserMapper;
import org.dromara.neutrinoproxy.server.dal.entity.DomainNameDO;
import org.dromara.neutrinoproxy.server.dal.entity.PortMappingDO;
import org.dromara.neutrinoproxy.server.dal.entity.UserDO;
import org.dromara.neutrinoproxy.server.proxy.enhance.SslContextManager;
import org.dromara.neutrinoproxy.server.service.bo.FullDomainNameBO;
import org.dromara.neutrinoproxy.server.util.ParamCheckUtil;
import org.dromara.neutrinoproxy.server.util.ProxyUtil;
import org.noear.solon.annotation.Component;
import org.noear.solon.annotation.Init;
import org.noear.solon.annotation.Inject;
import org.noear.solon.core.handle.UploadedFile;
import org.noear.solon.core.runtime.NativeDetector;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @author Mirac
* @date 21/7/2024
*/
@Slf4j
@Component
public class DomainService {
@Db
private DomainMapper domainMapper;
@Db
private UserMapper userMapper;
@Db
private PortMappingMapper portMappingMapper;
@Db
private DomainPortMappingMapper domainPortMappingMapper;
@Inject
private SslContextManager sslContextManager;
public PageInfo<DomainListRes> page(PageQuery pageQuery, DomainListReq req) {
Page<DomainNameDO> page = domainMapper.selectPage(new Page<>(pageQuery.getCurrent(), pageQuery.getSize()), new LambdaQueryWrapper<DomainNameDO>()
.eq(req.getEnable() != null, DomainNameDO::getEnable, req.getEnable())
.eq(req.getUserId() != null, DomainNameDO::getUserId, req.getUserId())
.orderByAsc(Arrays.asList(DomainNameDO::getUserId, DomainNameDO::getId))
);
List<DomainListRes> resList = page.getRecords().stream().map(DomainNameDO::toRes).collect(Collectors.toList());
if (CollectionUtils.isEmpty(page.getRecords())) {
return PageInfo.of(resList, page);
}
Set<Integer> userIds = resList.stream().map(DomainListRes::getUserId).collect(Collectors.toSet());
List<UserDO> userDOList = userMapper.findByIds(userIds);
Map<Integer, UserDO> userMap = userDOList.stream().collect(Collectors.toMap(UserDO::getId, c -> c));
for (DomainListRes item : resList) {
UserDO userDO = userMap.get(item.getUserId());
if (null != userDO) {
item.setUserName(userDO.getName());
}
}
return PageInfo.of(resList, page);
}
public List<DomainListRes> all(DomainListReq req) {
LambdaQueryWrapper<DomainNameDO> wrapper = Wrappers.<DomainNameDO>lambdaQuery()
.eq(req.getEnable() != null, DomainNameDO::getEnable, req.getEnable());
List<DomainNameDO> domainNameDOS = domainMapper.selectList(wrapper);
if (CollectionUtil.isEmpty(domainNameDOS)) {
return null;
}
List<DomainListRes> resList = domainNameDOS.stream().map(DomainNameDO::toRes).toList();
Set<Integer> userIds = resList.stream().map(DomainListRes::getUserId).collect(Collectors.toSet());
List<UserDO> userDOList = userMapper.findByIds(userIds);
Map<Integer, UserDO> userMap = userDOList.stream().collect(Collectors.toMap(UserDO::getId, c -> c));
for (DomainListRes item : resList) {
UserDO userDO = userMap.get(item.getUserId());
if (null != userDO) {
item.setUserName(userDO.getName());
}
}
return resList;
}
/**
* 创建域名
*
* @param req
*/
public void create(DomainCreateReq req, UploadedFile jks) {
DomainNameDO domainNameCheck = domainMapper.checkRepeat(req.getDomain(), null);
ParamCheckUtil.checkMustNull(domainNameCheck, ExceptionConstant.DOMAIN_NAME_CANNOT_REPEAT);
DomainNameDO domainNameDO = new DomainNameDO();
if (null != jks) {
try {
ParamCheckUtil.checkNotEmpty(req.getKeyStorePassword(), "keyStorePassword");
InputStream content = jks.getContent();
byte[] byteArray = toByteArray(content);
domainNameDO.setJks(byteArray);
domainNameDO.setKeyStorePassword(req.getKeyStorePassword());
//添加证书
sslContextManager.addDomainAndCert(req.getDomain(), byteArray, req.getKeyStorePassword());
} catch (Exception e) {
log.error("证书添加失败", e);
e.printStackTrace();
}
}
Integer userId = SystemContextHolder.getUserId();
Date now = new Date();
domainNameDO.setDomain(req.getDomain());
domainNameDO.setIsDefault(DefaultDomainStatusEnum.DISABLE.getStatus());
domainNameDO.setForceHttps(req.getForceHttps() != null ? HttpsStatusEnum.of(req.getForceHttps()).getStatus() : HttpsStatusEnum.DISABLE_ONLY_HTTPS.getStatus());
domainNameDO.setUserId(userId);
domainNameDO.setEnable(EnableStatusEnum.ENABLE.getStatus());
domainNameDO.setCreateTime(now);
domainNameDO.setUpdateTime(now);
domainMapper.insert(domainNameDO);
//更新主域名到域名id映射
ProxyUtil.setDomainToDomainNameId(domainNameDO.getDomain(), domainNameDO.getId());
}
/**
* InputStream 转换为 byte[]
*/
private byte[] toByteArray(InputStream input) throws IOException {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
int nRead;
byte[] data = new byte[1024];
while ((nRead = input.read(data, 0, data.length)) != -1) {
buffer.write(data, 0, nRead);
}
buffer.flush();
return buffer.toByteArray();
}
public void update(DomainUpdateReq req, UploadedFile jks) {
DomainNameDO domainNameCheck = domainMapper.checkRepeat(req.getDomain(), Sets.newHashSet(req.getId()));
ParamCheckUtil.checkMustNull(domainNameCheck, ExceptionConstant.DOMAIN_NAME_CANNOT_REPEAT);
DomainNameDO oldDomainNameDO = domainMapper.selectOne(Wrappers.<DomainNameDO>lambdaQuery().eq(DomainNameDO::getId, req.getId()));
List<FullDomainNameBO> oldFullDomainNameBOS = domainMapper.selectFullDomainNameListByDomainNameIds(Sets.newHashSet(req.getId()));
LambdaUpdateWrapper<DomainNameDO> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(DomainNameDO::getId, req.getId());
if (null != jks) {
try {
ParamCheckUtil.checkNotEmpty(req.getKeyStorePassword(), "keyStorePassword");
InputStream content = jks.getContent();
byte[] byteArray = toByteArray(content);
updateWrapper.set(DomainNameDO::getKeyStorePassword, req.getKeyStorePassword());
updateWrapper.set(DomainNameDO::getJks, byteArray);
//添加证书并删除旧的证书
sslContextManager.addDomainAndCert(req.getDomain(), byteArray, req.getKeyStorePassword());
if (!req.getDomain().equals(oldDomainNameDO.getDomain())) {
sslContextManager.removeSslContextByDomain(oldDomainNameDO.getDomain());
}
} catch (Exception e) {
log.error("证书添加失败", e);
e.printStackTrace();
}
}
updateWrapper.set(DomainNameDO::getDomain, req.getDomain());
updateWrapper.set(DomainNameDO::getUpdateTime, new Date());
updateWrapper.set(req.getForceHttps() != null, DomainNameDO::getForceHttps, req.getForceHttps());
domainMapper.update(updateWrapper);
//更新域名相关映射
if (!Objects.equals(oldDomainNameDO.getDomain(), req.getDomain())) {
//更新主域名到域名id映射
ProxyUtil.removeDomainToDomainNameId(oldDomainNameDO.getDomain());
ProxyUtil.setDomainToDomainNameId(req.getDomain(), req.getId());
if (CollectionUtil.isEmpty(oldFullDomainNameBOS)) return;
//存在域名映射更新完整域名到服务器端口映射
for (FullDomainNameBO oldFullDomainNameBO : oldFullDomainNameBOS) {
String oldFullDomain = StrUtil.join(StrPool.DOT, oldFullDomainNameBO.getSubdomain(), oldFullDomainNameBO.getDomain());
Integer serverPort = ProxyUtil.getServerPortByFullDomain(oldFullDomain);
ProxyUtil.removeFullDomainToServerPort(oldFullDomain);
ProxyUtil.setFullDomainToServerPort(StrUtil.join(StrPool.DOT, oldFullDomainNameBO.getSubdomain(), req.getDomain()), serverPort);
}
}
}
public DomainUpdateEnableStatusRes updateEnableStatus(DomainUpdateEnableStatusReq req) {
if (Objects.equals(req.getEnable(), EnableStatusEnum.DISABLE.getStatus())) {
//如果设置状态为禁用则将默认域名设置为非默认域名
updateDefaultStatus(req.getId(), DefaultDomainStatusEnum.DISABLE.getStatus());
}
domainMapper.updateEnableStatus(req.getId(), req.getEnable(), new Date());
if (Objects.equals(req.getEnable(), EnableStatusEnum.ENABLE.getStatus())) {
ProxyUtil.setDomainToDomainNameId(req.getDomain(), req.getId());
} else {
ProxyUtil.removeDomainToDomainNameId(req.getDomain());
}
return new DomainUpdateEnableStatusRes();
}
public void delete(Integer domainNameId) {
//检查当前域名是否正在使用
boolean checkUsed = domainPortMappingMapper.checkUsed(domainNameId);
ParamCheckUtil.checkExpression(!checkUsed, ExceptionConstant.DOMAIN_NAME_IS_USED);
DomainNameDO domainNameDO = domainMapper.selectOne(Wrappers.<DomainNameDO>lambdaQuery()
.eq(DomainNameDO::getId, domainNameId)
.select(DomainNameDO::getDomain, DomainNameDO::getEnable));
if (Objects.equals(domainNameDO.getEnable(), EnableStatusEnum.ENABLE.getStatus())) {
ProxyUtil.removeDomainToDomainNameId(domainNameDO.getDomain());
}
domainMapper.deleteById(domainNameId);
//删除证书
sslContextManager.removeSslContextByDomain(domainNameDO.getDomain());
}
public DomainUpdateDefaultStatusRes updateDefaultStatus(Integer id, Integer isDefault) {
if (Objects.equals(isDefault, DefaultDomainStatusEnum.ENABLE.getStatus())) {
//如果设置状态为默认域名则将之前的默认域名设置为非默认域名
DomainNameDO oldDomainNameDO = domainMapper.selectOne(Wrappers.<DomainNameDO>lambdaQuery()
.select(DomainNameDO::getId)
.eq(DomainNameDO::getIsDefault, DefaultDomainStatusEnum.ENABLE.getStatus()));
if (oldDomainNameDO != null) {
oldDomainNameDO.setIsDefault(DefaultDomainStatusEnum.DISABLE.getStatus());
domainMapper.updateById(oldDomainNameDO);
}
}
DomainNameDO domainNameDO = new DomainNameDO();
domainNameDO.setId(id);
domainNameDO.setIsDefault(isDefault);
domainMapper.updateById(domainNameDO);
return new DomainUpdateDefaultStatusRes();
}
@Init
public void init() {
// aot 阶段不初始化
if (NativeDetector.isAotRuntime()) {
return;
}
List<FullDomainNameBO> fullDomainNameBOS = domainMapper.selectFullDomainNameList();
if (CollectionUtil.isEmpty(fullDomainNameBOS)) {
return;
}
Set<Integer> portMappingIds = fullDomainNameBOS.stream().map(FullDomainNameBO::getPortMappingId).collect(Collectors.toSet());
List<PortMappingDO> portMappingDOS = portMappingMapper.selectBatchIds(portMappingIds);
if (CollectionUtil.isEmpty(portMappingDOS)) {
return;
}
Map<Integer, PortMappingDO> portMappingDOMap = portMappingDOS.stream()
.filter(item -> NetworkProtocolEnum.HTTP.getDesc().equals(item.getProtocal()))
.collect(Collectors.toMap(PortMappingDO::getId, Function.identity()));
fullDomainNameBOS.forEach(item -> {
PortMappingDO portMappingDO = portMappingDOMap.get(item.getPortMappingId());
if (null == portMappingDO) {
return;
}
String fullDomain = StrUtil.join(StrPool.DOT, item.getSubdomain(), item.getDomain());
//更新完整域名到端口映射
ProxyUtil.setFullDomainToServerPort(fullDomain, portMappingDO.getServerPort());
});
//更新主域名到主域名id缓存未禁用
List<DomainNameDO> domainNameDOS = domainMapper.selectList(Wrappers.<DomainNameDO>lambdaQuery()
.eq(DomainNameDO::getEnable, EnableStatusEnum.ENABLE.getStatus())
.select(DomainNameDO::getDomain, DomainNameDO::getId));
for (DomainNameDO domainNameDO : domainNameDOS) {
ProxyUtil.setDomainToDomainNameId(domainNameDO.getDomain(), domainNameDO.getId());
}
}
public boolean isOnlyHttps(Integer domainNameId) {
ParamCheckUtil.checkExpression((domainNameId != null && domainNameId > 0), ExceptionConstant.DOMAIN_NAME_NOT_EXIST);
DomainNameDO domainNameDO = domainMapper.selectOne(Wrappers.<DomainNameDO>lambdaQuery()
.eq(DomainNameDO::getId, domainNameId));
return domainNameDO != null && Objects.equals(domainNameDO.getForceHttps(), HttpsStatusEnum.ONLY_HTTPS.getStatus());
}
}
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.service;
import org.dromara.neutrinoproxy.core.util.LockUtil;
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -2,8 +2,8 @@ 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.text.StrPool;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@@ -30,16 +30,10 @@ import org.dromara.neutrinoproxy.server.controller.res.proxy.PortMappingCreateRe
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;
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.PortPoolDO;
import org.dromara.neutrinoproxy.server.dal.entity.UserDO;
import org.dromara.neutrinoproxy.server.dal.*;
import org.dromara.neutrinoproxy.server.dal.entity.*;
import org.dromara.neutrinoproxy.server.service.bo.FlowLimitBO;
import org.dromara.neutrinoproxy.server.service.bo.FullDomainNameBO;
import org.dromara.neutrinoproxy.server.util.ParamCheckUtil;
import org.dromara.neutrinoproxy.server.util.ProxyUtil;
import org.dromara.neutrinoproxy.server.util.StringUtil;
@@ -68,6 +62,10 @@ public class PortMappingService implements LifecycleBean {
private UserMapper userMapper;
@Db
private PortPoolMapper portPoolMapper;
@Db
private DomainMapper domainMapper;
@Db
private DomainPortMappingMapper domainPortMappingMapper;
@Inject
private VisitorChannelService visitorChannelService;
@@ -82,7 +80,6 @@ public class PortMappingService implements LifecycleBean {
/** 端口到安全组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);
@@ -118,6 +115,11 @@ public class PortMappingService implements LifecycleBean {
Map<Integer, LicenseDO> licenseMap = licenseList.stream().collect(Collectors.toMap(LicenseDO::getId, Function.identity()));
Map<Integer, UserDO> userMap = userList.stream().collect(Collectors.toMap(UserDO::getId, Function.identity()));
//域名相关
Set<Integer> portMappingIds = respList.stream().map(PortMappingListRes::getId).collect(Collectors.toSet());
List<FullDomainNameBO> fullDomainNameBOS = domainMapper.selectFullDomainNameListByPortMappingIds(portMappingIds);
Map<Integer, List<FullDomainNameBO>> fullDomainNameBOMap = fullDomainNameBOS.stream().collect(Collectors.groupingBy(FullDomainNameBO::getPortMappingId));
respList.forEach(item -> {
LicenseDO license = licenseMap.get(item.getLicenseId());
if (null == license) {
@@ -130,9 +132,8 @@ public class PortMappingService implements LifecycleBean {
return;
}
item.setUserName(user.getName());
if (StrUtil.isNotBlank(proxyConfig.getServer().getTcp().getDomainName()) && StrUtil.isNotBlank(item.getSubdomain())) {
item.setDomain(item.getSubdomain() + "." + proxyConfig.getServer().getTcp().getDomainName());
}
//域名映射
item.setFullDomainMappings(fullDomainNameBOMap.get(item.getId()));
if (NetworkProtocolEnum.HTTP.getDesc().equals(item.getProtocal())) {
item.setProtocal("HTTP(S)");
}
@@ -154,13 +155,25 @@ public class PortMappingService implements LifecycleBean {
PortPoolDO portPoolDO = portPoolMapper.findByPort(req.getServerPort());
ParamCheckUtil.checkNotNull(portPoolDO, ExceptionConstant.PORT_NOT_EXIST);
ParamCheckUtil.checkExpression(null == portMappingMapper.findByPort(req.getServerPort(), null), ExceptionConstant.PORT_CANNOT_REPEAT_MAPPING, req.getServerPort());
ParamCheckUtil.checkExpression(!portMappingMapper.checkRepeatBySubdomain(req.getSubdomain(), null), ExceptionConstant.PORT_MAPPING_SUBDONAME_CONNOT_REPEAT);
//验证域名映射相关参数条件
if (NetworkProtocolEnum.isHttp(req.getProtocal()) && CollectionUtil.isNotEmpty(req.getDomainMappings())) {
Set<Integer> domainIds = req.getDomainMappings().stream().map(item -> item.getDomainId()).collect(Collectors.toSet());
List<DomainNameDO> domainNameDOS = domainMapper.selectBatchIds(domainIds);
Map<Integer, DomainNameDO> domainNameDOMap = domainNameDOS.stream().collect(Collectors.toMap(DomainNameDO::getId, Function.identity()));
req.getDomainMappings().forEach(item -> {
DomainNameDO domainNameDO = domainNameDOMap.get(item.getDomainId());
ParamCheckUtil.checkNotNull(domainNameDO, ExceptionConstant.DOMAIN_NAME_NOT_EXIST);
//检查当前域名是否被禁用
//ParamCheckUtil.checkExpression(Objects.equals(EnableStatusEnum.ENABLE.getStatus(), domainNameDO.getEnable()), ExceptionConstant.DOMAIN_NAME_IS_DISABLE, domainNameDO.getDomain());
//检查子域名是否重复
ParamCheckUtil.checkExpression(!domainPortMappingMapper.checkRepeatBySubdomain(item.getSubdomain(), item.getDomainId(), null), ExceptionConstant.SUDOMAIN_NAME_CANNOT_REPEAT);
});
}
Date now = new Date();
PortMappingDO portMappingDO = new PortMappingDO();
portMappingDO.setLicenseId(req.getLicenseId());
portMappingDO.setProtocal(req.getProtocal());
portMappingDO.setSubdomain(req.getSubdomain());
portMappingDO.setServerPort(req.getServerPort());
portMappingDO.setClientIp(req.getClientIp());
portMappingDO.setClientPort(req.getClientPort());
@@ -176,9 +189,24 @@ public class PortMappingService implements LifecycleBean {
portMappingMapper.insert(portMappingDO);
// 更新VisitorChannel
visitorChannelService.addVisitorChannelByPortMapping(portMappingDO);
// 更新域名映射
if (NetworkProtocolEnum.isHttp(portMappingDO.getProtocal()) && StrUtil.isNotBlank(proxyConfig.getServer().getTcp().getDomainName()) && StrUtil.isNotBlank(portMappingDO.getSubdomain())) {
ProxyUtil.setSubdomainToServerPort(portMappingDO.getSubdomain(), portMappingDO.getServerPort());
// 更新域名映射添加新的域名映射
if (NetworkProtocolEnum.isHttp(portMappingDO.getProtocal()) && CollectionUtil.isNotEmpty(req.getDomainMappings())) {
Set<Integer> domainIds = req.getDomainMappings().stream().map(item -> item.getDomainId()).collect(Collectors.toSet());
List<DomainNameDO> domainNameDOS = domainMapper.selectBatchIds(domainIds);
Map<Integer, DomainNameDO> domainNameDOMap = domainNameDOS.stream().collect(Collectors.toMap(DomainNameDO::getId, Function.identity()));
req.getDomainMappings().forEach(item -> {
DomainNameDO domainNameDO = domainNameDOMap.get(item.getDomainId());
//创建域名映射
DomainPortMappingDO domainPortMappingDO = new DomainPortMappingDO();
domainPortMappingDO.setDomainNameId(item.getDomainId());
domainPortMappingDO.setSubdomain(item.getSubdomain());
domainPortMappingDO.setPortMappingId(portMappingDO.getId());
domainPortMappingMapper.insert(domainPortMappingDO);
//设置完整域名到服务端端口的映射
ProxyUtil.setFullDomainToServerPort(StrUtil.join(StrPool.DOT, item.getSubdomain(), domainNameDO.getDomain()), portMappingDO.getServerPort());
});
}
updateMappingPortToSecurityGroupMap(portMappingDO.getServerPort(), req.getSecurityGroupId());
@@ -203,17 +231,29 @@ public class PortMappingService implements LifecycleBean {
PortPoolDO portPoolDO = portPoolMapper.findByPort(req.getServerPort());
ParamCheckUtil.checkNotNull(portPoolDO, ExceptionConstant.PORT_NOT_EXIST);
ParamCheckUtil.checkExpression(null == portMappingMapper.findByPort(req.getServerPort(), Sets.newHashSet(req.getId())), ExceptionConstant.PORT_CANNOT_REPEAT_MAPPING, req.getServerPort());
ParamCheckUtil.checkExpression(!portMappingMapper.checkRepeatBySubdomain(req.getSubdomain(), Sets.newHashSet(req.getId())), ExceptionConstant.PORT_MAPPING_SUBDONAME_CONNOT_REPEAT);
// 查询原端口映射
PortMappingDO oldPortMappingDO = portMappingMapper.findById(req.getId());
ParamCheckUtil.checkNotNull(oldPortMappingDO, ExceptionConstant.PORT_MAPPING_NOT_EXIST);
//验证域名映射相关参数条件
if (NetworkProtocolEnum.isHttp(req.getProtocal()) && CollectionUtil.isNotEmpty(req.getDomainMappings())) {
Set<Integer> domainIds = req.getDomainMappings().stream().map(item -> item.getDomainId()).collect(Collectors.toSet());
List<DomainNameDO> domainNameDOS = domainMapper.selectBatchIds(domainIds);
Map<Integer, DomainNameDO> domainNameDOMap = domainNameDOS.stream().collect(Collectors.toMap(DomainNameDO::getId, Function.identity()));
req.getDomainMappings().forEach(item -> {
DomainNameDO domainNameDO = domainNameDOMap.get(item.getDomainId());
ParamCheckUtil.checkNotNull(domainNameDO, ExceptionConstant.DOMAIN_NAME_NOT_EXIST);
//检查子域名是否重复
boolean b = !domainPortMappingMapper.checkRepeatBySubdomain(item.getSubdomain(), item.getDomainId(), item.getId());
ParamCheckUtil.checkExpression(b,
ExceptionConstant.SUDOMAIN_NAME_CANNOT_REPEAT);
});
}
// 更新端口映射
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())
@@ -229,13 +269,34 @@ public class PortMappingService implements LifecycleBean {
// 更新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().getTcp().getDomainName()) && StrUtil.isNotBlank(portMappingDO.getSubdomain())) {
ProxyUtil.setSubdomainToServerPort(portMappingDO.getSubdomain(), portMappingDO.getServerPort());
// 删除老的域名映射
if (NetworkProtocolEnum.isHttp(oldPortMappingDO.getProtocal())) {
//删除完整域名到服务端端口的映射
ProxyUtil.removeFullDomainToServerPortByServerPort(oldPortMappingDO.getServerPort());
//删除旧的域名映射
LambdaQueryWrapper<DomainPortMappingDO> lambdaQueryWrapper = Wrappers.<DomainPortMappingDO>lambdaQuery()
.eq(DomainPortMappingDO::getPortMappingId, oldPortMappingDO.getId());
domainPortMappingMapper.delete(lambdaQueryWrapper);
}
// 添加新的域名映射
if (NetworkProtocolEnum.isHttp(portMappingDO.getProtocal()) && CollectionUtil.isNotEmpty(req.getDomainMappings())) {
Set<Integer> domainIds = req.getDomainMappings().stream().map(item -> item.getDomainId()).collect(Collectors.toSet());
List<DomainNameDO> domainNameDOS = domainMapper.selectBatchIds(domainIds);
Map<Integer, DomainNameDO> domainNameDOMap = domainNameDOS.stream().collect(Collectors.toMap(DomainNameDO::getId, Function.identity()));
req.getDomainMappings().forEach(item -> {
DomainNameDO domainNameDO = domainNameDOMap.get(item.getDomainId());
//创建域名映射
DomainPortMappingDO domainPortMappingDO = new DomainPortMappingDO();
domainPortMappingDO.setDomainNameId(item.getDomainId());
domainPortMappingDO.setSubdomain(item.getSubdomain());
domainPortMappingDO.setPortMappingId(portMappingDO.getId());
domainPortMappingMapper.insert(domainPortMappingDO);
//设置完整域名到服务端端口的映射
ProxyUtil.setFullDomainToServerPort(StrUtil.join(StrPool.DOT, item.getSubdomain(), domainNameDO.getDomain()), portMappingDO.getServerPort());
});
}
updateMappingPortToSecurityGroupMap(portMappingDO.getServerPort(), req.getSecurityGroupId());
@@ -316,9 +377,15 @@ public class PortMappingService implements LifecycleBean {
// 更新VisitorChannel
visitorChannelService.removeVisitorChannelByPortMapping(portMappingDO);
// 更新域名映射
if (NetworkProtocolEnum.isHttp(portMappingDO.getProtocal()) && StrUtil.isNotBlank(portMappingDO.getSubdomain())) {
ProxyUtil.removeSubdomainToServerPort(portMappingDO.getSubdomain());
// 删除域名映射
if (NetworkProtocolEnum.isHttp(portMappingDO.getProtocal())) {
//删除完整域名到服务端端口的映射
ProxyUtil.removeFullDomainToServerPortByServerPort(portMappingDO.getServerPort());
//删除旧的域名映射
LambdaQueryWrapper<DomainPortMappingDO> lambdaQueryWrapper = Wrappers.<DomainPortMappingDO>lambdaQuery()
.eq(DomainPortMappingDO::getPortMappingId, portMappingDO.getId());
domainPortMappingMapper.delete(lambdaQueryWrapper);
}
updateMappingPortToSecurityGroupMap(portMappingDO.getServerPort(), null);
@@ -391,24 +458,6 @@ public class PortMappingService implements LifecycleBean {
// 刷新流量限制缓存
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;
}
portMappingDOList.forEach(item -> {
if (StrUtil.isBlank(item.getSubdomain())) {
return;
}
ProxyUtil.setSubdomainToServerPort(item.getSubdomain(), item.getServerPort());
});
}
/**
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.service;
import org.dromara.neutrinoproxy.server.constant.OnlineStatusEnum;
@@ -3,6 +3,7 @@ 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.solon.plugins.pagination.Page;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.solon.annotation.Db;
import org.dromara.neutrinoproxy.core.util.DateUtil;
import org.dromara.neutrinoproxy.server.base.page.PageInfo;
@@ -131,6 +132,7 @@ public class UserService {
public PageInfo<UserListRes> page(PageQuery pageQuery, UserListReq req) {
Page<UserDO> page = userMapper.selectPage(new Page<>(pageQuery.getCurrent(), pageQuery.getSize()), new LambdaQueryWrapper<UserDO>()
.like(StringUtils.isNotBlank(req.getName()), UserDO::getName, req.getName())
.orderByAsc(UserDO::getId)
);
List<UserListRes> respList = page.getRecords().stream().map(UserDO::toRes).collect(Collectors.toList());
@@ -15,17 +15,11 @@ 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.proxy.core.BytesMetricsHandler;
import org.dromara.neutrinoproxy.server.proxy.core.TcpVisitorChannelHandler;
import org.dromara.neutrinoproxy.server.proxy.domain.CmdChannelAttachInfo;
import org.dromara.neutrinoproxy.server.proxy.domain.ProxyMapping;
import org.dromara.neutrinoproxy.server.util.ProxyUtil;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.Channel;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.solon.annotation.Db;
import org.noear.solon.annotation.Component;
@@ -0,0 +1,40 @@
package org.dromara.neutrinoproxy.server.service.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import org.dromara.neutrinoproxy.server.constant.HttpsStatusEnum;
/**
* 完整域名
* @author: mirac
* @date: 2024/8/8
*/
@Data
@Accessors(chain = true)
public class FullDomainNameBO {
/**
* 域名端口映射id
*/
private Integer id;
/**
* 端口映射id
*/
private Integer portMappingId;
/**
* 子域名
*/
private String subdomain;
/**
* 域名id
*/
private Integer domainNameId;
/**
* 域名
*/
private String domain;
/**
* 强制使用HTTPS(1 2)
* {@link HttpsStatusEnum}
*/
private Integer forceHttps;
}
@@ -1,24 +1,3 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.dromara.neutrinoproxy.server.util;
import java.math.BigInteger;
@@ -6,19 +6,25 @@ 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.controller.res.stats.StatsInfoRes;
import org.dromara.neutrinoproxy.server.proxy.domain.CmdChannelAttachInfo;
import org.dromara.neutrinoproxy.server.proxy.domain.ProxyAttachment;
import org.dromara.neutrinoproxy.server.proxy.domain.ProxyMapping;
import org.dromara.neutrinoproxy.server.proxy.domain.VisitorChannelAttachInfo;
import io.netty.channel.Channel;
import io.netty.util.AttributeKey;
import org.dromara.solonplugins.job.CustomThreadFactory;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.stream.Collectors;
/**
*
@@ -27,16 +33,16 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
*/
public class ProxyUtil {
public static final AttributeKey<ChannelAttribute> CHANNEL_ATTR_KEY = AttributeKey.valueOf("netty.channel.attr");
// /**
// * license -> 服务端口映射
// */
// private static final Map<Integer, Set<Integer>> licenseToServerPortMap = new HashMap<>();
/**
* license -> 服务端口映射
*/
private static final Map<Integer, Set<Integer>> licenseToServerPortMap = new HashMap<>();
/**
* 代理信息映射
* 代理信息映射 e.g.: 9104 -> 127.0.0.1:8848
*/
private static final Map<Integer, String> proxyInfoMap = new ConcurrentHashMap<>();
/**
* 服务端口 -> 指令通道映射
* 服务端口 -> 指令通道映射proxyInfoMap
*/
private static Map<Integer, Channel> serverPortToCmdChannelMap = new ConcurrentHashMap<>();
/**
@@ -58,16 +64,74 @@ public class ProxyUtil {
private static AtomicLong visitorIdProducer = new AtomicLong(0);
/**
* 代理 - connect附加映射
* TCP/HTTP场景下已优化不是用这个UDP由于无连接暂时还是要用这个
* UDP场景时需要记录最后读写时间使用定时器定期检查超时需要释放待后续优化
*/
private static Map<String, ProxyAttachment> proxyConnectAttachmentMap = new HashMap<>();
private static Map<String, Constants.ProxyAttachment> proxyConnectAttachmentMap = new HashMap<>();
/**
* 域名 - 服务端端口映射
* 完整域名 - 服务端端口映射
*/
private static Map<String, Integer> subdomainToServerPort = new HashMap<>();
private static Map<String, Integer> fullDomainToServerPortMap = new ConcurrentHashMap<>();
/**
* 主域名 - 域名id映射
*/
private static Map<String, Integer> domainToDomainNameIdMap = new ConcurrentHashMap<>();
/**
* licenseId - 客户端Id映射
*/
private static Map<Integer, String> licenseIdToClientIdMap = new HashMap<>();
/**
* visitorId - SocketAddress映射
*/
private static Map<String, SocketAddress> visitorIdToSocketAddressMap = new HashMap<>();
/**
* SocketAddress - visitorId 映射
*/
private static Map<SocketAddress, String> socketAddressToVisitorIdMap = new HashMap<>();
/**
* visitorId - tunnelChannel 映射
*/
private static Map<String, Channel> visitorIdToTunnelChannelMap = new HashMap<>();
/**
* cache扫描器
*/
private static final ScheduledExecutorService cacheScanner = Executors.newSingleThreadScheduledExecutor(new CustomThreadFactory("cacheScanner"));
/**
* 初始化启动一个定时器定时清理缓存
*/
public static void init() {
cacheScanner.scheduleWithFixedDelay(ProxyUtil::cacheScan, 5, 5, TimeUnit.SECONDS);
}
public static synchronized void cacheScan() {
for (Integer key : serverPortToCmdChannelMap.keySet()) {
Channel channel = serverPortToCmdChannelMap.get(key);
if (null == channel || !channel.isRegistered()) {
serverPortToCmdChannelMap.remove(key);
}
}
for (Integer key : licenseToCmdChannelMap.keySet()) {
Channel channel = licenseToCmdChannelMap.get(key);
if (null == channel || !channel.isRegistered()) {
licenseToCmdChannelMap.remove(key);
}
}
for (Integer key : serverPortToVisitorChannel.keySet()) {
Channel channel = serverPortToVisitorChannel.get(key);
if (null == channel || !channel.isRegistered()) {
serverPortToVisitorChannel.remove(key);
}
}
for (String key : visitorIdToTunnelChannelMap.keySet()) {
Channel channel = visitorIdToTunnelChannelMap.get(key);
if (null == channel || !channel.isRegistered()) {
visitorIdToTunnelChannelMap.remove(key);
}
}
}
/**
* 初始化代理信息
@@ -75,14 +139,14 @@ public class ProxyUtil {
* @param proxyMappingList 代理映射集合
*/
public static void initProxyInfo(Integer licenseId, List<ProxyMapping> proxyMappingList) {
licenseToServerPortMap.put(licenseId, new HashSet<>());
// licenseToServerPortMap.put(licenseId, new HashSet<>());
addProxyInfo(licenseId, proxyMappingList);
}
public static void addProxyInfo(Integer licenseId, List<ProxyMapping> proxyMappingList) {
if (!CollectionUtil.isEmpty(proxyMappingList)) {
for (ProxyMapping proxyMapping : proxyMappingList) {
licenseToServerPortMap.get(licenseId).add(proxyMapping.getServerPort());
// licenseToServerPortMap.get(licenseId).add(proxyMapping.getServerPort());
proxyInfoMap.put(proxyMapping.getServerPort(), proxyMapping.getLanInfo());
}
}
@@ -92,7 +156,7 @@ public class ProxyUtil {
if (null == licenseId || null == proxyMapping) {
return;
}
licenseToServerPortMap.get(licenseId).add(proxyMapping.getServerPort());
// licenseToServerPortMap.get(licenseId).add(proxyMapping.getServerPort());
proxyInfoMap.put(proxyMapping.getServerPort(), proxyMapping.getLanInfo());
}
@@ -100,14 +164,14 @@ public class ProxyUtil {
proxyInfoMap.remove(serverPort);
}
/**
* 根据licenseId获取服务端端口集合
* @param licenseId licenseId
* @return 服务端端口集合
*/
public static Set<Integer> getServerPortsByLicenseKey(Integer licenseId) {
return licenseToServerPortMap.get(licenseId);
}
// /**
// * 根据licenseId获取服务端端口集合
// * @param licenseId licenseId
// * @return 服务端端口集合
// */
// public static Set<Integer> getServerPortsByLicenseKey(Integer licenseId) {
// return licenseToServerPortMap.get(licenseId);
// }
/**
* 根据服务端端口获取客户端代理信息
@@ -317,7 +381,7 @@ public class ProxyUtil {
* @param visitorId
* @param proxyAttachment
*/
public static void addProxyConnectAttachment(String visitorId, ProxyAttachment proxyAttachment) {
public static void addProxyConnectAttachment(String visitorId, Constants.ProxyAttachment proxyAttachment) {
proxyConnectAttachmentMap.put(visitorId, proxyAttachment);
}
@@ -326,7 +390,7 @@ public class ProxyUtil {
* @param visitorId
* @return
*/
public static ProxyAttachment getProxyConnectAttachment(String visitorId) {
public static Constants.ProxyAttachment getProxyConnectAttachment(String visitorId) {
return proxyConnectAttachmentMap.get(visitorId);
}
@@ -339,32 +403,86 @@ public class ProxyUtil {
}
/**
* 设置域名到服务端端口的映射
* @param subdomain
* 设置完整域名到服务端端口的映射
* @param fullDomain
* @param serverPort
*/
public static void setSubdomainToServerPort(String subdomain, Integer serverPort) {
subdomainToServerPort.put(subdomain, serverPort);
public static void setFullDomainToServerPort(String fullDomain, Integer serverPort) {
fullDomainToServerPortMap.put(fullDomain, serverPort);
}
/**
* 删除域名到服务端端口的映射
* @param subdomain
* 删除完整域名到服务端端口的映射
* @param fullDomain
*/
public static void removeSubdomainToServerPort(String subdomain) {
subdomainToServerPort.remove(subdomain);
public static void removeFullDomainToServerPort(String fullDomain) {
fullDomainToServerPortMap.remove(fullDomain);
}
/**
* 通过服务器端口删除完整域名到服务端端口的映射
* @param serverPort
*/
public static void removeFullDomainToServerPortByServerPort(Integer serverPort) {
fullDomainToServerPortMap.entrySet().removeIf(entry -> Objects.equals(entry.getValue(), serverPort));
}
/**
* 根据域名获取外网端口
* @param subdomain
* 根据完整域名获取外网端口
* @param fullDomain
* @return
*/
public static Integer getServerPortBySubdomain(String subdomain) {
return subdomainToServerPort.get(subdomain);
public static Integer getServerPortByFullDomain(String fullDomain) {
return fullDomainToServerPortMap.get(fullDomain);
}
/**
/**
* 添加域名到域名id的映射
*/
public static void setDomainToDomainNameId(String domain, Integer domainNameId) {
domainToDomainNameIdMap.put(domain, domainNameId);
}
/**
* 删除域名到域名id的映射
*/
public static void removeDomainToDomainNameId(String domain) {
domainToDomainNameIdMap.remove(domain);
}
/**
* 通过主域名获取域名id
*/
public static Integer getDomainNameIdByDomain(String domain) {
return domainToDomainNameIdMap.get(domain);
}
/**
* 通过完整域名获取域名id
*/
public static Integer getDomainNameIdByFullDomain(String fullDomain) {
List<String> domains = domainToDomainNameIdMap.keySet().stream().sorted((a,b) -> b.length() - a.length()).filter(item -> fullDomain.endsWith(item)).collect(Collectors.toList());
// 不存在返回null
if (CollectionUtil.isEmpty(domains)) {
return null;
}
// 优先匹配最长的域名默认取第一个后续思考如何优化
return getDomainNameIdByDomain(domains.get(0));
}
/**
* 通过完整域名获取域名
*/
public static String getDomainNameByFullDomain(String fullDomain) {
List<String> domains = domainToDomainNameIdMap.keySet().stream().sorted((a,b) -> b.length() - a.length()).filter(item -> fullDomain.endsWith(item)).collect(Collectors.toList());
// 不存在 或者 有多条记录返回null
if (CollectionUtil.isEmpty(domains)) {
return null;
}
return domains.getFirst();
}
/**
* 关闭http响应channel
* @param channel
* @return
@@ -378,7 +496,7 @@ public class ProxyUtil {
if (StringUtils.isBlank(visitorId)) {
return;
}
ProxyAttachment proxyAttachment = ProxyUtil.getProxyConnectAttachment(visitorId);
Constants.ProxyAttachment proxyAttachment = ProxyUtil.getProxyConnectAttachment(visitorId);
if (null != proxyAttachment) {
tryClose(channel);
}
@@ -421,4 +539,50 @@ public class ProxyUtil {
public static void removeClientIdByLicenseId(Integer licenseId) {
licenseIdToClientIdMap.remove(licenseId);
}
public static void setVisitorIdToSocketAddressMap(String visitorId, SocketAddress socketAddress) {
visitorIdToSocketAddressMap.put(visitorId, socketAddress);
socketAddressToVisitorIdMap.put(socketAddress, visitorId);
}
public static SocketAddress getSocketAddressByVisitorId(String visitorId) {
return visitorIdToSocketAddressMap.get(visitorId);
}
public static void removeSocketAddressByVisitorId(String visitorId) {
SocketAddress socketAddress = visitorIdToSocketAddressMap.get(visitorId);
visitorIdToSocketAddressMap.remove(visitorId);
socketAddressToVisitorIdMap.remove(socketAddress);
visitorIdToTunnelChannelMap.remove(visitorId);
}
public static String getVisitorIdBySocketAddress(SocketAddress socketAddress) {
return socketAddressToVisitorIdMap.get(socketAddress);
}
public static void setVisitorIdToTunnelChannelMap(String visitorId, Channel tunnelChannel) {
visitorIdToTunnelChannelMap.put(visitorId, tunnelChannel);
}
public static Channel getTunnelChannelByVisitorId(String visitorId) {
return visitorIdToTunnelChannelMap.get(visitorId);
}
public static StatsInfoRes.CacheInfo getCacheInfo() {
return new StatsInfoRes.CacheInfo()
.setProxyInfoMapSize(proxyInfoMap.size())
.setServerPortToCmdChannelMapSize(serverPortToCmdChannelMap.size())
.setLicenseToCmdChannelMapSize(licenseToCmdChannelMap.size())
.setServerPortToVisitorChannelMapSize(serverPortToVisitorChannel.size())
.setProxyConnectAttachmentMapSize(proxyConnectAttachmentMap.size())
.setFullDomainToServerPortMapSize(fullDomainToServerPortMap.size())
.setDomainToDomainNameIdMapSize(domainToDomainNameIdMap.size())
.setLicenseIdToClientIdMapSize(licenseIdToClientIdMap.size())
.setVisitorIdToSocketAddressMapSize(visitorIdToSocketAddressMap.size())
.setSocketAddressToVisitorIdMapSize(socketAddressToVisitorIdMap.size())
.setVisitorIdToTunnelChannelMapSize(visitorIdToTunnelChannelMap.size())
;
}
}
@@ -1,6 +1,6 @@
server:
# 服务端web端口,用于支持HTTP接口,管理后台页面访问
port: 8888
port: ${WEB_PORT:8888}
# 日志级别
solon.logging:
logger:
@@ -12,15 +12,18 @@ solon.logging:
neutrino:
proxy:
protocol:
# 高低水位线,如:32KB/64KB、32KB/1MB、1MB/5MB
# water-mark: 1MB/8MB
# 隧道相关配置-用于维持服务端与客户端的通信
tunnel:
# 线程池相关配置,用于技术调优,可忽略
boss-thread-count: 2
work-thread-count: 10
# 隧道非SSL端口
port: 9000
port: ${OPEN_PORT:9000}
# 隧道SSL端口
ssl-port: 9002
ssl-port: ${SSL_PORT:9002}
# 隧道SSL证书配置
key-store-password: 123456
key-manager-password: 123456
@@ -34,15 +37,10 @@ neutrino:
# 线程池相关配置,用于技术调优,可忽略
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:
# http代理端口,默认80(不配置不支持)
http-proxy-port: ${HTTP_PROXY_PORT:80}
# https代理端口,默认443 不配置不支持,同时需要配置域名、证书)
https-proxy-port: ${HTTPS_PROXY_PORT:443}
# 是否开启代理服务报文日志(日志级别为debug时开启才有效)
transfer-log-enable: false
udp:
@@ -54,10 +52,10 @@ neutrino:
data:
db:
# 数据库类型,目前支持h2、mysql、mariadb
type: h2
type: ${DB_TYPE:h2}
# 数据库连接URL
url: jdbc:h2:file:./data/db;MODE=MySQL;AUTO_SERVER=TRUE
url: ${DB_URL:jdbc:h2:file:./data/db;MODE=MySQL;AUTO_SERVER=TRUE}
# 数据库用户名
username:
username: ${DB_USER:}
# 数据库密码
password:
password: ${DB_PASSWORD:}
@@ -5,7 +5,7 @@ server:
solon:
app:
name: neutrino-proxy-server
version: 2.0.1
version: 2.0.4
config:
add: ./app.yml
# 日志级别
@@ -32,6 +32,8 @@ neutrino:
read-idle-time: 120
write-idle-time: 20
all-idle-time-seconds: 0
# 高低水位线,如:32KB/64KB、32KB/1MB、1MB/5MB
# water-mark: 1MB/8MB
# 隧道相关配置-用于维持服务端与客户端的通信
tunnel:
# 线程池相关配置,用于技术调优,可忽略
@@ -54,15 +56,10 @@ neutrino:
# 线程池相关配置,用于技术调优,可忽略
boss-thread-count: 5
work-thread-count: 20
# http代理端口,默认80
# http代理端口,默认80(不配置不支持)
http-proxy-port: ${HTTP_PROXY_PORT:80}
# https代理端口,默认443 (需要配置域名、证书)
# 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:
@@ -0,0 +1,33 @@
<?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.DomainMapper">
<select id="selectFullDomainNameListByPortMappingIds" resultType="org.dromara.neutrinoproxy.server.service.bo.FullDomainNameBO">
SELECT dpm.id as id, pm.id AS portMappingId, dpm.subdomain as subdomain, dn.domain AS domain, dn.id as domainNameId, dn.force_https as forceHttps
FROM domain_port_mapping dpm
LEFT JOIN port_mapping pm ON pm.id = dpm.port_mapping_id
LEFT JOIN domain_name dn ON dn.id = dpm.domain_name_id
WHERE pm.id IN
<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="selectFullDomainNameList"
resultType="org.dromara.neutrinoproxy.server.service.bo.FullDomainNameBO">
SELECT dpm.id as id, pm.id AS portMappingId, dpm.subdomain as subdomain, dn.domain AS domain, dn.id as domainNameId, dn.force_https as forceHttps
FROM domain_port_mapping dpm
LEFT JOIN port_mapping pm ON pm.id = dpm.port_mapping_id
LEFT JOIN domain_name dn ON dn.id = dpm.domain_name_id
</select>
<select id="selectFullDomainNameListByDomainNameIds"
resultType="org.dromara.neutrinoproxy.server.service.bo.FullDomainNameBO">
SELECT dpm.id as id, pm.id AS portMappingId, dpm.subdomain as subdomain, dn.domain AS domain, dn.id as domainNameId, dn.force_https as forceHttps
FROM domain_port_mapping dpm
LEFT JOIN port_mapping pm ON pm.id = dpm.port_mapping_id
LEFT JOIN domain_name dn ON dn.id = dpm.domain_name_id
WHERE dn.id IN
<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
#{item}
</foreach>
</select>
</mapper>
@@ -48,7 +48,7 @@
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
LEFT JOIN (SELECT license_id,sum(write_bytes) write_bytes,sum(read_bytes) read_bytes from flow_report_day
WHERE date >= #{curMonthBeginDate} AND #{curDayBeginDate}
WHERE date >= #{curMonthBeginDate} AND date &lt;= #{curDayBeginDate}
GROUP BY license_id) frd ON l.id = frd.license_id
LEFT JOIN (SELECT license_id,sum(write_bytes) write_bytes,sum(read_bytes) read_bytes from flow_report_minute
WHERE date >= #{curDayBeginDate} AND date &lt;= #{curDate}
@@ -97,9 +97,8 @@ CREATE TABLE IF NOT EXISTS `port_mapping` (
`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_ip` VARCHAR(255) NOT NULL,
`client_port` INTEGER NOT NULL,
`up_limit_rate` VARCHAR(20) DEFAULT NULL,
`down_limit_rate` VARCHAR(20) DEFAULT NULL,
@@ -114,6 +113,32 @@ CREATE TABLE IF NOT EXISTS `port_mapping` (
);
CREATE UNIQUE INDEX IF NOT EXISTS I_port_mapping_server_port ON port_mapping (server_port ASC);
#
CREATE TABLE IF NOT EXISTS `domain_name` (
`id` INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
`domain` VARCHAR(50) NOT NULL,
`user_id` INTEGER NOT NULL,
`jks` BLOB DEFAULT NULL,
`key_store_password` varchar(255) DEFAULT NULL,
`is_default` INTEGER(2) NOT NULL,
`force_https` INTEGER(2) NOT NULL,
`enable` INTEGER(2) NOT NULL,
`create_time` TIMESTAMP NOT NULL,
`update_time` TIMESTAMP NOT NULL
);
CREATE UNIQUE INDEX IF NOT EXISTS I_domain_name_domain ON domain_name (`domain` ASC);
#
CREATE TABLE IF NOT EXISTS `domain_port_mapping` (
`id` INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
`subdomain` VARCHAR(50) NOT NULL,
`domain_name_id` INTEGER NOT NULL,
`port_mapping_id` INTEGER NOT NULL
);
CREATE UNIQUE INDEX IF NOT EXISTS I_unique_domain_port_mapping ON domain_port_mapping (`domain_name_id` ASC, `subdomain` ASC);
CREATE INDEX IF NOT EXISTS I_domain_port_mapping_domain_name_id ON domain_port_mapping (`domain_name_id` ASC);
CREATE INDEX IF NOT EXISTS I_domain_port_mapping_port_mapping_id ON domain_port_mapping (`port_mapping_id` ASC);
##########################################################
#
CREATE TABLE IF NOT EXISTS `user_login_record` (
@@ -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', 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', 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', now(), now());
INSERT INTO port_mapping(`id`, `license_id`, `server_port`, `protocal`,`client_ip`, `client_port`, `is_online`, `enable`,`description`,`create_time`, `update_time`) VALUES
(1, 1, 9101, 'HTTP', '127.0.0.1', 8080, 2, 1,'test1', now(), now());
INSERT INTO port_mapping(`id`, `license_id`, `server_port`, `protocal`, `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', now(), now());
INSERT INTO port_mapping(`id`, `license_id`, `server_port`, `protocal`, `client_ip`, `client_port`, `is_online`, `enable`,`description`, `create_time`, `update_time`) VALUES
(3, 1, 9103, 'HTTP', '127.0.0.1', 8081, 2, 1,'test3', now(), now());
@@ -0,0 +1,28 @@
#
CREATE TABLE IF NOT EXISTS `domain_name` (
`id` INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
`domain` VARCHAR(50) NOT NULL,
`user_id` INTEGER NOT NULL,
`jks` BLOB DEFAULT NULL,
`key_store_password` varchar(255) DEFAULT NULL,
`is_default` INTEGER(2) NOT NULL,
`force_https` INTEGER(2) NOT NULL,
`enable` INTEGER(2) NOT NULL,
`create_time` TIMESTAMP NOT NULL,
`update_time` TIMESTAMP NOT NULL
);
CREATE UNIQUE INDEX IF NOT EXISTS I_domain_name_domain ON domain_name (`domain` ASC);
#
CREATE TABLE IF NOT EXISTS `domain_port_mapping` (
`id` INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
`subdomain` VARCHAR(50) NOT NULL,
`domain_name_id` INTEGER NOT NULL,
`port_mapping_id` INTEGER NOT NULL
);
CREATE UNIQUE INDEX IF NOT EXISTS I_unique_domain_port_mapping ON domain_port_mapping (`domain_name_id` ASC, `subdomain` ASC);
CREATE INDEX IF NOT EXISTS I_domain_port_mapping_domain_name_id ON domain_port_mapping (`domain_name_id` ASC);
CREATE INDEX IF NOT EXISTS I_domain_port_mapping_port_mapping_id ON domain_port_mapping (`port_mapping_id` ASC);
# port_mapping表删除字段
ALTER TABLE `port_mapping` DROP COLUMN `subdomain`;
@@ -102,9 +102,8 @@ CREATE TABLE IF NOT EXISTS `port_mapping` (
`id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`license_id` int NOT NULL COMMENT 'licenseID',
`protocal` varchar(10) NOT NULL DEFAULT 'TCP' COMMENT '协议',
`subdomain` varchar(50) DEFAULT NULL COMMENT '子域名(仅HTTP时有效)',
`server_port` int NOT NULL COMMENT '服务端端口',
`client_ip` varchar(20) NOT NULL COMMENT '客户端IP',
`client_ip` varchar(255) 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 '下载限速',
@@ -119,6 +118,34 @@ CREATE TABLE IF NOT EXISTS `port_mapping` (
PRIMARY KEY (`id`),
KEY `I_port_mapping_server_port` (`server_port`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
#
CREATE TABLE IF NOT EXISTS `domain_name` (
`id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`domain` varchar(50) NOT NULL COMMENT '域名',
`user_id` int NOT NULL COMMENT '用户Id',
`jks` BLOB DEFAULT NULL COMMENT 'jks文件',
`key_store_password` varchar(255) DEFAULT NULL COMMENT 'jks密码',
`is_default` int(2) NOT NULL COMMENT '是否开启默认域名(1、开启 2、关闭)',
`force_https` int(2) NOT NULL COMMENT '是否启用强制https(1、开启 2、关闭)',
`enable` int(2) NOT NULL COMMENT '是否启用(1、启用 2、禁用)',
`create_time` datetime NOT NULL COMMENT '创建时间',
`update_time` datetime NOT NULL COMMENT '更新时间',
PRIMARY KEY (`id`),
UNIQUE INDEX `I_domain_name_domain` (`domain` ASC)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
#
CREATE TABLE IF NOT EXISTS `domain_port_mapping` (
`id` int NOT NULL AUTO_INCREMENT COMMENT '创建时间',
`subdomain` varchar(50) NOT NULL COMMENT '子域名',
`domain_name_id` int NOT NULL COMMENT '域名Id',
`port_mapping_id` int NOT NULL COMMENT '端口映射Id',
PRIMARY KEY (`id`),
UNIQUE INDEX `I_unique_domain_port_mapping` (`domain_name_id` ASC, `subdomain` ASC),
INDEX `I_domain_port_mapping_domain_name_id` (`domain_name_id` ASC),
INDEX `I_domain_port_mapping_port_mapping_id` (`port_mapping_id` ASC)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
##########################################################
#
CREATE TABLE IF NOT EXISTS `user_login_record` (
@@ -1,7 +1,7 @@
#port_mapping
INSERT INTO port_mapping(`id`, `license_id`, `server_port`, `protocal`, `subdomain`, `client_ip`, `client_port`, `is_online`, `enable`, `create_time`, `update_time`) VALUES
(1, 1, 9101, 'HTTP', 'test1', '127.0.0.1', 8080, 2, 1, now(), now());
INSERT INTO port_mapping(`id`, `license_id`, `server_port`, `protocal`, `subdomain`, `client_ip`, `client_port`, `is_online`, `enable`, `create_time`, `update_time`) VALUES
(2, 1, 9102, 'TCP', '', '127.0.0.1', 3306, 2, 1, now(), now());
INSERT INTO port_mapping(`id`, `license_id`, `server_port`, `protocal`, `subdomain`, `client_ip`, `client_port`, `is_online`, `enable`, `create_time`, `update_time`) VALUES
(3, 1, 9103, 'HTTP', 'test2', '127.0.0.1', 8081, 2, 1, now(), now());
INSERT INTO port_mapping(`id`, `license_id`, `server_port`, `protocal`, `client_ip`, `client_port`, `is_online`, `enable`, `create_time`, `update_time`) VALUES
(1, 1, 9101, 'HTTP', '127.0.0.1', 8080, 2, 1, now(), now());
INSERT INTO port_mapping(`id`, `license_id`, `server_port`, `protocal`, `client_ip`, `client_port`, `is_online`, `enable`, `create_time`, `update_time`) VALUES
(2, 1, 9102, 'TCP', '127.0.0.1', 3306, 2, 1, now(), now());
INSERT INTO port_mapping(`id`, `license_id`, `server_port`, `protocal`, `client_ip`, `client_port`, `is_online`, `enable`, `create_time`, `update_time`) VALUES
(3, 1, 9103, 'HTTP', '127.0.0.1', 8081, 2, 1, now(), now());
@@ -0,0 +1,3 @@
#
INSERT INTO domain_name(`id`, `domain`, `user_id`, `jks`, `key_store_password`, `is_default`, `force_https`, `enable`,`create_time`, `update_time`) VALUES
(1, 'default.fun', 1, null, null, 1, 2, 1, now(), now());
@@ -102,9 +102,8 @@ CREATE TABLE IF NOT EXISTS `port_mapping` (
`id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`license_id` int NOT NULL COMMENT 'licenseID',
`protocal` varchar(10) NOT NULL DEFAULT 'TCP' COMMENT '协议',
`subdomain` varchar(50) DEFAULT NULL COMMENT '子域名(仅HTTP时有效)',
`server_port` int NOT NULL COMMENT '服务端端口',
`client_ip` varchar(20) NOT NULL COMMENT '客户端IP',
`client_ip` varchar(255) 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 '下载限速',
@@ -119,6 +118,34 @@ CREATE TABLE IF NOT EXISTS `port_mapping` (
PRIMARY KEY (`id`),
KEY `I_port_mapping_server_port` (`server_port`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
#
CREATE TABLE IF NOT EXISTS `domain_name` (
`id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`domain` varchar(50) NOT NULL COMMENT '域名',
`user_id` int NOT NULL COMMENT '用户Id',
`jks` BLOB DEFAULT NULL COMMENT 'jks文件',
`key_store_password` varchar(255) DEFAULT NULL COMMENT 'jks密码',
`is_default` int(2) NOT NULL COMMENT '是否开启默认域名(1、开启 2、关闭)',
`force_https` int(2) NOT NULL COMMENT '是否启用强制https(1、开启 2、关闭)',
`enable` int(2) NOT NULL COMMENT '是否启用(1、启用 2、禁用)',
`create_time` datetime NOT NULL COMMENT '创建时间',
`update_time` datetime NOT NULL COMMENT '更新时间',
PRIMARY KEY (`id`),
UNIQUE INDEX `I_domain_name_domain` (`domain` ASC)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
#
CREATE TABLE IF NOT EXISTS `domain_port_mapping` (
`id` int NOT NULL AUTO_INCREMENT COMMENT '创建时间',
`subdomain` varchar(50) NOT NULL COMMENT '子域名',
`domain_name_id` int NOT NULL COMMENT '域名Id',
`port_mapping_id` int NOT NULL COMMENT '端口映射Id',
PRIMARY KEY (`id`),
UNIQUE INDEX `I_unique_domain_port_mapping` (`domain_name_id` ASC, `subdomain` ASC),
INDEX `I_domain_port_mapping_domain_name_id` (`domain_name_id` ASC),
INDEX `I_domain_port_mapping_port_mapping_id` (`port_mapping_id` ASC)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
##########################################################
#
CREATE TABLE IF NOT EXISTS `user_login_record` (
@@ -1,7 +1,7 @@
#port_mapping
INSERT INTO port_mapping(`id`, `license_id`, `server_port`, `protocal`, `subdomain`, `client_ip`, `client_port`, `is_online`, `enable`, `create_time`, `update_time`) VALUES
(1, 1, 9101, 'HTTP', 'test1', '127.0.0.1', 8080, 2, 1, now(), now());
INSERT INTO port_mapping(`id`, `license_id`, `server_port`, `protocal`, `subdomain`, `client_ip`, `client_port`, `is_online`, `enable`, `create_time`, `update_time`) VALUES
(2, 1, 9102, 'TCP', '', '127.0.0.1', 3306, 2, 1, now(), now());
INSERT INTO port_mapping(`id`, `license_id`, `server_port`, `protocal`, `subdomain`, `client_ip`, `client_port`, `is_online`, `enable`, `create_time`, `update_time`) VALUES
(3, 1, 9103, 'HTTP', 'test2', '127.0.0.1', 8081, 2, 1, now(), now());
INSERT INTO port_mapping(`id`, `license_id`, `server_port`, `protocal`, `client_ip`, `client_port`, `is_online`, `enable`, `create_time`, `update_time`) VALUES
(1, 1, 9101, 'HTTP', '127.0.0.1', 8080, 2, 1, now(), now());
INSERT INTO port_mapping(`id`, `license_id`, `server_port`, `protocal`, `client_ip`, `client_port`, `is_online`, `enable`, `create_time`, `update_time`) VALUES
(2, 1, 9102, 'TCP', '127.0.0.1', 3306, 2, 1, now(), now());
INSERT INTO port_mapping(`id`, `license_id`, `server_port`, `protocal`, `client_ip`, `client_port`, `is_online`, `enable`, `create_time`, `update_time`) VALUES
(3, 1, 9103, 'HTTP', '127.0.0.1', 8081, 2, 1, now(), now());
@@ -0,0 +1,30 @@
#
CREATE TABLE IF NOT EXISTS `domain_name` (
`id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`domain` varchar(50) NOT NULL COMMENT '域名',
`user_id` int NOT NULL COMMENT '用户Id',
`jks` BLOB DEFAULT NULL COMMENT 'jks文件',
`key_store_password` varchar(255) DEFAULT NULL COMMENT 'jks密码',
`is_default` int(2) NOT NULL COMMENT '是否开启默认域名(1、开启 2、关闭)',
`force_https` int(2) NOT NULL COMMENT '是否启用强制https(1、开启 2、关闭)',
`enable` int(2) NOT NULL COMMENT '是否启用(1、启用 2、禁用)',
`create_time` datetime NOT NULL COMMENT '创建时间',
`update_time` datetime NOT NULL COMMENT '更新时间',
PRIMARY KEY (`id`),
UNIQUE INDEX `I_domain_name_domain` (`domain` ASC)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
#
CREATE TABLE IF NOT EXISTS `domain_port_mapping` (
`id` int NOT NULL AUTO_INCREMENT COMMENT '创建时间',
`subdomain` varchar(50) NOT NULL COMMENT '子域名',
`domain_name_id` int NOT NULL COMMENT '域名Id',
`port_mapping_id` int NOT NULL COMMENT '端口映射Id',
PRIMARY KEY (`id`),
UNIQUE INDEX `I_unique_domain_port_mapping` (`domain_name_id` ASC, `subdomain` ASC),
INDEX `I_domain_port_mapping_domain_name_id` (`domain_name_id` ASC),
INDEX `I_domain_port_mapping_port_mapping_id` (`port_mapping_id` ASC)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
# port_mapping表删除字段
ALTER TABLE `port_mapping` DROP COLUMN `subdomain`;
+2
View File
@@ -8,3 +8,5 @@
[主题仓库](https://github.com/xugaoyi/vuepress-theme-vdoing)
[本仓库的gitee镜像](https://gitee.com/xugaoyi/vuepress-theme-vdoing-doc)
hello11
@@ -9,7 +9,8 @@ module.exports = {
title: "中微子代理",
description: '一个基于Netty的开源内网穿透神器',
base: '/neutrino-proxy/', // 默认'/'。如果你想将你的网站部署到如 https://foo.github.io/bar/,那么 base 应该被设置成 "/bar/",(否则页面将失去样式等文件)
// base: '/neutrino-proxy/', // 默认'/'。如果你想将你的网站部署到如 https://foo.github.io/bar/,那么 base 应该被设置成 "/bar/",(否则页面将失去样式等文件)
base: '/',
head: [ // 注入到页面<head> 中的标签,格式[tagName, { attrName: attrValue }, innerHTML?]
['link', {rel: 'icon', href: '/img/favicon.ico'}], //favicons,资源放在public文件夹
['meta', {name: 'keywords', content: 'vuepress,theme,blog,vdoing'}],
@@ -33,6 +34,7 @@ module.exports = {
{text: '案例', link: '/pages/5d571c/'},
{text: '支持', link: '/pages/1ab20b/'},
{text: '更新记录', link: '/pages/ff3519/'},
{text: 'GitCode', link: 'https://gitcode.com/dromara/neutrino-proxy'},
{text: 'Gitee', link: 'https://gitee.com/dromara/neutrino-proxy'},
],
sidebarDepth: 2, // 侧边栏显示深度,默认1,最大2(显示到h3标题)
Binary file not shown.

After

Width:  |  Height:  |  Size: 167 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

@@ -6,13 +6,7 @@ article: false
---
::: tip
当前最新版本2.0.0,如果从之前的版本升级来,请注意以下变更
1、jdk版本升级为了jdk17,jar部署时请注意
2、去掉了默认的sqlite数据库,改为了h2。如果之前使用sqlite,请自行处理数据迁移
3、配置文件做了较大调整,请参照使用须知中的`服务端配置``客户端配置`进行更新
当前最新版本2.0.3。从之前的版本升级来,请参照:更新记录 > 版本记录.
:::
## 1、快速上手须知
@@ -22,8 +16,7 @@ article: false
- 快速上手中涉及到的配置,仅仅是快速体验所必须的配置,完整的配置请参照使用须知中的`服务端配置``客户端配置`
## 2、部署服务
- 根据需要自行选择jar、docker、原生部署任意一种完成部署
- 三种方式分别参见对应的文档
- 根据需要自行选择宝塔面板、jar、docker、原生部署、docker-compose任意一种完成部署,分别参见对应的文档
- 任何一种部署方式,不要求客户端与服务端一致。如:服务端采用docker部署,客户端可以用docker部署、也可以用jar、原生部署
- 管理后台说明
- 服务端部署成功后,访问http://{服务端IP}:8888打开后台管理页面。使用默认的管理员帐号登录:admin/123456
@@ -0,0 +1,43 @@
---
title: 通过宝塔面板部署
date: 2024-23-20 13:32:00
permalink: /pages/9e0fde/
article: false
---
## 前提
- 仅适用于宝塔面板9.2.0及以上版本
- 安装宝塔面板,前往[宝塔面板](https://www.bt.cn/new/download.html?r=dk_neuproxy)官网,选择正式版的脚本下载安装
## 部署
#### 1、登录宝塔面板,在左侧菜单栏中点击`Docker`
<img :src="$withBase('/img/baota/step1.png')"></img>
#### 2、首次会提示安装Docker和Docker Compose服务,点击立即安装,若已安装请忽略。
<img :src="$withBase('/img/baota/step2.png')"></img>
#### 3、安装完成后在Docker-应用商店中找到 中微子代理(搜索“NeutrinoProxy”),点击安装
<img :src="$withBase('/img/baota/step3.png')"></img>
#### 4、设置基本信息,点击确定
- 名称:应用名称,默认`neuproxy_随机字符`
- 版本:默认`latest`
- 允许外部访问:如您需通过`IP+Port`直接访问,请勾选,如您已经设置了域名,请不要勾选此处
- web管理端口:默认`9988`,可自行修改
- 客户端连接端口:默认`9989`,可自行修改
- 客户端SSL连接端口:默认`9990`,可自行修改
<img :src="$withBase('/img/baota/step4.png')"></img>
#### 5、提交后面板会自动进行应用初始化,大概需要`1-3`分钟,初始化完成后即可访问。
- 如果部署失败,可能是从DockerHub拉取镜像失败,可以自行设置镜像加速。
<img :src="$withBase('/img/baota/step5.png')"></img>
#### 6、访问中微子代理管理后台
<img :src="$withBase('/img/baota/step6.png')"></img>
@@ -5,13 +5,13 @@ permalink: /pages/eebea1/
---
## 1、环境准备
- 首先确保已安装Java17运行环境
- 打开[发行版页面](https://gitee.com/dromara/neutrino-proxy/releases),下载最新的release包:`neutrino-proxy-server-jar.zip``neutrino-proxy-client-jar.zip`
- 首先确保已安装Java21运行环境
- 打开[发行版页面](https://gitee.com/dromara/neutrino-proxy/releases),下载最新的release包:`neutrino-proxy-server-jdk21-2.0.2-jar.zip``neutrino-proxy-client-jdk21-2.0.2-jar.zip`
- 百度网盘下载速度慢?[点击这里加速](https://docs.xigexb.com/s/neutrino-proxy/doc/neutrino-proxy-CROFc0fdYh),此站点由[喜鸽小宝](https://www.xigexb.com)提供。
## 2、部署服务端
- 在服务器上新建部署目录:`/work/projects/neutrino-proxy-server`
- 将`neutrino-proxy-server-jar.zip`上传至服务器部署目录,并解压
- 将`neutrino-proxy-server-jdk21-2.0.2-jar.zip`上传至服务器部署目录,并解压
- 执行命令`java -Dfile.encoding=utf-8 -jar neutrino-proxy-server.jar`启动服务端完成部署,默认使用h2数据库。
- 若需要指定自己的mysql数据库,则需要在当前目录下的`app.yml`文件中,修改数据库配置如下:
@@ -32,7 +32,7 @@ neutrino:
- 可参照 https://gitee.com/dromara/neutrino-proxy/blob/master/scripts/unix/server_start.sh 使用shell脚本启动服务端。
## 3、部署客户端
- 本地解压`neutrino-proxy-client-jar.zip`文件
- 本地解压`neutrino-proxy-client-jdk21-2.0.2-jar.zip`文件
- 修改`app.yml`文件中的server-ip为服务器公网ip,并配置license-key,以下是相关的部分配置:
```yml
neutrino:
@@ -5,6 +5,8 @@ permalink: /pages/5b9bef/
---
## 1、 部署服务端
- dockerHub镜像地址:aoshiguchen/neutrino-proxy-server:latest
- 阿里云镜像地址:registry.cn-hangzhou.aliyuncs.com/asgc/neutrino-proxy:latest
### 使用默认h2数据库一键部署
```shell
docker run -it -p 9000-9200:9000-9200/tcp -p 8888:8888 \
@@ -34,6 +36,8 @@ neutrino:
- 然后再执行上面的docker一键部署命令即可
## 2、部署客户端
- dockerHub镜像地址:aoshiguchen/neutrino-proxy-client:latest
- 阿里云镜像地址:registry.cn-hangzhou.aliyuncs.com/asgc/neutrino-proxy-client:latest
- 命令中的服务端ip、license请自行补充
- 若是首次使用,请仔细阅读快速上手,以确定license从哪里取得
```shell
@@ -18,7 +18,8 @@ permalink: /pages/69699a/
## 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`
- 比如服务器为linux则可下载`neutrino-proxy-server-linux-2.0.2-native.zip`文件,客户端为windows则可下载`neutrino-proxy-client-windows-2.0.2-native.zip`
- 百度网盘下载速度慢?[点击这里加速](https://docs.xigexb.com/s/neutrino-proxy/doc/neutrino-proxy-CROFc0fdYh),此站点由[喜鸽小宝](https://www.xigexb.com)提供。
## 2、部署服务端
- 将服务端安装包上传至服务器,并解压
@@ -0,0 +1,30 @@
---
title: 使用docker-compose部署
date: 2024-12-07 14:40:50
permalink: /pages/2d4123/
---
## 1、 部署服务端
### 使用默认h2数据库一键部署
- 注意自行修改配置文件:config/app.yml
```shell
git clone https://gitee.com/dromara/neutrino-proxy.git
cd neutrino-proxy/scripts/docker-compose/neutrino-proxy-server-h2
docker-compose up -d
```
### 使用默认mysql数据库一键部署
- 注意自行修改配置文件:config/app.yml
```shell
git clone https://gitee.com/dromara/neutrino-proxy.git
cd neutrino-proxy/scripts/docker-compose/neutrino-proxy-server-mysql
docker-compose up -d
```
## 2、部署客户端
- 注意自行修改配置文件:config/app.yml
```shell
git clone https://gitee.com/dromara/neutrino-proxy.git
cd neutrino-proxy/scripts/docker-compose/neutrino-proxy-client
docker-compose up -d
```
@@ -17,8 +17,23 @@ article: false
# 代理配置
- License管理:License是客户端连接服务端的唯一合法凭证。一个License同时只能被一个客户端使用,一个License可以维护多条端口映射
- 端口映射:服务端IP+端口 -> 客户端IP+端口的四元组映射(因目前服务端单节点只有一个公网IP,所以不体现出来),是内网穿透的基本单元。
- 限速:
- 默认所有代理没有限速
- 对License限速,将使得License下的所有端口映射都被限速
- 若License设置了限速,License下的某条映射也设置了限速,则对于该映射优先采用端口映射上的限速规则
- 域名管理:用于管理服务器主域名和证书,用于支持域名映射。一个主域名域名可以创建多个域名映射(配置不同的子域名)。
<img :src="$withBase('/img/run-example/license2.png')"></img>
<img :src="$withBase('/img/run-example/port-mapping2.png')"></img>
# 安全组
一个端口映射可绑定一个安全组,通过安全组的默认放行类型 + 安全组下的安全规则 控制该端口映射的安全访问规则。
- 场景1: 内部服务,穿透出来自己使用,不希望被其他人访问。端口映射可关联一个默认放行类型为“拒绝”的安全组,安全组下新增安全规则,将本地的出口ip添加到允许放行规则中。
- 场景2:公网服务,穿透出来开放给大家使用,但是希望拒绝某些IP访问。端口映射可关联一个默认放行类型为“允许”的安全组,安全组下新增安全规则,将黑名单ip添加到拒绝放行规则中。
<img :src="$withBase('/img/run-example/security-group1.png')"></img>
<img :src="$withBase('/img/run-example/security-rule1.png')"></img>
<img :src="$withBase('/img/run-example/license1.png')"></img>
# 系统管理
- 用户管理:支持多用户,一个用户可持有多个License。由于项目目前主推个人版,所以暂是没有权限这一套,管理员之外的所有用户都属于游客。对于绝大多数操作,游客仅有只读权限。
@@ -44,4 +59,4 @@ article: false
- 登录日志:管理后端登录、退出登录的日志
- 客户端连接日志:客户端连接、断开的日志
<img :src="$withBase('/img/run-example/login-log1.png')"></img>
<img :src="$withBase('/img/run-example/login-log1.png')"></img>
@@ -6,6 +6,7 @@ permalink: /pages/269a2e/
# 什么是域名映射?
域名映射是将指定端口映射绑定到某一个子域名上,通过直接访问域名的方式,达到访问被代理服务的目的。
支持维护多个主域名并为多个主域名配置不同的子域名实现域名映射。
# 域名映射能解决什么问题?
- 1、当服务端端口需要经常变动的时候,可以通过固定域名的方式,使得开发调试能够长期稳定的进行,不用每次更改访问地址。
@@ -17,8 +18,8 @@ permalink: /pages/269a2e/
## 情况1:代理服务端使用80端口
- 1、DNS解析配置泛域名解析 proxy.asgc.fun 指向代理服务端IP
- 2、代理服务端app.yml配置域名:proxy.asgc.fun,部署
- 3、服务端管理后台新建端口映射,协议选择:HTTP设置好子域名,如:test1
- 2、服务端管理后台域名管理新建域名,如:asgc.fun
- 3、服务端管理后台新建端口映射,协议选择:HTTP(S),选择主域名并设置好子域名,如:test1.proxy
- 4、配置好客户端并启动,代理映射完成
- 5、通过访问: http://test1.proxy.asgc.fun 实现访问被代理服务
@@ -27,8 +28,8 @@ permalink: /pages/269a2e/
- 1、DNS解析配置泛域名解析 proxy.asgc.fun 指向代理服务端IP
- 2、nginx 80端口下将 *.proxy.asgc.fun 请求转到82端口,并附带原有请求头(特别是`Host`
- 3、代理服务端app.yml配置域名:proxy.asgc.fun,部署
- 4、服务端管理后台新建端口映射,协议选择:HTTP,设置好子域名,如:test1
- 3、服务端管理后台域名管理新建域名,如:asgc.fun
- 4、服务端管理后台新建端口映射,协议选择:HTTP(S),设置好子域名,如:test1.proxy
- 5、配置好客户端并启动,代理映射完成
- 6、通过访问: http://test1.proxy.asgc.fun 实现访问被代理服务
@@ -36,6 +37,13 @@ permalink: /pages/269a2e/
不行的。之所以能实现域名绑定,原因是HTTP请求附带了Host请求头,包含了请求的域名信息,代理服务端能根据请求的域名做分发。而TCP协议本身并不包含域名,因此无法实现。
所以,目前只有HTTP(涵盖HTTPS)协议能支持。
# 域名映射支持HTTPS吗?
支持的。在服务端管理后台-域名管理中新建域名并上传域名对应的服务器证书,可以选择强制HTTPS,这样会拦截所有HTTP请求,只支持通过HTTPS访问。
如果上传后的证书仍不支持HTTPS访问,请确保上传证书有效并且和配置的主域名或完整域名映射匹配。
# 上传服务器证书的文件有要求吗?
有的。目前只支持通过jks文件上传服务器证书,jks文件中只包含服务器证书(如:.cer文件),并设置密码。
# 代理服务端使用非80端口时,nginx配置示例
```
server {
@@ -18,7 +18,8 @@ permalink: /pages/99a300/
## HTTPS配置流程
- 按照域名映射流程,完成域名的配置
- 在服务端配置域名的HTTPS证书信息(此处应该是通配符证书)
- 在服务端管理后台上传对应域名的HTTPS证书信息(此处应该是通配符证书)
## HTTPS端口问题
- 与HTTP类似,HTTPS也有一个默认端口:443,默认情况下需要占用服务端443端口
@@ -1,12 +1,12 @@
---
title: 服务端配置
date: 2023-05-27 11:41:44
date: 2024-09-22 11:41:44
permalink: /pages/f2d0f1/
---
::: tip
1.9.0版本,服务端配置格式有所调整。从之前的版本升级的,需要注意
2.0.2版本,服务端配置格式有所调整。从之前的版本升级的,需要注意
:::
@@ -16,13 +16,12 @@ permalink: /pages/f2d0f1/
server:
# 服务端web端口,用于支持HTTP接口,管理后台页面访问
port: ${WEB_PORT:8888}
# 日志级别
solon.logging.logger:
"root":
level: info
neutrino:
proxy:
logger:
# 日志级别
level: ${LOG_LEVEL:info}
# 隧道相关配置-用于维持服务端与客户端的通信
tunnel:
# 线程池相关配置,用于技术调优,可忽略
@@ -38,8 +37,6 @@ neutrino:
jks-path: ${JKS_PATH:classpath:/test.jks}
# 是否开启隧道传输报文日志(日志级别为debug时开启才有效)
transfer-log-enable: ${TUNNEL_LOG:false}
# 是否开启心跳日志
heartbeat-log-enable: ${HEARTBEAT_LOG:false}
server:
tcp:
# 线程池相关配置,用于技术调优,可忽略
@@ -49,11 +46,6 @@ neutrino:
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:
@@ -64,7 +56,7 @@ neutrino:
transfer-log-enable: ${SERVER_LOG:false}
data:
db:
# 数据库类型,目前支持h2、mysql、mariadb
# 数据库类型,目前支持sqlite、mysql、mariadb
type: ${DB_TYPE:h2}
# 数据库连接URL
url: ${DB_URL:jdbc:h2:file:./data/db;MODE=MySQL;AUTO_SERVER=TRUE}
@@ -0,0 +1,8 @@
---
title: 服务端原声包启动,db初始化异常
date: 2024-11-09 15:28:37
permalink: /pages/7dcba8/
---
## 1.1、报错“Data truncation: Data too long for column 'name' at row 1”
配置文件中配置的mysql连接地址,去掉“characterEncoding=UTF-8”参数
@@ -11,9 +11,9 @@ permalink: /pages/1ab20b/
|:-----|:-----|:----------------------|
| 任意金额 | - | 您将获得赞助者列表的永久留名。 |
| 30 | 一个月 | 您在群内反馈的问题将优先得到作者响应 |
| 80 | 三个月 | 获得微信一对一的咨询服务 |
| 180 | 个月 | 获得官网首页特别赞助席位一个,一次远程协助 |
| 更多金额 |-| 您将获得私人定制服务 |
| 120 | 三个月 | 获得微信一对一的咨询服务 |
| 399 | 个月 | 获得官网首页特别赞助席位一个,一次远程协助 |
| 更多金额 | - | 您将获得私人定制服务 |
> 注意1:服务项目是逐级叠加:如,您赞赏的金额是 80 员那么您将享受:任意金额、一个月、三个月的服务内容
@@ -6,6 +6,15 @@ permalink: /pages/cded59/
| 日期 | 渠道 | 金额 |昵称| 备注 |
|:-----------|:---|:-----|:-|:-----------------|
|2023-12-28|微信红包|50|雪猫|请大佬吃肯德基|
|2023-12-27|微信红包|50|D|请大佬喝杯茶|
|2023-12-25|微信赞赏码|30|Simen|伟大的项目,尽点绵薄之力|
|2023-12-25|微信红包|50|KAI|大佬加油|
|2023-12-22|微信赞赏|30|walking|好东西必须支持一下|
|2023-12-21|微信红包|100|洗最大的碗|中微子越来越强大,雨哥越来越富有|
|2023-12-15|Gitee捐助|10|一杯香梨||
|2023-12-12|微信红包|50|喜鸽小宝||
|2023-11-30|支付宝收款码|30|*平|大佬继续加油|
|2023-11-30|Gitee捐助|10|26263|感谢您的开源项目!|
|2023-11-30|微信红包|10|姫野永遠||
| 2023-11-26 |微信转账|180|Teacher Du||
@@ -0,0 +1,28 @@
---
title: 2024年
date: 2024-04-16 19:22:05
permalink: /pages/acdf0a/
---
| 日期 | 渠道 | 金额 |昵称| 备注 |
|:-----------|:---|:-----|:-|:--------------------------------------|
| 2024-11-19|支付宝收款码|2|*亮||
| 2024-10-06 |Gitee捐助|100|碧云天|感谢您的开源项目!|
| 2024-10-14 |微信红包|5|泛微eteams刘新东17699059661|
| 2024-09-04 |Gitee捐助|8.88|lusen998|感谢您的开源项目!|
| 2024-08-30 | 微信转账|100|吴忧吴虑|
| 2024-07-29 |Gitee捐助|10|QuanJWS|感谢您的开源项目!看着很不错的样子,加油! |
| 2024-07-29 |微信赞赏码|120|陈某| |
| 2024-05-07 |微信转账|100|仲秀| |
| 2024-04-16 |微信转账|100|暮光:城中城| |
| 2024-04-03 |微信转账|100|仲秀| 大神,非常感谢 |
| 2024-03-24 |Gitee捐助|10|include|
| 2024-03-24 |微信赞赏码|9|宗| 麻烦了,最好能加一个返回公网IP。<br/>不知道有没有几乎通用的方案 |
| 2024-03-22 |微信红包|20|不允| 请你吃外卖 |
| 2024-03-12 |微信红包|50|喜鸽小宝|
| 2024-02-12 |微信红包|50|喜鸽小宝|
| 2024-02-02 |微信红包|38.88|不请自来君|
| 2024-01-24 |Gitee捐助|30|唐吉诃德| 感谢您的开源项目!是一个不错的项目!<br/>希望继续完善界面UI的设计。 |
| 2024-01-20 |微信红包|shiyongsway|8.88|
| 2024-01-17 |微信红包|50|喜鸽小宝| |
@@ -4,6 +4,37 @@ date: 2023-10-26 17:43:43
permalink: /pages/ff3519/
---
## 2.0.3
- 紧急bug修复:解决http请求拆包情况下域名映射失效的问题
## 2.0.2
- bug修复
- 解决安全组在ipv6场景下误拦截导致域名映射访问不通的问题
- 解决native编译后,端口池批量删除报错的问题
- 解决客户端docker方式部署环境变量指定参数不生效的问题
- 服务端解决native下清理日志定时任务报错的问题
- 解决后台分页查询的已知问题
- 端口映射中的客户端ip字段加长一点,解决配置阿里云数据库域名字段不够的问题
- 解决服务端native部署时,访问后台用户列表,日志警告“you should use: nativeMetadata.registerField(field) at aot runtime”的问题
- 新增功能
- 新增后台域名管理,⽀持新增、修改、删除、禁⽤主域名,支持添加多级域名。
- 域名管理支持上传域名对应的SSL证书、⽀持设置强制HTTPS、⽀持域名映射⾃动加载对应的服务器证书。
- 端口映射支持选择切换不同的主域名,⽀持绑定多个⼦域名,单个端⼝⽀持绑定多个不同的主域名。
- 升级须知:
- **域名和SSL证书的配置由配置文件配置改为后台域名管理页面配置。**
- 去掉了配置文件声明服务器端域名和证书的方式,改为通过页面进行管理,请注意自行进行数据迁移。
- 数据库新增`域名表``域名映射中间表`,修改了`端口映射表`,涉及到表结构变更,执行[增量SQL](https://gitee.com/dromara/neutrino-proxy/blob/master/neutrino-proxy-server/src/main/resources/sql/mysql/update/UPDATE-20240808.SQL)
## 2.0.1
- jdk版本升级为21
- 新增安全组模块,支持黑名单、白名单限制
- 支持对用户、license限速
- 修复HTTP(S)映射时使用tcp端口访问正常,使用域名访问偶现一直loading的问题
- 修复HTTP(S)映射时使用映射的域名上传文件时,连接中断的问题
- 升级须知:
- jdk版本升级为了jdk21,jar部署时请注意
- 涉及到表结构变更,执行[增量SQL](https://gitee.com/dromara/neutrino-proxy/blob/master/neutrino-proxy-server/src/main/resources/sql/mysql/update/UPDATE-20231215.SQL)
## 2.0.0
- solon版本升级为`2.5.11`
- jdk版本升级为17
@@ -3,7 +3,11 @@ title: 里程碑
date: 2023-10-26 17:41:26
permalink: /pages/e406dd/
---
- 2025-08-14 中微子代理Gitee Star数突破2000
- 2024-12-20 中微子代理服务端支持宝塔面板一件部署
- 2024-12-10 2.0.2版本发布,新增域名管理,端口映射支持绑定多个域名
- 2024-08-12 中微子代理Gitcode 荣获G-Star认证
- 2023-12-21 2.0.1版本发布,jdk版本升级到21,支持安全组(黑/白名单IP限制)、限速
- 2023-10-31 2.0.0版本发布,升级jdk版本至jdk17、支持原生编译、去掉sqlite改为默认H2数据库
- 2023-09-25 中微子代理Gitee Star数突破1000
- 2023-09-22 1.9.0版本发布,端口映射支持UDP协议
+12 -8
View File
@@ -13,12 +13,12 @@ features: # 可选的
details: 首页图表、报表管理多维度流量监控。全方位掌握实时、历史代理数据。
- title: 域名映射
details: HTTP代理绑定子域名,开发调试三方回调更方便。
- title: 用户/License
details: 支持多用户、多客户端使用。后台禁用实时生效。
- title: 端口池
details: 对外端口统一管理,支持用户、License独占端口
- title: 端口映射
details: 新增、编辑、删除、禁用实时生效。
- title: 管理后台
details: 使用端口池统一管理对外代理端口,支持多用户、多客户端使用。端口/用户/License/端口映射在后台禁用实时生效。
- title: 安全组
details: 安全组模块支持黑/白名单IP访问限制
- title: 限速
details: 支持对License、端口映射限制上传、下载速率
- title: Docker
details: 服务端/客户端支持Docker一键部署。
- title: 隧道SSL加密
@@ -148,11 +148,15 @@ postList: none
<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>
<div><p class="name">喜鸽小宝</p> <p class="desc">一个爱好写代码的同学。<br/>&nbsp;</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>
<div><p class="name">去不图床</p> <p class="desc">杜老师说旗下付费图片外链平台。<br/>&nbsp;</p></div>
</a>
<a href="http://doc.zyplayer.com/#/integrate/zyplayer-doc?utm=neutrino-proxy" target="_blank" class="card-item row-3" style="background-color:#486898;--random-color:#c6ddff;color:#FFFFFF;">
<img src="img/sponsor/zyplayer-doc.png" class="no-zoom">
<div><p class="name">zyplayer-doc</p> <p class="desc">私有化部署的企业级文档管理与知识库AI问答平台。</p></div>
</a>
</div>
</div>
+2 -2
View File
@@ -4,8 +4,8 @@
"scripts": {
"dev": "vuepress dev docs",
"build": "vuepress build docs",
"buildAndDeploy": "vuepress build docs && bash deploy.sh",
"deploy": "bash deploy.sh",
"buildAndDeploy": "vuepress build docs && bash deploy/deploy1.sh",
"deploy": "bash deploy/deploy1.sh",
"updateTheme": "yarn remove vuepress-theme-vdoing && rm -rf node_modules && yarn && yarn add vuepress-theme-vdoing -D",
"editFm": "node utils/editFrontmatter.js"
},
+2 -3
View File
@@ -7,7 +7,7 @@
<parent>
<groupId>org.noear</groupId>
<artifactId>solon-parent</artifactId>
<version>2.5.12</version>
<version>2.7.6</version>
<relativePath />
</parent>
@@ -26,10 +26,9 @@
<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>2.0.1-SNAPSHOT</revision>
<revision>2.0.3</revision>
<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>
+35
View File
@@ -0,0 +1,35 @@
## 项目简介
- [中微子代理(neutrino-proxy)](https://gitee.com/dromara/neutrino-proxy) 是一款基于Solon、Netty的内网穿透神器。该项目采用最为宽松的MIT协议,因此您可以对它进行复制、修改、传播并用于任何个人或商业行为。
- 市面上基于内网穿透的常见产品有:花生壳、TeamView、cpolar等。
- 常见的使用场景:
- 本地开发调试第三方回调
- 本地开发异地接口连调
- 远程登录内网windows机器
- 将本地服务映射到外网,用于演示
- Gitee仓库:https://gitee.com/dromara/neutrino-proxy
- GitCode仓库:https://gitcode.com/dromara/neutrino-proxy
- GitHub仓库:https://github.com/dromara/neutrino-proxy
- 官网地址: https://neutrino-proxy.dromara.org
## 主要特点:
- 1、流量监控:首页图表、报表管理多维度流量监控。全方位掌握实时、历史代理数据。
- 2、用户/License:支持多用户、多客户端使用。后台禁用实时生效。
- 3、端口池:对外端口统一管理,支持用户、License独占端口。
- 4、端口映射:新增、编辑、删除、禁用实时生效。
- 5、Docker:服务端/客户端支持Docker一键部署。
- 6、SSL证书:隧道通信支持SSL加密,保护您的数据安全。
- 7、域名映射:支持绑定子域名,方便本地调试三方回调
- 8、多种协议:支持代理TCP、HTTP、HTTPS、UDP协议
- 9、原生部署:支持编译为原生可执行文件,更低部署门槛、更少内存占用
- 10、安全组:支持黑/白名单IP访问限制
- 11、限速:支持对License、端口映射限制上传/下载速度
- 12、采用最为宽松的MIT协议,免去你的后顾之忧
## 镜像版本&地址
- 版本:当前最新版本为`2.0.1`,可直接使用`latest`拉取最新镜像
- neutrino-proxy-server
- DockerHub镜像地址:aoshiguchen/neutrino-proxy-server:latest
- 阿里云镜像地址:neutrino-proxy registry.cn-hangzhou.aliyuncs.com/asgc/neutrino-proxy:latest
- neutrino-proxy-client
- DockerHub镜像地址:aoshiguchen/neutrino-proxy-client:latest
- 阿里云镜像地址:registry.cn-hangzhou.aliyuncs.com/asgc/neutrino-proxy-client:latest
@@ -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: host.docker.internal
# 服务端端口(对应服务端app.yml中的tunnel.port、tunnel.ssl-port)
server-port: 9002
# 是否启用SSL(注意:该配置必须和server-port对应上)
ssl-enable: true
# 客户端连接唯一凭证
license-key: b0a907332b474b25897c4dcb31fc7eb6
# 客户端唯一身份标识(可忽略,若不设置首次启动会自动生成)
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
@@ -0,0 +1,21 @@
version: '3.8'
networks:
npClient:
driver: bridge
services:
npClient:
image: aoshiguchen/neutrino-proxy-client:latest
container_name: compose-npClient
hostname: npClient
restart: always
environment:
TZ: Asia/Shanghai
LANG: zh_CN.UTF-8
volumes:
- ./config:/root/neutrino-proxy/config
- ./logs:/root/neutrino-proxy/logs
ports:
- "10000-10500:10000-10500/udp"
networks:
- npClient
@@ -0,0 +1,58 @@
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
# 是否开启代理服务报文日志(日志级别为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:
@@ -0,0 +1,25 @@
version: '3.8'
networks:
npServer:
driver: bridge
services:
npServer:
image: aoshiguchen/neutrino-proxy-server:latest
container_name: compose-npServer
hostname: npServer
restart: always
environment:
TZ: Asia/Shanghai
LANG: zh_CN.UTF-8
volumes:
- ./config:/root/neutrino-proxy/config
- ./data:/root/neutrino-proxy/data
- ./logs:/root/neutrino-proxy/logs
ports:
- "8888:8888"
- "9000:9000"
- "9002:9002"
- "9101-9120:9101-9120"
networks:
- npServer
@@ -0,0 +1,58 @@
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
# 是否开启代理服务报文日志(日志级别为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: mysql
# 数据库连接URL
url: jdbc:mysql://mysql:3306/neutrino-proxy?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&useAffectedRows=true&useSSL=false&allowPublicKeyRetrieval=true
# 数据库用户名
username: root
# 数据库密码
password: 123456
@@ -0,0 +1,21 @@
-- Licensed to the Apache Software Foundation (ASF) under one
-- or more contributor license agreements. See the NOTICE file
-- distributed with this work for additional information
-- regarding copyright ownership. The ASF licenses this file
-- to you under the Apache License, Version 2.0 (the
-- "License"); you may not use this file except in compliance
-- with the License. You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-- this file works for MySQL.
set names utf8mb4;
create database if not exists `neutrino-proxy` default charset utf8mb4 collate utf8mb4_general_ci;
commit;
@@ -0,0 +1,48 @@
version: '3.8'
networks:
npServer:
driver: bridge
services:
mysql:
image: mysql:8
container_name: compose-mysql
hostname: mysql
restart: always
healthcheck:
test: ['CMD-SHELL', 'mysqladmin ping -h 127.0.0.1 --silent']
interval: 3s
retries: 5
start_period: 3m
ports:
- "3308:3306"
environment:
TZ: Asia/Shanghai
MYSQL_ROOT_PASSWORD: 123456
volumes:
- ./data/mysqldata:/var/lib/mysql/
- ./config/sql:/docker-entrypoint-initdb.d/
networks:
- npServer
npServer:
image: aoshiguchen/neutrino-proxy-server:latest
container_name: compose-npServer
hostname: npServer
restart: always
environment:
TZ: Asia/Shanghai
LANG: zh_CN.UTF-8
depends_on:
mysql:
condition: service_healthy
volumes:
- ./config:/root/neutrino-proxy/config
- ./data:/root/neutrino-proxy/data
- ./logs:/root/neutrino-proxy/logs
ports:
- "8888:8888"
- "9000:9000"
- "9002:9002"
- "9101-9120:9101-9120"
networks:
- npServer
+1 -1
View File
@@ -1,7 +1,7 @@
#!/bin/sh
# 镜像版本,每次更新版本时需要调整
ImageVer=2.0.0
ImageVer=2.0.2
ImageName=neutrino-proxy-client
DockerFilePath=$PWD/../../neutrino-proxy-client
+23 -21
View File
@@ -5,9 +5,11 @@ export JAVA_HOME=/Users/yangwen/my/service/graalvm/graalvm-community-openjdk-21.
export MAVEN_HOME=/Users/yangwen/my/service/maven/apache-maven-3.8.1
export PATH=:$PATH:$JAVA_HOME/bin:$MAVEN_HOME/bin
MODULE_NAME=neutrino-proxy-client
deployDir="deploy"
clientDeployDir=$deployDir"/client"
machine=macos
VER=2.0.3
#切到项目根目录
cd ../..
@@ -15,38 +17,38 @@ 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
rm -rf $clientDeployDir/$MODULE_NAME.jar
rm -rf $clientDeployDir/$MODULE_NAME
rm -rf $clientDeployDir/$MODULE_NAME-jdk21-$VER-jar
rm -rf $clientDeployDir/$MODULE_NAME-jdk21-$VER-jar.zip
rm -rf $clientDeployDir/$MODULE_NAME-$machine-$VER-native
rm -rf $clientDeployDir/$MODULE_NAME-$machine-$VER-native.zip
#客户端打包
mvn clean install -U -pl neutrino-proxy-client -am -Dmaven.test.skip=true
cd neutrino-proxy-client
mvn clean install -U -pl $MODULE_NAME -am -Dmaven.test.skip=true
cd $MODULE_NAME
mvn clean native:compile -P native -DskipTests
cd ..
# 给执行权限
chmod +x ./neutrino-proxy-client/target/neutrino-proxy-client
chmod +x ./$MODULE_NAME/target/$MODULE_NAME
# 拷贝到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
cp ./$MODULE_NAME/target/$MODULE_NAME.jar $clientDeployDir/$MODULE_NAME.jar
cp ./$MODULE_NAME/target/$MODULE_NAME $clientDeployDir/$MODULE_NAME
#打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
mkdir $MODULE_NAME-jdk21-$VER-jar
cp ../../$MODULE_NAME/target/$MODULE_NAME.jar ./$MODULE_NAME-jdk21-$VER-jar/$MODULE_NAME.jar
cp ../../$MODULE_NAME/src/main/resources/app-copy.yml ./$MODULE_NAME-jdk21-$VER-jar/app.yml
zip -r $MODULE_NAME-jdk21-$VER-jar.zip ./$MODULE_NAME-jdk21-$VER-jar
rm -rf ./$MODULE_NAME-jdk21-$VER-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
mkdir $MODULE_NAME-$machine-$VER-native
cp ../../$MODULE_NAME/target/$MODULE_NAME ./$MODULE_NAME-$machine-$VER-native/$MODULE_NAME
cp ../../$MODULE_NAME/src/main/resources/app-copy.yml ./$MODULE_NAME-$machine-$VER-native/app.yml
zip -r $MODULE_NAME-$machine-$VER-native.zip ./$MODULE_NAME-$machine-$VER-native
rm -rf ./$MODULE_NAME-$machine-$VER-native
+1 -1
View File
@@ -1,7 +1,7 @@
#!/bin/sh
# 镜像版本,每次更新版本时需要调整
ImageVer=2.0.0
ImageVer=2.0.2
ImageName=neutrino-proxy
DockerFilePath=$PWD/../../neutrino-proxy-server
+23 -21
View File
@@ -5,9 +5,11 @@ export JAVA_HOME=/Users/yangwen/my/service/graalvm/graalvm-community-openjdk-21.
export MAVEN_HOME=/Users/yangwen/my/service/maven/apache-maven-3.8.1
export PATH=:$PATH:$JAVA_HOME/bin:$MAVEN_HOME/bin
MODULE_NAME=neutrino-proxy-server
deployDir="deploy"
serverDeployDir=$deployDir"/server"
machine=macos
VER=2.0.3
#切到项目根目录
cd ../..
@@ -15,12 +17,12 @@ 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
rm -rf $serverDeployDir/$MODULE_NAME.jar
rm -rf $serverDeployDir/$MODULE_NAME
rm -rf $serverDeployDir/$MODULE_NAME-jdk21-$VER-jar
rm -rf $serverDeployDir/$MODULE_NAME-jdk21-$VER-jar.zip
rm -rf $serverDeployDir/$MODULE_NAME-$machine-$VER-native
rm -rf $serverDeployDir/$MODULE_NAME-$machine-$VER-native.zip
# 不需要每次都重新编译一次前端代码,如果前端代码有变更,编译前需要手动执行`admin_build_docker.sh`
##前端页面打包
@@ -32,30 +34,30 @@ rm -rf $serverDeployDir/neutrino-proxy-server-${machine}-native.zip
#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 install -U -pl $MODULE_NAME -am -Dmaven.test.skip=true
cd $MODULE_NAME
mvn clean native:compile -P native -DskipTests
cd ..
# 给执行权限
chmod +x ./neutrino-proxy-server/target/neutrino-proxy-server
chmod +x ./$MODULE_NAME/target/$MODULE_NAME
# 拷贝到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
cp ./$MODULE_NAME/target/$MODULE_NAME.jar $serverDeployDir/$MODULE_NAME.jar
cp ./$MODULE_NAME/target/$MODULE_NAME $serverDeployDir/$MODULE_NAME
#打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
mkdir $MODULE_NAME-jdk21-$VER-jar
cp ../../$MODULE_NAME/target/$MODULE_NAME.jar ./$MODULE_NAME-jdk21-$VER-jar/$MODULE_NAME.jar
cp ../../$MODULE_NAME/src/main/resources/app-copy.yml ./$MODULE_NAME-jdk21-$VER-jar/app.yml
zip -r $MODULE_NAME-jdk21-$VER-jar.zip ./$MODULE_NAME-jdk21-$VER-jar
rm -rf ./$MODULE_NAME-jdk21-$VER-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
mkdir $MODULE_NAME-$machine-$VER-native
cp ../../$MODULE_NAME/target/$MODULE_NAME ./$MODULE_NAME-$machine-$VER-native/$MODULE_NAME
cp ../../$MODULE_NAME/src/main/resources/app-copy.yml ./$MODULE_NAME-$machine-$VER-native/app.yml
zip -r $MODULE_NAME-$machine-$VER-native.zip ./$MODULE_NAME-$machine-$VER-native
rm -rf ./$MODULE_NAME-$machine-$VER-native
-29
View File
@@ -1,29 +0,0 @@
@echo off
@rem basic params
set ENV=dev
set NODE_VERSION=v13.12.0
set MODULE_NAME=neutrino-proxy-admin
@rem 判断当前node版本是否符合,如果不符合切换node版本
for /f "tokens=1" %%v in ('node -v') do set v=%%v
if not "%v%" == "%NODE_VERSION%" (
echo Node.js version is not %NODE_VERSION%.
@rem 判断是否安装nvm
set "nvm_home=%NVM_HOME%"
set "nvm_symlink=%NVM_SYMLINK%"
if not defined nvm_home (
echo nvm is not installed,then use nvm to install node %NODE_VERSION%.
) else if not defined nvm_symlink (
echo nvm is not installed,then use nvm to install node %NODE_VERSION%.
) else (
echo nvm is installed.
nvm use %NODE_VERSION%
)
)
cd %~dp0 && cd ../../%MODULE_NAME%
@rem 检查dist文件夹是否存在,存在就删除,/s选项表示将目录及其所有子目录一起删除,/q选项表示不需要确认操作
if exist dist (
rmdir /s /q dist
)
@rem 等待npm执行完毕
call npm install
npm run build:%ENV% && pause
+13 -2
View File
@@ -24,6 +24,17 @@ cd %~dp0 && cd ../../%MODULE_NAME%
if exist dist (
rmdir /s /q dist
)
@rem 等待npm执行完毕
@rem 编译
call npm install
npm run build:%ENV% && pause
call npm run build:%ENV%
echo 开始拷贝
@rem 拷贝
cd ..
del /Q /F .\neutrino-proxy-server\src\main\resources\static
rd /S /Q .\neutrino-proxy-server\src\main\resources\static
mkdir .\neutrino-proxy-server\src\main\resources\static
xcopy /S /E neutrino-proxy-admin\dist neutrino-proxy-server\src\main\resources\static
@rem 回到脚本目录
cd scripts\win
+63
View File
@@ -0,0 +1,63 @@
@echo off
@rem console output code changed to UTF-8
chcp 65001
@rem basic params
set MODULE_NAME=neutrino-proxy-client
@rem step
cd %~dp0 && cd ../../
SET VS_HOME=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519
SET JAVA_HOME=C:\my\package\jdk\graalvm-community-openjdk-21.0.2
SET MAVEN_HOME=C:\my\package\maven\apache-maven-3.9.6
SET WIN_RAR_HOME=C:\Program Files\WinRAR
SET PATH=%PATH%;%JAVA_HOME%\bin;%MAVEN_HOME%\bin;%VS_HOME%\bin;%WIN_RAR_HOME%
SET INCLUDE=%INCLUDE%;%VS_HOME%\include;
SET LIB=%LIB%;%VS_HOME%\lib;
SET deployDir=deploy
SET clientDeployDir=%deployDir%\client
SET machine=windows
SET VER=2.0.1
@rem 初始化文件夹
mkdir -p %clientDeployDir%
@rem 删除原来的编译文件
del /S /Q /F %clientDeployDir%\%MODULE_NAME%.jar
del /S /Q /F %clientDeployDir%\%MODULE_NAME%.exe
del /S /Q /F %clientDeployDir%\%MODULE_NAME%-jdk21-%VER%-jar
del /S /Q /F %clientDeployDir%\%MODULE_NAME%-jdk21-%VER%-jar.zip
del /S /Q /F %clientDeployDir%\%MODULE_NAME%-%machine%-%VER%-native
del /S /Q /F %clientDeployDir%\%MODULE_NAME%-%machine%-%VER%-native.zip
rd /S /Q %clientDeployDir%\%MODULE_NAME%-jdk21-%VER%-jar
rd /S /Q %clientDeployDir%\%MODULE_NAME%-%machine%-%VER%-native
@rem 客户端打包
call mvn clean install -U -pl %MODULE_NAME% -am -Dmaven.test.skip=true
cd %MODULE_NAME%
call mvn clean native:compile -P native -DskipTests
cd ..
@rem 拷贝到deploy目录下
copy .\%MODULE_NAME%\target\%MODULE_NAME%.jar .\%clientDeployDir%\%MODULE_NAME%.jar
copy .\%MODULE_NAME%\target\%MODULE_NAME%.exe .\%clientDeployDir%\%MODULE_NAME%.exe
@rem 打zip包,用于发版
cd %clientDeployDir%
@rem jar
mkdir %MODULE_NAME%-jdk21-%VER%-jar
copy %MODULE_NAME%.jar %MODULE_NAME%-jdk21-%VER%-jar
copy ..\..\%MODULE_NAME%\src\main\resources\app-copy.yml %MODULE_NAME%-jdk21-%VER%-jar\app.yml
Rar a %MODULE_NAME%-jdk21-%VER%-jar.zip %MODULE_NAME%-jdk21-%VER%-jar
@rem native
mkdir %MODULE_NAME%-%machine%-%VER%-native
copy %MODULE_NAME%.exe %MODULE_NAME%-%machine%-%VER%-native
copy ..\..\%MODULE_NAME%\src\main\resources\app-copy.yml %MODULE_NAME%-%machine%-%VER%-native\app.yml
Rar a %MODULE_NAME%-%machine%-%VER%-native.zip %MODULE_NAME%-%machine%-%VER%-native
@rem 删除临时文件
@rem 回到脚本目录
cd ..\..\scripts\win
+63
View File
@@ -0,0 +1,63 @@
@echo off
@rem console output code changed to UTF-8
chcp 65001
@rem basic params
set MODULE_NAME=neutrino-proxy-server
@rem step
cd %~dp0 && cd ../../
SET VS_HOME=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519
SET JAVA_HOME=C:\my\package\jdk\graalvm-community-openjdk-21.0.2
SET MAVEN_HOME=C:\my\package\maven\apache-maven-3.9.6
SET WIN_RAR_HOME=C:\Program Files\WinRAR
SET PATH=%PATH%;%JAVA_HOME%\bin;%MAVEN_HOME%\bin;%VS_HOME%\bin;%WIN_RAR_HOME%
SET INCLUDE=%INCLUDE%;%VS_HOME%\include;
SET LIB=%LIB%;%VS_HOME%\lib;
SET deployDir=deploy
SET serverDeployDir=%deployDir%\server
SET machine=windows
SET VER=2.0.1
@rem 初始化文件夹
mkdir -p %serverDeployDir%
@rem 删除原来的编译文件
del /S /Q /F %serverDeployDir%\%MODULE_NAME%.jar
del /S /Q /F %serverDeployDir%\%MODULE_NAME%.exe
del /S /Q /F %serverDeployDir%\%MODULE_NAME%-jdk21-%VER%-jar
del /S /Q /F %serverDeployDir%\%MODULE_NAME%-jdk21-%VER%-jar.zip
del /S /Q /F %serverDeployDir%\%MODULE_NAME%-%machine%-%VER%-native
del /S /Q /F %serverDeployDir%\%MODULE_NAME%-%machine%-%VER%-native.zip
rd /S /Q %serverDeployDir%\%MODULE_NAME%-jdk21-%VER%-jar
rd /S /Q %serverDeployDir%\%MODULE_NAME%-%machine%-%VER%-native
@rem 服务端打包
call mvn clean install -U -pl %MODULE_NAME% -am -Dmaven.test.skip=true
cd %MODULE_NAME%
call mvn clean native:compile -P native -DskipTests
cd ..
@rem 拷贝到deploy目录下
copy .\%MODULE_NAME%\target\%MODULE_NAME%.jar .\%serverDeployDir%\%MODULE_NAME%.jar
copy .\%MODULE_NAME%\target\%MODULE_NAME%.exe .\%serverDeployDir%\%MODULE_NAME%.exe
@rem 打zip包,用于发版
cd %serverDeployDir%
@rem jar
mkdir %MODULE_NAME%-jdk21-%VER%-jar
copy %MODULE_NAME%.jar %MODULE_NAME%-jdk21-%VER%-jar
copy ..\..\%MODULE_NAME%\src\main\resources\app-copy.yml %MODULE_NAME%-jdk21-%VER%-jar\app.yml
Rar a %MODULE_NAME%-jdk21-%VER%-jar.zip %MODULE_NAME%-jdk21-%VER%-jar
@rem native
mkdir %MODULE_NAME%-%machine%-%VER%-native
copy %MODULE_NAME%.exe %MODULE_NAME%-%machine%-%VER%-native
copy ..\..\%MODULE_NAME%\src\main\resources\app-copy.yml %MODULE_NAME%-%machine%-%VER%-native\app.yml
Rar a %MODULE_NAME%-%machine%-%VER%-native.zip %MODULE_NAME%-%machine%-%VER%-native
@rem 删除临时文件
@rem 回到脚本目录
cd ..\..\scripts\win