mirror of
https://github.com/certd/certd.git
synced 2026-04-24 04:17:25 +08:00
Merge remote-tracking branch 'origin/v2-dev' into v2-dev
This commit is contained in:
@@ -10,6 +10,7 @@ RUN cp /workspace/certd-client/dist/* /workspace/certd-server/public/ -rf
|
||||
RUN cd /workspace/certd-server && pnpm install && npm run build-on-docker
|
||||
|
||||
|
||||
|
||||
FROM node:22-alpine
|
||||
EXPOSE 7001
|
||||
EXPOSE 7002
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
#登录与权限开启
|
||||
VITE_APP_PM_ENABLED=false
|
||||
@@ -3,6 +3,45 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.37.1](https://github.com/certd/certd/compare/v1.37.0...v1.37.1) (2025-09-29)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 修复版本比较bug ([109696e](https://github.com/certd/certd/commit/109696e965d68c50c8627ffd40203edd1d2daea5))
|
||||
|
||||
# [1.37.0](https://github.com/certd/certd/compare/v1.36.25...v1.37.0) (2025-09-28)
|
||||
|
||||
**Note:** Version bump only for package @certd/ui-client
|
||||
|
||||
## [1.36.25](https://github.com/certd/certd/compare/v1.36.24...v1.36.25) (2025-09-27)
|
||||
|
||||
**Note:** Version bump only for package @certd/ui-client
|
||||
|
||||
## [1.36.24](https://github.com/certd/certd/compare/v1.36.23...v1.36.24) (2025-09-27)
|
||||
|
||||
**Note:** Version bump only for package @certd/ui-client
|
||||
|
||||
## [1.36.23](https://github.com/certd/certd/compare/v1.36.22...v1.36.23) (2025-09-26)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 授权页面,id列位置不在第一列的bug ([3f1722d](https://github.com/certd/certd/commit/3f1722d54debcb4849dc14521a2da0d9b304b69f))
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* 动态加载验证码script ([dcc396a](https://github.com/certd/certd/commit/dcc396afb7a23aeb8af57c01014b09af5f033e61))
|
||||
* 验证码支持测试,登录验证码需要测试通过后才能开启 ([83e6476](https://github.com/certd/certd/commit/83e6476408090b741fabb1b542fb458d9a8b4134))
|
||||
|
||||
## [1.36.22](https://github.com/certd/certd/compare/v1.36.21...v1.36.22) (2025-09-23)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 选择授权对话框编辑时,名称字段排在最后的bug ([31cfb09](https://github.com/certd/certd/commit/31cfb09468bda3272f5f63af65ff3e9272220b39))
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* 登录失败时清除验证码状态 ([1c15bea](https://github.com/certd/certd/commit/1c15beadc7fe8a7c6ec1903b7e722ca2f52e05b3))
|
||||
|
||||
## [1.36.21](https://github.com/certd/certd/compare/v1.36.20...v1.36.21) (2025-09-15)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
</div>
|
||||
<script type="module" src="/src/main.ts"></script>
|
||||
<script src="https://static.geetest.com/v4/gt4.js"></script>
|
||||
<!--<script src="https://static.geetest.com/v4/gt4.js"></script>-->
|
||||
<!--<script src="https://turing.captcha.qcloud.com/TJCaptcha.js"></script>-->
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
{
|
||||
"name": "@certd/ui-client",
|
||||
"version": "1.36.21",
|
||||
"version": "1.37.1",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "vite --open",
|
||||
"dev:pm": "vite --mode pm",
|
||||
"dev:force": "vite --force",
|
||||
"remote": "vite --mode remote --open",
|
||||
"debug": "vite --mode debug --open",
|
||||
"debug:pm": "vite --mode debugpm",
|
||||
"debug:force": "vite --force --mode debug",
|
||||
@@ -97,6 +98,7 @@
|
||||
"vue-cropperjs": "^5.0.0",
|
||||
"vue-echarts": "^7.0.3",
|
||||
"vue-i18n": "^9.10.2",
|
||||
"vue-plugin-load-script": "2.1.1",
|
||||
"vue-router": "^4.3.0",
|
||||
"vuedraggable": "^4.1.0",
|
||||
"watermark-js-plus": "^1.5.8",
|
||||
@@ -104,8 +106,8 @@
|
||||
"zod-defaults": "^0.1.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@certd/lib-iframe": "^1.36.21",
|
||||
"@certd/pipeline": "^1.36.21",
|
||||
"@certd/lib-iframe": "^1.37.1",
|
||||
"@certd/pipeline": "^1.37.1",
|
||||
"@rollup/plugin-commonjs": "^25.0.7",
|
||||
"@rollup/plugin-node-resolve": "^15.2.3",
|
||||
"@types/chai": "^4.3.12",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<component :is="captchaComponent" v-if="settingStore.inited" ref="captchaRef" class="captcha_input" :captcha-get="getCaptcha" @change="onChange" />
|
||||
<component :is="captchaComponent" v-if="settingStore.inited" ref="captchaRef" :model-value="modelValue" class="captcha_input" :captcha-get="getCaptcha" @change="onChange" />
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, defineAsyncComponent } from "vue";
|
||||
@@ -7,6 +7,20 @@ import { useSettingStore } from "/@/store/settings";
|
||||
import { nanoid } from "nanoid";
|
||||
import { request } from "/@/api/service";
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: {
|
||||
type: Object,
|
||||
default: () => ({}),
|
||||
},
|
||||
type: {
|
||||
type: String,
|
||||
default: "image",
|
||||
},
|
||||
addonId: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
});
|
||||
const captchaRef = ref(null);
|
||||
const settingStore = useSettingStore();
|
||||
|
||||
@@ -17,7 +31,7 @@ const captchaAddonId = computed(() => {
|
||||
return settingStore.sysPublic.captchaAddonId ?? 0;
|
||||
});
|
||||
const captchaComponent = computed(() => {
|
||||
let type = "image";
|
||||
let type: any = props.type ?? "image";
|
||||
if (settingStore.sysPublic.captchaAddonId && settingStore.sysPublic.captchaType) {
|
||||
type = settingStore.sysPublic.captchaType;
|
||||
}
|
||||
@@ -36,7 +50,7 @@ async function getCaptcha(): Promise<any> {
|
||||
});
|
||||
}
|
||||
|
||||
function onChange(data) {
|
||||
function onChange(data: any) {
|
||||
emits("update:modelValue", data);
|
||||
emits("change", data);
|
||||
}
|
||||
@@ -44,7 +58,11 @@ function onChange(data) {
|
||||
async function getCaptchaForm() {
|
||||
return await captchaRef.value.getCaptchaForm();
|
||||
}
|
||||
async function reset() {
|
||||
await captchaRef.value.reset();
|
||||
}
|
||||
defineExpose({
|
||||
getCaptchaForm,
|
||||
reset,
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -2,28 +2,32 @@
|
||||
<div ref="captchaRef" class="geetest_captcha_wrapper"></div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { onMounted, defineProps, defineEmits, ref, onUnmounted } from "vue";
|
||||
import { onMounted, defineProps, defineEmits, ref, onUnmounted, Ref, watch } from "vue";
|
||||
import { useSettingStore } from "/@/store/settings";
|
||||
import { request } from "/src/api/service";
|
||||
import { notification } from "ant-design-vue";
|
||||
|
||||
import { loadScript } from "vue-plugin-load-script";
|
||||
const loaded = ref(false);
|
||||
async function loadCaptchaScript() {
|
||||
// 加载验证码js
|
||||
await loadScript("https://static.geetest.com/v4/gt4.js");
|
||||
loaded.value = true;
|
||||
}
|
||||
|
||||
defineOptions({
|
||||
name: "GeetestCaptcha",
|
||||
});
|
||||
const emit = defineEmits(["update:modelValue", "change"]);
|
||||
const props = defineProps<{
|
||||
modelValue: any;
|
||||
captchaGet: () => Promise<any>;
|
||||
}>();
|
||||
const captchaRef = ref(null);
|
||||
// const addonApi = createAddonApi();
|
||||
const settingStore = useSettingStore();
|
||||
|
||||
const captchaInstanceRef = ref({});
|
||||
const captchaInstanceRef: Ref = ref({});
|
||||
async function init() {
|
||||
// if (!initGeetest4) {
|
||||
// await import("https://static.geetest.com/v4/gt4.js");
|
||||
// }
|
||||
|
||||
await loadCaptchaScript();
|
||||
const { captchaId } = await props.captchaGet();
|
||||
// @ts-ignore
|
||||
initGeetest4(
|
||||
@@ -35,6 +39,13 @@ async function init() {
|
||||
captcha.appendTo(captchaRef.value); // 调用appendTo将验证码插入到页的某一个元素中,这个元素用户可以自定义
|
||||
captchaInstanceRef.value.instance = captcha;
|
||||
captchaInstanceRef.value.captchaId = captchaId;
|
||||
|
||||
captcha.onSuccess(function () {
|
||||
const form = getCaptchaForm();
|
||||
if (form) {
|
||||
emitChange(form);
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -58,29 +69,51 @@ function getCaptchaForm() {
|
||||
return result;
|
||||
}
|
||||
|
||||
const valueRef = ref(null);
|
||||
const timeoutId = setInterval(() => {
|
||||
const form = getCaptchaForm();
|
||||
if (form && valueRef.value != form) {
|
||||
console.log("form", form);
|
||||
valueRef.value = form;
|
||||
emitChange(form);
|
||||
}
|
||||
}, 1000);
|
||||
// const valueRef = ref(null);
|
||||
// const timeoutId = setInterval(() => {
|
||||
// const form = getCaptchaForm();
|
||||
// if (form && valueRef.value != form) {
|
||||
// console.log("form", form);
|
||||
// valueRef.value = form;
|
||||
// emitChange(form);
|
||||
// }
|
||||
// }, 1000);
|
||||
|
||||
onUnmounted(() => {
|
||||
clearTimeout(timeoutId);
|
||||
});
|
||||
// onUnmounted(() => {
|
||||
// clearTimeout(timeoutId);
|
||||
// });
|
||||
|
||||
function emitChange(value: string) {
|
||||
emit("update:modelValue", value);
|
||||
emit("change", value);
|
||||
}
|
||||
function reset() {
|
||||
captchaInstanceRef.value.instance.reset();
|
||||
}
|
||||
|
||||
watch(
|
||||
() => {
|
||||
return props.modelValue;
|
||||
},
|
||||
value => {
|
||||
if (value == null) {
|
||||
reset();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
defineExpose({
|
||||
getCaptchaForm,
|
||||
reset,
|
||||
});
|
||||
|
||||
watch(
|
||||
() => [props.captchaGet],
|
||||
async () => {
|
||||
await init();
|
||||
}
|
||||
);
|
||||
|
||||
onMounted(async () => {
|
||||
await init();
|
||||
});
|
||||
|
||||
@@ -11,10 +11,11 @@
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { defineEmits, defineExpose, defineProps, ref } from "vue";
|
||||
import { defineEmits, defineExpose, defineProps, ref, watch } from "vue";
|
||||
import { nanoid } from "nanoid";
|
||||
|
||||
const props = defineProps<{
|
||||
modelValue: any;
|
||||
captchaGet?: () => Promise<any>;
|
||||
}>();
|
||||
defineOptions({
|
||||
@@ -42,6 +43,7 @@ function getCaptchaForm() {
|
||||
defineExpose({
|
||||
resetImageCode,
|
||||
getCaptchaForm,
|
||||
reset: resetImageCode,
|
||||
});
|
||||
|
||||
resetImageCode();
|
||||
@@ -52,7 +54,18 @@ function onChange(value: string) {
|
||||
emitChange(form);
|
||||
}
|
||||
|
||||
function emitChange(value) {
|
||||
watch(
|
||||
() => {
|
||||
return props.modelValue;
|
||||
},
|
||||
value => {
|
||||
if (value == null) {
|
||||
resetImageCode();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
function emitChange(value: any) {
|
||||
emit("update:modelValue", value);
|
||||
emit("change", value);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,226 @@
|
||||
<template>
|
||||
<div ref="captchaRef" class="tencent_captcha_wrapper" :class="{ tencent_captcha_ok: modelValue }" @click="triggerCaptcha">
|
||||
<div class="validation-box" :class="{ validated: modelValue != null }">
|
||||
<div class="sweep-animation"></div>
|
||||
<div class="box-content">
|
||||
<div class="box-icon">✓</div>
|
||||
<span v-if="modelValue == null" class="status-text">点击进行验证</span>
|
||||
<span v-else class="status-text">验证成功</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { onMounted, defineProps, defineEmits, ref, onUnmounted, Ref, watch } from "vue";
|
||||
import { notification } from "ant-design-vue";
|
||||
|
||||
import { loadScript } from "vue-plugin-load-script";
|
||||
const loaded = ref(false);
|
||||
async function loadCaptchaScript() {
|
||||
// 加载验证码js
|
||||
// var appid = "您的CaptchaAppId";
|
||||
// loadScript("https://turing.captcha.qq.com/TJCaptcha.js?appid=" + appid);
|
||||
await loadScript("https://turing.captcha.qcloud.com/TJCaptcha.js");
|
||||
loaded.value = true;
|
||||
}
|
||||
loadCaptchaScript();
|
||||
|
||||
defineOptions({
|
||||
name: "TencentCaptcha",
|
||||
});
|
||||
const emit = defineEmits(["update:modelValue", "change"]);
|
||||
const props = defineProps<{
|
||||
modelValue: any;
|
||||
captchaGet: () => Promise<any>;
|
||||
}>();
|
||||
const captchaRef = ref(null);
|
||||
|
||||
const captchaInstanceRef: Ref = ref({});
|
||||
|
||||
// 定义回调函数
|
||||
function callback(res: { ret: number; ticket: string; randstr: string; errorCode?: number; errorMessage?: string }) {
|
||||
// 第一个参数传入回调结果,结果如下:
|
||||
// ret Int 验证结果,0:验证成功。2:用户主动关闭验证码。
|
||||
// ticket String 验证成功的票据,当且仅当 ret = 0 时 ticket 有值。
|
||||
// CaptchaAppId String 验证码应用ID。
|
||||
// bizState Any 自定义透传参数。
|
||||
// randstr String 本次验证的随机串,后续票据校验时需传递该参数。
|
||||
// verifyDuration Int 验证码校验接口耗时(ms)。
|
||||
// actionDuration Int 操作校验成功耗时(用户动作+校验完成)(ms)。
|
||||
// sid String 链路sid。
|
||||
console.log("callback:", res);
|
||||
// res(用户主动关闭验证码)= {ret: 2, ticket: null}
|
||||
// res(验证成功) = {ret: 0, ticket: "String", randstr: "String"}
|
||||
// res(请求验证码发生错误,验证码自动返回trerror_前缀的容灾票据) = {ret: 0, ticket: "String", randstr: "String", errorCode: Number, errorMessage: "String"}
|
||||
// 此处代码仅为验证结果的展示示例,真实业务接入,建议基于ticket和errorCode情况做不同的业务处理
|
||||
if (res.ret === 0) {
|
||||
emitChange({
|
||||
ticket: res.ticket,
|
||||
randstr: res.randstr,
|
||||
});
|
||||
} else if (res.ret === 2) {
|
||||
console.log("用户主动关闭验证码");
|
||||
}
|
||||
}
|
||||
|
||||
// 定义验证码js加载错误处理函数
|
||||
function loadErrorCallback(error: any) {
|
||||
// var appid = "您的CaptchaAppId";
|
||||
// // 生成容灾票据或自行做其它处理
|
||||
// var ticket = "trerror_1001_" + appid + "_" + Math.floor(new Date().getTime() / 1000);
|
||||
// callback({
|
||||
// ret: 0,
|
||||
// randstr: "@" + Math.random().toString(36).substr(2),
|
||||
// ticket: ticket,
|
||||
// errorCode: 1001,
|
||||
// errorMessage: "jsload_error",
|
||||
// });
|
||||
notification.error({
|
||||
message: `验证码加载失败:${error?.message || error}`,
|
||||
});
|
||||
}
|
||||
async function triggerCaptcha() {
|
||||
if (!loaded.value) {
|
||||
notification.error({
|
||||
message: "验证码还未加载完成,请稍后再试",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const { captchaAppId } = await props.captchaGet();
|
||||
|
||||
try {
|
||||
// 生成一个验证码对象
|
||||
// CaptchaAppId:登录验证码控制台,从【验证管理】页面进行查看。如果未创建过验证,请先新建验证。注意:不可使用客户端类型为小程序的CaptchaAppId,会导致数据统计错误。
|
||||
//callback:定义的回调函数
|
||||
// @ts-ignore
|
||||
var captcha = new TencentCaptcha(captchaAppId + "", callback, {
|
||||
userLanguage: "zh-cn",
|
||||
// showFn: (ret: any) => {
|
||||
// const {
|
||||
// duration, // 验证码渲染完成的耗时(ms)
|
||||
// sid, // 链路sid
|
||||
// } = ret;
|
||||
// },
|
||||
});
|
||||
// 调用方法,显示验证码
|
||||
captcha.show();
|
||||
} catch (error) {
|
||||
// 加载异常,调用验证码js加载错误处理函数
|
||||
loadErrorCallback(error);
|
||||
}
|
||||
}
|
||||
|
||||
function emitChange(value: any) {
|
||||
emit("update:modelValue", value);
|
||||
emit("change", value);
|
||||
}
|
||||
function reset() {
|
||||
captchaInstanceRef.value.instance.reset();
|
||||
}
|
||||
|
||||
watch(
|
||||
() => {
|
||||
return props.modelValue;
|
||||
},
|
||||
value => {
|
||||
if (value == null) {
|
||||
reset();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
defineExpose({
|
||||
reset,
|
||||
});
|
||||
</script>
|
||||
<style lang="less">
|
||||
.tencent_captcha_wrapper {
|
||||
.validation-box {
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
margin: 0 auto 30px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 8px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
background-color: #f9f9f9;
|
||||
}
|
||||
|
||||
.validation-box:hover {
|
||||
border-color: #aaa;
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
|
||||
.validation-box.validated {
|
||||
border-color: #4caf50;
|
||||
background-color: #f1f8e9;
|
||||
}
|
||||
|
||||
.box-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 2;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.box-icon {
|
||||
font-size: 18px;
|
||||
color: #bbb;
|
||||
margin-right: 15px;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.validation-box.validated .box-icon {
|
||||
color: #4caf50;
|
||||
}
|
||||
|
||||
.status-text {
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: #888;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.validation-box.validated .status-text {
|
||||
color: #4caf50;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* 划过动画效果 */
|
||||
.sweep-animation {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: -100%;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: linear-gradient(90deg, transparent, rgba(76, 175, 80, 0.2), transparent);
|
||||
z-index: 1;
|
||||
opacity: 0;
|
||||
transition: opacity 0.3s;
|
||||
}
|
||||
|
||||
.validation-box.validated .sweep-animation {
|
||||
animation: sweep 0.8s ease forwards;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
@keyframes sweep {
|
||||
0% {
|
||||
left: -100%;
|
||||
}
|
||||
50% {
|
||||
left: 0;
|
||||
}
|
||||
100% {
|
||||
left: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
+10
@@ -45,6 +45,16 @@ export async function DoVerify(id: number) {
|
||||
});
|
||||
}
|
||||
|
||||
export async function ResetStatus(id: number) {
|
||||
return await request({
|
||||
url: apiPrefix + "/resetStatus",
|
||||
method: "post",
|
||||
data: {
|
||||
id,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function ParseDomain(fullDomain: string) {
|
||||
return await request({
|
||||
url: subDomainApiPrefix + "/parseDomain",
|
||||
|
||||
+19
-1
@@ -16,6 +16,9 @@
|
||||
<a-tooltip v-if="cnameRecord.error" :title="cnameRecord.error">
|
||||
<fs-icon class="ml-5 color-red" icon="ion:warning-outline"></fs-icon>
|
||||
</a-tooltip>
|
||||
<a-tooltip v-if="cnameRecord.status === 'valid'" title="重置校验状态,重新校验">
|
||||
<fs-icon class="ml-2 color-yellow text-md pointer" icon="solar:undo-left-square-bold" @click="resetStatus"></fs-icon>
|
||||
</a-tooltip>
|
||||
</td>
|
||||
<td class="center">
|
||||
<template v-if="cnameRecord.status !== 'valid'">
|
||||
@@ -35,6 +38,7 @@ import { ref, watch } from "vue";
|
||||
import { dict } from "@fast-crud/fast-crud";
|
||||
import * as api from "./api.js";
|
||||
import CnameTip from "./cname-tip.vue";
|
||||
import { Modal } from "ant-design-vue";
|
||||
const statusDict = dict({
|
||||
data: [
|
||||
{ label: "待设置CNAME", value: "cname", color: "warning" },
|
||||
@@ -71,12 +75,15 @@ function onRecordChange() {
|
||||
});
|
||||
}
|
||||
|
||||
async function loadRecord() {
|
||||
cnameRecord.value = await GetByDomain(props.domain);
|
||||
}
|
||||
let refreshIntervalId: any = null;
|
||||
async function doRefresh() {
|
||||
if (!props.domain) {
|
||||
return;
|
||||
}
|
||||
cnameRecord.value = await GetByDomain(props.domain);
|
||||
await loadRecord();
|
||||
onRecordChange();
|
||||
|
||||
if (cnameRecord.value.status === "validating") {
|
||||
@@ -114,6 +121,17 @@ async function doVerify() {
|
||||
}
|
||||
await doRefresh();
|
||||
}
|
||||
|
||||
async function resetStatus() {
|
||||
Modal.confirm({
|
||||
title: "重置状态",
|
||||
content: "确定要重置校验状态吗?",
|
||||
onOk: async () => {
|
||||
await api.ResetStatus(cnameRecord.value.id);
|
||||
await loadRecord();
|
||||
},
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
|
||||
@@ -175,6 +175,7 @@ export default {
|
||||
suiteSetting: "Suite Settings",
|
||||
orderManager: "Order Management",
|
||||
userSuites: "User Suites",
|
||||
netTest: "Network Test",
|
||||
},
|
||||
certificateRepo: {
|
||||
title: "Certificate Repository",
|
||||
@@ -447,6 +448,7 @@ export default {
|
||||
description: "Description",
|
||||
createTime: "Creation Time",
|
||||
updateTime: "Update Time",
|
||||
mainDomain: "Main Domain",
|
||||
edit: "Edit",
|
||||
groupName: "Group Name",
|
||||
enterGroupName: "Please enter group name",
|
||||
@@ -723,11 +725,14 @@ export default {
|
||||
captchaEnabled: "Enable Login Captcha",
|
||||
captchaHelper: "Whether to enable captcha verification for login",
|
||||
captchaType: "Captcha Setting",
|
||||
|
||||
captchaTest: "Captcha Test",
|
||||
// 保存后再点击测试,请务必测试通过了,再开启登录验证码
|
||||
captchaTestHelper: "Save and click test, please make sure the test is passed before enabling login captcha",
|
||||
baseSetting: "Base Settings",
|
||||
registerSetting: "Register Settings",
|
||||
safeSetting: "Safe Settings",
|
||||
paymentSetting: "Payment Settings",
|
||||
captchaSetting: "Captcha Setting",
|
||||
},
|
||||
},
|
||||
modal: {
|
||||
|
||||
@@ -181,6 +181,7 @@ export default {
|
||||
suiteSetting: "套餐设置",
|
||||
orderManager: "订单管理",
|
||||
userSuites: "用户套餐",
|
||||
netTest: "网络测试",
|
||||
},
|
||||
certificateRepo: {
|
||||
title: "证书仓库",
|
||||
@@ -453,6 +454,7 @@ export default {
|
||||
description: "说明",
|
||||
createTime: "创建时间",
|
||||
updateTime: "更新时间",
|
||||
mainDomain: "主域名",
|
||||
edit: "编辑",
|
||||
groupName: "分组名称",
|
||||
enterGroupName: "请输入分组名称",
|
||||
@@ -461,7 +463,7 @@ export default {
|
||||
batchDeleteConfirm: "确定要批量删除这{count}条记录吗",
|
||||
selectRecordFirst: "请先勾选记录",
|
||||
subdomainHosted: "托管的子域名",
|
||||
subdomainHelpText: "如果您不理解什么是子域托管,请不要随意设置,可能导致证书无法申请,可以参考文档",
|
||||
subdomainHelpText: "如果您不理解什么是子域托管,请不要随意设置(可能导致证书无法申请,以前设置过的cname记录也需要重新配置),可以参考文档",
|
||||
subdomainManagement: "子域管理",
|
||||
isDisabled: "是否禁用",
|
||||
enabled: "启用",
|
||||
@@ -725,11 +727,13 @@ export default {
|
||||
captchaEnabled: "启用登录验证码",
|
||||
captchaHelper: "登录时是否启用验证码",
|
||||
captchaType: "验证码配置",
|
||||
|
||||
captchaTest: "测试验证码",
|
||||
captchaTestHelper: "保存后再点击测试,请务必测试通过了,再开启登录验证码",
|
||||
baseSetting: "基本设置",
|
||||
registerSetting: "注册设置",
|
||||
safeSetting: "安全设置",
|
||||
paymentSetting: "支付设置",
|
||||
captchaSetting: "验证码设置",
|
||||
},
|
||||
},
|
||||
modal: {
|
||||
|
||||
@@ -14,7 +14,7 @@ import { usePreferences } from "/@/vben/preferences";
|
||||
import { LocalStorage } from "/@/utils/util.storage";
|
||||
|
||||
import { FsEditorCode } from "@fast-crud/editor-code";
|
||||
import "@fast-crud/editor-code/dist/style.css"
|
||||
import "@fast-crud/editor-code/dist/style.css";
|
||||
|
||||
class ColumnSizeSaver {
|
||||
save: (key: string, size: number) => void;
|
||||
|
||||
@@ -249,6 +249,17 @@ export const sysResources = [
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: "certd.sysResources.netTest",
|
||||
name: "NetTest",
|
||||
path: "/sys/nettest",
|
||||
component: "/sys/nettest/index.vue",
|
||||
meta: {
|
||||
icon: "ion:build-outline",
|
||||
auth: true,
|
||||
keepAlive: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
@@ -19,6 +19,10 @@ div#app {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
pre.pre{
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
|
||||
}
|
||||
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
|
||||
@@ -54,8 +54,8 @@ export function useVbenModal<TParentModalProps extends ModalProps = ModalProps>(
|
||||
);
|
||||
},
|
||||
{
|
||||
inheritAttrs: false,
|
||||
name: "VbenParentModal",
|
||||
inheritAttrs: false,
|
||||
}
|
||||
);
|
||||
return [Modal, extendedApi as ExtendedModalApi] as const;
|
||||
@@ -104,8 +104,8 @@ export function useVbenModal<TParentModalProps extends ModalProps = ModalProps>(
|
||||
);
|
||||
},
|
||||
{
|
||||
inheritAttrs: false,
|
||||
name: "VbenModal",
|
||||
inheritAttrs: false,
|
||||
}
|
||||
);
|
||||
injectData.extendApi?.(extendedApi);
|
||||
|
||||
@@ -91,6 +91,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||
type: "number",
|
||||
column: {
|
||||
width: 50,
|
||||
order: -999,
|
||||
},
|
||||
form: {
|
||||
show: false,
|
||||
|
||||
@@ -66,6 +66,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||
type: "number",
|
||||
column: {
|
||||
width: 100,
|
||||
order: -999,
|
||||
},
|
||||
form: {
|
||||
show: false,
|
||||
|
||||
@@ -75,6 +75,7 @@ export function getCommonColumnDefine(crudExpose: any, typeRef: any, api: any, a
|
||||
type: "number",
|
||||
column: {
|
||||
width: 100,
|
||||
order: -999,
|
||||
},
|
||||
form: {
|
||||
show: false,
|
||||
|
||||
@@ -57,4 +57,3 @@ export async function DeleteBatch(ids: any[]) {
|
||||
data: { ids },
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -95,6 +95,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||
type: "number",
|
||||
column: {
|
||||
width: 80,
|
||||
order: -999,
|
||||
},
|
||||
form: {
|
||||
show: false,
|
||||
|
||||
@@ -67,3 +67,13 @@ export async function DoVerify(id: number) {
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function ResetStatus(id: number) {
|
||||
return await request({
|
||||
url: apiPrefix + "/resetStatus",
|
||||
method: "post",
|
||||
data: {
|
||||
id,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import { useRouter } from "vue-router";
|
||||
import { AddReq, compute, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, UserPageQuery, UserPageRes } from "@fast-crud/fast-crud";
|
||||
import { useUserStore } from "/@/store/user";
|
||||
import { useSettingStore } from "/@/store/settings";
|
||||
import { message } from "ant-design-vue";
|
||||
import { message, Modal } from "ant-design-vue";
|
||||
import CnameTip from "/@/components/plugins/cert/domains-verify-plan-editor/cname-tip.vue";
|
||||
export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
|
||||
const router = useRouter();
|
||||
@@ -79,6 +79,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||
type: "number",
|
||||
column: {
|
||||
width: 80,
|
||||
order: -999,
|
||||
},
|
||||
form: {
|
||||
show: false,
|
||||
@@ -188,16 +189,32 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||
},
|
||||
column: {
|
||||
width: 120,
|
||||
align: "center",
|
||||
align: "left",
|
||||
cellRender({ value, row }) {
|
||||
async function resetStatus() {
|
||||
Modal.confirm({
|
||||
title: "重置状态",
|
||||
content: "确定要重置校验状态吗?",
|
||||
onOk: async () => {
|
||||
await api.ResetStatus(row.id);
|
||||
await crudExpose.doRefresh();
|
||||
},
|
||||
});
|
||||
}
|
||||
return (
|
||||
<div class={"flex flex-center"}>
|
||||
<div class={"flex flex-left"}>
|
||||
<fs-values-format modelValue={value} dict={dictRef}></fs-values-format>
|
||||
{row.error && (
|
||||
<a-tooltip title={row.error}>
|
||||
<fs-icon class={"ml-5 color-red"} icon="ion:warning-outline"></fs-icon>
|
||||
</a-tooltip>
|
||||
)}
|
||||
|
||||
{row.status === "valid" && (
|
||||
<a-tooltip title={"重置校验状态,重新校验"}>
|
||||
<fs-icon class={"ml-5 pointer "} icon="solar:undo-left-square-bold" onClick={resetStatus}></fs-icon>
|
||||
</a-tooltip>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
},
|
||||
@@ -251,8 +268,15 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||
},
|
||||
},
|
||||
},
|
||||
mainDomain: {
|
||||
title: t("certd.mainDomain"),
|
||||
type: "text",
|
||||
form: {
|
||||
show: false,
|
||||
},
|
||||
},
|
||||
createTime: {
|
||||
title: t("certd.create_time"),
|
||||
title: t("certd.createTime"),
|
||||
type: "datetime",
|
||||
form: {
|
||||
show: false,
|
||||
@@ -264,7 +288,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||
},
|
||||
},
|
||||
updateTime: {
|
||||
title: t("certd.update_time"),
|
||||
title: t("certd.updateTime"),
|
||||
type: "datetime",
|
||||
form: {
|
||||
show: false,
|
||||
|
||||
@@ -93,6 +93,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||
type: "number",
|
||||
column: {
|
||||
width: 100,
|
||||
order: -999,
|
||||
},
|
||||
form: {
|
||||
show: false,
|
||||
|
||||
@@ -217,14 +217,10 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||
show: false,
|
||||
},
|
||||
column: {
|
||||
sorter: true,
|
||||
sorter: false,
|
||||
conditionalRender: false,
|
||||
cellRender({ row }) {
|
||||
const {
|
||||
applyTime,
|
||||
effectiveTime,
|
||||
expiresTime,
|
||||
} = row || {};
|
||||
const { applyTime, effectiveTime, expiresTime } = row || {};
|
||||
if (!expiresTime) {
|
||||
return "-";
|
||||
}
|
||||
|
||||
@@ -385,10 +385,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||
column: {
|
||||
conditionalRender: false,
|
||||
cellRender({ row }) {
|
||||
const {
|
||||
certEffectiveTime: effectiveTime,
|
||||
certExpiresTime: expiresTime,
|
||||
} = row || {};
|
||||
const { certEffectiveTime: effectiveTime, certExpiresTime: expiresTime } = row || {};
|
||||
if (!expiresTime) {
|
||||
return "-";
|
||||
}
|
||||
|
||||
@@ -72,6 +72,7 @@ export function getCommonColumnDefine(crudExpose: any, typeRef: any, api: any) {
|
||||
type: "number",
|
||||
column: {
|
||||
width: 100,
|
||||
order: -999,
|
||||
},
|
||||
form: {
|
||||
show: false,
|
||||
|
||||
@@ -366,10 +366,7 @@ export default function ({ crudExpose, context: { groupDictRef, selectedRowKeys
|
||||
},
|
||||
column: {
|
||||
cellRender({ row }) {
|
||||
const {
|
||||
certEffectiveTime: effectiveTime,
|
||||
certExpiresTime: expiresTime,
|
||||
} = row?.lastVars || {};
|
||||
const { certEffectiveTime: effectiveTime, certExpiresTime: expiresTime } = row?.lastVars || {};
|
||||
if (!expiresTime) {
|
||||
return "-";
|
||||
}
|
||||
|
||||
@@ -21,10 +21,17 @@
|
||||
</a-input>
|
||||
</a-form-item>
|
||||
<a-form-item has-feedback name="captchaForEmail" label="验证码">
|
||||
<CaptchaInput v-model:model-value="formState.captchaForEmail"></CaptchaInput>
|
||||
<CaptchaInput ref="captchaForEmailRef" v-model:model-value="formState.captchaForEmail"></CaptchaInput>
|
||||
</a-form-item>
|
||||
<a-form-item has-feedback name="validateCode" label="邮件验证码">
|
||||
<email-code v-model:value="formState.validateCode" :captcha="formState.captchaForEmail" :email="formState.input" :random-str="formState.randomStr" verification-type="forgotPassword" />
|
||||
<email-code
|
||||
v-model:value="formState.validateCode"
|
||||
:captcha="formState.captchaForEmail"
|
||||
:email="formState.input"
|
||||
:random-str="formState.randomStr"
|
||||
verification-type="forgotPassword"
|
||||
@error="formState.captchaForEmail = null"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-tab-pane>
|
||||
<a-tab-pane key="mobile" tab="手机号找回">
|
||||
@@ -36,10 +43,17 @@
|
||||
</a-input>
|
||||
</a-form-item>
|
||||
<a-form-item has-feedback name="captchaForSms" label="验证码">
|
||||
<CaptchaInput v-model:model-value="formState.captchaForSms"></CaptchaInput>
|
||||
<CaptchaInput ref="captchaForSmsRef" v-model:model-value="formState.captchaForSms"></CaptchaInput>
|
||||
</a-form-item>
|
||||
<a-form-item name="validateCode" label="手机验证码">
|
||||
<sms-code v-model:value="formState.validateCode" :captcha="formState.captchaForSms" :mobile="formState.input" :phone-code="formState.phoneCode" verification-type="forgotPassword" />
|
||||
<sms-code
|
||||
v-model:value="formState.validateCode"
|
||||
:captcha="formState.captchaForSms"
|
||||
:mobile="formState.input"
|
||||
:phone-code="formState.phoneCode"
|
||||
verification-type="forgotPassword"
|
||||
@error="formState.captchaForSms = null"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-tab-pane>
|
||||
</a-tabs>
|
||||
|
||||
@@ -177,6 +177,8 @@ function isNewVersion(version: string, latestVersion: string) {
|
||||
for (let i = 0; i < current.length; i++) {
|
||||
if (parseInt(latest[i]) > parseInt(current[i])) {
|
||||
return true;
|
||||
} else if (parseInt(latest[i]) < parseInt(current[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -191,7 +193,6 @@ async function loadLatestVersion() {
|
||||
|
||||
const minVersion = settingsStore.productInfo?.app?.minVersion;
|
||||
if (minVersion) {
|
||||
//
|
||||
if (isNewVersion(version.value, minVersion)) {
|
||||
notification.error({
|
||||
message: settingsStore.productInfo?.app?.minVersionTip ?? "版本过低,为了您的数据安全,请尽快升级",
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item name="smsCode" :rules="rules.smsCode">
|
||||
<sms-code v-model:value="formState.smsCode" :captcha="formState.smsCaptcha" :mobile="formState.mobile" :phone-code="formState.phoneCode" />
|
||||
<sms-code v-model:value="formState.smsCode" :captcha="formState.smsCaptcha" :mobile="formState.mobile" :phone-code="formState.phoneCode" @error="formState.smsCaptcha = null" />
|
||||
</a-form-item>
|
||||
</template>
|
||||
</a-tab-pane>
|
||||
@@ -188,6 +188,7 @@ export default defineComponent({
|
||||
}
|
||||
} finally {
|
||||
loading.value = false;
|
||||
formState.captcha = null;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -209,18 +210,6 @@ export default defineComponent({
|
||||
|
||||
const captchaInputRef = ref();
|
||||
const captchaInputForSmsCode = ref();
|
||||
async function doCaptchaValidate() {
|
||||
if (!sysPublicSettings.captchaEnabled) {
|
||||
return {};
|
||||
}
|
||||
const res = await captchaInputRef.value.getValidatedForm();
|
||||
if (!res) {
|
||||
return false;
|
||||
}
|
||||
return {
|
||||
...res,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
t,
|
||||
|
||||
@@ -24,7 +24,7 @@ const props = defineProps<{
|
||||
captcha?: any;
|
||||
verificationType?: string;
|
||||
}>();
|
||||
const emit = defineEmits(["update:value", "change"]);
|
||||
const emit = defineEmits(["update:value", "change", "error"]);
|
||||
|
||||
function onChange(value: string) {
|
||||
emit("update:value", value);
|
||||
@@ -59,6 +59,9 @@ async function sendSmsCode() {
|
||||
captcha: props.captcha,
|
||||
verificationType: props.verificationType,
|
||||
});
|
||||
} catch (e) {
|
||||
emit("error", e);
|
||||
throw e;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ const props = defineProps<{
|
||||
captcha?: any;
|
||||
verificationType?: string;
|
||||
}>();
|
||||
const emit = defineEmits(["update:value", "change"]);
|
||||
const emit = defineEmits(["update:value", "change", "error"]);
|
||||
|
||||
function onChange(value: string) {
|
||||
emit("update:value", value);
|
||||
@@ -54,6 +54,9 @@ async function sendSmsCode() {
|
||||
captcha: props.captcha,
|
||||
verificationType: props.verificationType,
|
||||
});
|
||||
} catch (e) {
|
||||
emit("error", e);
|
||||
throw e;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item has-feedback name="validateCode" :rules="rules.validateCode" label="邮件验证码">
|
||||
<email-code v-model:value="formState.validateCode" :captcha="formState.captchaForEmail" :email="formState.email" />
|
||||
<email-code v-model:value="formState.validateCode" :captcha="formState.captchaForEmail" :email="formState.email" @error="formState.captchaForEmail = null" />
|
||||
</a-form-item>
|
||||
</template>
|
||||
</a-tab-pane>
|
||||
@@ -182,16 +182,20 @@ export default defineComponent({
|
||||
};
|
||||
|
||||
const handleFinish = async (values: any) => {
|
||||
await userStore.register(
|
||||
toRaw({
|
||||
type: registerType.value,
|
||||
password: formState.password,
|
||||
username: formState.username,
|
||||
email: formState.email,
|
||||
captcha: formState.captcha,
|
||||
validateCode: formState.validateCode,
|
||||
}) as any
|
||||
);
|
||||
try {
|
||||
await userStore.register(
|
||||
toRaw({
|
||||
type: registerType.value,
|
||||
password: formState.password,
|
||||
username: formState.username,
|
||||
email: formState.email,
|
||||
captcha: formState.captcha,
|
||||
validateCode: formState.validateCode,
|
||||
}) as any
|
||||
);
|
||||
} finally {
|
||||
formState.captcha = null;
|
||||
}
|
||||
};
|
||||
|
||||
const handleFinishFailed = (errors: any) => {
|
||||
|
||||
@@ -0,0 +1,288 @@
|
||||
<template>
|
||||
<div class="domain-test-card">
|
||||
<div class="card-header flex flex-wrap justify-start">
|
||||
<div v-if="title">{{ title }}</div>
|
||||
<a-form v-if="editing" layout="inline" :model="formData">
|
||||
<a-form-item label="域名">
|
||||
<a-input v-model:value="formData.domain" placeholder="请输入要测试的域名或IP" style="width: 240px" />
|
||||
</a-form-item>
|
||||
<a-form-item label="端口">
|
||||
<a-input-number v-model:value="formData.port" placeholder="请输入端口" :min="1" :max="65535" style="width: 120px" />
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
|
||||
<div v-else class="domain-info">
|
||||
<span>域名: {{ formData.domain }}</span>
|
||||
<span>端口: {{ formData.port }}</span>
|
||||
</div>
|
||||
|
||||
<a-button :disabled="!formData.domain" size="small" type="primary" :loading="loading" @click="runAllTests"> 开始测试 </a-button>
|
||||
</div>
|
||||
|
||||
<div class="card-content">
|
||||
<div class="test-results">
|
||||
<!-- 域名解析结果 -->
|
||||
<test-case ref="domainResolveRef" title="域名解析" :test-method="() => createDomainResolveMethod()" :disabled="!getCurrentDomain()" />
|
||||
|
||||
<!-- Ping测试结果 -->
|
||||
<test-case ref="pingTestRef" title="Ping测试" :test-method="() => createPingTestMethod()" :disabled="!getCurrentDomain()" />
|
||||
|
||||
<!-- Telnet测试结果 -->
|
||||
<test-case ref="telnetTestRef" title="Telnet测试" :port="getCurrentPort()" :test-method="() => createTelnetTestMethod()" :disabled="!getCurrentDomain() || !getCurrentPort()" />
|
||||
</div>
|
||||
|
||||
<div class="summary">
|
||||
<a-alert :message="testSummary.title" :type="testSummary.status === 'success' ? 'success' : testSummary.status === 'failed' ? 'error' : 'warning'" show-icon :closable="false">
|
||||
<template v-if="testSummary.text" #description>
|
||||
<pre class="summary-text pre">{{ testSummary.text }}</pre>
|
||||
</template>
|
||||
</a-alert>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, computed, onMounted, watch } from "vue";
|
||||
import { message } from "ant-design-vue";
|
||||
import { DomainResolve, PingTest, TelnetTest } from "./api";
|
||||
import TestCase from "./TestCase.vue";
|
||||
|
||||
// 组件属性
|
||||
const props = defineProps<{
|
||||
title?: string;
|
||||
domain?: string;
|
||||
port?: number;
|
||||
autoStart?: boolean;
|
||||
}>();
|
||||
|
||||
const editing = ref(!props.domain);
|
||||
|
||||
// 测试组件的引用
|
||||
const domainResolveRef = ref();
|
||||
const pingTestRef = ref();
|
||||
const telnetTestRef = ref();
|
||||
|
||||
// 表单数据
|
||||
const formData = reactive({
|
||||
domain: props.domain || "",
|
||||
port: props.port || 443,
|
||||
});
|
||||
|
||||
// 加载状态
|
||||
const loading = ref(false);
|
||||
|
||||
// 创建域名解析测试方法
|
||||
const createDomainResolveMethod = async () => {
|
||||
const domain = getCurrentDomain();
|
||||
return DomainResolve(domain);
|
||||
};
|
||||
|
||||
// 创建Ping测试方法
|
||||
const createPingTestMethod = async () => {
|
||||
const domain = getCurrentDomain();
|
||||
return PingTest(domain);
|
||||
};
|
||||
|
||||
// 创建Telnet测试方法
|
||||
const createTelnetTestMethod = async () => {
|
||||
const domain = getCurrentDomain();
|
||||
const port = getCurrentPort();
|
||||
|
||||
return TelnetTest(domain, port);
|
||||
};
|
||||
|
||||
// 获取当前使用的域名
|
||||
const getCurrentDomain = () => {
|
||||
return formData.domain;
|
||||
};
|
||||
|
||||
// 获取当前使用的端口
|
||||
const getCurrentPort = () => {
|
||||
return formData.port;
|
||||
};
|
||||
|
||||
// 获取各测试用例的状态
|
||||
const getTestStatus = (testRef: any) => {
|
||||
const result = testRef?.getResult();
|
||||
if (!result) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const isNetTestResult = typeof result === "object" && result !== null && "success" in result && "message" in result;
|
||||
|
||||
return {
|
||||
success: isNetTestResult ? result.success : false,
|
||||
message: isNetTestResult ? result.message : "测试失败",
|
||||
};
|
||||
};
|
||||
|
||||
// 生成测试总结
|
||||
const testSummary = computed(() => {
|
||||
if (loading.value) {
|
||||
return { status: "waiting", title: "测试中,请稍后..." };
|
||||
}
|
||||
// 通过computed获取各测试结果
|
||||
const domainResolveResult = getTestStatus(domainResolveRef.value);
|
||||
const pingTestResult = getTestStatus(pingTestRef.value);
|
||||
const telnetTestResult = getTestStatus(telnetTestRef.value);
|
||||
|
||||
// 检查是否有测试结果
|
||||
const testDone = domainResolveResult != null && pingTestResult != null && telnetTestResult != null;
|
||||
if (!testDone) {
|
||||
return { status: "waiting", title: '请点击"开始测试"按钮进行网络测试' };
|
||||
}
|
||||
|
||||
// 详细分析不同的测试结果组合
|
||||
// 1. 三个测试都失败
|
||||
if (domainResolveResult?.success === false && pingTestResult?.success === false && telnetTestResult?.success === false) {
|
||||
return {
|
||||
status: "failed",
|
||||
title: "所有测试均未通过",
|
||||
text: `这表明应用容器内的网络可能完全不通。建议:\n1. 检查宿主机的网络连接状态\n2. 确认容器网络配置是否正确\n3. 检查防火墙设置是否阻止了网络访问`,
|
||||
};
|
||||
}
|
||||
|
||||
// 2. 域名解析成功,但Ping不通
|
||||
if (domainResolveResult?.success === true && pingTestResult?.success === false) {
|
||||
return {
|
||||
status: "partial",
|
||||
title: "域名解析成功,但Ping不通",
|
||||
text: `可能原因:\n1. DNS被劫持,解析到了错误的IP地址\n2. 目标服务器禁止了Ping请求\n3. 目标服务器IP被墙\n4. 目标服务器网络不通或已下线`,
|
||||
};
|
||||
}
|
||||
|
||||
// 3. 域名解析和Ping都成功,但Telnet连接失败
|
||||
if (domainResolveResult?.success === true && pingTestResult?.success === true && telnetTestResult?.success === false) {
|
||||
return {
|
||||
status: "partial",
|
||||
title: "域名解析和Ping测试均通过,但Telnet连接失败",
|
||||
text: `可能原因:\n1. 端口号输入错误,请确认目标服务使用的正确端口\n2. 目标服务器上该端口未开放或服务未启动\n3. 防火墙或安全组限制了该端口的访问\n4. 目标网站被墙`,
|
||||
};
|
||||
}
|
||||
|
||||
// 4. 域名解析失败,但其他测试可能成功或未执行
|
||||
if (domainResolveResult?.success === false) {
|
||||
return {
|
||||
status: "partial",
|
||||
title: "域名解析失败",
|
||||
text: `可能原因:\n1. 域名输入错误或不存在\n2. DNS服务器配置问题\n3. 本地网络DNS解析故障\n4. 域名已过期或被注销`,
|
||||
};
|
||||
}
|
||||
|
||||
// 5. 所有测试都成功
|
||||
if (domainResolveResult?.success === true && pingTestResult?.success === true && telnetTestResult?.success === true) {
|
||||
return {
|
||||
status: "success",
|
||||
title: "所有测试均通过",
|
||||
text: `域名${formData.domain}解析正常,能够正常Ping通,且端口${formData.port}可访问。`,
|
||||
};
|
||||
}
|
||||
|
||||
// 6. 其他部分成功的情况
|
||||
return {
|
||||
status: "partial",
|
||||
title: "部分测试未通过",
|
||||
text: `请结合具体测试结果进行分析:\n- 域名解析:${domainResolveResult ? (domainResolveResult.success ? "成功" : "失败") : "未执行"}\n- Ping测试:${pingTestResult ? (pingTestResult.success ? "成功" : "失败") : "未执行"}\n- Telnet测试:${telnetTestResult ? (telnetTestResult.success ? "成功" : "失败") : "未执行"}`,
|
||||
};
|
||||
});
|
||||
|
||||
// 运行全部测试
|
||||
async function runAllTests() {
|
||||
const domain = getCurrentDomain();
|
||||
|
||||
// 检查是否有域名
|
||||
if (!domain) {
|
||||
message.error("请输入域名");
|
||||
return;
|
||||
}
|
||||
|
||||
loading.value = true;
|
||||
|
||||
// 通过组件引用调用测试方法
|
||||
try {
|
||||
await Promise.allSettled([domainResolveRef.value?.test(), pingTestRef.value?.test(), telnetTestRef.value?.test()]);
|
||||
} catch (error) {
|
||||
message.error("部分测试执行失败,请查看详细结果");
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (props.autoStart) {
|
||||
runAllTests();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
.domain-test-card {
|
||||
border: 1px solid #e8e8e8;
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
background-color: #fff;
|
||||
|
||||
.card-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 12px 16px;
|
||||
background-color: #fafafa;
|
||||
border-bottom: 1px solid #e8e8e8;
|
||||
}
|
||||
|
||||
.card-header h3 {
|
||||
margin: 0;
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.card-content {
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.input-form {
|
||||
margin-bottom: 12px;
|
||||
padding: 12px;
|
||||
background-color: #fafafa;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.domain-info {
|
||||
padding: 5.5px 12px;
|
||||
background-color: #f0f0f0;
|
||||
border-radius: 4px;
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
font-size: 14px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.test-buttons {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.test-results {
|
||||
margin-top: 0px;
|
||||
}
|
||||
|
||||
.summary {
|
||||
margin-top: 16px;
|
||||
padding: 12px;
|
||||
background-color: #f8f9fa;
|
||||
border-radius: 4px;
|
||||
.summary-text {
|
||||
}
|
||||
}
|
||||
|
||||
/* 调整按钮大小 */
|
||||
.ant-btn {
|
||||
font-size: 12px;
|
||||
padding: 2px 8px;
|
||||
height: 24px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,140 @@
|
||||
<template>
|
||||
<a-card title="服务端信息" class="server-info-card">
|
||||
<template #extra>
|
||||
<a-button size="small" :loading="loading" @click="refreshServerInfo">
|
||||
<template #icon>
|
||||
<a-icon type="sync" :spin="loading" />
|
||||
</template>
|
||||
刷新
|
||||
</a-button>
|
||||
</template>
|
||||
<div v-if="loading" class="loading">
|
||||
<a-spin size="small" />
|
||||
<span style="margin-left: 8px">加载中...</span>
|
||||
</div>
|
||||
<div v-else-if="error" class="error">
|
||||
<a-alert message="获取服务器信息失败" :description="error" type="error" show-icon />
|
||||
</div>
|
||||
<div v-else class="server-info-grid">
|
||||
<!-- 本地IP -->
|
||||
<div class="info-item">
|
||||
<div class="info-label">本地IP:</div>
|
||||
<div v-if="serverInfo.localIP && serverInfo.localIP.length > 0" class="info-value">
|
||||
<a-tag v-for="ip in serverInfo.localIP" :key="ip" type="info" color="blue">{{ ip }}</a-tag>
|
||||
</div>
|
||||
<div v-else class="info-empty">暂无信息</div>
|
||||
</div>
|
||||
|
||||
<!-- 外网IP -->
|
||||
<div class="info-item">
|
||||
<div class="info-label">外网IP:</div>
|
||||
<div v-if="serverInfo.publicIP && serverInfo.publicIP.length > 0" class="info-value">
|
||||
<a-tag v-for="ip in serverInfo.publicIP" :key="ip" type="info" color="green">{{ ip }}</a-tag>
|
||||
</div>
|
||||
<div v-else class="info-empty">暂无信息</div>
|
||||
</div>
|
||||
|
||||
<!-- DNS服务器 -->
|
||||
<div class="info-item">
|
||||
<div class="info-label">DNS服务器:</div>
|
||||
<div v-if="serverInfo.dnsServers && serverInfo.dnsServers.length > 0" class="info-value">
|
||||
<a-tag v-for="dns in serverInfo.dnsServers" :key="dns" type="info" color="cyan">{{ dns }}</a-tag>
|
||||
</div>
|
||||
<div v-else class="info-empty">暂无信息</div>
|
||||
</div>
|
||||
</div>
|
||||
</a-card>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, onMounted } from "vue";
|
||||
import { message } from "ant-design-vue";
|
||||
import { GetServerInfo } from "./api";
|
||||
|
||||
// 服务器信息类型
|
||||
interface ServerInfo {
|
||||
localIP?: string[];
|
||||
publicIP?: string[];
|
||||
dnsServers?: string[];
|
||||
}
|
||||
|
||||
const loading = ref(false);
|
||||
const error = ref<string | null>(null);
|
||||
const serverInfo = ref<ServerInfo>({});
|
||||
|
||||
// 加载服务器信息
|
||||
const loadServerInfo = async () => {
|
||||
loading.value = true;
|
||||
error.value = null;
|
||||
try {
|
||||
serverInfo.value = await GetServerInfo();
|
||||
} catch (e) {
|
||||
error.value = e instanceof Error ? e.message : String(e);
|
||||
message.error("获取服务器信息失败");
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 刷新服务器信息
|
||||
const refreshServerInfo = () => {
|
||||
loadServerInfo();
|
||||
};
|
||||
|
||||
// 组件挂载时加载数据
|
||||
onMounted(() => {
|
||||
loadServerInfo();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
.server-info-card {
|
||||
margin-bottom: 16px;
|
||||
|
||||
.loading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 20px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.error {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.server-info-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.info-item {
|
||||
background-color: #fafafa;
|
||||
border-radius: 4px;
|
||||
padding: 12px;
|
||||
|
||||
.info-label {
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: #666;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.info-value {
|
||||
font-size: 14px;
|
||||
color: #333;
|
||||
|
||||
.ant-list-item {
|
||||
padding: 4px 0;
|
||||
}
|
||||
}
|
||||
|
||||
.info-empty {
|
||||
font-size: 14px;
|
||||
color: #999;
|
||||
font-style: italic;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,186 @@
|
||||
<template>
|
||||
<div class="test-case" :class="{ loading }">
|
||||
<div class="case-header">
|
||||
<span class="flex items-center">
|
||||
<fs-button size="small" type="text" icon="ion:play-circle" :loading="loading" :disabled="disabled" class="test-button" @click="runTest" />
|
||||
<a-tag color="blue" class="case-title">
|
||||
{{ title }}
|
||||
</a-tag>
|
||||
<span v-if="port" class="port-info">{{ port }}</span>
|
||||
</span>
|
||||
<span v-if="result && isNetTestResult" class="result-status flex-1" :style="{ color: isSuccess ? 'green' : 'red' }">
|
||||
<span>
|
||||
{{ isSuccess ? "✓" : "✗" }}
|
||||
</span>
|
||||
<span class="ml-2">
|
||||
{{ result.message }}
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="result" class="result-content">
|
||||
<div v-if="error" class="error-message">
|
||||
<span style="color: red">{{ error }}</span>
|
||||
</div>
|
||||
<div v-else-if="isNetTestResult">
|
||||
<div v-if="resultTestLog" class="test-log">
|
||||
<pre>{{ resultTestLog }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else-if="typeof result === 'object'" class="object-result">
|
||||
<pre>{{ JSON.stringify(result, null, 2) }}</pre>
|
||||
</div>
|
||||
<div v-else class="text-result">
|
||||
<pre>{{ result }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="no-result">
|
||||
<p>暂无结果</p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, computed } from "vue";
|
||||
import { message } from "ant-design-vue";
|
||||
|
||||
// 组件属性
|
||||
const props = defineProps<{
|
||||
title: string;
|
||||
port?: number | string;
|
||||
testMethod: () => Promise<any>;
|
||||
disabled?: boolean;
|
||||
}>();
|
||||
|
||||
// 内部状态
|
||||
const loading = ref(false);
|
||||
const result = ref<any>(null);
|
||||
const error = ref<string | null>(null);
|
||||
|
||||
// 运行测试
|
||||
const runTest = async () => {
|
||||
loading.value = true;
|
||||
error.value = null;
|
||||
result.value = null;
|
||||
try {
|
||||
const testResult = await props.testMethod();
|
||||
// 如果结果有 data 属性,则使用 data,否则使用整个结果
|
||||
result.value = testResult.data || testResult;
|
||||
} catch (err: any) {
|
||||
result.value = null;
|
||||
error.value = err.message || "测试失败";
|
||||
message.error(`${props.title} 测试失败: ${error.value}`);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 暴露方法给父组件
|
||||
defineExpose({
|
||||
test: runTest,
|
||||
getResult: () => result.value,
|
||||
});
|
||||
|
||||
// 辅助计算属性,用于模板中显示结果
|
||||
const isNetTestResult = computed(() => {
|
||||
return typeof result.value === "object" && result.value !== null && "success" in result.value && "message" in result.value && "testLog" in result.value;
|
||||
});
|
||||
|
||||
const isSuccess = computed(() => {
|
||||
return isNetTestResult.value && result.value.success;
|
||||
});
|
||||
|
||||
const resultMessage = computed(() => {
|
||||
return isNetTestResult.value ? result.value.message : "";
|
||||
});
|
||||
|
||||
const resultTestLog = computed(() => {
|
||||
return isNetTestResult.value ? result.value.testLog : "";
|
||||
});
|
||||
|
||||
const resultError = computed(() => {
|
||||
return isNetTestResult.value ? result.value.error : "";
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.test-case {
|
||||
padding: 12px 16px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
position: relative;
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
&.loading {
|
||||
opacity: 0.7;
|
||||
}
|
||||
}
|
||||
|
||||
.case-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 8px;
|
||||
|
||||
.result-status {
|
||||
font-size: 14px;
|
||||
color: #999;
|
||||
margin-right: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.case-title {
|
||||
font-weight: 500;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.port-info {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
background-color: #f0f0f0;
|
||||
padding: 2px 6px;
|
||||
border-radius: 3px;
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.test-button {
|
||||
color: #1890ff;
|
||||
font-size: 12px;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.result-content {
|
||||
.error-message,
|
||||
.object-result,
|
||||
.text-result {
|
||||
background-color: #f8f8f8;
|
||||
padding: 8px 10px;
|
||||
border-radius: 3px;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
pre {
|
||||
margin: 0;
|
||||
font-size: 12px;
|
||||
line-height: 1.4;
|
||||
font-family: "Monaco", "Menlo", "Ubuntu Mono", monospace;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
.test-log {
|
||||
background-color: #f8f8f8;
|
||||
padding: 8px 10px;
|
||||
border-radius: 3px;
|
||||
overflow-x: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.no-result {
|
||||
padding: 12px 0;
|
||||
text-align: center;
|
||||
color: #999;
|
||||
font-size: 12px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,33 @@
|
||||
import { request } from "/@/api/service";
|
||||
|
||||
export async function DomainResolve(domain: string) {
|
||||
return await request({
|
||||
url: "/sys/nettest/domainResolve",
|
||||
method: "post",
|
||||
data: { domain },
|
||||
});
|
||||
}
|
||||
|
||||
export async function PingTest(domain: string) {
|
||||
return await request({
|
||||
url: "/sys/nettest/ping",
|
||||
method: "post",
|
||||
data: { domain },
|
||||
});
|
||||
}
|
||||
|
||||
export async function TelnetTest(domain: string, port: number) {
|
||||
return await request({
|
||||
url: "/sys/nettest/telnet",
|
||||
method: "post",
|
||||
data: { domain, port },
|
||||
});
|
||||
}
|
||||
|
||||
// 获取服务器信息(包括本地IP、外网IP和DNS服务器)
|
||||
export async function GetServerInfo() {
|
||||
return await request({
|
||||
url: "/sys/nettest/serverInfo",
|
||||
method: "post",
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<template>
|
||||
<fs-page class="page-sys-nettest">
|
||||
<template #header>
|
||||
<div class="title">
|
||||
网络测试
|
||||
<span class="sub">测试您的服务器容器网络连接是否正常</span>
|
||||
</div>
|
||||
</template>
|
||||
<div class="nettest-container">
|
||||
<!-- 服务端信息 -->
|
||||
<server-info-card />
|
||||
|
||||
<!-- 测试区域 -->
|
||||
<div class="test-areas flex-wrap md:flex-nowrap">
|
||||
<!-- 百度域名测试 (用于对比) -->
|
||||
<domain-test-card class="test-card" :domain="'baidu.com'" :port="443" :auto-start="true" />
|
||||
<!-- 用户输入域名测试 -->
|
||||
<domain-test-card class="test-card" :title="'自定义域名测试'" />
|
||||
</div>
|
||||
</div>
|
||||
</fs-page>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import DomainTestCard from "./DomainTestCard.vue";
|
||||
import ServerInfoCard from "./ServerInfoCard.vue";
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
.page-sys-nettest {
|
||||
.nettest-container {
|
||||
padding: 16px;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.test-areas {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.test-card {
|
||||
min-width: 50%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -79,6 +79,14 @@ export async function SysSettingsSave(data: SysSettings) {
|
||||
});
|
||||
}
|
||||
|
||||
export async function TestCaptcha(form: any) {
|
||||
return await request({
|
||||
url: apiPrefix + "/captchaTest",
|
||||
method: "post",
|
||||
data: form,
|
||||
});
|
||||
}
|
||||
|
||||
export async function TestProxy() {
|
||||
return await request({
|
||||
url: apiPrefix + "/testProxy",
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
<a-tab-pane key="safe" :tab="t('certd.sys.setting.safeSetting')">
|
||||
<SettingSafe v-if="activeKey === 'safe'" />
|
||||
</a-tab-pane>
|
||||
<a-tab-pane key="captcha" :tab="t('certd.sys.setting.captchaSetting')">
|
||||
<SettingCaptcha v-if="activeKey === 'captcha'" />
|
||||
</a-tab-pane>
|
||||
</a-tabs>
|
||||
</div>
|
||||
</fs-page>
|
||||
@@ -27,6 +30,8 @@ import SettingBase from "/@/views/sys/settings/tabs/base.vue";
|
||||
import SettingRegister from "/@/views/sys/settings/tabs/register.vue";
|
||||
import SettingPayment from "/@/views/sys/settings/tabs/payment.vue";
|
||||
import SettingSafe from "/@/views/sys/settings/tabs/safe.vue";
|
||||
import SettingCaptcha from "/@/views/sys/settings/tabs/captcha.vue";
|
||||
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import { ref } from "vue";
|
||||
import { useSettingStore } from "/@/store/settings";
|
||||
@@ -58,7 +63,7 @@ function onChange(value: string) {
|
||||
<style lang="less">
|
||||
.page-sys-settings {
|
||||
.sys-settings-form {
|
||||
width: 600px;
|
||||
width: 800px;
|
||||
max-width: 100%;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
@@ -47,18 +47,6 @@
|
||||
<div class="helper" v-html="t('certd.commonCnameHelper')"></div>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item :label="t('certd.sys.setting.captchaEnabled')" :name="['public', 'captchaEnabled']">
|
||||
<a-switch v-model:checked="formState.public.captchaEnabled" />
|
||||
<div class="helper" v-html="t('certd.sys.setting.captchaHelper')"></div>
|
||||
</a-form-item>
|
||||
<a-form-item :label="t('certd.sys.setting.captchaType')" :name="['public', 'captchaAddonId']">
|
||||
<addon-selector v-model:model-value="formState.public.captchaAddonId" addon-type="captcha" from="sys" @selected-change="onAddonChanged" />
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item :name="['public', 'captchaType']" class="hidden">
|
||||
<a-input v-model:model-value="formState.public.captchaType"></a-input>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label=" " :colon="false" :wrapper-col="{ span: 8 }">
|
||||
<a-button :loading="saveLoading" type="primary" html-type="submit">{{ t("certd.saveButton") }}</a-button>
|
||||
</a-form-item>
|
||||
@@ -76,6 +64,7 @@ import { notification } from "ant-design-vue";
|
||||
import { util } from "/@/utils";
|
||||
import { useI18n } from "/src/locales";
|
||||
import AddonSelector from "../../../certd/addon/addon-selector/index.vue";
|
||||
import CaptchaInput from "/@/components/captcha/captcha-input.vue";
|
||||
const { t } = useI18n();
|
||||
|
||||
defineOptions({
|
||||
@@ -106,6 +95,7 @@ const settingsStore = useSettingStore();
|
||||
const onFinish = async (form: any) => {
|
||||
try {
|
||||
saveLoading.value = true;
|
||||
|
||||
await api.SysSettingsSave(form);
|
||||
await settingsStore.loadSysSettings();
|
||||
notification.success({
|
||||
@@ -116,21 +106,6 @@ const onFinish = async (form: any) => {
|
||||
}
|
||||
};
|
||||
|
||||
const onFinishFailed = (errorInfo: any) => {
|
||||
// console.log("Failed:", errorInfo);
|
||||
};
|
||||
|
||||
async function stopOtherUserTimer() {
|
||||
await api.stopOtherUserTimer();
|
||||
notification.success({
|
||||
message: t("certd.stopSuccess"),
|
||||
});
|
||||
}
|
||||
|
||||
function onAddonChanged(target: any) {
|
||||
formState.public.captchaType = target.type;
|
||||
}
|
||||
|
||||
const testProxyLoading = ref(false);
|
||||
async function testProxy() {
|
||||
testProxyLoading.value = true;
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
<template>
|
||||
<div class="sys-settings-form sys-settings-base">
|
||||
<a-form :model="formState" name="basic" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }" autocomplete="off" @finish="onFinish">
|
||||
<a-form-item :label="t('certd.sys.setting.captchaEnabled')" :name="['public', 'captchaEnabled']">
|
||||
<a-switch v-model:checked="formState.public.captchaEnabled" />
|
||||
<div class="helper" v-html="t('certd.sys.setting.captchaHelper')"></div>
|
||||
</a-form-item>
|
||||
<a-form-item :label="t('certd.sys.setting.captchaType')" :name="['public', 'captchaAddonId']">
|
||||
<addon-selector v-model:model-value="formState.public.captchaAddonId" addon-type="captcha" from="sys" @selected-change="onAddonChanged" />
|
||||
</a-form-item>
|
||||
<a-form-item v-if="formState.public.captchaType === settingsStore.sysPublic.captchaType" :label="t('certd.sys.setting.captchaTest')">
|
||||
<div class="flex">
|
||||
<CaptchaInput v-model:model-value="captchaTestForm.captcha" class="w-50%"></CaptchaInput>
|
||||
<a-button class="ml-2" type="primary" @click="doCaptchaValidate">后端验证</a-button>
|
||||
</div>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item :name="['public', 'captchaType']" class="hidden">
|
||||
<a-input v-model:model-value="formState.public.captchaType"></a-input>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label=" " :colon="false" :wrapper-col="{ span: 8 }">
|
||||
<a-button :loading="saveLoading" type="primary" html-type="submit">{{ t("certd.saveButton") }}</a-button>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="tsx">
|
||||
import { reactive, ref } from "vue";
|
||||
import { SysSettings } from "/@/views/sys/settings/api";
|
||||
import * as api from "/@/views/sys/settings/api";
|
||||
import { merge } from "lodash-es";
|
||||
import { useSettingStore } from "/@/store/settings";
|
||||
import { notification } from "ant-design-vue";
|
||||
import { util } from "/@/utils";
|
||||
import { useI18n } from "/src/locales";
|
||||
import AddonSelector from "../../../certd/addon/addon-selector/index.vue";
|
||||
import CaptchaInput from "/@/components/captcha/captcha-input.vue";
|
||||
const { t } = useI18n();
|
||||
|
||||
defineOptions({
|
||||
name: "SettingCaptcha",
|
||||
});
|
||||
|
||||
const captchaTestForm = reactive({
|
||||
captcha: null,
|
||||
pass: false,
|
||||
});
|
||||
|
||||
async function doCaptchaValidate() {
|
||||
if (!captchaTestForm.captcha) {
|
||||
notification.error({
|
||||
message: "请进行验证码验证",
|
||||
});
|
||||
return;
|
||||
}
|
||||
await api.TestCaptcha(captchaTestForm.captcha);
|
||||
notification.success({
|
||||
message: "校验通过",
|
||||
});
|
||||
captchaTestForm.pass = true;
|
||||
}
|
||||
|
||||
const formState = reactive<Partial<SysSettings>>({
|
||||
public: {
|
||||
icpNo: "",
|
||||
mpsNo: "",
|
||||
},
|
||||
private: {},
|
||||
});
|
||||
|
||||
async function loadSysSettings() {
|
||||
const data: any = await api.SysSettingsGet();
|
||||
merge(formState, data);
|
||||
}
|
||||
|
||||
const saveLoading = ref(false);
|
||||
loadSysSettings();
|
||||
const settingsStore = useSettingStore();
|
||||
const onFinish = async (form: any) => {
|
||||
try {
|
||||
saveLoading.value = true;
|
||||
|
||||
if (form.public.captchaEnabled && !captchaTestForm.pass) {
|
||||
if (form.public.captchaType === settingsStore.sysPublic.captchaType) {
|
||||
notification.error({
|
||||
message: "您正在开启登录验证码,请先通过验证码测试,后端校验成功后才能保存",
|
||||
});
|
||||
} else {
|
||||
notification.error({
|
||||
message: "您正在开启登录验证码,请先关闭登录验证码开关,保存,然后会显示验证码,进行验证码测试,后端校验成功,之后再开启登录验证码,并保存",
|
||||
});
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
await api.SysSettingsSave(form);
|
||||
await settingsStore.loadSysSettings();
|
||||
notification.success({
|
||||
message: t("certd.saveSuccess"),
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
clearValidState();
|
||||
} finally {
|
||||
saveLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
function clearValidState() {
|
||||
captchaTestForm.pass = false;
|
||||
captchaTestForm.captcha = null;
|
||||
}
|
||||
|
||||
function onAddonChanged(target: any) {
|
||||
formState.public.captchaType = target.type;
|
||||
clearValidState();
|
||||
}
|
||||
</script>
|
||||
<style lang="less">
|
||||
.sys-settings-base {
|
||||
}
|
||||
</style>
|
||||
@@ -55,15 +55,15 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||
groups: {
|
||||
base: {
|
||||
header: t("certd.basicInfo"),
|
||||
columns: ["title", "type", "disabled", "order", "supportBuy", "intro"]
|
||||
columns: ["title", "type", "disabled", "order", "supportBuy", "intro"],
|
||||
},
|
||||
content: {
|
||||
header: t("certd.packageContent"),
|
||||
columns: ["content.maxDomainCount", "content.maxPipelineCount", "content.maxDeployCount", "content.maxMonitorCount"]
|
||||
columns: ["content.maxDomainCount", "content.maxPipelineCount", "content.maxDeployCount", "content.maxMonitorCount"],
|
||||
},
|
||||
price: {
|
||||
header: t("certd.price"),
|
||||
columns: ["durationPrices"]
|
||||
columns: ["durationPrices"],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -41,7 +41,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||
//这里使用行选择插件,生成行选择crudOptions配置,最终会与crudOptions合并
|
||||
rowSelection: {
|
||||
enabled: true,
|
||||
order: -2,
|
||||
order: -99,
|
||||
before: true,
|
||||
// handle: (pluginProps,useCrudProps)=>CrudOptions,
|
||||
props: {
|
||||
|
||||
@@ -84,6 +84,7 @@ export default ({ command, mode }) => {
|
||||
host: "0.0.0.0",
|
||||
port: 3008,
|
||||
fs: devServerFs,
|
||||
allowedHosts: ["localhost", "127.0.0.1", "yfy.docmirror.cn"],
|
||||
proxy: {
|
||||
// with options
|
||||
"/api": {
|
||||
|
||||
@@ -23,7 +23,6 @@ typeorm:
|
||||
database: './data/db-plus-dev-1.sqlite'
|
||||
|
||||
# plus server: 'http://127.0.0.1:11007'
|
||||
|
||||
account:
|
||||
server:
|
||||
baseUrl: 'http://localhost:1017/subject'
|
||||
|
||||
@@ -3,6 +3,54 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.37.1](https://github.com/certd/certd/compare/v1.37.0...v1.37.1) (2025-09-29)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 修复某些情况下cname申请证书报错主域名不一致的bug ([2671781](https://github.com/certd/certd/commit/2671781e1bb0838981728d85eacf0e1a25a0fa48))
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* dns解析支持阿里esa ([9291fa6](https://github.com/certd/certd/commit/9291fa68aa7a88a05c2f888bf3048df36a8fbde3))
|
||||
|
||||
# [1.37.0](https://github.com/certd/certd/compare/v1.36.25...v1.37.0) (2025-09-28)
|
||||
|
||||
### Features
|
||||
|
||||
* dist打包前检查 ([8f6e5bd](https://github.com/certd/certd/commit/8f6e5bd24b3b65fbfcba36c08f532a3abad2d606))
|
||||
|
||||
## [1.36.25](https://github.com/certd/certd/compare/v1.36.24...v1.36.25) (2025-09-27)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 固定midwayjs版本,修复ui-server import 错误的bug ([eb4d125](https://github.com/certd/certd/commit/eb4d125eaf4a41e88c752d0c68993829589f8f27))
|
||||
|
||||
## [1.36.24](https://github.com/certd/certd/compare/v1.36.23...v1.36.24) (2025-09-27)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 修复 ui-server 加载失败问题 ([c2ccdbe](https://github.com/certd/certd/commit/c2ccdbec9dd08bca4688eeb2f34d0105eec43ba1))
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* 重置管理员密码同时会关闭验证码,防止验证码失效之后无法登录 ([03899d4](https://github.com/certd/certd/commit/03899d4d9c76fc2077dacc53ab88e2c9ca41af7c))
|
||||
|
||||
## [1.36.23](https://github.com/certd/certd/compare/v1.36.22...v1.36.23) (2025-09-26)
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* 开启子域名托管之后cname记录支持重置 ([54c8d62](https://github.com/certd/certd/commit/54c8d622437761d350db0f17e07f7517f1911211))
|
||||
* 验证码支持测试,登录验证码需要测试通过后才能开启 ([83e6476](https://github.com/certd/certd/commit/83e6476408090b741fabb1b542fb458d9a8b4134))
|
||||
|
||||
## [1.36.22](https://github.com/certd/certd/compare/v1.36.21...v1.36.22) (2025-09-23)
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* 7001绑定::地址 ([7188997](https://github.com/certd/certd/commit/7188997dd1979f1c10fa29b30221015e0bd5fe9e))
|
||||
* 公共cname支持权限校验 ([9cc5f0f](https://github.com/certd/certd/commit/9cc5f0f889d4362ff36e7a1f0e448e02d32ecee7))
|
||||
* dns支持新网域名解析 ([cf3a78e](https://github.com/certd/certd/commit/cf3a78e1145ff0505c87fbc485d9e731b1aa88a8))
|
||||
* gcore flush plugin ssl_id改为必填项 ([4b90972](https://github.com/certd/certd/commit/4b909723411c57505aa13b07d8699fb9ac77c937))
|
||||
|
||||
## [1.36.21](https://github.com/certd/certd/compare/v1.36.20...v1.36.21) (2025-09-15)
|
||||
|
||||
**Note:** Version bump only for package @certd/ui-server
|
||||
|
||||
@@ -5,9 +5,8 @@ const { Bootstrap } = require('@midwayjs/bootstrap');
|
||||
const DirectoryFileDetector = require('@midwayjs/core').DirectoryFileDetector;
|
||||
|
||||
const baseDir = process.cwd();
|
||||
const pipelineDir = baseDir + './node_modules/@certd/pipeline/dist';
|
||||
const customFileDetector = new DirectoryFileDetector({
|
||||
loadDir: [baseDir, pipelineDir],
|
||||
loadDir: [baseDir],
|
||||
});
|
||||
|
||||
module.exports = async () => {
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE cd_cname_record ADD COLUMN `main_domain` varchar(100);
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE cd_cname_record ADD COLUMN "main_domain" varchar(100);
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE cd_cname_record ADD COLUMN "main_domain" varchar(100);
|
||||
@@ -1,12 +1,14 @@
|
||||
{
|
||||
"name": "@certd/ui-server",
|
||||
"version": "1.36.21",
|
||||
"version": "1.37.1",
|
||||
"description": "fast-server base midway",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"start": "cross-env NODE_ENV=production node ./bootstrap.js",
|
||||
"dev": "cross-env NODE_ENV=local mwtsc --watch --run @midwayjs/mock/app",
|
||||
"dev-start": "mwtsc --watch --run @midwayjs/mock/app",
|
||||
"dc": "cd ../../../ && pnpm run dev",
|
||||
"dev": "cross-env NODE_ENV=local & pnpm run dev-start",
|
||||
"dev-commlocal": "cross-env NODE_ENV=dev-commlocal mwtsc --watch --run @midwayjs/mock/app",
|
||||
"dev-commpro": "cross-env NODE_ENV=dev-commpro mwtsc --watch --run @midwayjs/mock/app",
|
||||
"dev-pg": "cross-env NODE_ENV=dev-pg mwtsc --watch --run @midwayjs/mock/app",
|
||||
@@ -43,34 +45,34 @@
|
||||
"@aws-sdk/client-cloudfront": "^3.699.0",
|
||||
"@aws-sdk/client-iam": "^3.699.0",
|
||||
"@aws-sdk/client-s3": "^3.705.0",
|
||||
"@certd/acme-client": "^1.36.21",
|
||||
"@certd/basic": "^1.36.21",
|
||||
"@certd/commercial-core": "^1.36.21",
|
||||
"@certd/acme-client": "^1.37.1",
|
||||
"@certd/basic": "^1.37.1",
|
||||
"@certd/commercial-core": "^1.37.1",
|
||||
"@certd/cv4pve-api-javascript": "^8.4.2",
|
||||
"@certd/jdcloud": "^1.36.21",
|
||||
"@certd/lib-huawei": "^1.36.21",
|
||||
"@certd/lib-k8s": "^1.36.21",
|
||||
"@certd/lib-server": "^1.36.21",
|
||||
"@certd/midway-flyway-js": "^1.36.21",
|
||||
"@certd/pipeline": "^1.36.21",
|
||||
"@certd/plugin-cert": "^1.36.21",
|
||||
"@certd/plugin-lib": "^1.36.21",
|
||||
"@certd/plugin-plus": "^1.36.21",
|
||||
"@certd/plus-core": "^1.36.21",
|
||||
"@certd/jdcloud": "^1.37.1",
|
||||
"@certd/lib-huawei": "^1.37.1",
|
||||
"@certd/lib-k8s": "^1.37.1",
|
||||
"@certd/lib-server": "^1.37.1",
|
||||
"@certd/midway-flyway-js": "^1.37.1",
|
||||
"@certd/pipeline": "^1.37.1",
|
||||
"@certd/plugin-cert": "^1.37.1",
|
||||
"@certd/plugin-lib": "^1.37.1",
|
||||
"@certd/plugin-plus": "^1.37.1",
|
||||
"@certd/plus-core": "^1.37.1",
|
||||
"@huaweicloud/huaweicloud-sdk-cdn": "^3.1.120",
|
||||
"@huaweicloud/huaweicloud-sdk-core": "^3.1.120",
|
||||
"@koa/cors": "^5.0.0",
|
||||
"@midwayjs/bootstrap": "~3.20.3",
|
||||
"@midwayjs/cache": "~3.14.0",
|
||||
"@midwayjs/core": "~3.20.3",
|
||||
"@midwayjs/i18n": "~3.20.3",
|
||||
"@midwayjs/info": "~3.20.3",
|
||||
"@midwayjs/koa": "~3.20.3",
|
||||
"@midwayjs/logger": "~3.4.2",
|
||||
"@midwayjs/static-file": "~3.20.3",
|
||||
"@midwayjs/typeorm": "~3.20.3",
|
||||
"@midwayjs/upload": "~3.20.3",
|
||||
"@midwayjs/validate": "~3.20.3",
|
||||
"@midwayjs/bootstrap": "3.20.11",
|
||||
"@midwayjs/cache": "3.14.0",
|
||||
"@midwayjs/core": "3.20.11",
|
||||
"@midwayjs/i18n": "3.20.13",
|
||||
"@midwayjs/info": "3.20.13",
|
||||
"@midwayjs/koa": "3.20.13",
|
||||
"@midwayjs/logger": "3.4.2",
|
||||
"@midwayjs/static-file": "3.20.13",
|
||||
"@midwayjs/typeorm": "3.20.11",
|
||||
"@midwayjs/upload": "3.20.13",
|
||||
"@midwayjs/validate": "3.20.13",
|
||||
"@volcengine/openapi": "^1.28.1",
|
||||
"ali-oss": "^6.21.0",
|
||||
"axios": "^1.7.2",
|
||||
@@ -123,7 +125,7 @@
|
||||
"uuid": "^10.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@midwayjs/mock": "~3.20.3",
|
||||
"@midwayjs/mock": "3.20.11",
|
||||
"@types/ali-oss": "^6.16.11",
|
||||
"@types/cache-manager": "^4.0.6",
|
||||
"@types/jest": "^29.5.13",
|
||||
@@ -142,7 +144,7 @@
|
||||
"why-is-node-running": "^3.2.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
"node": ">=20.0.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { ALL, Body, Controller, Inject, Post, Provide, Query } from '@midwayjs/core';
|
||||
import { AccessService, Constants } from '@certd/lib-server';
|
||||
import { AccessController } from '../../user/pipeline/access-controller.js';
|
||||
import { checkComm } from '@certd/plus-core';
|
||||
import { ALL, Body, Controller, Inject, Post, Provide, Query } from "@midwayjs/core";
|
||||
import { AccessService, Constants } from "@certd/lib-server";
|
||||
import { AccessController } from "../../user/pipeline/access-controller.js";
|
||||
|
||||
/**
|
||||
* 授权
|
||||
@@ -17,7 +16,7 @@ export class SysAccessController extends AccessController {
|
||||
}
|
||||
|
||||
getUserId() {
|
||||
checkComm();
|
||||
// checkComm();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
import { BaseController } from '@certd/lib-server';
|
||||
import { ALL, Body, Controller, Inject, Post, Provide } from '@midwayjs/core';
|
||||
import { NetTestService } from '../../../modules/sys/nettest/nettest-service.js';
|
||||
|
||||
|
||||
@Provide()
|
||||
@Controller('/api/sys/nettest/')
|
||||
export class SysNetTestController extends BaseController {
|
||||
|
||||
@Inject()
|
||||
netTestService: NetTestService;
|
||||
|
||||
|
||||
@Post('/domainResolve', { summary: 'sys:settings:view' })
|
||||
public async domainResolve(@Body(ALL) body: { domain: string }) {
|
||||
|
||||
const { domain } = body;
|
||||
const result = await this.netTestService.domainResolve(domain);
|
||||
return this.ok(result);
|
||||
}
|
||||
|
||||
// ping
|
||||
@Post('/ping', { summary: 'sys:settings:view' })
|
||||
public async ping(@Body(ALL) body: { domain: string }) {
|
||||
|
||||
const { domain } = body;
|
||||
const result = await this.netTestService.ping(domain);
|
||||
return this.ok(result);
|
||||
}
|
||||
|
||||
// telnet
|
||||
@Post('/telnet', { summary: 'sys:settings:view' })
|
||||
public async telnet(@Body(ALL) body: { domain: string, port: number }) {
|
||||
|
||||
const { domain, port } = body;
|
||||
const result = await this.netTestService.telnet(domain, port);
|
||||
return this.ok(result);
|
||||
}
|
||||
|
||||
// telnet
|
||||
@Post('/serverInfo', { summary: 'sys:settings:view' })
|
||||
public async serverInfo() {
|
||||
|
||||
const result = await this.netTestService.serverInfo();
|
||||
return this.ok(result);
|
||||
}
|
||||
}
|
||||
@@ -192,4 +192,11 @@ export class SysSettingsController extends CrudController<SysSettingsService> {
|
||||
await this.service.saveSetting(blankSetting);
|
||||
return this.ok({});
|
||||
}
|
||||
|
||||
|
||||
@Post("/captchaTest", { summary: "sys:settings:edit" })
|
||||
async captchaTest(@Body(ALL) body: any) {
|
||||
await this.codeService.checkCaptcha(body)
|
||||
return this.ok({});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,56 +11,59 @@ import {
|
||||
import { AuthService } from "../../../modules/sys/authority/service/auth-service.js";
|
||||
import { checkPlus } from "@certd/plus-core";
|
||||
import { http, logger, utils } from "@certd/basic";
|
||||
import { TaskServiceBuilder } from "../../../modules/pipeline/service/getter/task-service-getter.js";
|
||||
|
||||
/**
|
||||
* Addon
|
||||
*/
|
||||
@Provide()
|
||||
@Controller('/api/addon')
|
||||
@Controller("/api/addon")
|
||||
export class AddonController extends CrudController<AddonService> {
|
||||
@Inject()
|
||||
service: AddonService;
|
||||
@Inject()
|
||||
authService: AuthService;
|
||||
@Inject()
|
||||
taskServiceBuilder:TaskServiceBuilder
|
||||
|
||||
getService(): AddonService {
|
||||
return this.service;
|
||||
}
|
||||
|
||||
@Post('/page', { summary: Constants.per.authOnly })
|
||||
@Post("/page", { summary: Constants.per.authOnly })
|
||||
async page(@Body(ALL) body) {
|
||||
body.query = body.query ?? {};
|
||||
delete body.query.userId;
|
||||
const buildQuery = qb => {
|
||||
qb.andWhere('user_id = :userId', { userId: this.getUserId() });
|
||||
qb.andWhere("user_id = :userId", { userId: this.getUserId() });
|
||||
};
|
||||
const res = await this.service.page({
|
||||
query: body.query,
|
||||
page: body.page,
|
||||
sort: body.sort,
|
||||
buildQuery,
|
||||
buildQuery
|
||||
});
|
||||
return this.ok(res);
|
||||
}
|
||||
|
||||
@Post('/list', { summary: Constants.per.authOnly })
|
||||
@Post("/list", { summary: Constants.per.authOnly })
|
||||
async list(@Body(ALL) body) {
|
||||
body.query = body.query ?? {};
|
||||
body.query.userId = this.getUserId();
|
||||
return super.list(body);
|
||||
}
|
||||
|
||||
@Post('/add', { summary: Constants.per.authOnly })
|
||||
@Post("/add", { summary: Constants.per.authOnly })
|
||||
async add(@Body(ALL) bean) {
|
||||
bean.userId = this.getUserId();
|
||||
const type = bean.type;
|
||||
const addonType = bean.addonType;
|
||||
if (! type || !addonType){
|
||||
throw new ValidateException('请选择Addon类型');
|
||||
if (!type || !addonType) {
|
||||
throw new ValidateException("请选择Addon类型");
|
||||
}
|
||||
const define: AddonDefine = this.service.getDefineByType(type,addonType);
|
||||
const define: AddonDefine = this.service.getDefineByType(type, addonType);
|
||||
if (!define) {
|
||||
throw new ValidateException('Addon类型不存在');
|
||||
throw new ValidateException("Addon类型不存在");
|
||||
}
|
||||
if (define.needPlus) {
|
||||
checkPlus();
|
||||
@@ -68,19 +71,19 @@ export class AddonController extends CrudController<AddonService> {
|
||||
return super.add(bean);
|
||||
}
|
||||
|
||||
@Post('/update', { summary: Constants.per.authOnly })
|
||||
@Post("/update", { summary: Constants.per.authOnly })
|
||||
async update(@Body(ALL) bean) {
|
||||
await this.service.checkUserId(bean.id, this.getUserId());
|
||||
const old = await this.service.info(bean.id);
|
||||
if (!old) {
|
||||
throw new ValidateException('Addon配置不存在');
|
||||
throw new ValidateException("Addon配置不存在");
|
||||
}
|
||||
if (old.type !== bean.type ) {
|
||||
if (old.type !== bean.type) {
|
||||
const addonType = old.type;
|
||||
const type = bean.type;
|
||||
const define: AddonDefine = this.service.getDefineByType(type,addonType);
|
||||
const define: AddonDefine = this.service.getDefineByType(type, addonType);
|
||||
if (!define) {
|
||||
throw new ValidateException('Addon类型不存在');
|
||||
throw new ValidateException("Addon类型不存在");
|
||||
}
|
||||
if (define.needPlus) {
|
||||
checkPlus();
|
||||
@@ -89,26 +92,27 @@ export class AddonController extends CrudController<AddonService> {
|
||||
delete bean.userId;
|
||||
return super.update(bean);
|
||||
}
|
||||
@Post('/info', { summary: Constants.per.authOnly })
|
||||
async info(@Query('id') id: number) {
|
||||
|
||||
@Post("/info", { summary: Constants.per.authOnly })
|
||||
async info(@Query("id") id: number) {
|
||||
await this.service.checkUserId(id, this.getUserId());
|
||||
return super.info(id);
|
||||
}
|
||||
|
||||
@Post('/delete', { summary: Constants.per.authOnly })
|
||||
async delete(@Query('id') id: number) {
|
||||
@Post("/delete", { summary: Constants.per.authOnly })
|
||||
async delete(@Query("id") id: number) {
|
||||
await this.service.checkUserId(id, this.getUserId());
|
||||
return super.delete(id);
|
||||
}
|
||||
|
||||
@Post('/define', { summary: Constants.per.authOnly })
|
||||
async define(@Query('type') type: string,@Query('addonType') addonType: string) {
|
||||
const notification = this.service.getDefineByType(type,addonType);
|
||||
@Post("/define", { summary: Constants.per.authOnly })
|
||||
async define(@Query("type") type: string, @Query("addonType") addonType: string) {
|
||||
const notification = this.service.getDefineByType(type, addonType);
|
||||
return this.ok(notification);
|
||||
}
|
||||
|
||||
@Post('/getTypeDict', { summary: Constants.per.authOnly })
|
||||
async getTypeDict(@Query('addonType') addonType: string) {
|
||||
@Post("/getTypeDict", { summary: Constants.per.authOnly })
|
||||
async getTypeDict(@Query("addonType") addonType: string) {
|
||||
const list: any = this.service.getDefineList(addonType);
|
||||
let dict = [];
|
||||
for (const item of list) {
|
||||
@@ -116,7 +120,7 @@ export class AddonController extends CrudController<AddonService> {
|
||||
value: item.name,
|
||||
label: item.title,
|
||||
needPlus: item.needPlus ?? false,
|
||||
icon: item.icon,
|
||||
icon: item.icon
|
||||
});
|
||||
}
|
||||
dict = dict.sort(a => {
|
||||
@@ -125,13 +129,13 @@ export class AddonController extends CrudController<AddonService> {
|
||||
return this.ok(dict);
|
||||
}
|
||||
|
||||
@Post('/simpleInfo', { summary: Constants.per.authOnly })
|
||||
async simpleInfo(@Query('addonType') addonType: string,@Query('id') id: number) {
|
||||
@Post("/simpleInfo", { summary: Constants.per.authOnly })
|
||||
async simpleInfo(@Query("addonType") addonType: string, @Query("id") id: number) {
|
||||
if (id === 0) {
|
||||
//获取默认
|
||||
const res = await this.service.getDefault(this.getUserId(),addonType);
|
||||
const res = await this.service.getDefault(this.getUserId(), addonType);
|
||||
if (!res) {
|
||||
throw new ValidateException('默认Addon配置不存在');
|
||||
throw new ValidateException("默认Addon配置不存在");
|
||||
}
|
||||
const simple = await this.service.getSimpleInfo(res.id);
|
||||
return this.ok(simple);
|
||||
@@ -141,27 +145,27 @@ export class AddonController extends CrudController<AddonService> {
|
||||
return this.ok(res);
|
||||
}
|
||||
|
||||
@Post('/getDefaultId', { summary: Constants.per.authOnly })
|
||||
async getDefaultId(@Query('addonType') addonType: string) {
|
||||
const res = await this.service.getDefault(this.getUserId(),addonType);
|
||||
@Post("/getDefaultId", { summary: Constants.per.authOnly })
|
||||
async getDefaultId(@Query("addonType") addonType: string) {
|
||||
const res = await this.service.getDefault(this.getUserId(), addonType);
|
||||
return this.ok(res?.id);
|
||||
}
|
||||
|
||||
@Post('/setDefault', { summary: Constants.per.authOnly })
|
||||
async setDefault(@Query('addonType') addonType: string,@Query('id') id: number) {
|
||||
@Post("/setDefault", { summary: Constants.per.authOnly })
|
||||
async setDefault(@Query("addonType") addonType: string, @Query("id") id: number) {
|
||||
await this.service.checkUserId(id, this.getUserId());
|
||||
const res = await this.service.setDefault(id, this.getUserId(),addonType);
|
||||
const res = await this.service.setDefault(id, this.getUserId(), addonType);
|
||||
return this.ok(res);
|
||||
}
|
||||
|
||||
|
||||
@Post('/options', { summary: Constants.per.authOnly })
|
||||
async options(@Query('addonType') addonType: string) {
|
||||
@Post("/options", { summary: Constants.per.authOnly })
|
||||
async options(@Query("addonType") addonType: string) {
|
||||
const res = await this.service.list({
|
||||
query: {
|
||||
userId: this.getUserId(),
|
||||
addonType
|
||||
},
|
||||
}
|
||||
});
|
||||
for (const item of res) {
|
||||
delete item.setting;
|
||||
@@ -170,7 +174,7 @@ export class AddonController extends CrudController<AddonService> {
|
||||
}
|
||||
|
||||
|
||||
@Post('/handle', { summary: Constants.per.authOnly })
|
||||
@Post("/handle", { summary: Constants.per.authOnly })
|
||||
async handle(@Body(ALL) body: AddonRequestHandleReq) {
|
||||
const userId = this.getUserId();
|
||||
let inputAddon = body.input.addon;
|
||||
@@ -178,21 +182,24 @@ export class AddonController extends CrudController<AddonService> {
|
||||
const oldEntity = await this.service.info(body.input.id);
|
||||
if (oldEntity) {
|
||||
if (oldEntity.userId !== userId) {
|
||||
throw new Error('addon not found');
|
||||
throw new Error("addon not found");
|
||||
}
|
||||
// const param: any = {
|
||||
// type: body.typeName,
|
||||
// setting: JSON.stringify(body.input.access),
|
||||
// };
|
||||
inputAddon = JSON.parse( oldEntity.setting)
|
||||
inputAddon = JSON.parse(oldEntity.setting);
|
||||
}
|
||||
}
|
||||
const serviceGetter = this.taskServiceBuilder.create({ userId });
|
||||
|
||||
const ctx = {
|
||||
http: http,
|
||||
logger:logger,
|
||||
utils:utils,
|
||||
}
|
||||
const addon = await newAddon(body.addonType,body.typeName, inputAddon,ctx);
|
||||
logger: logger,
|
||||
utils: utils,
|
||||
serviceGetter
|
||||
};
|
||||
const addon = await newAddon(body.addonType, body.typeName, inputAddon, ctx);
|
||||
const res = await addon.onRequest(body);
|
||||
return this.ok(res);
|
||||
}
|
||||
|
||||
@@ -85,10 +85,18 @@ export class CnameRecordController extends CrudController<CnameRecordService> {
|
||||
}
|
||||
|
||||
@Post('/verify', { summary: Constants.per.authOnly })
|
||||
async verify(@Body(ALL) body: { id: string }) {
|
||||
async verify(@Body(ALL) body: { id: number }) {
|
||||
const userId = this.getUserId();
|
||||
await this.service.checkUserId(body.id, userId);
|
||||
const res = await this.service.verify(body.id);
|
||||
return this.ok(res);
|
||||
}
|
||||
|
||||
@Post('/resetStatus', { summary: Constants.per.authOnly })
|
||||
async resetStatus(@Body(ALL) body: { id: number }) {
|
||||
const userId = this.getUserId();
|
||||
await this.service.checkUserId(body.id, userId);
|
||||
const res = await this.service.resetStatus(body.id);
|
||||
return this.ok(res);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {ALL, Body, Controller, Inject, Post, Provide, Query} from '@midwayjs/core';
|
||||
import {Constants, CrudController} from '@certd/lib-server';
|
||||
import {SubDomainService} from "../../../modules/pipeline/service/sub-domain-service.js";
|
||||
import {DomainParser} from '@certd/plugin-cert/dist/dns-provider/domain-parser.js';
|
||||
import {DomainParser} from '@certd/plugin-cert';
|
||||
import { SubDomainsGetter } from '../../../modules/pipeline/service/getter/sub-domain-getter.js';
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Autoload, Config, Init, Inject, Provide, Scope, ScopeEnum } from '@midwayjs/core';
|
||||
import { IMidwayKoaContext, IWebMiddleware, NextFunction } from '@midwayjs/koa';
|
||||
import { CommonException } from '@certd/lib-server';
|
||||
import { CommonException, SysSettingsService } from "@certd/lib-server";
|
||||
import { UserService } from '../../modules/sys/authority/service/user-service.js';
|
||||
import { logger } from '@certd/basic';
|
||||
import {UserSettingsService} from "../../modules/mine/service/user-settings-service.js";
|
||||
@@ -17,6 +17,8 @@ export class ResetPasswdMiddleware implements IWebMiddleware {
|
||||
|
||||
@Inject()
|
||||
userSettingsService: UserSettingsService;
|
||||
@Inject()
|
||||
sysSettingsService: SysSettingsService;
|
||||
|
||||
@Config('system.resetAdminPasswd')
|
||||
private resetAdminPasswd: boolean;
|
||||
@@ -40,8 +42,12 @@ export class ResetPasswdMiddleware implements IWebMiddleware {
|
||||
userId: 1,
|
||||
key:"user.two.factor"
|
||||
})
|
||||
const publicSettings = await this.sysSettingsService.getPublicSettings()
|
||||
publicSettings.captchaEnabled = false
|
||||
await this.sysSettingsService.savePublicSettings(publicSettings);
|
||||
|
||||
const user = await this.userService.info(1);
|
||||
logger.info(`重置1号管理员用户的密码完成,2FA设置已删除,用户名:${user.username},新密码:${newPasswd},请在登录进去之后尽快修改密码`);
|
||||
logger.info(`重置1号管理员用户的密码完成,2FA设置已删除,验证码登录已禁用,用户名:${user.username},新密码:${newPasswd},请在登录进去之后尽快修改密码`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Autoload, Init, Inject, Scope, ScopeEnum } from "@midwayjs/core";
|
||||
import { CertInfoService } from "../monitor/index.js";
|
||||
import { pipelineEmitter } from "@certd/pipeline";
|
||||
import { CertInfo, EVENT_CERT_APPLY_SUCCESS } from "@certd/plugin-cert";
|
||||
import { PipelineEvent } from "@certd/pipeline/dist/service/emit.js";
|
||||
import { PipelineEvent } from "@certd/pipeline";
|
||||
|
||||
@Autoload()
|
||||
@Scope(ScopeEnum.Request, { allowDowngrade: true })
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { Inject, Provide, Scope, ScopeEnum } from "@midwayjs/core";
|
||||
import { AddonService, SysSettingsService } from "@certd/lib-server";
|
||||
import { SysSettingsService } from "@certd/lib-server";
|
||||
import { logger } from "@certd/basic";
|
||||
import { ICaptchaAddon } from "../../../plugins/plugin-captcha/api.js";
|
||||
import { AddonGetterService } from "../../pipeline/service/addon-getter-service.js";
|
||||
|
||||
@Provide()
|
||||
@Scope(ScopeEnum.Request, { allowDowngrade: true })
|
||||
@@ -9,45 +10,48 @@ export class CaptchaService {
|
||||
@Inject()
|
||||
sysSettingsService: SysSettingsService;
|
||||
@Inject()
|
||||
addonService: AddonService;
|
||||
addonGetterService: AddonGetterService;
|
||||
|
||||
|
||||
async getCaptcha(captchaAddonId?:number){
|
||||
async getCaptcha(captchaAddonId?: number) {
|
||||
if (!captchaAddonId) {
|
||||
const settings = await this.sysSettingsService.getPublicSettings()
|
||||
captchaAddonId = settings.captchaAddonId ?? 0
|
||||
const settings = await this.sysSettingsService.getPublicSettings();
|
||||
captchaAddonId = settings.captchaAddonId ?? 0;
|
||||
}
|
||||
const addon:ICaptchaAddon = await this.addonService.getAddonById(captchaAddonId,true,0)
|
||||
const addon: ICaptchaAddon = await this.addonGetterService.getAddonById(captchaAddonId, true, 0, {
|
||||
type: "captcha",
|
||||
name: "image"
|
||||
});
|
||||
if (!addon) {
|
||||
throw new Error('验证码插件还未配置')
|
||||
throw new Error("验证码插件还未配置");
|
||||
}
|
||||
return await addon.getCaptcha()
|
||||
return await addon.getCaptcha();
|
||||
}
|
||||
|
||||
|
||||
async doValidate(opts:{form:any,must?:boolean,captchaAddonId?:number}){
|
||||
async doValidate(opts: { form: any, must?: boolean, captchaAddonId?: number }) {
|
||||
if (!opts.captchaAddonId) {
|
||||
const settings = await this.sysSettingsService.getPublicSettings()
|
||||
opts.captchaAddonId = settings.captchaAddonId ?? 0
|
||||
const settings = await this.sysSettingsService.getPublicSettings();
|
||||
opts.captchaAddonId = settings.captchaAddonId ?? 0;
|
||||
}
|
||||
const addon = await this.addonService.getById(opts.captchaAddonId,0)
|
||||
const addon = await this.addonGetterService.getById(opts.captchaAddonId, 0);
|
||||
if (!addon) {
|
||||
if (opts.must) {
|
||||
throw new Error('请先配置验证码插件');
|
||||
throw new Error("请先配置验证码插件");
|
||||
}
|
||||
logger.warn('验证码插件还未配置,忽略验证码校验')
|
||||
return true
|
||||
logger.warn("验证码插件还未配置,忽略验证码校验");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!opts.form) {
|
||||
throw new Error('请输入验证码');
|
||||
throw new Error("请输入验证码");
|
||||
}
|
||||
const res = await addon.onValidate(opts.form)
|
||||
const res = await addon.onValidate(opts.form);
|
||||
if (!res) {
|
||||
throw new Error('验证码错误');
|
||||
throw new Error("验证码错误");
|
||||
}
|
||||
|
||||
return true
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { cache, isDev, randomNumber } from '@certd/basic';
|
||||
import { SysSettingsService, SysSiteInfo } from '@certd/lib-server';
|
||||
import { SmsServiceFactory } from '../sms/factory.js';
|
||||
import { ISmsService } from '../sms/api.js';
|
||||
import { CodeErrorException } from '@certd/lib-server/dist/basic/exception/code-error-exception.js';
|
||||
import { CodeErrorException } from '@certd/lib-server';
|
||||
import { EmailService } from './email-service.js';
|
||||
import { AccessService } from '@certd/lib-server';
|
||||
import { AccessSysGetter } from '@certd/lib-server';
|
||||
|
||||
@@ -4,7 +4,7 @@ import {In, Not, Repository} from 'typeorm';
|
||||
import {AccessService, BaseService} from '@certd/lib-server';
|
||||
import {DomainEntity} from '../entity/domain.js';
|
||||
import {SubDomainService} from "../../pipeline/service/sub-domain-service.js";
|
||||
import {DomainParser} from "@certd/plugin-cert/dist/dns-provider/domain-parser.js";
|
||||
import {DomainParser} from "@certd/plugin-cert";
|
||||
import {DomainVerifiers} from "@certd/plugin-cert";
|
||||
import { SubDomainsGetter } from '../../pipeline/service/getter/sub-domain-getter.js';
|
||||
import { CnameRecordService } from '../../cname/service/cname-record-service.js';
|
||||
|
||||
@@ -13,6 +13,8 @@ export class CnameRecordEntity {
|
||||
|
||||
@Column({ comment: '证书申请域名', length: 100 })
|
||||
domain: string;
|
||||
@Column({ comment: '主域名', name: 'main_domain', length: 100 })
|
||||
mainDomain:string;
|
||||
|
||||
@Column({ comment: '主机记录', name: 'host_record', length: 100 })
|
||||
hostRecord: string;
|
||||
|
||||
@@ -17,10 +17,11 @@ import { getAuthoritativeDnsResolver, walkTxtRecord } from "@certd/acme-client";
|
||||
import { CnameProviderService } from "./cname-provider-service.js";
|
||||
import { CnameProviderEntity } from "../entity/cname-provider.js";
|
||||
import { CommonDnsProvider } from "./common-provider.js";
|
||||
import { DomainParser } from "@certd/plugin-cert/dist/dns-provider/domain-parser.js";
|
||||
import { DomainParser } from "@certd/plugin-cert";
|
||||
import punycode from "punycode.js";
|
||||
import { SubDomainService } from "../../pipeline/service/sub-domain-service.js";
|
||||
import { SubDomainsGetter } from "../../pipeline/service/getter/sub-domain-getter.js";
|
||||
import { TaskServiceBuilder } from "../../pipeline/service/getter/task-service-getter.js";
|
||||
|
||||
type CnameCheckCacheValue = {
|
||||
validating: boolean;
|
||||
@@ -36,7 +37,7 @@ type CnameCheckCacheValue = {
|
||||
* 授权
|
||||
*/
|
||||
@Provide()
|
||||
@Scope(ScopeEnum.Request, {allowDowngrade: true})
|
||||
@Scope(ScopeEnum.Request, { allowDowngrade: true })
|
||||
export class CnameRecordService extends BaseService<CnameRecordEntity> {
|
||||
@InjectEntityModel(CnameRecordEntity)
|
||||
repository: Repository<CnameRecordEntity>;
|
||||
@@ -55,6 +56,10 @@ export class CnameRecordService extends BaseService<CnameRecordEntity> {
|
||||
@Inject()
|
||||
subDomainService: SubDomainService;
|
||||
|
||||
@Inject()
|
||||
taskServiceBuilder: TaskServiceBuilder;
|
||||
|
||||
|
||||
//@ts-ignore
|
||||
getRepository() {
|
||||
return this.repository;
|
||||
@@ -66,16 +71,16 @@ export class CnameRecordService extends BaseService<CnameRecordEntity> {
|
||||
*/
|
||||
async add(param: any): Promise<CnameRecordEntity> {
|
||||
if (!param.domain) {
|
||||
throw new ValidateException('域名不能为空');
|
||||
throw new ValidateException("域名不能为空");
|
||||
}
|
||||
if (!param.userId) {
|
||||
throw new ValidateException('userId不能为空');
|
||||
throw new ValidateException("userId不能为空");
|
||||
}
|
||||
if (param.domain.startsWith('*.')) {
|
||||
if (param.domain.startsWith("*.")) {
|
||||
param.domain = param.domain.substring(2);
|
||||
}
|
||||
param.domain = param.domain.trim()
|
||||
const info = await this.getRepository().findOne({where: {domain: param.domain, userId: param.userId}});
|
||||
param.domain = param.domain.trim();
|
||||
const info = await this.getRepository().findOne({ where: { domain: param.domain, userId: param.userId } });
|
||||
if (info) {
|
||||
return info;
|
||||
}
|
||||
@@ -85,63 +90,62 @@ export class CnameRecordService extends BaseService<CnameRecordEntity> {
|
||||
//获取默认的cnameProviderId
|
||||
cnameProvider = await this.cnameProviderService.getByPriority();
|
||||
if (cnameProvider == null) {
|
||||
throw new ValidateException('找不到CNAME服务,请先前往“系统管理->CNAME服务设置”添加CNAME服务');
|
||||
throw new ValidateException("找不到CNAME服务,请先前往“系统管理->CNAME服务设置”添加CNAME服务");
|
||||
}
|
||||
} else {
|
||||
cnameProvider = await this.cnameProviderService.info(param.cnameProviderId);
|
||||
}
|
||||
await this.cnameProviderChanged(param.userId, param, cnameProvider);
|
||||
|
||||
param.status = 'cname';
|
||||
const {id} = await super.add(param);
|
||||
param.status = "cname";
|
||||
const { id } = await super.add(param);
|
||||
return await this.info(id);
|
||||
}
|
||||
|
||||
private async cnameProviderChanged(userId: number, param: any, cnameProvider: CnameProviderEntity) {
|
||||
param.cnameProviderId = cnameProvider.id;
|
||||
|
||||
const subDomainGetter = new SubDomainsGetter(userId, this.subDomainService)
|
||||
const subDomainGetter = new SubDomainsGetter(userId, this.subDomainService);
|
||||
const domainParser = new DomainParser(subDomainGetter);
|
||||
|
||||
const realDomain = await domainParser.parse(param.domain);
|
||||
const prefix = param.domain.replace(realDomain, '');
|
||||
const prefix = param.domain.replace(realDomain, "");
|
||||
let hostRecord = `_acme-challenge.${prefix}`;
|
||||
if (hostRecord.endsWith('.')) {
|
||||
if (hostRecord.endsWith(".")) {
|
||||
hostRecord = hostRecord.substring(0, hostRecord.length - 1);
|
||||
}
|
||||
param.hostRecord = hostRecord;
|
||||
param.mainDomain = realDomain;
|
||||
|
||||
const randomKey = utils.id.simpleNanoId(6).toLowerCase();
|
||||
|
||||
let userIdHash = ""
|
||||
if(param.cnameProviderId < 0){
|
||||
//公共cname服务
|
||||
userIdHash = utils.hash.md5(`userId${userId}_${randomKey}`).substring(0, 10)
|
||||
}else{
|
||||
const installInfo = await this.sysSettingsService.getSetting<SysInstallInfo>(SysInstallInfo)
|
||||
userIdHash = utils.hash.md5(`${installInfo.siteId}_${randomKey}`).substring(0, 10)
|
||||
}
|
||||
const cnameKey = `${userIdHash}-${randomKey}`;
|
||||
const safeDomain = param.domain.replaceAll('.', '-');
|
||||
const userIdHex = utils.hash.toHex(userId);
|
||||
let userKeyHash = "";
|
||||
const installInfo = await this.sysSettingsService.getSetting<SysInstallInfo>(SysInstallInfo);
|
||||
userKeyHash = `${installInfo.siteId}_${userIdHex}_${randomKey}`;
|
||||
userKeyHash = utils.hash.md5(userKeyHash).substring(0, 10);
|
||||
logger.info(`userKeyHash:${userKeyHash},subjectId:${installInfo.siteId},randomKey:${randomKey},userIdHex:${userIdHex}`);
|
||||
const cnameKey = `${userKeyHash}-${userIdHex}-${randomKey}`;
|
||||
const safeDomain = param.domain.replaceAll(".", "-");
|
||||
param.recordValue = `${safeDomain}.${cnameKey}.${cnameProvider.domain}`;
|
||||
}
|
||||
|
||||
async update(param: any) {
|
||||
if (!param.id) {
|
||||
throw new ValidateException('id不能为空');
|
||||
throw new ValidateException("id不能为空");
|
||||
}
|
||||
|
||||
const old = await this.info(param.id);
|
||||
if (!old) {
|
||||
throw new ValidateException('数据不存在');
|
||||
throw new ValidateException("数据不存在");
|
||||
}
|
||||
if (old.domain !== param.domain) {
|
||||
throw new ValidateException('域名不允许修改');
|
||||
if (param.domain && old.domain !== param.domain) {
|
||||
throw new ValidateException("域名不允许修改");
|
||||
}
|
||||
if (old.cnameProviderId !== param.cnameProviderId) {
|
||||
if (param.cnameProviderId && old.cnameProviderId !== param.cnameProviderId) {
|
||||
const cnameProvider = await this.cnameProviderService.info(param.cnameProviderId);
|
||||
await this.cnameProviderChanged(old.userId, param, cnameProvider);
|
||||
param.status = 'cname';
|
||||
param.status = "cname";
|
||||
}
|
||||
return await super.update(param);
|
||||
}
|
||||
@@ -166,7 +170,7 @@ export class CnameRecordService extends BaseService<CnameRecordEntity> {
|
||||
} else {
|
||||
record.commonDnsProvider = new CommonDnsProvider({
|
||||
config: record.cnameProvider,
|
||||
plusService: this.plusService,
|
||||
plusService: this.plusService
|
||||
});
|
||||
}
|
||||
|
||||
@@ -175,19 +179,22 @@ export class CnameRecordService extends BaseService<CnameRecordEntity> {
|
||||
|
||||
async getByDomain(domain: string, userId: number, createOnNotFound = true) {
|
||||
if (!domain) {
|
||||
throw new ValidateException('domain不能为空');
|
||||
throw new ValidateException("domain不能为空");
|
||||
}
|
||||
if (userId == null) {
|
||||
throw new ValidateException('userId不能为空');
|
||||
throw new ValidateException("userId不能为空");
|
||||
}
|
||||
let record = await this.getRepository().findOne({where: {domain, userId}});
|
||||
let record = await this.getRepository().findOne({ where: { domain, userId } });
|
||||
if (record == null) {
|
||||
if (createOnNotFound) {
|
||||
record = await this.add({domain, userId});
|
||||
record = await this.add({ domain, userId });
|
||||
} else {
|
||||
throw new ValidateException(`找不到${domain}的CNAME记录`);
|
||||
}
|
||||
}
|
||||
|
||||
await this.fillMainDomain(record);
|
||||
|
||||
const provider = await this.cnameProviderService.info(record.cnameProviderId);
|
||||
if (provider == null) {
|
||||
throw new ValidateException(`找不到${domain}的CNAME服务`);
|
||||
@@ -196,25 +203,53 @@ export class CnameRecordService extends BaseService<CnameRecordEntity> {
|
||||
return {
|
||||
...record,
|
||||
cnameProvider: {
|
||||
...provider,
|
||||
} as CnameProvider,
|
||||
...provider
|
||||
} as CnameProvider
|
||||
} as CnameRecord;
|
||||
}
|
||||
|
||||
async fillMainDomain(record: CnameRecordEntity, update = true) {
|
||||
const notMainDomain = !record.mainDomain;
|
||||
const hasErrorMainDomain = record.mainDomain && !record.mainDomain.includes(".");
|
||||
if (notMainDomain || hasErrorMainDomain) {
|
||||
let domainPrefix = record.hostRecord.replace("_acme-challenge", "");
|
||||
if (domainPrefix.startsWith(".")) {
|
||||
domainPrefix = domainPrefix.substring(1);
|
||||
}
|
||||
|
||||
if (domainPrefix) {
|
||||
const prefixStr = domainPrefix + ".";
|
||||
record.mainDomain = record.domain.substring(prefixStr.length);
|
||||
}else{
|
||||
record.mainDomain = record.domain;
|
||||
}
|
||||
|
||||
if (update) {
|
||||
await this.update({
|
||||
id: record.id,
|
||||
mainDomain: record.mainDomain
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证是否配置好cname
|
||||
* @param id
|
||||
*/
|
||||
async verify(id: string) {
|
||||
async verify(id: number) {
|
||||
const bean = await this.info(id);
|
||||
if (!bean) {
|
||||
throw new ValidateException(`CnameRecord:${id} 不存在`);
|
||||
}
|
||||
if (bean.status === 'valid') {
|
||||
if (bean.status === "valid") {
|
||||
return true;
|
||||
}
|
||||
|
||||
const subDomainGetter = new SubDomainsGetter(bean.userId, this.subDomainService)
|
||||
await this.getByDomain(bean.domain, bean.userId);
|
||||
|
||||
const subDomainGetter = new SubDomainsGetter(bean.userId, this.subDomainService);
|
||||
const domainParser = new DomainParser(subDomainGetter);
|
||||
|
||||
const cacheKey = `cname.record.verify.${bean.id}`;
|
||||
@@ -224,7 +259,7 @@ export class CnameRecordService extends BaseService<CnameRecordEntity> {
|
||||
value = {
|
||||
validating: false,
|
||||
pass: false,
|
||||
startTime: new Date().getTime(),
|
||||
startTime: new Date().getTime()
|
||||
};
|
||||
}
|
||||
let ttl = 5 * 60 * 1000;
|
||||
@@ -246,15 +281,16 @@ export class CnameRecordService extends BaseService<CnameRecordEntity> {
|
||||
//公共CNAME
|
||||
return new CommonDnsProvider({
|
||||
config: cnameProvider,
|
||||
plusService: this.plusService,
|
||||
plusService: this.plusService
|
||||
});
|
||||
}
|
||||
|
||||
const serviceGetter = this.taskServiceBuilder.create({ userId: cnameProvider.userId });
|
||||
const access = await this.accessService.getById(cnameProvider.accessId, cnameProvider.userId);
|
||||
const context = {access, logger, http, utils, domainParser};
|
||||
const context = { access, logger, http, utils, domainParser, serviceGetter };
|
||||
const dnsProvider: IDnsProvider = await createDnsProvider({
|
||||
dnsProviderType: cnameProvider.dnsProviderType,
|
||||
context,
|
||||
context
|
||||
});
|
||||
return dnsProvider;
|
||||
};
|
||||
@@ -262,15 +298,15 @@ export class CnameRecordService extends BaseService<CnameRecordEntity> {
|
||||
const clearVerifyRecord = async () => {
|
||||
cache.delete(cacheKey);
|
||||
try {
|
||||
let dnsProvider = value.dnsProvider
|
||||
let dnsProvider = value.dnsProvider;
|
||||
if (!dnsProvider) {
|
||||
dnsProvider = await buildDnsProvider();
|
||||
}
|
||||
await dnsProvider.removeRecord({
|
||||
recordReq: value.recordReq,
|
||||
recordRes: value.recordRes,
|
||||
recordRes: value.recordRes
|
||||
});
|
||||
logger.info('删除CNAME的校验DNS记录成功');
|
||||
logger.info("删除CNAME的校验DNS记录成功");
|
||||
} catch (e) {
|
||||
logger.error(`删除CNAME的校验DNS记录失败, ${e.message},req:${JSON.stringify(value.recordReq)},recordRes:${JSON.stringify(value.recordRes)}`, e);
|
||||
}
|
||||
@@ -283,8 +319,8 @@ export class CnameRecordService extends BaseService<CnameRecordEntity> {
|
||||
if (value.startTime + ttl < new Date().getTime()) {
|
||||
logger.warn(`cname验证超时,停止检查,${bean.domain} ${testRecordValue}`);
|
||||
clearInterval(value.intervalId);
|
||||
await this.updateStatus(bean.id, 'timeout');
|
||||
await clearVerifyRecord()
|
||||
await this.updateStatus(bean.id, "timeout");
|
||||
await clearVerifyRecord();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -295,7 +331,7 @@ export class CnameRecordService extends BaseService<CnameRecordEntity> {
|
||||
logger.info(`检查CNAME配置 ${fullDomain} ${testRecordValue}`);
|
||||
|
||||
//检查是否有重复的acme配置
|
||||
await this.checkRepeatAcmeChallengeRecords(fullDomain,bean.recordValue)
|
||||
await this.checkRepeatAcmeChallengeRecords(fullDomain, bean.recordValue);
|
||||
|
||||
// const txtRecords = await dns.promises.resolveTxt(fullDomain);
|
||||
// if (txtRecords.length) {
|
||||
@@ -312,9 +348,9 @@ export class CnameRecordService extends BaseService<CnameRecordEntity> {
|
||||
if (success) {
|
||||
clearInterval(value.intervalId);
|
||||
logger.info(`检测到CNAME配置,修改状态 ${fullDomain} ${testRecordValue}`);
|
||||
await this.updateStatus(bean.id, 'valid', "");
|
||||
await this.updateStatus(bean.id, "valid", "");
|
||||
value.pass = true;
|
||||
await clearVerifyRecord()
|
||||
await clearVerifyRecord();
|
||||
return success;
|
||||
}
|
||||
};
|
||||
@@ -325,88 +361,88 @@ export class CnameRecordService extends BaseService<CnameRecordEntity> {
|
||||
}
|
||||
|
||||
cache.set(cacheKey, value, {
|
||||
ttl: ttl,
|
||||
ttl: ttl
|
||||
});
|
||||
|
||||
const domain = await domainParser.parse(bean.recordValue);
|
||||
const fullRecord = bean.recordValue;
|
||||
const hostRecord = fullRecord.replace(`.${domain}`, '');
|
||||
const hostRecord = fullRecord.replace(`.${domain}`, "");
|
||||
const req = {
|
||||
domain: domain,
|
||||
fullRecord: fullRecord,
|
||||
hostRecord: hostRecord,
|
||||
type: 'TXT',
|
||||
value: testRecordValue,
|
||||
type: "TXT",
|
||||
value: testRecordValue
|
||||
};
|
||||
|
||||
const dnsProvider = await buildDnsProvider();
|
||||
if(dnsProvider.usePunyCode()){
|
||||
if (dnsProvider.usePunyCode()) {
|
||||
//是否需要中文转英文
|
||||
req.domain = dnsProvider.punyCodeEncode(req.domain)
|
||||
req.fullRecord = dnsProvider.punyCodeEncode(req.fullRecord)
|
||||
req.hostRecord = dnsProvider.punyCodeEncode(req.hostRecord)
|
||||
req.value = dnsProvider.punyCodeEncode(req.value)
|
||||
req.domain = dnsProvider.punyCodeEncode(req.domain);
|
||||
req.fullRecord = dnsProvider.punyCodeEncode(req.fullRecord);
|
||||
req.hostRecord = dnsProvider.punyCodeEncode(req.hostRecord);
|
||||
req.value = dnsProvider.punyCodeEncode(req.value);
|
||||
}
|
||||
const recordRes = await dnsProvider.createRecord(req);
|
||||
value.dnsProvider = dnsProvider;
|
||||
value.validating = true;
|
||||
value.recordReq = req;
|
||||
value.recordRes = recordRes;
|
||||
await this.updateStatus(bean.id, 'validating', "");
|
||||
await this.updateStatus(bean.id, "validating", "");
|
||||
|
||||
value.intervalId = setInterval(async () => {
|
||||
try {
|
||||
await checkRecordValue();
|
||||
} catch (e) {
|
||||
logger.error('检查cname出错:', e);
|
||||
logger.error("检查cname出错:", e);
|
||||
await this.updateError(bean.id, e.message);
|
||||
}
|
||||
}, 10000);
|
||||
}
|
||||
|
||||
async updateStatus(id: number, status: CnameRecordStatusType, error?: string) {
|
||||
const updated: any = {status}
|
||||
const updated: any = { status };
|
||||
if (error != null) {
|
||||
updated.error = error
|
||||
updated.error = error;
|
||||
}
|
||||
await this.getRepository().update(id, updated);
|
||||
}
|
||||
|
||||
async updateError(id: number, error: string) {
|
||||
await this.getRepository().update(id, {error});
|
||||
await this.getRepository().update(id, { error });
|
||||
}
|
||||
|
||||
async checkRepeatAcmeChallengeRecords(acmeRecordDomain: string,targetCnameDomain:string) {
|
||||
async checkRepeatAcmeChallengeRecords(acmeRecordDomain: string, targetCnameDomain: string) {
|
||||
|
||||
let dnsResolver = null
|
||||
try{
|
||||
dnsResolver = await getAuthoritativeDnsResolver(acmeRecordDomain)
|
||||
}catch (e) {
|
||||
logger.error(`获取${acmeRecordDomain}的权威DNS服务器失败,${e.message}`)
|
||||
return
|
||||
let dnsResolver = null;
|
||||
try {
|
||||
dnsResolver = await getAuthoritativeDnsResolver(acmeRecordDomain);
|
||||
} catch (e) {
|
||||
logger.error(`获取${acmeRecordDomain}的权威DNS服务器失败,${e.message}`);
|
||||
return;
|
||||
}
|
||||
let cnameRecords = []
|
||||
try{
|
||||
let cnameRecords = [];
|
||||
try {
|
||||
cnameRecords = await dnsResolver.resolveCname(acmeRecordDomain);
|
||||
}catch (e) {
|
||||
logger.error(`查询CNAME记录失败:${e.message}`)
|
||||
return
|
||||
} catch (e) {
|
||||
logger.error(`查询CNAME记录失败:${e.message}`);
|
||||
return;
|
||||
}
|
||||
targetCnameDomain = targetCnameDomain.toLowerCase()
|
||||
targetCnameDomain = punycode.toASCII(targetCnameDomain)
|
||||
targetCnameDomain = targetCnameDomain.toLowerCase();
|
||||
targetCnameDomain = punycode.toASCII(targetCnameDomain);
|
||||
if (cnameRecords.length > 0) {
|
||||
for (const cnameRecord of cnameRecords) {
|
||||
if(cnameRecord.toLowerCase() !== targetCnameDomain){
|
||||
if (cnameRecord.toLowerCase() !== targetCnameDomain) {
|
||||
//确保只有一个cname记录
|
||||
throw new Error(`${acmeRecordDomain}存在多个CNAME记录,请删除多余的CNAME记录:${cnameRecord}`)
|
||||
throw new Error(`${acmeRecordDomain}存在多个CNAME记录,请删除多余的CNAME记录:${cnameRecord}`);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 确保权威服务器里面没有纯粹的TXT记录
|
||||
let txtRecords = []
|
||||
try{
|
||||
let txtRecords = [];
|
||||
try {
|
||||
const txtRecordRes = await dnsResolver.resolveTxt(acmeRecordDomain);
|
||||
|
||||
if (txtRecordRes && txtRecordRes.length > 0) {
|
||||
@@ -414,13 +450,13 @@ export class CnameRecordService extends BaseService<CnameRecordEntity> {
|
||||
logger.info(`TXT records: ${JSON.stringify(txtRecords)}`);
|
||||
txtRecords = txtRecords.concat(...txtRecordRes);
|
||||
}
|
||||
}catch (e) {
|
||||
logger.error(`查询Txt记录失败:${e.message}`)
|
||||
} catch (e) {
|
||||
logger.error(`查询Txt记录失败:${e.message}`);
|
||||
}
|
||||
|
||||
if (txtRecords.length === 0) {
|
||||
//如果权威服务器中查不到txt,无需继续检查
|
||||
return
|
||||
return;
|
||||
}
|
||||
if (cnameRecords.length > 0) {
|
||||
// 从cname记录中获取txt记录
|
||||
@@ -429,11 +465,18 @@ export class CnameRecordService extends BaseService<CnameRecordEntity> {
|
||||
if (res.length > 0) {
|
||||
for (const txtRecord of txtRecords) {
|
||||
if (!res.includes(txtRecord)) {
|
||||
throw new Error(`${acmeRecordDomain}存在多个TXT记录,请删除多余的TXT记录:${txtRecord}`)
|
||||
throw new Error(`${acmeRecordDomain}存在多个TXT记录,请删除多余的TXT记录:${txtRecord}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async resetStatus(id: number) {
|
||||
if (!id) {
|
||||
throw new ValidateException("id不能为空");
|
||||
}
|
||||
await this.getRepository().update(id, { status: "cname", mainDomain: "" });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,12 +11,12 @@ import {
|
||||
import { RoleService } from "../../sys/authority/service/role-service.js";
|
||||
import { UserEntity } from "../../sys/authority/entity/user.js";
|
||||
import { cache, utils } from "@certd/basic";
|
||||
import { LoginErrorException } from "@certd/lib-server/dist/basic/exception/login-error-exception.js";
|
||||
import { LoginErrorException } from "@certd/lib-server";
|
||||
import { CodeService } from "../../basic/service/code-service.js";
|
||||
import { TwoFactorService } from "../../mine/service/two-factor-service.js";
|
||||
import { UserSettingsService } from "../../mine/service/user-settings-service.js";
|
||||
import { isPlus } from "@certd/plus-core";
|
||||
import { AddonService } from "@certd/lib-server/dist/user/addon/service/addon-service.js";
|
||||
import { AddonService } from "@certd/lib-server";
|
||||
|
||||
/**
|
||||
* 系统用户
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
import { Inject, Provide, Scope, ScopeEnum } from "@midwayjs/core";
|
||||
import { http, logger, utils } from "@certd/basic";
|
||||
import { TaskServiceBuilder } from "./getter/task-service-getter.js";
|
||||
import { AddonService, newAddon, PermissionException, ValidateException } from "@certd/lib-server";
|
||||
|
||||
/**
|
||||
* Addon
|
||||
*/
|
||||
@Provide()
|
||||
@Scope(ScopeEnum.Request, { allowDowngrade: true })
|
||||
export class AddonGetterService {
|
||||
|
||||
@Inject()
|
||||
taskServiceBuilder: TaskServiceBuilder;
|
||||
@Inject()
|
||||
addonService: AddonService;
|
||||
|
||||
|
||||
async getAddonById(id: any, checkUserId: boolean, userId?: number, defaultAddon?:{type:string,name:string} ): Promise<any> {
|
||||
const serviceGetter = this.taskServiceBuilder.create({
|
||||
userId
|
||||
});
|
||||
const ctx = {
|
||||
http,
|
||||
logger,
|
||||
utils,
|
||||
serviceGetter
|
||||
}
|
||||
|
||||
if (!id) {
|
||||
if (!defaultAddon) {
|
||||
return null;
|
||||
}
|
||||
return await newAddon(defaultAddon.type, defaultAddon.name, {}, ctx);
|
||||
}
|
||||
const entity = await this.addonService.info(id);
|
||||
if (entity == null) {
|
||||
if (!defaultAddon) {
|
||||
return null;
|
||||
}
|
||||
return await newAddon(defaultAddon.type, defaultAddon.name, {}, ctx);
|
||||
}
|
||||
if (checkUserId) {
|
||||
if (userId == null) {
|
||||
throw new ValidateException("userId不能为空");
|
||||
}
|
||||
if (userId !== entity.userId) {
|
||||
throw new PermissionException("您对该Addon无访问权限");
|
||||
}
|
||||
}
|
||||
|
||||
const setting = JSON.parse(entity.setting ?? "{}");
|
||||
const input = {
|
||||
id: entity.id,
|
||||
...setting
|
||||
};
|
||||
|
||||
return await newAddon(entity.addonType, entity.type, input, ctx);
|
||||
}
|
||||
|
||||
async getById(id: any, userId: number): Promise<any> {
|
||||
return await this.getAddonById(id, true, userId);
|
||||
}
|
||||
|
||||
}
|
||||
+15
-5
@@ -10,6 +10,9 @@ import { DomainVerifierGetter } from "./domain-verifier-getter.js";
|
||||
import { DomainService } from "../../../cert/service/domain-service.js";
|
||||
import { SubDomainService } from "../sub-domain-service.js";
|
||||
|
||||
const serviceNames = [
|
||||
'ocrService',
|
||||
]
|
||||
export class TaskServiceGetter implements IServiceGetter{
|
||||
private userId: number;
|
||||
private appCtx : IMidwayContainer;
|
||||
@@ -30,7 +33,13 @@ export class TaskServiceGetter implements IServiceGetter{
|
||||
} else if (serviceName === 'domainVerifierGetter') {
|
||||
return await this.getDomainVerifierGetter() as T
|
||||
}else{
|
||||
throw new Error(`service ${serviceName} not found`)
|
||||
if(!serviceNames.includes(serviceName)){
|
||||
throw new Error(`${serviceName} not in whitelist`)
|
||||
}
|
||||
const service = await this.appCtx.getAsync(serviceName)
|
||||
if (! service){
|
||||
throw new Error(`${serviceName} not found`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +53,7 @@ export class TaskServiceGetter implements IServiceGetter{
|
||||
return new AccessGetter(this.userId, accessService.getById.bind(accessService));
|
||||
}
|
||||
|
||||
|
||||
async getCnameProxyService(): Promise<CnameProxyService> {
|
||||
const cnameRecordService:CnameRecordService = await this.appCtx.getAsync("cnameRecordService")
|
||||
return new CnameProxyService(this.userId, cnameRecordService.getWithAccessByDomain.bind(cnameRecordService));
|
||||
@@ -59,10 +69,6 @@ export class TaskServiceGetter implements IServiceGetter{
|
||||
return new DomainVerifierGetter(this.userId, domainService);
|
||||
}
|
||||
}
|
||||
export type TaskServiceCreateReq = {
|
||||
userId: number;
|
||||
}
|
||||
|
||||
@Provide()
|
||||
@Scope(ScopeEnum.Request, { allowDowngrade: true })
|
||||
export class TaskServiceBuilder {
|
||||
@@ -75,6 +81,10 @@ export class TaskServiceBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
export type TaskServiceCreateReq = {
|
||||
userId: number;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,231 @@
|
||||
import { Provide, Scope, ScopeEnum } from '@midwayjs/core';
|
||||
import { http, logger, utils } from '@certd/basic';
|
||||
|
||||
// 使用@certd/basic包中已有的utils.sp.spawn函数替代自定义的asyncExec
|
||||
// 该函数已经内置了Windows系统编码问题的解决方案
|
||||
|
||||
export type NetTestResult = {
|
||||
success: boolean; //是否成功
|
||||
message: string; //结果
|
||||
testLog: string; //测试日志
|
||||
error?: string; //执行错误信息
|
||||
}
|
||||
|
||||
@Provide('nettestService')
|
||||
@Scope(ScopeEnum.Request, { allowDowngrade: true })
|
||||
export class NetTestService {
|
||||
/**
|
||||
* 执行Telnet测试
|
||||
* @param domain 域名
|
||||
* @param port 端口
|
||||
* @returns 测试结果
|
||||
*/
|
||||
async telnet(domain: string, port: number): Promise<NetTestResult> {
|
||||
try {
|
||||
let command = '';
|
||||
|
||||
if (this.isWindows()) {
|
||||
// Windows系统使用PowerShell执行测试,避免输入重定向问题
|
||||
// 使用PowerShell的Test-NetConnection命令进行端口测试
|
||||
command = `powershell -Command "& { $result = Test-NetConnection -ComputerName ${domain} -Port ${port} -InformationLevel Quiet; if ($result) { Write-Host '端口连接成功' } else { Write-Host '端口连接失败' } }"`;
|
||||
} else {
|
||||
// Linux系统使用nc命令进行端口测试
|
||||
command = `nc -zv -w 5 ${domain} ${port} 2>&1`;
|
||||
}
|
||||
|
||||
// 使用utils.sp.spawn执行命令,它会自动处理Windows编码问题
|
||||
const output = await utils.sp.spawn({
|
||||
cmd: command,
|
||||
logger: undefined // 可以根据需要传入logger
|
||||
});
|
||||
|
||||
// 判断测试是否成功
|
||||
const success = this.isWindows()
|
||||
? output.includes('端口连接成功')
|
||||
: output.includes('Connected to');
|
||||
|
||||
// 处理结果
|
||||
return {
|
||||
success,
|
||||
message: success ? '端口连接测试成功' : '端口连接测试失败',
|
||||
testLog: output,
|
||||
};
|
||||
|
||||
} catch (error) {
|
||||
return {
|
||||
success: false,
|
||||
message: 'Telnet测试执行失败',
|
||||
testLog: error.stdout || error.stderr || error?.message || String(error),
|
||||
error: error.stderr || error?.message || String(error),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行Ping测试
|
||||
* @param domain 域名
|
||||
* @returns 测试结果
|
||||
*/
|
||||
async ping(domain: string): Promise<NetTestResult> {
|
||||
try {
|
||||
let command = '';
|
||||
|
||||
if (this.isWindows()) {
|
||||
// Windows系统ping命令,发送4个包
|
||||
command = `ping -n 4 ${domain}`;
|
||||
} else {
|
||||
// Linux系统ping命令,发送4个包
|
||||
command = `ping -c 4 ${domain}`;
|
||||
}
|
||||
|
||||
// 使用utils.sp.spawn执行命令
|
||||
const output = await utils.sp.spawn({
|
||||
cmd: command,
|
||||
logger: undefined
|
||||
});
|
||||
|
||||
// 判断测试是否成功
|
||||
const success = this.isWindows()
|
||||
? output.includes('TTL=')
|
||||
: output.includes('time=');
|
||||
|
||||
return {
|
||||
success,
|
||||
message: success ? 'Ping测试成功' : 'Ping测试失败',
|
||||
testLog: output,
|
||||
};
|
||||
|
||||
} catch (error) {
|
||||
const errorMessage = error instanceof Error ? error.message : String(error);
|
||||
return {
|
||||
success: false,
|
||||
message: 'Ping测试执行失败',
|
||||
testLog: error.stderr|| error.stdout || errorMessage,
|
||||
error: errorMessage
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private isWindows() {
|
||||
return process.platform === 'win32';
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行域名解析测试
|
||||
* @param domain 域名
|
||||
* @returns 解析结果
|
||||
*/
|
||||
async domainResolve(domain: string): Promise<NetTestResult> {
|
||||
try {
|
||||
let command = '';
|
||||
if (this.isWindows()) {
|
||||
// Windows系统使用nslookup命令
|
||||
command = `nslookup ${domain}`;
|
||||
} else {
|
||||
// Linux系统优先使用dig命令,如果没有则回退到nslookup
|
||||
command = `which dig > /dev/null && dig ${domain} || nslookup ${domain}`;
|
||||
}
|
||||
|
||||
// 使用utils.sp.spawn执行命令
|
||||
const output = await utils.sp.spawn({
|
||||
cmd: command,
|
||||
logger: undefined
|
||||
});
|
||||
|
||||
// 判断测试是否成功
|
||||
const success = output.includes('Address:') || output.includes('IN A') || output.includes('IN AAAA') ||
|
||||
(this.isWindows() && output.includes('Name:'));
|
||||
|
||||
return {
|
||||
success,
|
||||
message: success ? '域名解析测试成功' : '域名解析测试失败',
|
||||
testLog: output,
|
||||
};
|
||||
} catch (error) {
|
||||
const errorMessage = error instanceof Error ? error.message : String(error);
|
||||
return {
|
||||
success: false,
|
||||
message: '域名解析测试执行失败',
|
||||
testLog: error.stdoout || error.stderr || errorMessage,
|
||||
error: errorMessage
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async getLocalIP(): Promise<string[]> {
|
||||
try {
|
||||
const output = await utils.sp.spawn({
|
||||
cmd: 'ip a | grep \'inet \' | grep -v \'127.0.0.1\' | awk \'{print $2}\' | cut -d/ -f1',
|
||||
logger: undefined
|
||||
});
|
||||
// 去除 inet 前缀
|
||||
let ips = output.trim().replace(/inet /g, '');
|
||||
return ips.split('\n').filter(ip => ip.length > 0);
|
||||
} catch (error) {
|
||||
return [error instanceof Error ? error.message : String(error)];
|
||||
}
|
||||
}
|
||||
|
||||
async getPublicIP(): Promise<string[]> {
|
||||
try {
|
||||
const res = await http.request({
|
||||
url:"https://ipinfo.io/ip",
|
||||
method:"GET",
|
||||
})
|
||||
return[res]
|
||||
} catch (error) {
|
||||
return [error instanceof Error ? error.message : String(error)]
|
||||
}
|
||||
}
|
||||
|
||||
async getDNSservers(): Promise<string[]> {
|
||||
let dnsServers: string[] = [];
|
||||
try {
|
||||
const output = await utils.sp.spawn({
|
||||
cmd: 'cat /etc/resolv.conf | grep nameserver | awk \'{print $2}\'',
|
||||
logger: undefined
|
||||
});
|
||||
dnsServers = output.trim().split('\n');
|
||||
} catch (error) {
|
||||
dnsServers = [error instanceof Error ? error.message : String(error)];
|
||||
}
|
||||
try{
|
||||
/**
|
||||
* /app # cat /etc/resolv.conf | grep "ExtServers"
|
||||
# ExtServers: [223.5.5.5 223.6.6.6]
|
||||
*/
|
||||
const extDnsServers = await utils.sp.spawn({
|
||||
cmd: 'cat /etc/resolv.conf | grep "ExtServers"',
|
||||
logger: undefined
|
||||
});
|
||||
const line = extDnsServers.trim()
|
||||
if (line.includes('ExtServers') && line.includes('[')) {
|
||||
const extDns = line.substring(line.indexOf('[') + 1, line.indexOf(']')).split(' ');
|
||||
const dnsList = extDns.map(item=>`Ext:${item}`)
|
||||
dnsServers = dnsServers.concat(dnsList);
|
||||
}
|
||||
} catch (error) {
|
||||
logger.error('获取DNS ExtServers 服务器失败', error);
|
||||
// dnsServers.push(error instanceof Error ? error.message : String(error));
|
||||
}
|
||||
return dnsServers;
|
||||
}
|
||||
/**
|
||||
* 获取服务器信息(包括本地IP、外网IP和DNS服务器)
|
||||
* @returns 服务器信息
|
||||
*/
|
||||
async serverInfo(): Promise<any> {
|
||||
|
||||
const res = {
|
||||
localIP: [],
|
||||
publicIP: [],
|
||||
dnsServers: [],
|
||||
}
|
||||
|
||||
res.localIP = await this.getLocalIP();
|
||||
res.publicIP = await this.getPublicIP();
|
||||
res.dnsServers = await this.getDNSservers();
|
||||
return res
|
||||
}
|
||||
}
|
||||
@@ -36,3 +36,4 @@ export * from './plugin-apisix/index.js'
|
||||
export * from './plugin-dokploy/index.js'
|
||||
export * from './plugin-godaddy/index.js'
|
||||
export * from './plugin-captcha/index.js'
|
||||
export * from './plugin-xinnet/index.js'
|
||||
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
import { IAccessService } from '@certd/pipeline';
|
||||
import { AbstractDnsProvider, CreateRecordOptions, IsDnsProvider, RemoveRecordOptions } from '@certd/plugin-cert';
|
||||
|
||||
import { AliesaAccess, AliyunAccess, AliyunClientV2 } from '@certd/plugin-lib';
|
||||
|
||||
@IsDnsProvider({
|
||||
name: 'aliesa',
|
||||
title: '阿里ESA',
|
||||
desc: '阿里ESA DNS解析',
|
||||
accessType: 'aliesa',
|
||||
icon: 'svg:icon-aliyun',
|
||||
order: 0,
|
||||
})
|
||||
export class AliesaDnsProvider extends AbstractDnsProvider {
|
||||
|
||||
|
||||
client: AliyunClientV2
|
||||
async onInstance() {
|
||||
const access: AliesaAccess = this.ctx.access as AliesaAccess
|
||||
const accessGetter = await this.ctx.serviceGetter.get("accessService") as IAccessService
|
||||
const aliAccess = await accessGetter.getById(access.accessId) as AliyunAccess
|
||||
const endpoint = `esa.${access.region}.aliyuncs.com`
|
||||
this.client = aliAccess.getClient(endpoint)
|
||||
}
|
||||
|
||||
|
||||
async getSiteItem(domain: string) {
|
||||
const ret = await this.client.doRequest({
|
||||
// 接口名称
|
||||
action: "ListSites",
|
||||
// 接口版本
|
||||
version: "2024-09-10",
|
||||
// 接口协议
|
||||
protocol: "HTTPS",
|
||||
// 接口 HTTP 方法
|
||||
method: "GET",
|
||||
authType: "AK",
|
||||
style: "RPC",
|
||||
data: {
|
||||
query: {
|
||||
SiteName: domain,
|
||||
// ["SiteSearchType"] = "exact";
|
||||
SiteSearchType: "exact",
|
||||
AccessType: "NS"
|
||||
}
|
||||
}
|
||||
})
|
||||
const list = ret.Sites
|
||||
if (list?.length === 0) {
|
||||
throw new Error(`阿里云ESA中不存在此域名站点:${domain},请确认域名已添加到ESA中,且为NS接入方式`);
|
||||
}
|
||||
return list[0]
|
||||
|
||||
}
|
||||
|
||||
async createRecord(options: CreateRecordOptions): Promise<any> {
|
||||
const { fullRecord, value, type, domain } = options;
|
||||
this.logger.info('添加域名解析:', fullRecord, value, domain);
|
||||
|
||||
|
||||
const siteItem = await this.getSiteItem(domain)
|
||||
const siteId = siteItem.SiteId
|
||||
|
||||
|
||||
const res = await this.client.doRequest({
|
||||
action: "CreateRecord",
|
||||
version: "2024-09-10",
|
||||
method: "POST",
|
||||
data: {
|
||||
query: {
|
||||
SiteId: siteId,
|
||||
RecordName: fullRecord,
|
||||
Type: type,
|
||||
// queries["Ttl"] = 1231311;
|
||||
Ttl: 100,
|
||||
Data: JSON.stringify({ Value: value }),
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
this.logger.info('添加域名解析成功:', fullRecord, value, res.RecordId);
|
||||
return {
|
||||
RecordId: res.RecordId,
|
||||
SiteId: siteId,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async removeRecord(options: RemoveRecordOptions<any>): Promise<any> {
|
||||
const record = options.recordRes;
|
||||
|
||||
await this.client.doRequest({
|
||||
action: "DeleteRecord",
|
||||
version: "2024-09-10",
|
||||
data: {
|
||||
query: {
|
||||
RecordId: record.RecordId,
|
||||
}
|
||||
}
|
||||
})
|
||||
this.logger.info('删除域名解析成功:', record.RecordId);
|
||||
}
|
||||
}
|
||||
|
||||
new AliesaDnsProvider();
|
||||
@@ -1 +1,2 @@
|
||||
import './aliyun-dns-provider.js';
|
||||
import './aliesa-dns-provider.js';
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
createRemoteSelectInputDefine
|
||||
} from "@certd/plugin-lib";
|
||||
import { CertApplyPluginNames, CertInfo, CertReader } from "@certd/plugin-cert";
|
||||
import {optionsUtils} from "@certd/basic/dist/utils/util.options.js";
|
||||
import {optionsUtils} from "@certd/basic";
|
||||
|
||||
@IsTaskPlugin({
|
||||
name: 'DeployCertToAliyunApig',
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import {AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput} from '@certd/pipeline';
|
||||
import {AliyunAccess, createCertDomainGetterInputDefine, createRemoteSelectInputDefine} from "@certd/plugin-lib";
|
||||
import {CertApplyPluginNames, CertInfo} from '@certd/plugin-cert';
|
||||
import {optionsUtils} from "@certd/basic/dist/utils/util.options.js";
|
||||
import {optionsUtils} from "@certd/basic";
|
||||
|
||||
@IsTaskPlugin({
|
||||
name: 'DeployCertToAliyunApiGateway',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput } from '@certd/pipeline';
|
||||
import { AliyunAccess, AliyunClient, AliyunSslClient, createCertDomainGetterInputDefine, createRemoteSelectInputDefine } from '@certd/plugin-lib';
|
||||
import { optionsUtils } from '@certd/basic/dist/utils/util.options.js';
|
||||
import { optionsUtils } from '@certd/basic';
|
||||
import { CertApplyPluginNames, CertReader } from "@certd/plugin-cert";
|
||||
@IsTaskPlugin({
|
||||
name: 'DeployCertToAliyunCDN',
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
} from "@certd/plugin-lib";
|
||||
import { CertInfo } from '@certd/plugin-cert';
|
||||
import { CertApplyPluginNames} from '@certd/plugin-cert';
|
||||
import { optionsUtils } from "@certd/basic/dist/utils/util.options.js";
|
||||
import { optionsUtils } from "@certd/basic";
|
||||
@IsTaskPlugin({
|
||||
name: 'DeployCertToAliyunDCDN',
|
||||
title: '阿里云-部署证书至DCDN',
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
} from '@certd/plugin-lib';
|
||||
import {CertInfo, CertReader} from '@certd/plugin-cert';
|
||||
import { CertApplyPluginNames} from '@certd/plugin-cert';
|
||||
import {optionsUtils} from "@certd/basic/dist/utils/util.options.js";
|
||||
import {optionsUtils} from "@certd/basic";
|
||||
import {isArray} from "lodash-es";
|
||||
@IsTaskPlugin({
|
||||
name: 'DeployCertToAliyunOSS',
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ import { CertApplyPluginNames, CertInfo } from "@certd/plugin-cert";
|
||||
import { AwsAccess, AwsRegions } from "../access.js";
|
||||
import { AwsAcmClient } from "../libs/aws-acm-client.js";
|
||||
import { createCertDomainGetterInputDefine, createRemoteSelectInputDefine } from "@certd/plugin-lib";
|
||||
import { optionsUtils } from "@certd/basic/dist/utils/util.options.js";
|
||||
import { optionsUtils } from "@certd/basic";
|
||||
|
||||
@IsTaskPlugin({
|
||||
name: 'AwsDeployToCloudFront',
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
export * from './geetest/index.js';
|
||||
export * from './image/index.js';
|
||||
export * from './tencent/index.js';
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
import { AddonInput, BaseAddon, IsAddon } from "@certd/lib-server";
|
||||
import { ICaptchaAddon } from "../api.js";
|
||||
import { TencentAccess } from "@certd/plugin-lib";
|
||||
|
||||
@IsAddon({
|
||||
addonType:"captcha",
|
||||
name: 'tencent',
|
||||
title: '腾讯云验证码',
|
||||
desc: '',
|
||||
showTest:false,
|
||||
})
|
||||
export class TencentCaptcha extends BaseAddon implements ICaptchaAddon{
|
||||
|
||||
@AddonInput({
|
||||
title: '腾讯云授权',
|
||||
helper: '腾讯云授权',
|
||||
component: {
|
||||
name: 'access-selector',
|
||||
vModel:"modelValue",
|
||||
from: "sys",
|
||||
type: 'tencent', //固定授权类型
|
||||
},
|
||||
required: true,
|
||||
})
|
||||
accessId :number;
|
||||
|
||||
@AddonInput({
|
||||
title: '验证ID',
|
||||
component: {
|
||||
name:"a-input-number",
|
||||
placeholder: 'CaptchaAppId',
|
||||
},
|
||||
helper:"[腾讯云验证码](https://cloud.tencent.com/act/cps/redirect?redirect=37716&cps_key=b3ef73330335d7a6efa4a4bbeeb6b2c9)",
|
||||
required: true,
|
||||
})
|
||||
captchaAppId:number;
|
||||
|
||||
@AddonInput({
|
||||
title: '验证Key',
|
||||
component: {
|
||||
placeholder: 'AppSecretKey',
|
||||
},
|
||||
required: true,
|
||||
})
|
||||
appSecretKey = '';
|
||||
|
||||
|
||||
async onValidate(data?:any) {
|
||||
if (!data) {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
const access = await this.getAccess<TencentAccess>(this.accessId)
|
||||
|
||||
const sdk =await import("tencentcloud-sdk-nodejs/tencentcloud/services/captcha/v20190722/index.js");
|
||||
|
||||
const CaptchaClient = sdk.v20190722.Client;
|
||||
|
||||
const clientConfig = {
|
||||
credential: {
|
||||
secretId: access.secretId,
|
||||
secretKey: access.secretKey,
|
||||
},
|
||||
region: "",
|
||||
profile: {
|
||||
httpProfile: {
|
||||
endpoint: "captcha.tencentcloudapi.com",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// 实例化要请求产品的client对象,clientProfile是可选的
|
||||
const client = new CaptchaClient(clientConfig);
|
||||
const params = {
|
||||
"CaptchaType": 9, //固定值9
|
||||
"UserIp": "127.0.0.1",
|
||||
"Ticket": data.ticket,
|
||||
"Randstr": data.randstr,
|
||||
"AppSecretKey": this.appSecretKey,
|
||||
"CaptchaAppId": this.captchaAppId,
|
||||
};
|
||||
const res = await client.DescribeCaptchaResult(params)
|
||||
|
||||
if (res.CaptchaCode == 1) {
|
||||
// 验证成功
|
||||
// verification successful
|
||||
return true;
|
||||
} else {
|
||||
// 验证失败
|
||||
// verification failed
|
||||
this.logger.error("腾讯云验证码验证失败",res.CaptchaMsg)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async getCaptcha(): Promise<any> {
|
||||
return {
|
||||
captchaAppId: this.captchaAppId,
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput } from '@certd/pipeline';
|
||||
import { CertInfo, CertReader } from '@certd/plugin-cert';
|
||||
import { createCertDomainGetterInputDefine, createRemoteSelectInputDefine } from '@certd/plugin-lib';
|
||||
import { optionsUtils } from '@certd/basic/dist/utils/util.options.js';
|
||||
import { optionsUtils } from '@certd/basic';
|
||||
import { CertApplyPluginNames} from '@certd/plugin-cert';
|
||||
@IsTaskPlugin({
|
||||
//命名规范,插件类型+功能(就是目录plugin-demo中的demo),大写字母开头,驼峰命名
|
||||
|
||||
@@ -6,7 +6,6 @@ import {
|
||||
SshAccess,
|
||||
SshClient
|
||||
} from "@certd/plugin-lib";
|
||||
import path from "node:path";
|
||||
|
||||
@IsTaskPlugin({
|
||||
//命名规范,插件类型+功能(就是目录plugin-demo中的demo),大写字母开头,驼峰命名
|
||||
@@ -57,7 +56,7 @@ export class FnOSDeployToNAS extends AbstractTaskPlugin {
|
||||
@TaskInput(
|
||||
createRemoteSelectInputDefine({
|
||||
title: "证书Id",
|
||||
helper: "要更新的证书id",
|
||||
helper: "面板证书请选择fnOS,其他FTP、webdav等证书请选择已使用,可多选(如果证书域名都匹配的话)",
|
||||
action: FnOSDeployToNAS.prototype.onGetCertList.name
|
||||
})
|
||||
)
|
||||
@@ -87,7 +86,9 @@ export class FnOSDeployToNAS extends AbstractTaskPlugin {
|
||||
this.logger.info(`----------- 找到证书,开始部署:${item.sum},${item.domain}`)
|
||||
const certPath = item.certificate;
|
||||
const keyPath = item.privateKey;
|
||||
const certDir = path.dirname(keyPath)
|
||||
const certDir = keyPath.substring(0, keyPath.lastIndexOf("/"));
|
||||
const fullchainPath = certDir+ "/fullchain.crt"
|
||||
const caPath = certDir+ "/issuer_certificate.crt"
|
||||
const cmd = `
|
||||
sudo tee ${certPath} > /dev/null <<'EOF'
|
||||
${this.cert.crt}
|
||||
@@ -95,6 +96,12 @@ EOF
|
||||
sudo tee ${keyPath} > /dev/null <<'EOF'
|
||||
${this.cert.key}
|
||||
EOF
|
||||
sudo tee ${fullchainPath} > /dev/null <<'EOF'
|
||||
${this.cert.crt}
|
||||
EOF
|
||||
sudo tee ${caPath} > /dev/null <<'EOF'
|
||||
${this.cert.ic}
|
||||
EOF
|
||||
|
||||
sudo chmod 0755 "${certDir}/" -R
|
||||
|
||||
@@ -157,7 +164,7 @@ echo "服务重启完成!"
|
||||
}
|
||||
|
||||
if (!list || list.length === 0) {
|
||||
throw new Error("没有找到证书,请先在证书管理也没上传一次证书");
|
||||
throw new Error("没有找到证书,请先在证书管理页面上传一次证书");
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput } from "@certd/pipeline";
|
||||
import { createCertDomainGetterInputDefine, createRemoteSelectInputDefine } from "@certd/plugin-lib";
|
||||
import { CertApplyPluginNames, CertInfo } from "@certd/plugin-cert";
|
||||
import { optionsUtils } from "@certd/basic/dist/utils/util.options.js";
|
||||
import { optionsUtils } from "@certd/basic";
|
||||
import { JDCloudAccess } from "../access.js";
|
||||
|
||||
@IsTaskPlugin({
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput } from "@certd/pipeline";
|
||||
import { createCertDomainGetterInputDefine, createRemoteSelectInputDefine } from "@certd/plugin-lib";
|
||||
import { CertApplyPluginNames, CertInfo } from "@certd/plugin-cert";
|
||||
import { optionsUtils } from "@certd/basic/dist/utils/util.options.js";
|
||||
import { optionsUtils } from "@certd/basic";
|
||||
import { JDCloudAccess } from "../access.js";
|
||||
|
||||
@IsTaskPlugin({
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput } from '@certd/pipeline';
|
||||
import { createCertDomainGetterInputDefine, createRemoteSelectInputDefine, QiniuAccess, QiniuClient } from '@certd/plugin-lib';
|
||||
import { CertInfo } from '@certd/plugin-cert';
|
||||
import { optionsUtils } from '@certd/basic/dist/utils/util.options.js';
|
||||
import { optionsUtils } from '@certd/basic';
|
||||
import { CertApplyPluginNames} from '@certd/plugin-cert';
|
||||
@IsTaskPlugin({
|
||||
name: 'QiniuDeployCertToCDN',
|
||||
|
||||
@@ -2,7 +2,7 @@ import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput
|
||||
import { CertApplyPluginNames, CertInfo } from "@certd/plugin-cert";
|
||||
import { UpyunAccess } from "../access.js";
|
||||
import { createCertDomainGetterInputDefine, createRemoteSelectInputDefine } from "@certd/plugin-lib";
|
||||
import { optionsUtils } from "@certd/basic/dist/utils/util.options.js";
|
||||
import { optionsUtils } from "@certd/basic";
|
||||
import { UpyunClient } from "../client.js";
|
||||
|
||||
@IsTaskPlugin({
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput } from "@certd/pipeline";
|
||||
import { createCertDomainGetterInputDefine, createRemoteSelectInputDefine } from "@certd/plugin-lib";
|
||||
import { CertApplyPluginNames, CertInfo } from "@certd/plugin-cert";
|
||||
import { optionsUtils } from "@certd/basic/dist/utils/util.options.js";
|
||||
import { optionsUtils } from "@certd/basic";
|
||||
import { VolcengineAccess } from "../access.js";
|
||||
import { VolcengineCdnClient } from "../cdn-client.js";
|
||||
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
import { IsAccess, AccessInput, BaseAccess } from "@certd/pipeline";
|
||||
import { XinnetClient } from "@certd/plugin-plus";
|
||||
|
||||
/**
|
||||
* 这个注解将注册一个授权配置
|
||||
* 在certd的后台管理系统中,用户可以选择添加此类型的授权
|
||||
*/
|
||||
@IsAccess({
|
||||
name: "xinnet",
|
||||
title: "新网授权",
|
||||
icon: "lsicon:badge-new-filled",
|
||||
desc: ""
|
||||
})
|
||||
export class XinnetAccess extends BaseAccess {
|
||||
|
||||
/**
|
||||
* 授权属性配置
|
||||
*/
|
||||
@AccessInput({
|
||||
title: "用户名",
|
||||
component: {
|
||||
placeholder: "手机号/用户名"
|
||||
},
|
||||
required: true,
|
||||
encrypt: true
|
||||
})
|
||||
username = "";
|
||||
|
||||
@AccessInput({
|
||||
title: "登录密码",
|
||||
component: {
|
||||
name: "a-input-password",
|
||||
vModel: "value",
|
||||
placeholder: "登录密码"
|
||||
},
|
||||
required: true,
|
||||
encrypt: true
|
||||
})
|
||||
password = "";
|
||||
|
||||
@AccessInput({
|
||||
title: "测试",
|
||||
component: {
|
||||
name: "api-test",
|
||||
action: "TestRequest"
|
||||
},
|
||||
helper: "点击测试接口是否正常"
|
||||
})
|
||||
testRequest = true;
|
||||
|
||||
async onTestRequest() {
|
||||
|
||||
const client = new XinnetClient({
|
||||
access: this,
|
||||
logger: this.ctx.logger,
|
||||
http: this.ctx.http
|
||||
});
|
||||
|
||||
await client.getDomainList({ pageNo: 1, pageSize: 1 });
|
||||
|
||||
return "ok";
|
||||
}
|
||||
|
||||
|
||||
getCacheKey () {
|
||||
let hashStr = ""
|
||||
for (const key in this) {
|
||||
if (Object.prototype.hasOwnProperty.call(this, key)) {
|
||||
const element = this[key];
|
||||
hashStr += element;
|
||||
}
|
||||
}
|
||||
const hashCode = this.ctx.utils.hash.sha256(hashStr);
|
||||
return `xinnet-${hashCode}`;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
new XinnetAccess();
|
||||
@@ -0,0 +1,110 @@
|
||||
import { AbstractDnsProvider, CreateRecordOptions, IsDnsProvider, RemoveRecordOptions } from "@certd/plugin-cert";
|
||||
import { XinnetAccess } from "./access.js";
|
||||
import { XinnetClient } from "@certd/plugin-plus";
|
||||
|
||||
export type XinnetRecord = {
|
||||
recordId: number;
|
||||
recordFullName: string;
|
||||
recordValue: string;
|
||||
type: string;
|
||||
serviceCode: string;
|
||||
dcpCookie: string;
|
||||
};
|
||||
|
||||
// 这里通过IsDnsProvider注册一个dnsProvider
|
||||
@IsDnsProvider({
|
||||
name: "xinnet",
|
||||
title: "新网",
|
||||
desc: "新网域名解析",
|
||||
icon: "lsicon:badge-new-filled",
|
||||
// 这里是对应的 cloudflare的access类型名称
|
||||
accessType: "xinnet",
|
||||
order: 7
|
||||
})
|
||||
export class XinnetProvider extends AbstractDnsProvider<XinnetRecord> {
|
||||
access!: XinnetAccess;
|
||||
|
||||
async onInstance() {
|
||||
//一些初始化的操作
|
||||
// 也可以通过ctx成员变量传递context
|
||||
this.access = this.ctx.access as XinnetAccess;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建dns解析记录,用于验证域名所有权
|
||||
*/
|
||||
async createRecord(options: CreateRecordOptions): Promise<XinnetRecord> {
|
||||
/**
|
||||
* fullRecord: '_acme-challenge.test.example.com',
|
||||
* value: 一串uuid
|
||||
* type: 'TXT',
|
||||
* domain: 'example.com'
|
||||
*/
|
||||
const { fullRecord, hostRecord, value, type, domain } = options;
|
||||
this.logger.info("添加域名解析:", fullRecord, value, type, domain);
|
||||
|
||||
const client = new XinnetClient({
|
||||
logger: this.logger,
|
||||
access: this.access,
|
||||
http: this.http
|
||||
});
|
||||
|
||||
const res = await client.getDomainList({
|
||||
searchKey: domain
|
||||
});
|
||||
|
||||
if (!res.list || res.list.length == 0) {
|
||||
throw new Error("域名不存在");
|
||||
}
|
||||
const serviceCode = res.list[0].serviceCode;
|
||||
|
||||
const dcpCookie = await client.getDcpCookie({
|
||||
serviceCode
|
||||
});
|
||||
|
||||
const recordRes = await client.addDomainDnsRecord({
|
||||
recordName: hostRecord,
|
||||
type: type,
|
||||
recordValue: value
|
||||
}, {
|
||||
dcpCookie,
|
||||
serviceCode
|
||||
});
|
||||
return {
|
||||
...recordRes,
|
||||
serviceCode,
|
||||
dcpCookie
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除dns解析记录,清理申请痕迹
|
||||
* @param options
|
||||
*/
|
||||
async removeRecord(options: RemoveRecordOptions<XinnetRecord>): Promise<void> {
|
||||
const client = new XinnetClient({
|
||||
logger: this.logger,
|
||||
access: this.access,
|
||||
http: this.http
|
||||
});
|
||||
|
||||
const recordRes = options.recordRes;
|
||||
let dcpCookie = recordRes.dcpCookie;
|
||||
if (!dcpCookie) {
|
||||
dcpCookie = await client.getDcpCookie({
|
||||
serviceCode: recordRes.serviceCode
|
||||
});
|
||||
}
|
||||
|
||||
await client.deleteDomainDnsRecord(recordRes, {
|
||||
dcpCookie,
|
||||
serviceCode: recordRes.serviceCode
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//实例化这个provider,将其自动注册到系统中
|
||||
new XinnetProvider();
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './dns-provider.js';
|
||||
export * from './access.js';
|
||||
Reference in New Issue
Block a user