mirror of
https://github.com/certd/certd.git
synced 2026-04-27 15:17:24 +08:00
chore:
This commit is contained in:
@@ -11,26 +11,15 @@ import { IsAccess, AccessInput, BaseAccess } from '@certd/pipeline';
|
|||||||
desc: '',
|
desc: '',
|
||||||
})
|
})
|
||||||
export class XinnetAccess extends BaseAccess {
|
export class XinnetAccess extends BaseAccess {
|
||||||
/**
|
|
||||||
* 授权属性配置
|
|
||||||
*/
|
|
||||||
@AccessInput({
|
|
||||||
title: '用户名',
|
|
||||||
component: {
|
|
||||||
placeholder: '用户名或手机号',
|
|
||||||
},
|
|
||||||
required: true,
|
|
||||||
encrypt: false,
|
|
||||||
})
|
|
||||||
username = '';
|
|
||||||
|
|
||||||
@AccessInput({
|
@AccessInput({
|
||||||
title: '登录密码',
|
title: '域名登录密码',
|
||||||
component: {
|
component: {
|
||||||
name:"a-input-password",
|
name:"a-input-password",
|
||||||
vModel:"value",
|
vModel:"value",
|
||||||
placeholder: '密码',
|
placeholder: '域名密码',
|
||||||
},
|
},
|
||||||
|
helper:"您可以在此处[重置域名管理密码](https://domain.xinnet.com/#domain/manage/domain_manage_pwd)",
|
||||||
required: true,
|
required: true,
|
||||||
encrypt: true,
|
encrypt: true,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -25,11 +25,6 @@ export class XinnetProvider extends AbstractDnsProvider<XinnetRecord> {
|
|||||||
//一些初始化的操作
|
//一些初始化的操作
|
||||||
// 也可以通过ctx成员变量传递context
|
// 也可以通过ctx成员变量传递context
|
||||||
this.access = this.ctx.access as XinnetAccess;
|
this.access = this.ctx.access as XinnetAccess;
|
||||||
this.client = new XinnetClient({
|
|
||||||
logger: this.logger,
|
|
||||||
access: this.access,
|
|
||||||
http: this.http
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,27 +37,37 @@ export class XinnetProvider extends AbstractDnsProvider<XinnetRecord> {
|
|||||||
* type: 'TXT',
|
* type: 'TXT',
|
||||||
* domain: 'example.com'
|
* domain: 'example.com'
|
||||||
*/
|
*/
|
||||||
const { fullRecord,hostRecord, value, type, domain } = options;
|
// const { fullRecord,hostRecord, value, type, domain } = options;
|
||||||
this.logger.info('添加域名解析:', fullRecord, value, type, domain);
|
// this.logger.info('添加域名解析:', fullRecord, value, type, domain);
|
||||||
|
|
||||||
|
// const client = new XinnetClient({
|
||||||
|
// logger: this.logger,
|
||||||
|
// access: {
|
||||||
|
// domain: "",
|
||||||
|
// password: this.access.password
|
||||||
|
// },
|
||||||
|
// http: this.http
|
||||||
|
// });
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// const domainId = await this.client.getDomainId(domain);
|
||||||
|
// this.logger.info('获取domainId成功:', domainId);
|
||||||
|
//
|
||||||
|
// const res = await this.client.createRecord({
|
||||||
|
// domain: domain,
|
||||||
|
// domainId: domainId,
|
||||||
|
// type: 'TXT',
|
||||||
|
// host: hostRecord,
|
||||||
|
// data: value,
|
||||||
|
// ttl: 300,
|
||||||
|
// })
|
||||||
|
// return {
|
||||||
|
// id: res.id,
|
||||||
|
// domainId: domainId,
|
||||||
|
// };
|
||||||
|
|
||||||
const domainId = await this.client.getDomainId(domain);
|
return 1 as any
|
||||||
this.logger.info('获取domainId成功:', domainId);
|
|
||||||
|
|
||||||
const res = await this.client.createRecord({
|
|
||||||
domain: domain,
|
|
||||||
domainId: domainId,
|
|
||||||
type: 'TXT',
|
|
||||||
host: hostRecord,
|
|
||||||
data: value,
|
|
||||||
ttl: 300,
|
|
||||||
})
|
|
||||||
return {
|
|
||||||
id: res.id,
|
|
||||||
domainId: domainId,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -70,29 +75,30 @@ export class XinnetProvider extends AbstractDnsProvider<XinnetRecord> {
|
|||||||
* 删除dns解析记录,清理申请痕迹
|
* 删除dns解析记录,清理申请痕迹
|
||||||
* @param options
|
* @param options
|
||||||
*/
|
*/
|
||||||
async removeRecord(options: RemoveRecordOptions<Dns51Record>): Promise<void> {
|
async removeRecord(options: RemoveRecordOptions<XinnetRecord>): Promise<void> {
|
||||||
const { fullRecord, value } = options.recordReq;
|
// const { fullRecord, value } = options.recordReq;
|
||||||
const record = options.recordRes;
|
// const record = options.recordRes;
|
||||||
this.logger.info('删除域名解析:', fullRecord, value);
|
// this.logger.info('删除域名解析:', fullRecord, value);
|
||||||
if (!record) {
|
// if (!record) {
|
||||||
this.logger.info('record为空,不执行删除');
|
// this.logger.info('record为空,不执行删除');
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
//这里调用删除txt dns解析记录接口
|
// //这里调用删除txt dns解析记录接口
|
||||||
/**
|
// /**
|
||||||
* 请求示例
|
// * 请求示例
|
||||||
* DELETE /api/record?id=85371689655342080 HTTP/1.1
|
// * DELETE /api/record?id=85371689655342080 HTTP/1.1
|
||||||
* Authorization: Basic {token}
|
// * Authorization: Basic {token}
|
||||||
* 请求参数
|
// * 请求参数
|
||||||
*/
|
// */
|
||||||
const {id,domainId} = record
|
// const {id,domainId} = record
|
||||||
await this.client.deleteRecord({
|
// await this.client.deleteRecord({
|
||||||
id,
|
// id,
|
||||||
domainId
|
// domainId
|
||||||
})
|
// })
|
||||||
this.logger.info(`删除域名解析成功:fullRecord=${fullRecord},id=${id}`);
|
// this.logger.info(`删除域名解析成功:fullRecord=${fullRecord},id=${id}`);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//实例化这个provider,将其自动注册到系统中
|
//实例化这个provider,将其自动注册到系统中
|
||||||
new Dns51DnsProvider();
|
new XinnetProvider();
|
||||||
|
|||||||
Reference in New Issue
Block a user