perf: 优化华为dns解析记录创建和删除问题

This commit is contained in:
xiaojunnuo
2025-04-05 00:24:57 +08:00
parent 857589b365
commit 0948c5bc69
5 changed files with 124 additions and 54 deletions
+3 -1
View File
@@ -149,7 +149,7 @@ export default async (client, userOpts) => {
}
challengeCompleted = true;
log(`[auto] [${d}] 等待返回valid状态`);
await client.waitForValidStatus(challenge);
await client.waitForValidStatus(challenge,d);
});
@@ -242,6 +242,8 @@ export default async (client, userOpts) => {
await wait(60 * 1000);
} else {
await runPromisePa(localVerifyTasks, 1000);
log("本地校验完成,等待30s")
await wait(30 * 1000)
}
log("开始向提供商请求挑战验证");
+6 -6
View File
@@ -554,9 +554,9 @@ class AcmeClient {
* ```
*/
async waitForValidStatus(item) {
async waitForValidStatus(item,d) {
if (!item.url) {
throw new Error('Unable to verify status of item, URL not found');
throw new Error(`[${d}] Unable to verify status of item, URL not found`);
}
const verifyFn = async (abort) => {
@@ -568,23 +568,23 @@ class AcmeClient {
const resp = await this.api.apiRequest(item.url, null, [200]);
/* Verify status */
log(`Item has status(挑战状态): ${resp.data.status}`);
log(`[${d}] Item has status(挑战状态): ${resp.data.status}`);
if (invalidStates.includes(resp.data.status)) {
abort();
throw new Error(util.formatResponseError(resp));
}
else if (pendingStates.includes(resp.data.status)) {
throw new Error('Operation is pending or processing(当前仍然在等待状态)');
throw new Error(`[${d}] Operation is pending or processing(当前仍然在等待状态)`);
}
else if (validStates.includes(resp.data.status)) {
return resp.data;
}
throw new Error(`Unexpected item status: ${resp.data.status}`);
throw new Error(`[${d}] Unexpected item status: ${resp.data.status}`);
};
log(`Waiting for valid status (等待valid状态): ${item.url}`, this.backoffOpts);
log(`[${d}] Waiting for valid status (等待valid状态): ${item.url}`, this.backoffOpts);
return util.retry(verifyFn, this.backoffOpts);
}
+2 -2
View File
@@ -147,12 +147,12 @@ async function verifyDnsChallenge(authz, challenge, keyAuthorization, prefix = '
let recordValues = await walkTxtRecord(recordName);
//去重
recordValues = [...new Set(recordValues)];
log(`DNS查询成功, 找到 ${recordValues.length} 条TXT记录`);
log(`DNS查询成功, 找到 ${recordValues.length} 条TXT记录${recordValues}`);
if (!recordValues.length || !recordValues.includes(keyAuthorization)) {
throw new Error(`没有找到需要的DNS TXT记录: ${recordName},期望:${keyAuthorization},结果:${recordValues}`);
}
log(`关键授权匹配成功(${challenge.type}/${recordName},校验成功, ACME challenge verified`);
log(`关键授权匹配成功(${challenge.type}/${recordName}:${keyAuthorization}校验成功 ACME challenge verified`);
return true;
}