perf: 触发证书重新申请input变化对比规则优化,减少升级版本后触发申请证书的情况

This commit is contained in:
xiaojunnuo
2024-10-16 12:20:42 +08:00
parent 84fd3b250d
commit c46a2a9a39
10 changed files with 57 additions and 18 deletions

View File

@@ -5,6 +5,7 @@ import { CertReader } from "./cert-reader.js";
import JSZip from "jszip";
import { CertConverter } from "./convert.js";
import fs from "fs";
import { pick } from "lodash-es";
export { CertReader };
export type { CertInfo };
@@ -203,10 +204,35 @@ export abstract class CertApplyBasePlugin extends AbstractTaskPlugin {
return null;
}
const inputChanged = this.ctx.inputChanged;
let inputChanged = this.ctx.inputChanged;
if (inputChanged) {
this.logger.info("输入参数变更,准备申请证书");
return null;
this.logger.info("input hash 有变更,检查是否需要重新申请证书");
//判断域名有没有变更
/**
* "renewDays": 20,
* "certApplyPlugin": "CertApply",
* "sslProvider": "letsencrypt",
* "privateKeyType": "rsa_2048_pkcs1",
* "dnsProviderType": "aliyun",
* "domains": [
* "*.handsfree.work"
* ],
* "email": "xiaojunnuo@qq.com",
* "dnsProviderAccess": 3,
* "useProxy": false,
* "skipLocalVerify": false,
* "successNotify": true,
* "pfxPassword": "123456"
*/
const checkInputChanges = ["domains", "sslProvider", "privateKeyType", "dnsProviderType", "dnsProviderAccess", "pfxPassword"];
const oldInput = JSON.stringify(pick(this.lastStatus?.input, checkInputChanges));
const thisInput = JSON.stringify(pick(this, checkInputChanges));
inputChanged = oldInput !== thisInput;
if (inputChanged) {
this.logger.info("输入参数变更,准备申请新证书");
return null;
}
}
let oldCert: CertReader | undefined = undefined;