From db9d27468e880ed4d6227b576081756d9bab087e Mon Sep 17 00:00:00 2001
From: xiaojunnuo
Date: Wed, 14 Aug 2024 21:24:12 +0800
Subject: [PATCH] =?UTF-8?q?chore:=20license=E8=AF=B4=E6=98=8E?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
LICENSE.md | 30 +++++
README.md | 33 ++++--
.../core/pipeline/src/core/license.spec.ts | 1 -
packages/core/pipeline/src/core/license.ts | 42 +++++--
.../certd-client/src/api/modules/api.user.ts | 9 +-
.../src/layout/components/vip-info/api.ts | 9 ++
.../src/layout/components/vip-info/index.vue | 83 +++++++++++++
.../src/layout/layout-framework.vue | 61 +++++-----
.../src/layout/layout-outside.vue | 1 -
packages/ui/certd-client/src/router/index.ts | 1 +
.../ui/certd-client/src/store/modules/user.ts | 47 ++++++--
.../ui/certd-client/src/style/common.less | 8 +-
.../db/migration-pg/v10007__access_text.sql | 4 +
.../ui/certd-server/src/basic/constants.ts | 4 +
.../src/basic/exception/vip-exception.ts | 10 ++
packages/ui/certd-server/src/configuration.ts | 2 -
.../src/middleware/global-exception.ts | 2 +-
.../src/middleware/report.middleware.ts | 27 -----
.../ui/certd-server/src/middleware/report.ts | 24 ----
.../mine/controller/mine-controller.ts | 9 ++
.../pipeline/service/pipeline-service.ts | 22 +++-
.../system/controller/plus-controller.ts | 57 +++++++++
.../src/plugins/plugin-other/index.ts | 1 +
.../src/plugins/plugin-other/plugins/index.ts | 1 +
.../plugin-other/plugins/plugin-k8s.ts | 109 ++++++++++++++++++
25 files changed, 483 insertions(+), 114 deletions(-)
create mode 100644 LICENSE.md
create mode 100644 packages/ui/certd-client/src/layout/components/vip-info/api.ts
create mode 100644 packages/ui/certd-client/src/layout/components/vip-info/index.vue
create mode 100644 packages/ui/certd-server/src/basic/exception/vip-exception.ts
delete mode 100644 packages/ui/certd-server/src/middleware/report.middleware.ts
delete mode 100644 packages/ui/certd-server/src/middleware/report.ts
create mode 100644 packages/ui/certd-server/src/modules/system/controller/plus-controller.ts
create mode 100644 packages/ui/certd-server/src/plugins/plugin-other/index.ts
create mode 100644 packages/ui/certd-server/src/plugins/plugin-other/plugins/index.ts
create mode 100644 packages/ui/certd-server/src/plugins/plugin-other/plugins/plugin-k8s.ts
diff --git a/LICENSE.md b/LICENSE.md
new file mode 100644
index 000000000..bfab44e51
--- /dev/null
+++ b/LICENSE.md
@@ -0,0 +1,30 @@
+# Certd Open Source License
+
+- This project is licensed under the **GNU Affero General Public License (AGPL)** with the following additional terms.
+- 本项目遵循 GNU Affero General Public License(AGPL),并附加以下条款。
+
+## 1. License Terms ( 许可证条款 )
+
+1. **Freedom to Use** (自由使用)
+ - You are free to use, copy, modify, and distribute the source code of this project for personal or organizational use, provided that you comply with the terms of this license.
+ - 您可以自由使用、复制、修改和分发本项目的源代码,前提是您遵循本许可证的条款。
+
+2. **Modification for Personal Use** (个人使用的修改)
+ - Individuals and companies are allowed to modify the project according to their needs for non-commercial purposes. However, modifications to the logo, copyright information, or any code related to licensing are strictly prohibited.
+ - 个人和公司允许根据自身需求对本项目进行修改以供非商业用途。但任何对logo、版权信息或与许可相关代码的修改都是严格禁止的。
+
+3. **Commercial Authorization** (商业授权)
+ - If you wish to make any form of monetary gain from this project, you must first obtain commercial authorization from the original author. Users should contact the author directly to negotiate the relevant licensing terms.
+ - 如果您希望从本项目获得任何形式的经济收益,您必须首先从原作者处获得商业授权,用户应直接与作者联系,以协商相关许可条款。
+
+4. **Retention of Rights** (保留权利)
+ - All rights, title, and interest in the project remain with the original author.
+ - 本项目的所有权利、标题和利益仍归原作者所有。
+
+## 2. As a contributor ( 作为贡献者 )
+ - you should agree that your contributed code:
+ - 您应同意您贡献的代码:
+ 1. - The original author can adjust the open-source agreement to be more strict or relaxed.
+ - 原作者可以调整开源协议以使其更严格或更宽松。
+ 2. - Can be used for commercial purposes.
+ - 可用于商业用途。
diff --git a/README.md b/README.md
index 694218ff6..601cc8bcb 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
-# CertD
+# Certd
-CertD 是一个免费全自动申请和自动部署更新SSL证书的工具。
-后缀D取自linux守护进程的命名风格,意为证书守护进程。
+Certd 是一个免费全自动申请和自动部署更新SSL证书的工具。
+后缀d取自linux守护进程的命名风格,意为证书守护进程。
关键字:证书自动申请、证书自动更新、证书自动续期、证书自动续签
@@ -180,26 +180,37 @@ docker compose up -d
## 十、捐赠
-媳妇儿说:“一天到晚搞开源,也不管管老婆孩子!😡😡😡”
-拜托各位捐赠支持一下,让媳妇儿开心开心,我也能有更多时间进行开源项目,感谢🙏🙏🙏
-
-
-
+支持开源,为爱发电,我已入驻爱发电
+https://afdian.com/a/greper
+
+发电权益:
+1. 可加入发电专属群(先加我好友,发送发电截图,我拉你进群)
+2. 你的需求优先实现
+3. 可以获得作者一对一技术支持
+4. 更多权益陆续增加中...
## 十一、贡献代码
-[贡献插件教程](./plugin.md)
+1. [贡献插件教程](./plugin.md)
+2. 作为贡献者,代表您同意您贡献的代码如下许可:
+ 1. 可以调整开源协议以使其更严格或更宽松。
+ 2. 可以用于商业用途。
+## 十二、 开源许可
+* 本项目遵循 GNU Affero General Public License(AGPL)开源协议。
+* 允许个人和公司使用、复制、修改和分发本项目,禁止任何形式的商业用途
+* 未获得商业授权情况下,禁止任何对logo、版权信息及授权许可相关代码的修改。
+* 如需商业授权,请联系作者。
-## 十二、我的其他项目(求Star)
+## 十三、我的其他项目(求Star)
* [袖手GPT](https://ai.handsfree.work/) ChatGPT,国内可用,无需FQ,每日免费额度
* [fast-crud](https://gitee.com/fast-crud/fast-crud/) 基于vue3的crud快速开发框架
* [dev-sidecar](https://github.com/docmirror/dev-sidecar/) 直连访问github工具,无需FQ,解决github无法访问的问题
-## 十三、更新日志
+## 十四、更新日志
更新日志:[CHANGELOG](./CHANGELOG.md)
diff --git a/packages/core/pipeline/src/core/license.spec.ts b/packages/core/pipeline/src/core/license.spec.ts
index 4f3c2543a..772ad5cbd 100644
--- a/packages/core/pipeline/src/core/license.spec.ts
+++ b/packages/core/pipeline/src/core/license.spec.ts
@@ -3,7 +3,6 @@ import { equal } from "assert";
describe("license", function () {
it("#license", async function () {
const req = {
- appKey: "z4nXOeTeSnnpUpnmsV",
subjectId: "999",
license: "",
};
diff --git a/packages/core/pipeline/src/core/license.ts b/packages/core/pipeline/src/core/license.ts
index a5cef7e42..0c145b31b 100644
--- a/packages/core/pipeline/src/core/license.ts
+++ b/packages/core/pipeline/src/core/license.ts
@@ -2,8 +2,8 @@ import { createVerify } from "node:crypto";
import { logger } from "../utils/index.js";
const SecreteKey =
- "LS0tLS1CRUdJTiBSU0EgUFVCTElDIEtFWS0tLS0tCk1JSUJDZ0tDQVFFQXY3TGtMaUp1dGM0NzhTU3RaTExjajVGZXh1YjJwR2NLMGxwa0hwVnlZWjhMY29rRFhuUlAKUGQ5UlJSTVRTaGJsbFl2Mzd4QUhOV1ZIQ0ZsWHkrQklVU001bUlBU1NDQTV0azlJNmpZZ2F4bEFDQm1BY0lGMwozKzBjeGZIYVkrVW9YdVluMkZ6YUt2Ym5GdFZIZ0lkMDg4a3d4clZTZzlCT3BDRVZIR1pxR2I5TWN5MXVHVXhUClFTVENCbmpoTWZlZ0p6cXVPYWVOY0ZPSE5tbmtWRWpLTythbTBPeEhNS1lyS3ZnQnVEbzdoVnFENlBFMUd6V3AKZHdwZUV4QXZDSVJxL2pWTkdRK3FtMkRWOVNJZ3U5bmF4MktmSUtFeU50dUFFS1VpekdqL0VmRFhDM1cxMExhegpKaGNYNGw1SUFZU1o3L3JWVmpGbExWSVl0WDU1T054L1Z3SURBUUFCCi0tLS0tRU5EIFJTQSBQVUJMSUMgS0VZLS0tLS0K";
-const appKey = "z4nXOeTeSnnpUpnmsV";
+ "LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQkNnS0NBUUVBMjdoZDM0NjRYbyt3TkpmTTNCWjE5MXlQK2NLaTd3ck9CbXdjTWJPZUdsNlJOMUVtTGhyMgplOFdvOGpmMW9IVXc5RFV6L2I2ZHU3Q3ZXMXZNUDA1Q3dSS3lNd2U3Q1BYRGQ2U01mSkwxRFZyUkw5Ylh0cEYzCjJkQVA5UENrakFJcFMvRE5jVkhLRXk1QW8yMnFFenpTKzlUT0JVY2srREdZcmo4KzI5U3h2aEZDRE5ZbEE2d1EKbEkyRWc5TWNBV2xDU3p1S1JWa2ZWUWdYVlU3SmE5OXp1Um1oWWtYZjFxQzBLcVAwQkpDakdDNEV6ZHorMmwyaAo2T3RxVHVVLzRkemlYYnRMUS8vU0JqNEgxdi9PZ3dUZjJkSVBjUnRHOXlWVTB2ZlQzVzdUTkdlMjU3em5ESDBYCkd6Wm4zdWJxTXJuL084b2ltMHRrS3ZHZXZ1V2ZraWNwVVFJREFRQUIKLS0tLS1FTkQgUFVCTElDIEtFWS0tLS0tCg==";
+export const appKey = "GGtrKRWRknFdIID0rW";
export type LicenseVerifyReq = {
subjectId: string;
license: string;
@@ -18,11 +18,15 @@ type License = {
duration: number;
version: number;
secret: string;
+ level: number;
signature: string;
};
class LicenseHolder {
isPlus = false;
+ expireTime = 0;
+ level = 1;
+ message?: string = undefined;
}
const holder = new LicenseHolder();
holder.isPlus = false;
@@ -35,9 +39,20 @@ class LicenseVerifier {
return await this.verify(req);
}
- setPlus(value: boolean) {
- holder.isPlus = value;
- return value;
+ setPlus(value: boolean, info: any = {}) {
+ if (value && !info) {
+ holder.isPlus = true;
+ holder.expireTime = info.expireTime;
+ holder.level = info.level;
+ } else {
+ holder.isPlus = false;
+ holder.expireTime = 0;
+ holder.level = 1;
+ holder.message = info.message;
+ }
+ return {
+ ...holder,
+ };
}
async verify(req: LicenseVerifyReq) {
this.licenseReq = req;
@@ -54,7 +69,7 @@ class LicenseVerifier {
const json: License = JSON.parse(licenseJson);
if (json.expireTime < Date.now()) {
logger.warn("授权已过期");
- return this.setPlus(false);
+ return this.setPlus(false, { message: "授权已过期" });
}
const content = `${appKey},${this.licenseReq.subjectId},${json.code},${json.secret},${json.activeTime},${json.duration},${json.expireTime},${json.version}`;
const publicKey = Buffer.from(SecreteKey, "base64").toString();
@@ -62,9 +77,12 @@ class LicenseVerifier {
this.checked = true;
if (!res) {
logger.warn("授权校验失败");
- return this.setPlus(false);
+ return this.setPlus(false, { message: "授权校验失败" });
}
- return this.setPlus(true);
+ return this.setPlus(true, {
+ expireTime: json.expireTime,
+ level: json.level || 1,
+ });
}
verifySignature(content: string, signature: any, publicKey: string) {
@@ -80,6 +98,14 @@ export function isPlus() {
return holder.isPlus;
}
+export function getPlusInfo() {
+ return {
+ isPlus: holder.isPlus,
+ level: holder.level,
+ expireTime: holder.expireTime,
+ };
+}
+
export async function verify(req: LicenseVerifyReq) {
return await verifier.reVerify(req);
}
diff --git a/packages/ui/certd-client/src/api/modules/api.user.ts b/packages/ui/certd-client/src/api/modules/api.user.ts
index 6eccf47d2..d51e38ebb 100644
--- a/packages/ui/certd-client/src/api/modules/api.user.ts
+++ b/packages/ui/certd-client/src/api/modules/api.user.ts
@@ -60,7 +60,14 @@ export async function mine(): Promise {
});
}
return await request({
- url: "/sys/authority/user/mine",
+ url: "/mine/info",
+ method: "post"
+ });
+}
+
+export async function getPlusInfo() {
+ return await request({
+ url: "/mine/plusInfo",
method: "post"
});
}
diff --git a/packages/ui/certd-client/src/layout/components/vip-info/api.ts b/packages/ui/certd-client/src/layout/components/vip-info/api.ts
new file mode 100644
index 000000000..f90a058a7
--- /dev/null
+++ b/packages/ui/certd-client/src/layout/components/vip-info/api.ts
@@ -0,0 +1,9 @@
+import { request } from "/@/api/service";
+
+export async function doActive(form: any) {
+ return await request({
+ url: "/sys/plus/active",
+ method: "post",
+ data: form
+ });
+}
diff --git a/packages/ui/certd-client/src/layout/components/vip-info/index.vue b/packages/ui/certd-client/src/layout/components/vip-info/index.vue
new file mode 100644
index 000000000..d45e49ac4
--- /dev/null
+++ b/packages/ui/certd-client/src/layout/components/vip-info/index.vue
@@ -0,0 +1,83 @@
+
+
+
+
+
+
+ 专业版
+ {{ expireTime }}
+
+ 当前免费版
+
+
+
+
+
+
diff --git a/packages/ui/certd-client/src/layout/layout-framework.vue b/packages/ui/certd-client/src/layout/layout-framework.vue
index c3d58f08a..929de14b4 100644
--- a/packages/ui/certd-client/src/layout/layout-framework.vue
+++ b/packages/ui/certd-client/src/layout/layout-framework.vue
@@ -12,14 +12,14 @@