mirror of
https://github.com/certd/certd.git
synced 2026-04-05 07:20:56 +08:00
perf: 子域名托管域名支持配置通配符
This commit is contained in:
@@ -511,6 +511,7 @@ export default {
|
||||
selectRecordFirst: "Please select records first",
|
||||
subdomainHosted: "Hosted Subdomain",
|
||||
subdomainHelpText: "If you don't understand what subdomain hosting is,Do not set it randomly, as it may result in the inability to apply for the certificate. please refer to the documentation ",
|
||||
subdomainHelpSupportStart: "Supports * wildcard, indicating that all subdomains of the domain are hosted (free subdomains)",
|
||||
subdomainManagement: "Subdomain Management",
|
||||
isDisabled: "Is Disabled",
|
||||
enabled: "Enabled",
|
||||
|
||||
@@ -521,6 +521,7 @@ export default {
|
||||
selectRecordFirst: "请先勾选记录",
|
||||
subdomainHosted: "托管的子域名",
|
||||
subdomainHelpText: "如果您不理解什么是子域托管,请不要随意设置(可能导致证书无法申请,以前设置过的cname记录也需要重新配置),可以参考文档",
|
||||
subdomainHelpSupportStart: "支持*号通配符,表示该域名下的子域名都是托管的(免费子域名)",
|
||||
subdomainManagement: "子域管理",
|
||||
isDisabled: "是否禁用",
|
||||
enabled: "启用",
|
||||
|
||||
@@ -80,10 +80,13 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
{t("certd.subdomainHelpText")}
|
||||
<a href={"https://help.aliyun.com/zh/dns/subdomain-management"} target={"_blank"}>
|
||||
{t("certd.subdomainManagement")}
|
||||
</a>
|
||||
<div>
|
||||
1. {t("certd.subdomainHelpText")}
|
||||
<a href={"https://help.aliyun.com/zh/dns/subdomain-management"} target={"_blank"}>
|
||||
{t("certd.subdomainManagement")}
|
||||
</a>
|
||||
</div>
|
||||
<div>2. {t("certd.subdomainHelpSupportStart")}</div>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {ISubDomainsGetter} from "@certd/plugin-cert";
|
||||
import {SubDomainService} from "../sub-domain-service.js";
|
||||
import { ISubDomainsGetter } from "@certd/plugin-cert";
|
||||
import { SubDomainService } from "../sub-domain-service.js";
|
||||
import { DomainService } from "../../../cert/service/domain-service.js";
|
||||
|
||||
export class SubDomainsGetter implements ISubDomainsGetter {
|
||||
@@ -18,18 +18,39 @@ export class SubDomainsGetter implements ISubDomainsGetter {
|
||||
}
|
||||
|
||||
async hasSubDomain(fullDomain: string) {
|
||||
let arr = fullDomain.split(".")
|
||||
const subDomains = await this.getSubDomains()
|
||||
if (subDomains && subDomains.length > 0) {
|
||||
if (subDomains && subDomains.length > 0) {
|
||||
const fullDomainDot = "." + fullDomain;
|
||||
for (const subDomain of subDomains) {
|
||||
if (fullDomainDot.endsWith("." + subDomain)) {
|
||||
//找到子域名托管
|
||||
return subDomain;
|
||||
}
|
||||
|
||||
if (subDomain.startsWith("*.")) {
|
||||
//如果子域名配置的是泛域名,说明这一层及以下的子域名都是托管的
|
||||
//以fullDomain在这一层的子域名作为返回值
|
||||
const nonStarDomain = subDomain.slice(1)
|
||||
if (fullDomainDot.endsWith(nonStarDomain)) {
|
||||
//提取fullDomain在这一层的子域名
|
||||
const fullArr = arr.reverse()
|
||||
const subArr = subDomain.split(".").reverse()
|
||||
let strBuilder = ""
|
||||
for (let i =0 ;i<subArr.length;i++) {
|
||||
if (strBuilder) {
|
||||
strBuilder = fullArr[i] + "." + strBuilder
|
||||
} else {
|
||||
strBuilder = fullArr[i]
|
||||
}
|
||||
}
|
||||
return strBuilder
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
let arr = fullDomain.split(".")
|
||||
while(arr.length>0){
|
||||
while (arr.length > 0) {
|
||||
const subDomain = arr.join(".")
|
||||
const domain = await this.domainService.findOne({
|
||||
where: {
|
||||
@@ -38,10 +59,10 @@ export class SubDomainsGetter implements ISubDomainsGetter {
|
||||
challengeType: "dns",
|
||||
}
|
||||
})
|
||||
if(domain){
|
||||
if (domain) {
|
||||
return subDomain
|
||||
}
|
||||
arr = arr.slice(1)
|
||||
arr = arr.slice(1)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user