mirror of https://github.com/certd/certd
perf: 申请证书启用新的反代地址
parent
f8b99b81a2
commit
a705182b85
|
@ -128,6 +128,10 @@ export class Executor {
|
||||||
this.runtime.skip(runnable);
|
this.runtime.skip(runnable);
|
||||||
return resultType;
|
return resultType;
|
||||||
}
|
}
|
||||||
|
if (resultType == ResultType.disabled) {
|
||||||
|
this.runtime.disabled(runnable);
|
||||||
|
return resultType;
|
||||||
|
}
|
||||||
this.runtime.success(runnable);
|
this.runtime.success(runnable);
|
||||||
return ResultType.success;
|
return ResultType.success;
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
|
@ -164,12 +168,14 @@ export class Executor {
|
||||||
|
|
||||||
let resList: ResultType[] = [];
|
let resList: ResultType[] = [];
|
||||||
if (stage.concurrency === ConcurrencyStrategy.Parallel) {
|
if (stage.concurrency === ConcurrencyStrategy.Parallel) {
|
||||||
|
//并行
|
||||||
const pList = [];
|
const pList = [];
|
||||||
for (const item of runnerList) {
|
for (const item of runnerList) {
|
||||||
pList.push(item());
|
pList.push(item());
|
||||||
}
|
}
|
||||||
resList = await Promise.all(pList);
|
resList = await Promise.all(pList);
|
||||||
} else {
|
} else {
|
||||||
|
//串行
|
||||||
for (let i = 0; i < runnerList.length; i++) {
|
for (let i = 0; i < runnerList.length; i++) {
|
||||||
const runner = runnerList[i];
|
const runner = runnerList[i];
|
||||||
resList[i] = await runner();
|
resList[i] = await runner();
|
||||||
|
@ -181,6 +187,7 @@ export class Executor {
|
||||||
compositionResultType(resList: ResultType[]): ResultType {
|
compositionResultType(resList: ResultType[]): ResultType {
|
||||||
let hasSuccess = false;
|
let hasSuccess = false;
|
||||||
let hasSkip = false;
|
let hasSkip = false;
|
||||||
|
let hasDisabled = false;
|
||||||
for (const type of resList) {
|
for (const type of resList) {
|
||||||
if (type === ResultType.error) {
|
if (type === ResultType.error) {
|
||||||
return ResultType.error;
|
return ResultType.error;
|
||||||
|
@ -188,8 +195,14 @@ export class Executor {
|
||||||
hasSuccess = true;
|
hasSuccess = true;
|
||||||
} else if (type === ResultType.skip) {
|
} else if (type === ResultType.skip) {
|
||||||
hasSkip = true;
|
hasSkip = true;
|
||||||
|
} else if (type === ResultType.disabled) {
|
||||||
|
hasDisabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!hasSuccess && !hasSkip && hasDisabled) {
|
||||||
|
//全是disabled
|
||||||
|
return ResultType.disabled;
|
||||||
|
}
|
||||||
if (!hasSuccess && hasSkip) {
|
if (!hasSuccess && hasSkip) {
|
||||||
//全是跳过
|
//全是跳过
|
||||||
return ResultType.skip;
|
return ResultType.skip;
|
||||||
|
|
|
@ -150,10 +150,10 @@ export class SysSettingsService extends BaseService<SysSettingsEntity> {
|
||||||
|
|
||||||
async backupSecret() {
|
async backupSecret() {
|
||||||
const settings = await this.getSettingByKey(SysSecretBackup.__key__);
|
const settings = await this.getSettingByKey(SysSecretBackup.__key__);
|
||||||
|
const privateSettings = await this.getPrivateSettings();
|
||||||
|
const installInfo = await this.getSetting<SysInstallInfo>(SysInstallInfo);
|
||||||
if (settings == null) {
|
if (settings == null) {
|
||||||
const backup = new SysSecretBackup();
|
const backup = new SysSecretBackup();
|
||||||
const privateSettings = await this.getPrivateSettings();
|
|
||||||
const installInfo = await this.getSetting<SysInstallInfo>(SysInstallInfo);
|
|
||||||
if (installInfo.siteId == null || privateSettings.encryptSecret == null) {
|
if (installInfo.siteId == null || privateSettings.encryptSecret == null) {
|
||||||
logger.error('备份密钥失败,siteId或encryptSecret为空');
|
logger.error('备份密钥失败,siteId或encryptSecret为空');
|
||||||
return;
|
return;
|
||||||
|
@ -162,6 +162,14 @@ export class SysSettingsService extends BaseService<SysSettingsEntity> {
|
||||||
backup.encryptSecret = privateSettings.encryptSecret;
|
backup.encryptSecret = privateSettings.encryptSecret;
|
||||||
await this.saveSetting(backup);
|
await this.saveSetting(backup);
|
||||||
logger.info('备份密钥成功');
|
logger.info('备份密钥成功');
|
||||||
|
} else {
|
||||||
|
//校验是否有变化
|
||||||
|
if (settings.siteId !== installInfo.siteId) {
|
||||||
|
throw new Error(`siteId与备份不一致,可能是数据异常,请检查:backup=${settings.siteId}, current=${installInfo.siteId}`);
|
||||||
|
}
|
||||||
|
if (settings.encryptSecret !== privateSettings.encryptSecret) {
|
||||||
|
throw new Error('encryptSecret与备份不一致,可能是数据异常,请检查');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,8 +92,8 @@ export class AcmeService {
|
||||||
const urlMapping: UrlMapping = {
|
const urlMapping: UrlMapping = {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
mappings: {
|
mappings: {
|
||||||
"acme-v02.api.letsencrypt.org": this.options.reverseProxy || "letsencrypt.proxy.handsfree.work",
|
"acme-v02.api.letsencrypt.org": this.options.reverseProxy || "le.px.certd.handfree.work",
|
||||||
"dv.acme-v02.api.pki.goog": this.options.reverseProxy || "google.proxy.handsfree.work",
|
"dv.acme-v02.api.pki.goog": this.options.reverseProxy || "gg.px.certd.handfree.work",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const conf = await this.getAccountConfig(email, urlMapping);
|
const conf = await this.getAccountConfig(email, urlMapping);
|
||||||
|
|
Loading…
Reference in New Issue