roster-server 2.1.27 → 2.1.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +3 -3
- package/package.json +1 -1
- package/vendor/acme-dns-01-cli-wrapper.js +45 -8
package/index.js
CHANGED
|
@@ -258,7 +258,7 @@ class Roster {
|
|
|
258
258
|
provided.module = defaultDnsChallengeModule;
|
|
259
259
|
}
|
|
260
260
|
if (provided.propagationDelay === undefined) {
|
|
261
|
-
provided.propagationDelay =
|
|
261
|
+
provided.propagationDelay = 120000;
|
|
262
262
|
}
|
|
263
263
|
if (provided.autoContinue === undefined) {
|
|
264
264
|
provided.autoContinue = false;
|
|
@@ -270,9 +270,9 @@ class Roster {
|
|
|
270
270
|
} else {
|
|
271
271
|
this.dnsChallenge = {
|
|
272
272
|
module: defaultDnsChallengeModule,
|
|
273
|
-
propagationDelay:
|
|
273
|
+
propagationDelay: 120000,
|
|
274
274
|
autoContinue: false,
|
|
275
|
-
dryRunDelay:
|
|
275
|
+
dryRunDelay: 120000
|
|
276
276
|
};
|
|
277
277
|
}
|
|
278
278
|
}
|
package/package.json
CHANGED
|
@@ -81,6 +81,23 @@ module.exports.create = function create(config = {}) {
|
|
|
81
81
|
: Number.isFinite(Number(process.env.ROSTER_DNS_POLL_TIMEOUT_MS))
|
|
82
82
|
? Number(process.env.ROSTER_DNS_POLL_TIMEOUT_MS)
|
|
83
83
|
: null;
|
|
84
|
+
const dryRunPollTimeoutMs = Number.isFinite(config.dryRunPollTimeoutMs)
|
|
85
|
+
? config.dryRunPollTimeoutMs
|
|
86
|
+
: Number.isFinite(Number(process.env.ROSTER_DNS_DRYRUN_POLL_TIMEOUT_MS))
|
|
87
|
+
? Number(process.env.ROSTER_DNS_DRYRUN_POLL_TIMEOUT_MS)
|
|
88
|
+
: null;
|
|
89
|
+
const parseResolvers = (value) => String(value || '')
|
|
90
|
+
.split(',')
|
|
91
|
+
.map((s) => s.trim())
|
|
92
|
+
.filter(Boolean);
|
|
93
|
+
const configuredResolvers = Array.isArray(config.dnsResolvers)
|
|
94
|
+
? config.dnsResolvers.map((s) => String(s).trim()).filter(Boolean)
|
|
95
|
+
: parseResolvers(process.env.ROSTER_DNS_RESOLVERS);
|
|
96
|
+
const resolverClients = configuredResolvers.map((server) => {
|
|
97
|
+
const resolver = new dns.Resolver();
|
|
98
|
+
resolver.setServers([server]);
|
|
99
|
+
return { server, resolver };
|
|
100
|
+
});
|
|
84
101
|
|
|
85
102
|
function sleep(ms) {
|
|
86
103
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -95,10 +112,29 @@ module.exports.create = function create(config = {}) {
|
|
|
95
112
|
return candidate ? String(candidate).trim() : '';
|
|
96
113
|
}
|
|
97
114
|
|
|
115
|
+
async function resolveTxtRecords(dnsHost) {
|
|
116
|
+
const records = [];
|
|
117
|
+
if (resolverClients.length === 0) {
|
|
118
|
+
return await dns.resolveTxt(dnsHost);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
for (const { resolver } of resolverClients) {
|
|
122
|
+
try {
|
|
123
|
+
const result = await resolver.resolveTxt(dnsHost);
|
|
124
|
+
if (Array.isArray(result)) {
|
|
125
|
+
records.push(...result);
|
|
126
|
+
}
|
|
127
|
+
} catch (_) {
|
|
128
|
+
// Try next configured resolver
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return records;
|
|
132
|
+
}
|
|
133
|
+
|
|
98
134
|
async function hasDnsTxtToken(dnsHost, expectedToken) {
|
|
99
135
|
if (!dnsHost || !expectedToken) return false;
|
|
100
136
|
try {
|
|
101
|
-
const records = await
|
|
137
|
+
const records = await resolveTxtRecords(dnsHost);
|
|
102
138
|
for (const recordParts of records || []) {
|
|
103
139
|
const joined = (recordParts || []).map(normalizeTxtChunk).join('').trim();
|
|
104
140
|
if (joined === expectedToken) return true;
|
|
@@ -111,10 +147,9 @@ module.exports.create = function create(config = {}) {
|
|
|
111
147
|
|
|
112
148
|
async function waitForDnsTxtPropagation(dnsHost, expectedToken, timeoutMs) {
|
|
113
149
|
const started = Date.now();
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
while ((Date.now() - started) <= maxWait) {
|
|
150
|
+
const hasFiniteTimeout = Number.isFinite(timeoutMs) && timeoutMs >= 0;
|
|
151
|
+
const maxWait = hasFiniteTimeout ? timeoutMs : null;
|
|
152
|
+
while (maxWait === null || (Date.now() - started) <= maxWait) {
|
|
118
153
|
if (await hasDnsTxtToken(dnsHost, expectedToken)) return true;
|
|
119
154
|
await sleep(Math.max(1000, dnsPollIntervalMs));
|
|
120
155
|
}
|
|
@@ -142,7 +177,9 @@ module.exports.create = function create(config = {}) {
|
|
|
142
177
|
const effectiveDelay = isDryRunChallenge
|
|
143
178
|
? Math.max(0, dryRunDelay)
|
|
144
179
|
: propagationDelay;
|
|
145
|
-
const effectiveTimeoutMs =
|
|
180
|
+
const effectiveTimeoutMs = isDryRunChallenge
|
|
181
|
+
? dryRunPollTimeoutMs
|
|
182
|
+
: (dnsPollTimeoutMs === null ? effectiveDelay : dnsPollTimeoutMs);
|
|
146
183
|
const expectedToken = resolveExpectedToken(opts, ch);
|
|
147
184
|
|
|
148
185
|
log.info('DNS-01 ' + altname);
|
|
@@ -152,7 +189,7 @@ module.exports.create = function create(config = {}) {
|
|
|
152
189
|
'DNS verification enabled. Continuing automatically when TXT appears at ' +
|
|
153
190
|
dnsHost +
|
|
154
191
|
' (timeout ' +
|
|
155
|
-
effectiveTimeoutMs +
|
|
192
|
+
(effectiveTimeoutMs === null ? 'infinite' : effectiveTimeoutMs) +
|
|
156
193
|
'ms, poll ' +
|
|
157
194
|
dnsPollIntervalMs +
|
|
158
195
|
'ms).'
|
|
@@ -163,7 +200,7 @@ module.exports.create = function create(config = {}) {
|
|
|
163
200
|
return null;
|
|
164
201
|
}
|
|
165
202
|
log.warn(
|
|
166
|
-
`DNS TXT not detected for ${dnsHost} within ${effectiveTimeoutMs}
|
|
203
|
+
`DNS TXT not detected for ${dnsHost} within ${effectiveTimeoutMs}; ` +
|
|
167
204
|
'continuing anyway (ACME preflight may still fail).'
|
|
168
205
|
);
|
|
169
206
|
return null;
|