mirror of
https://github.com/certd/certd.git
synced 2026-04-23 19:57:27 +08:00
perf: 所有的dnsprovider 支持导入域名列表
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { AbstractDnsProvider, CreateRecordOptions, IsDnsProvider, RemoveRecordOptions } from '@certd/plugin-cert';
|
||||
import { AbstractDnsProvider, CreateRecordOptions, DomainRecord, IsDnsProvider, RemoveRecordOptions } from '@certd/plugin-cert';
|
||||
|
||||
import { CloudflareAccess } from './access.js';
|
||||
import { Pager, PageRes, PageSearch } from '@certd/pipeline';
|
||||
|
||||
export type CloudflareRecord = {
|
||||
id: string;
|
||||
@@ -144,6 +145,27 @@ export class CloudflareDnsProvider extends AbstractDnsProvider<CloudflareRecord>
|
||||
await this.doRequestApi(url, null, 'delete');
|
||||
this.logger.info(`删除域名解析成功:fullRecord=${fullRecord},value=${value}`);
|
||||
}
|
||||
|
||||
async getDomainListPage(req: PageSearch): Promise<PageRes<DomainRecord>> {
|
||||
const pager = new Pager(req);
|
||||
|
||||
let url = `https://api.cloudflare.com/client/v4/zones?page=${pager.pageNo}&per_page=${pager.pageSize}`;
|
||||
if (req.searchKey) {
|
||||
url += `&name=${req.searchKey}`;
|
||||
}
|
||||
const ret = await this.doRequestApi(url, null, 'get');
|
||||
|
||||
let list = ret.result || []
|
||||
list = list.map((item: any) => ({
|
||||
id: item.id,
|
||||
domain: item.name,
|
||||
}));
|
||||
const total = ret.result_info.total_count || list.length;
|
||||
return {
|
||||
total,
|
||||
list,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
//实例化这个provider,将其自动注册到系统中
|
||||
|
||||
Reference in New Issue
Block a user