mirror of
https://github.com/certd/certd.git
synced 2026-07-09 22:47:38 +08:00
fix: 修复火山引擎查不到自定义源站域名的问题
This commit is contained in:
@@ -65,7 +65,7 @@ export class MineController extends BaseController {
|
||||
user.needInitAccount = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return this.ok(user);
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ export class MineController extends BaseController {
|
||||
|
||||
@Post("/accountInit", { description: Constants.per.authOnly, summary: "初始化Let's Encrypt ACME账号和邮件通知" })
|
||||
public async accountInit(@Body("email") email?: string) {
|
||||
let userId = this.getUserId();
|
||||
const userId = this.getUserId();
|
||||
let userEmail = email;
|
||||
let user: any = null;
|
||||
if (!userEmail) {
|
||||
@@ -190,7 +190,7 @@ export class MineController extends BaseController {
|
||||
type: "acmeAccount",
|
||||
name: "Let's Encrypt",
|
||||
userId,
|
||||
projectId:undefined,
|
||||
projectId: undefined,
|
||||
setting: JSON.stringify({
|
||||
caType: "letsencrypt",
|
||||
email: userEmail,
|
||||
|
||||
@@ -114,7 +114,7 @@ export class AsiaIspClient {
|
||||
|
||||
if (response.code !== "0") {
|
||||
this.logger.error(`接口请求失败: code=${response.code}, msg=${response.msg}`);
|
||||
const e= new Error(response.msg || "接口请求失败");
|
||||
const e = new Error(response.msg || "接口请求失败");
|
||||
// @ts-ignore
|
||||
e.errorCode = response.code;
|
||||
throw e;
|
||||
@@ -122,9 +122,9 @@ export class AsiaIspClient {
|
||||
|
||||
return response;
|
||||
} catch (error: any) {
|
||||
const response = error.response
|
||||
const response = error.response;
|
||||
if (response && response.data) {
|
||||
const e = new Error(response.data.msg || error.message || "接口请求失败");
|
||||
const e = new Error(response.data.msg || error.message || "接口请求失败");
|
||||
// @ts-ignore
|
||||
e.errorCode = response.data.code;
|
||||
throw e;
|
||||
@@ -245,7 +245,7 @@ export class AsiaIspClient {
|
||||
this.logger.info(`域名 ${req.domain} 已绑定该证书 ${req.certId},无需重复绑定`);
|
||||
return;
|
||||
}
|
||||
throw e
|
||||
throw e;
|
||||
}
|
||||
this.logger.info(`部署证书到域名成功: ${req.domain}, certId=${req.certId}`);
|
||||
}
|
||||
|
||||
+38
-28
@@ -86,8 +86,6 @@ export class VolcengineDeployToVOD extends AbstractTaskPlugin {
|
||||
})
|
||||
domainType!: string;
|
||||
|
||||
|
||||
|
||||
@TaskInput(
|
||||
createRemoteSelectInputDefine({
|
||||
title: "域名",
|
||||
@@ -111,18 +109,24 @@ export class VolcengineDeployToVOD extends AbstractTaskPlugin {
|
||||
const access = await this.getAccess<VolcengineAccess>(this.accessId);
|
||||
const certId = await this.uploadOrGetCertId(access);
|
||||
|
||||
const service = await this.getVodService({ version: "2023-07-01", region: this.regionId });
|
||||
const domainTypeMapping: Record<string, string> = {
|
||||
play: "vod_play",
|
||||
image: "vod_image",
|
||||
};
|
||||
const apiDomainType = domainTypeMapping[this.domainType] || this.domainType;
|
||||
|
||||
const service = await this.getVodService({ version: "2026-01-01", region: this.regionId });
|
||||
const domains = Array.isArray(this.domainList) ? this.domainList : [this.domainList];
|
||||
for (const domain of domains) {
|
||||
this.logger.info(`开始部署域名${domain}证书`);
|
||||
await service.request({
|
||||
action: "UpdateDomainConfig",
|
||||
action: "UpdateVodDomainConfig",
|
||||
method: "POST",
|
||||
body: {
|
||||
SpaceName: this.spaceName,
|
||||
DomainType: this.domainType,
|
||||
DomainType: apiDomainType,
|
||||
Domain: domain,
|
||||
Config: {
|
||||
UpdateCdnConfigParam: {
|
||||
HTTPS: {
|
||||
Switch: true,
|
||||
CertInfo: {
|
||||
@@ -207,34 +211,40 @@ export class VolcengineDeployToVOD extends AbstractTaskPlugin {
|
||||
if (!this.spaceName) {
|
||||
throw new Error("请先选择空间名称");
|
||||
}
|
||||
const service = await this.getVodService({ version: "2023-01-01", region: this.regionId });
|
||||
const service = await this.getVodService({ version: "2026-01-01", region: this.regionId });
|
||||
|
||||
const query: Record<string, any> = {
|
||||
SpaceName: this.spaceName,
|
||||
DomainType: this.domainType,
|
||||
const domainTypeMapping: Record<string, string> = {
|
||||
play: "vod_play",
|
||||
image: "vod_image",
|
||||
};
|
||||
const apiDomainType = domainTypeMapping[this.domainType] || this.domainType;
|
||||
|
||||
const body: Record<string, any> = {
|
||||
SpaceName: this.spaceName,
|
||||
ListCdnDomainsParam: {
|
||||
PageNum: 1,
|
||||
PageSize: 100,
|
||||
},
|
||||
};
|
||||
if (apiDomainType) {
|
||||
body.DomainType = apiDomainType;
|
||||
}
|
||||
const res = await service.request({
|
||||
action: "ListDomain",
|
||||
query,
|
||||
action: "ListVodDomains",
|
||||
method: "POST",
|
||||
body,
|
||||
});
|
||||
|
||||
const instances = res.Result?.PlayInstanceInfo?.ByteInstances;
|
||||
if (!instances || instances.length === 0) {
|
||||
throw new Error("找不到域名,您也可以手动输入域名");
|
||||
}
|
||||
const list = [];
|
||||
for (const item of instances) {
|
||||
if (item.Domains && item.Domains.length > 0) {
|
||||
for (const domain of item.Domains) {
|
||||
if (domain.Domain) {
|
||||
list.push({
|
||||
value: domain.Domain,
|
||||
label: domain.Domain,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
const domains = res.Result?.VodInfo?.Domains;
|
||||
if (!domains || domains.length === 0) {
|
||||
return [];
|
||||
}
|
||||
const list = domains.map((item: any) => {
|
||||
return {
|
||||
value: item.Domain,
|
||||
label: item.Domain,
|
||||
};
|
||||
});
|
||||
return this.ctx.utils.options.buildGroupOptions(list, this.certDomains);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user