perf: 支持雨云dns解析以及雨云证书更新

This commit is contained in:
xiaojunnuo
2025-06-12 23:51:21 +08:00
parent 83543487e7
commit 43c7a19849
5 changed files with 230 additions and 70 deletions
@@ -1,5 +1,6 @@
import {AccessInput, BaseAccess, IsAccess} from "@certd/pipeline";
import {HttpRequestConfig} from "@certd/basic";
import { CertInfo } from "@certd/plugin-cert";
/**
@@ -41,13 +42,13 @@ export class RainyunAccess extends BaseAccess {
testRequest = true;
async onTestRequest() {
await this.getDomainList({});
await this.getDomainList({limit:1});
return "ok"
}
// {"columnFilters":{"domains.Domain":"domain"},"sort":[],"page":1,"perPage":20}
async getDomainList(req:{offset?:number,size?:number,query?:string}){
const size = req.size ?? 20;
async getDomainList(req:{offset?:number,limit?:number,query?:string}){
const size = req.limit ?? 20;
const offset = req.offset ?? 0;
let page = Math.floor(offset / size);
if(offset % size === 0 ){
@@ -67,17 +68,63 @@ export class RainyunAccess extends BaseAccess {
return {
total: res.TotalRecords,
list: res.Records || []
list: res.Records || [],
limit: size,
offset: offset
}
}
async getDomainId(domain:string){
const res = await this.getDomainList({query: domain,size:1});
if (res.list.length === 0) {
throw new Error(`域名${domain}不存在 ` );
async getCertList(req:{offset?:number,limit?:number,query?:string}){
const size = req.limit ?? 20;
const offset = req.offset ?? 0;
let page = Math.floor(offset / size);
if(offset % size === 0 ){
page++
}
return res.list[0].ID;
const options ={
columnFilters: {
Domain: req.query??""
},
sort:[],
page: page,
perPage: size,
}
const res = await this.doRequest({
url: `product/sslcenter/?options=${encodeURIComponent(JSON.stringify(options))}`,
method: "GET",
});
return {
total: res.TotalRecords,
list: res.Records || [],
limit: size,
offset: offset
}
}
async doCertReplace(req:{certId:number,cert:CertInfo}){
// /product/sslcenter/{id}
return await this.doRequest({
url: `product/sslcenter/${req.certId}`,
method: "PUT",
data: {
cert: req.cert.crt,
key: req.cert.key,
}
});
}
async getDomainId(domain:string){
const res = await this.getDomainList({query: domain,limit:1});
if (res.list.length === 0) {
throw new Error(`域名${domain}不存在` );
}
return res.list[0].id;
}
async doRequest(req:HttpRequestConfig){