mirror of
https://github.com/certd/certd.git
synced 2026-04-15 05:00:52 +08:00
perf: 支持cloudflare域名
This commit is contained in:
@@ -13,8 +13,9 @@ export type CreateRecordOptions = {
|
||||
value: any;
|
||||
domain: string;
|
||||
};
|
||||
export type RemoveRecordOptions = CreateRecordOptions & {
|
||||
record: any;
|
||||
export type RemoveRecordOptions<T> = CreateRecordOptions & {
|
||||
// 本次创建的dns解析记录,实际上就是createRecord接口的返回值
|
||||
record: T;
|
||||
};
|
||||
|
||||
export type DnsProviderContext = {
|
||||
@@ -23,9 +24,9 @@ export type DnsProviderContext = {
|
||||
http: HttpClient;
|
||||
};
|
||||
|
||||
export interface IDnsProvider {
|
||||
export interface IDnsProvider<T = any> {
|
||||
onInstance(): Promise<void>;
|
||||
createRecord(options: CreateRecordOptions): Promise<any>;
|
||||
removeRecord(options: RemoveRecordOptions): Promise<any>;
|
||||
createRecord(options: CreateRecordOptions): Promise<T>;
|
||||
removeRecord(options: RemoveRecordOptions<T>): Promise<void>;
|
||||
setCtx(ctx: DnsProviderContext): void;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import { CreateRecordOptions, DnsProviderContext, IDnsProvider, RemoveRecordOptions } from "./api";
|
||||
|
||||
export abstract class AbstractDnsProvider implements IDnsProvider {
|
||||
export abstract class AbstractDnsProvider<T = any> implements IDnsProvider<T> {
|
||||
ctx!: DnsProviderContext;
|
||||
|
||||
setCtx(ctx: DnsProviderContext) {
|
||||
this.ctx = ctx;
|
||||
}
|
||||
|
||||
abstract createRecord(options: CreateRecordOptions): Promise<any>;
|
||||
abstract createRecord(options: CreateRecordOptions): Promise<T>;
|
||||
|
||||
abstract onInstance(): Promise<void>;
|
||||
|
||||
abstract removeRecord(options: RemoveRecordOptions): Promise<any>;
|
||||
abstract removeRecord(options: RemoveRecordOptions<T>): Promise<void>;
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ export class CertApplyPlugin extends AbstractTaskPlugin {
|
||||
@TaskInput({
|
||||
title: "CsrInfo",
|
||||
})
|
||||
csrInfo: any;
|
||||
csrInfo!: string;
|
||||
|
||||
acme!: AcmeService;
|
||||
logger!: Logger;
|
||||
@@ -167,7 +167,6 @@ export class CertApplyPlugin extends AbstractTaskPlugin {
|
||||
|
||||
/**
|
||||
* 是否更新证书
|
||||
* @param input
|
||||
*/
|
||||
async condition() {
|
||||
if (this.forceUpdate) {
|
||||
@@ -220,7 +219,7 @@ export class CertApplyPlugin extends AbstractTaskPlugin {
|
||||
organizationUnit: "IT Department",
|
||||
emailAddress: email,
|
||||
},
|
||||
this.csrInfo
|
||||
this.csrInfo ? JSON.parse(this.csrInfo) : {}
|
||||
);
|
||||
this.logger.info("开始申请证书,", email, domains);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user