mirror of
https://github.com/certd/certd.git
synced 2026-04-24 04:17:25 +08:00
feat: 域名验证方法支持CNAME间接方式,此方式支持所有域名注册商,且无需提供Access授权,但是需要手动添加cname解析
This commit is contained in:
@@ -8,14 +8,16 @@ export type DnsProviderDefine = Registrable & {
|
||||
};
|
||||
|
||||
export type CreateRecordOptions = {
|
||||
domain: string;
|
||||
fullRecord: string;
|
||||
hostRecord: string;
|
||||
type: string;
|
||||
value: any;
|
||||
domain: string;
|
||||
};
|
||||
export type RemoveRecordOptions<T> = CreateRecordOptions & {
|
||||
export type RemoveRecordOptions<T> = {
|
||||
recordReq: CreateRecordOptions;
|
||||
// 本次创建的dns解析记录,实际上就是createRecord接口的返回值
|
||||
record: T;
|
||||
recordRes: T;
|
||||
};
|
||||
|
||||
export type DnsProviderContext = {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { CreateRecordOptions, DnsProviderContext, IDnsProvider, RemoveRecordOptions } from "./api.js";
|
||||
import psl from "psl";
|
||||
|
||||
export abstract class AbstractDnsProvider<T = any> implements IDnsProvider<T> {
|
||||
ctx!: DnsProviderContext;
|
||||
@@ -13,3 +14,11 @@ export abstract class AbstractDnsProvider<T = any> implements IDnsProvider<T> {
|
||||
|
||||
abstract removeRecord(options: RemoveRecordOptions<T>): Promise<void>;
|
||||
}
|
||||
|
||||
export function parseDomain(fullDomain: string) {
|
||||
const parsed = psl.parse(fullDomain) as psl.ParsedDomain;
|
||||
if (parsed.error) {
|
||||
throw new Error(`解析${fullDomain}域名失败:` + JSON.stringify(parsed.error));
|
||||
}
|
||||
return parsed.domain as string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user