mirror of
https://github.com/certd/certd.git
synced 2026-05-16 13:17:29 +08:00
perf: 站点监控支持监控IP
This commit is contained in:
@@ -14,6 +14,7 @@ import { CertInfo, CertReader } from "@certd/plugin-cert";
|
||||
export class FarcdnAccess extends BaseAccess {
|
||||
@AccessInput({
|
||||
title: "接口地址",
|
||||
value:"https://open.farcdn.net/api/source",
|
||||
component: {
|
||||
placeholder: "https://open.farcdn.net/api/source",
|
||||
name: "a-input",
|
||||
@@ -79,21 +80,16 @@ export class FarcdnAccess extends BaseAccess {
|
||||
testRequest = true;
|
||||
|
||||
async onTestRequest() {
|
||||
try{
|
||||
const data = await this.findSSLCertConfig(2106);
|
||||
if (data) {
|
||||
return "ok";
|
||||
}
|
||||
}catch (e) {
|
||||
if(e.message.indexOf("11111111")>-1){
|
||||
return "ok";
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
|
||||
throw "测试失败,未知错误";
|
||||
await this.getSSLCertList({size:1});
|
||||
return "ok"
|
||||
}
|
||||
|
||||
async getSSLCertList(req:{offset?:number,size?:number}){
|
||||
return await this.doRequest({
|
||||
url: "/getSSLCertList",
|
||||
data: req
|
||||
});
|
||||
}
|
||||
|
||||
async findSSLCertConfig(sslCertId: number) {
|
||||
/**
|
||||
@@ -120,7 +116,7 @@ export class FarcdnAccess extends BaseAccess {
|
||||
sslCertId,
|
||||
};
|
||||
const res= await this.doRequest({
|
||||
url: "/api/source/findSSLCertConfig",
|
||||
url: "/findSSLCertConfig",
|
||||
data: params
|
||||
});
|
||||
this.ctx.logger.info(`找到证书${sslCertId}: name=${res.name},domain=${res.commonNames},dnsNames=${res.dnsNames}`);
|
||||
@@ -186,7 +182,7 @@ export class FarcdnAccess extends BaseAccess {
|
||||
logData:true,
|
||||
});
|
||||
|
||||
if (res.code === "200") {
|
||||
if (res.code === 200) {
|
||||
return res.data;
|
||||
}
|
||||
throw new Error(res.message || res);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { IsTaskPlugin, pluginGroups, RunStrategy, TaskInput } from "@certd/pipeline";
|
||||
import { IsTaskPlugin, PageReq, pluginGroups, RunStrategy, TaskInput } from "@certd/pipeline";
|
||||
import { CertApplyPluginNames, CertInfo } from "@certd/plugin-cert";
|
||||
import { createCertDomainGetterInputDefine, createRemoteSelectInputDefine } from "@certd/plugin-lib";
|
||||
import { FarcdnAccess } from "../access.js";
|
||||
@@ -8,6 +8,7 @@ import { AbstractPlusTaskPlugin } from "@certd/plugin-plus";
|
||||
//命名规范,插件类型+功能(就是目录plugin-demo中的demo),大写字母开头,驼峰命名
|
||||
name: "FarcdnRefreshCert",
|
||||
title: "farcdn-更新证书",
|
||||
desc:"www.farcdn.net",
|
||||
icon: "svg:icon-lucky",
|
||||
//插件分组
|
||||
group: pluginGroups.cdn.key,
|
||||
@@ -77,28 +78,31 @@ export class FarcdnRefreshCert extends AbstractPlusTaskPlugin {
|
||||
this.logger.info("部署完成");
|
||||
}
|
||||
|
||||
async onGetCertList() {
|
||||
throw new Error("暂无查询证书列表接口,您需要手动输入证书id");
|
||||
// const access = await this.getAccess<FarcdnAccess>(this.accessId);
|
||||
async onGetCertList(data:PageReq = {}) {
|
||||
const access = await this.getAccess<FarcdnAccess>(this.accessId);
|
||||
|
||||
// const res = await access.doRequest({
|
||||
// url: "/SSLCertService/listSSLCerts",
|
||||
// data: { size: 1000 },
|
||||
// method: "POST"
|
||||
// });
|
||||
// const list = JSON.parse(this.ctx.utils.hash.base64Decode(res.sslCertsJSON));
|
||||
// if (!list || list.length === 0) {
|
||||
// throw new Error("没有找到证书,请先在控制台上传一次证书且关联网站");
|
||||
// }
|
||||
//
|
||||
// const options = list.map((item: any) => {
|
||||
// return {
|
||||
// label: `${item.name}<${item.id}-${item.dnsNames[0]}>`,
|
||||
// value: item.id,
|
||||
// domain: item.dnsNames
|
||||
// };
|
||||
// });
|
||||
// return this.ctx.utils.options.buildGroupOptions(options, this.certDomains);
|
||||
const res = await access.getSSLCertList({
|
||||
offset: data.offset?? 0,
|
||||
size: data.limit?? 100,
|
||||
});
|
||||
const list = res.list
|
||||
if (!list || list.length === 0) {
|
||||
throw new Error("没有找到证书,请先在控制台上传一次证书且关联网站");
|
||||
}
|
||||
|
||||
const options = list.map((item: any) => {
|
||||
return {
|
||||
label: `${item.name}<${item.id}>`,
|
||||
value: item.id,
|
||||
domain: item.dnsNames
|
||||
};
|
||||
});
|
||||
return {
|
||||
list:this.ctx.utils.options.buildGroupOptions(options, this.certDomains),
|
||||
total:res.total,
|
||||
offset: res.offset,
|
||||
limit:res.size
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user