mirror of
https://github.com/certd/certd.git
synced 2026-04-24 20:57:26 +08:00
perf: 子域名托管域名支持配置通配符
This commit is contained in:
@@ -511,6 +511,7 @@ export default {
|
|||||||
selectRecordFirst: "Please select records first",
|
selectRecordFirst: "Please select records first",
|
||||||
subdomainHosted: "Hosted Subdomain",
|
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 ",
|
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",
|
subdomainManagement: "Subdomain Management",
|
||||||
isDisabled: "Is Disabled",
|
isDisabled: "Is Disabled",
|
||||||
enabled: "Enabled",
|
enabled: "Enabled",
|
||||||
|
|||||||
@@ -521,6 +521,7 @@ export default {
|
|||||||
selectRecordFirst: "请先勾选记录",
|
selectRecordFirst: "请先勾选记录",
|
||||||
subdomainHosted: "托管的子域名",
|
subdomainHosted: "托管的子域名",
|
||||||
subdomainHelpText: "如果您不理解什么是子域托管,请不要随意设置(可能导致证书无法申请,以前设置过的cname记录也需要重新配置),可以参考文档",
|
subdomainHelpText: "如果您不理解什么是子域托管,请不要随意设置(可能导致证书无法申请,以前设置过的cname记录也需要重新配置),可以参考文档",
|
||||||
|
subdomainHelpSupportStart: "支持*号通配符,表示该域名下的子域名都是托管的(免费子域名)",
|
||||||
subdomainManagement: "子域管理",
|
subdomainManagement: "子域管理",
|
||||||
isDisabled: "是否禁用",
|
isDisabled: "是否禁用",
|
||||||
enabled: "启用",
|
enabled: "启用",
|
||||||
|
|||||||
@@ -80,10 +80,13 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
|||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{t("certd.subdomainHelpText")}
|
<div>
|
||||||
<a href={"https://help.aliyun.com/zh/dns/subdomain-management"} target={"_blank"}>
|
1. {t("certd.subdomainHelpText")}
|
||||||
{t("certd.subdomainManagement")}
|
<a href={"https://help.aliyun.com/zh/dns/subdomain-management"} target={"_blank"}>
|
||||||
</a>
|
{t("certd.subdomainManagement")}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div>2. {t("certd.subdomainHelpSupportStart")}</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {ISubDomainsGetter} from "@certd/plugin-cert";
|
import { ISubDomainsGetter } from "@certd/plugin-cert";
|
||||||
import {SubDomainService} from "../sub-domain-service.js";
|
import { SubDomainService } from "../sub-domain-service.js";
|
||||||
import { DomainService } from "../../../cert/service/domain-service.js";
|
import { DomainService } from "../../../cert/service/domain-service.js";
|
||||||
|
|
||||||
export class SubDomainsGetter implements ISubDomainsGetter {
|
export class SubDomainsGetter implements ISubDomainsGetter {
|
||||||
@@ -18,18 +18,39 @@ export class SubDomainsGetter implements ISubDomainsGetter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async hasSubDomain(fullDomain: string) {
|
async hasSubDomain(fullDomain: string) {
|
||||||
|
let arr = fullDomain.split(".")
|
||||||
const subDomains = await this.getSubDomains()
|
const subDomains = await this.getSubDomains()
|
||||||
if (subDomains && subDomains.length > 0) {
|
if (subDomains && subDomains.length > 0) {
|
||||||
const fullDomainDot = "." + fullDomain;
|
const fullDomainDot = "." + fullDomain;
|
||||||
for (const subDomain of subDomains) {
|
for (const subDomain of subDomains) {
|
||||||
if (fullDomainDot.endsWith("." + subDomain)) {
|
if (fullDomainDot.endsWith("." + subDomain)) {
|
||||||
//找到子域名托管
|
//找到子域名托管
|
||||||
return 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 subDomain = arr.join(".")
|
||||||
const domain = await this.domainService.findOne({
|
const domain = await this.domainService.findOne({
|
||||||
where: {
|
where: {
|
||||||
@@ -38,10 +59,10 @@ export class SubDomainsGetter implements ISubDomainsGetter {
|
|||||||
challengeType: "dns",
|
challengeType: "dns",
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if(domain){
|
if (domain) {
|
||||||
return subDomain
|
return subDomain
|
||||||
}
|
}
|
||||||
arr = arr.slice(1)
|
arr = arr.slice(1)
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user