mirror of
https://github.com/certd/certd.git
synced 2025-11-25 09:10:11 +08:00
chore: 新网dns完善
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
"@certd/acme-client": "^1.36.21",
|
||||
"@certd/basic": "^1.36.21",
|
||||
"@certd/pipeline": "^1.36.21",
|
||||
"@certd/plugin-lib": "^1.36.21",
|
||||
"@certd/plus-core": "^1.36.21",
|
||||
"@midwayjs/cache": "~3.14.0",
|
||||
"@midwayjs/core": "~3.20.3",
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
export * from './service/plus-service.js';
|
||||
export * from './service/file-service.js';
|
||||
export * from './service/encryptor.js';
|
||||
export * from './service/ocr-service.js';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { HttpClient, ILogger, utils } from "@certd/basic";
|
||||
import { IAccess, Registrable } from "@certd/pipeline";
|
||||
import { IAccess, IServiceGetter, Registrable } from "@certd/pipeline";
|
||||
|
||||
export type DnsProviderDefine = Registrable & {
|
||||
accessType: string;
|
||||
@@ -25,6 +25,7 @@ export type DnsProviderContext = {
|
||||
http: HttpClient;
|
||||
utils: typeof utils;
|
||||
domainParser: IDomainParser;
|
||||
serviceGetter: IServiceGetter;
|
||||
};
|
||||
|
||||
export interface IDnsProvider<T = any> {
|
||||
|
||||
@@ -524,6 +524,7 @@ export class CertApplyPlugin extends CertApplyBasePlugin {
|
||||
http: this.ctx.http,
|
||||
utils,
|
||||
domainParser,
|
||||
serviceGetter: this.ctx.serviceGetter,
|
||||
};
|
||||
return await createDnsProvider({
|
||||
dnsProviderType,
|
||||
|
||||
@@ -21,6 +21,7 @@ import { DomainParser } from "@certd/plugin-cert/dist/dns-provider/domain-parser
|
||||
import punycode from "punycode.js";
|
||||
import { SubDomainService } from "../../pipeline/service/sub-domain-service.js";
|
||||
import { SubDomainsGetter } from "../../pipeline/service/getter/sub-domain-getter.js";
|
||||
import { TaskServiceBuilder } from "../../pipeline/service/getter/task-service-getter.js";
|
||||
|
||||
type CnameCheckCacheValue = {
|
||||
validating: boolean;
|
||||
@@ -55,6 +56,10 @@ export class CnameRecordService extends BaseService<CnameRecordEntity> {
|
||||
@Inject()
|
||||
subDomainService: SubDomainService;
|
||||
|
||||
@Inject()
|
||||
taskServiceBuilder: TaskServiceBuilder;
|
||||
|
||||
|
||||
//@ts-ignore
|
||||
getRepository() {
|
||||
return this.repository;
|
||||
@@ -248,8 +253,9 @@ export class CnameRecordService extends BaseService<CnameRecordEntity> {
|
||||
});
|
||||
}
|
||||
|
||||
const serviceGetter = this.taskServiceBuilder.create({userId:cnameProvider.userId})
|
||||
const access = await this.accessService.getById(cnameProvider.accessId, cnameProvider.userId);
|
||||
const context = {access, logger, http, utils, domainParser};
|
||||
const context = {access, logger, http, utils, domainParser,serviceGetter};
|
||||
const dnsProvider: IDnsProvider = await createDnsProvider({
|
||||
dnsProviderType: cnameProvider.dnsProviderType,
|
||||
context,
|
||||
|
||||
@@ -10,6 +10,9 @@ import { DomainVerifierGetter } from "./domain-verifier-getter.js";
|
||||
import { DomainService } from "../../../cert/service/domain-service.js";
|
||||
import { SubDomainService } from "../sub-domain-service.js";
|
||||
|
||||
const serviceNames = [
|
||||
'ocrService',
|
||||
]
|
||||
export class TaskServiceGetter implements IServiceGetter{
|
||||
private userId: number;
|
||||
private appCtx : IMidwayContainer;
|
||||
@@ -29,8 +32,14 @@ export class TaskServiceGetter implements IServiceGetter{
|
||||
return await this.getNotificationService() as T
|
||||
} else if (serviceName === 'domainVerifierGetter') {
|
||||
return await this.getDomainVerifierGetter() as T
|
||||
}else{
|
||||
throw new Error(`service ${serviceName} not found`)
|
||||
} else{
|
||||
if(!serviceNames.includes(serviceName)){
|
||||
throw new Error(`${serviceName} not in whitelist`)
|
||||
}
|
||||
const service = await this.appCtx.getAsync(serviceName)
|
||||
if (! service){
|
||||
throw new Error(`${serviceName} not found`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,3 +36,4 @@ export * from './plugin-apisix/index.js'
|
||||
export * from './plugin-dokploy/index.js'
|
||||
export * from './plugin-godaddy/index.js'
|
||||
export * from './plugin-captcha/index.js'
|
||||
export * from './plugin-xinnet/index.js'
|
||||
|
||||
@@ -1,29 +1,67 @@
|
||||
import { IsAccess, AccessInput, BaseAccess } from '@certd/pipeline';
|
||||
import { IsAccess, AccessInput, BaseAccess } from "@certd/pipeline";
|
||||
import { XinnetClient } from "@certd/plugin-plus";
|
||||
|
||||
/**
|
||||
* 这个注解将注册一个授权配置
|
||||
* 在certd的后台管理系统中,用户可以选择添加此类型的授权
|
||||
*/
|
||||
@IsAccess({
|
||||
name: 'xinnet',
|
||||
title: '新网授权',
|
||||
icon: 'arcticons:dns-changer-3',
|
||||
desc: '',
|
||||
name: "xinnet",
|
||||
title: "新网授权",
|
||||
icon: "arcticons:dns-changer-3",
|
||||
desc: ""
|
||||
})
|
||||
export class XinnetAccess extends BaseAccess {
|
||||
|
||||
/**
|
||||
* 授权属性配置
|
||||
*/
|
||||
@AccessInput({
|
||||
title: '域名登录密码',
|
||||
title: "用户名",
|
||||
component: {
|
||||
name:"a-input-password",
|
||||
vModel:"value",
|
||||
placeholder: '域名密码',
|
||||
placeholder: "手机号"
|
||||
},
|
||||
helper:"您可以在此处[重置域名管理密码](https://domain.xinnet.com/#domain/manage/domain_manage_pwd)",
|
||||
required: true,
|
||||
encrypt: true,
|
||||
encrypt: true
|
||||
})
|
||||
password = '';
|
||||
username = "";
|
||||
|
||||
@AccessInput({
|
||||
title: "域名登录密码",
|
||||
component: {
|
||||
name: "a-input-password",
|
||||
vModel: "value",
|
||||
placeholder: "域名密码"
|
||||
},
|
||||
helper: "您可以在此处[重置域名管理密码](https://domain.xinnet.com/#domain/manage/domain_manage_pwd)",
|
||||
required: true,
|
||||
encrypt: true
|
||||
})
|
||||
password = "";
|
||||
|
||||
@AccessInput({
|
||||
title: "测试",
|
||||
component: {
|
||||
name: "api-test",
|
||||
action: "TestRequest"
|
||||
},
|
||||
helper: "点击测试接口是否正常"
|
||||
})
|
||||
testRequest = true;
|
||||
|
||||
async onTestRequest() {
|
||||
|
||||
const client = new XinnetClient({
|
||||
access: this,
|
||||
logger: this.ctx.logger,
|
||||
http: this.ctx.http
|
||||
});
|
||||
|
||||
await client.getDomainList({ pageNo: 1, pageSize: 1 });
|
||||
|
||||
return "ok";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
new XinnetAccess();
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
export * from './dns-provider.js';
|
||||
export * from './access.js';
|
||||
export * from './client.js';
|
||||
|
||||
Reference in New Issue
Block a user