Files
certd/packages/ui/certd-server/src/plugins/plugin-demo/dns-provider.ts
T

46 lines
1.5 KiB
TypeScript
Raw Normal View History

2024-06-14 01:25:30 +08:00
import { AbstractDnsProvider, CreateRecordOptions, IsDnsProvider, RemoveRecordOptions } from "@certd/plugin-cert";
import { Autowire, ILogger } from "@certd/pipeline";
import { DemoAccess } from "./access";
2024-03-22 00:50:02 +08:00
// TODO 这里注册一个dnsProvider
@IsDnsProvider({
2024-06-11 01:55:29 +08:00
name: 'demo',
title: 'Dns提供商Demo',
2024-06-11 01:55:29 +08:00
desc: 'dns provider示例',
accessType: 'demo', //这里是对应的access name
2024-03-22 00:50:02 +08:00
})
2024-06-14 01:25:30 +08:00
export class DemoDnsProvider extends AbstractDnsProvider {
2024-03-22 00:50:02 +08:00
@Autowire()
access!: DemoAccess;
@Autowire()
logger!: ILogger;
async onInstance() {
const access: any = this.access;
this.logger.debug('access', access);
2024-03-22 00:50:02 +08:00
//初始化的操作
//...
}
async createRecord(options: CreateRecordOptions): Promise<any> {
const { fullRecord, value, type,domain } = options;
this.logger.info('添加域名解析:', fullRecord, value, type,domain);
2024-03-22 00:50:02 +08:00
//TODO 然后调用接口,创建txt类型的dns解析记录
// .. 这里调用对应平台的后台接口
const access = this.access;
this.logger.debug('access', access);
2024-03-22 00:50:02 +08:00
}
async removeRecord(options: RemoveRecordOptions): Promise<any> {
const { fullRecord, value, record } = options;
this.logger.info('删除域名解析:', fullRecord, value, record);
2024-03-22 00:50:02 +08:00
//TODO 这里调用删除txt dns解析记录接口
const access = this.access;
this.logger.debug('access', access);
this.logger.info('删除域名解析成功:', fullRecord, value);
2024-03-22 00:50:02 +08:00
}
}
//TODO 实例化这个provider,将其自动注册到系统中
new DemoDnsProvider();