mirror of
https://github.com/certd/certd.git
synced 2026-04-24 12:27:25 +08:00
perf: 支持从提供商导入域名列表
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
ALTER TABLE cd_domain ADD COLUMN from_type varchar(20);
|
||||
ALTER TABLE cd_domain ADD COLUMN registration_date integer;
|
||||
ALTER TABLE cd_domain ADD COLUMN expiration_date integer;
|
||||
@@ -25,6 +25,15 @@ export class DomainEntity {
|
||||
@Column({ comment: '是否禁用', name: 'disabled' })
|
||||
disabled: boolean;
|
||||
|
||||
@Column({ comment: '注册时间', name: 'registration_date' })
|
||||
registrationDate: number;
|
||||
|
||||
@Column({ comment: '过期时间', name: 'expiration_date' })
|
||||
expirationDate: number;
|
||||
|
||||
@Column({ comment: '来源', name: 'from', length: 50 })
|
||||
fromType: string;
|
||||
|
||||
|
||||
@Column({ comment: 'http上传类型', name: 'http_uploader_type', length: 50 })
|
||||
httpUploaderType: string;
|
||||
|
||||
@@ -226,13 +226,19 @@ export class DomainService extends BaseService<DomainEntity> {
|
||||
}
|
||||
})
|
||||
if (old) {
|
||||
const updateObj :any={
|
||||
id: old.id,
|
||||
registrationDate: domainRecord.registrationDate,
|
||||
expirationDate: domainRecord.expirationDate,
|
||||
}
|
||||
if (old.fromType !== 'manual'){
|
||||
//如果不是手动的,更新校验配置
|
||||
updateObj.dnsProviderType = dnsProviderType
|
||||
updateObj.dnsProviderAccess = dnsProviderAccessId
|
||||
updateObj.challengeType = challengeType
|
||||
}
|
||||
//更新
|
||||
await this.update({
|
||||
id: old.id,
|
||||
dnsProviderType,
|
||||
dnsProviderAccess: dnsProviderAccessId,
|
||||
challengeType,
|
||||
})
|
||||
await this.update(updateObj)
|
||||
} else {
|
||||
//添加
|
||||
await this.add({
|
||||
@@ -241,6 +247,10 @@ export class DomainService extends BaseService<DomainEntity> {
|
||||
dnsProviderType,
|
||||
dnsProviderAccess: dnsProviderAccessId,
|
||||
challengeType,
|
||||
disabled: false,
|
||||
fromType: 'auto',
|
||||
registrationDate: domainRecord.registrationDate,
|
||||
expirationDate: domainRecord.expirationDate,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -254,10 +264,6 @@ export class DomainService extends BaseService<DomainEntity> {
|
||||
}
|
||||
//处理
|
||||
for (const domainRecord of pageRes.list) {
|
||||
if (domainRecord.thirdDns) {
|
||||
//域名由第三方dns解析,不导入
|
||||
continue
|
||||
}
|
||||
await importDomain(domainRecord)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {CreateRecordOptions, DnsProviderContext, IDnsProvider, RemoveRecordOptions} from '@certd/plugin-cert';
|
||||
import {CreateRecordOptions, DnsProviderContext, DomainRecord, IDnsProvider, RemoveRecordOptions} from '@certd/plugin-cert';
|
||||
import {PlusService} from '@certd/lib-server';
|
||||
import punycode from 'punycode.js'
|
||||
import { Pager, PageRes } from '@certd/pipeline';
|
||||
export type CommonCnameProvider = {
|
||||
id: number;
|
||||
domain: string;
|
||||
@@ -23,6 +24,9 @@ export class CommonDnsProvider implements IDnsProvider {
|
||||
this.config = opts.config;
|
||||
this.plusService = opts.plusService;
|
||||
}
|
||||
getDomainListPage(pager: Pager): Promise<PageRes<DomainRecord>> {
|
||||
throw new Error('公共CNAME服务不支持获取域名列表');
|
||||
}
|
||||
|
||||
/**
|
||||
* 中文转英文
|
||||
|
||||
+29
-1
@@ -1,6 +1,7 @@
|
||||
import { AbstractDnsProvider, CreateRecordOptions, IsDnsProvider, RemoveRecordOptions } from '@certd/plugin-cert';
|
||||
import { AbstractDnsProvider, CreateRecordOptions, DomainRecord, IsDnsProvider, RemoveRecordOptions } from '@certd/plugin-cert';
|
||||
import { AliyunAccess } from '../../plugin-lib/aliyun/access/aliyun-access.js';
|
||||
import { AliyunClient } from '../../plugin-lib/aliyun/index.js';
|
||||
import { Pager, PageRes } from '@certd/pipeline';
|
||||
|
||||
|
||||
@IsDnsProvider({
|
||||
@@ -153,6 +154,33 @@ export class AliyunDnsProvider extends AbstractDnsProvider {
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
async getDomainListPage(pager: Pager) :Promise<PageRes<DomainRecord>> {
|
||||
const params = {
|
||||
RegionId: 'cn-hangzhou',
|
||||
PageSize: pager.pageSize,
|
||||
PageNumber: pager.pageNo,
|
||||
};
|
||||
|
||||
const requestOption = {
|
||||
method: 'POST',
|
||||
};
|
||||
|
||||
const ret = await this.client.request(
|
||||
'DescribeDomains',
|
||||
params,
|
||||
requestOption
|
||||
);
|
||||
const list = ret.Domains?.Domain?.map(item => ({
|
||||
id: item.DomainId,
|
||||
domain: item.DomainName,
|
||||
})) || []
|
||||
|
||||
return {
|
||||
list,
|
||||
total: ret.TotalCount,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
new AliyunDnsProvider();
|
||||
|
||||
Reference in New Issue
Block a user