core-3nweb-client-lib 0.50.0 → 0.50.1
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.
|
@@ -247,42 +247,42 @@ function makeServiceLocator(...resolvers) {
|
|
|
247
247
|
}
|
|
248
248
|
return (serviceLabel, logError) => async (address) => {
|
|
249
249
|
const domain = domainOfAddress(address);
|
|
250
|
-
let
|
|
250
|
+
let exc = undefined;
|
|
251
|
+
let connectionExc = undefined;
|
|
251
252
|
for (let i = 0; i < resolvers.length; i += 1) {
|
|
252
253
|
const resolver = resolvers[i];
|
|
254
|
+
let txtRecords;
|
|
253
255
|
try {
|
|
254
|
-
|
|
255
|
-
const recValue = extractPair(txtRecords, serviceLabel);
|
|
256
|
-
if (!recValue) {
|
|
257
|
-
throw noServiceRecordExc(address);
|
|
258
|
-
}
|
|
259
|
-
const url = checkAndPrepareURL(recValue);
|
|
260
|
-
return url;
|
|
256
|
+
txtRecords = await resolver.resolveTxt(domain);
|
|
261
257
|
}
|
|
262
258
|
catch (err) {
|
|
263
259
|
await logError(err, `Resolver ${i + 1} fails to get TXT records of ${domain}`);
|
|
264
260
|
const { code, hostname, message } = err;
|
|
265
261
|
if (code === exports.NODATA) {
|
|
266
|
-
|
|
262
|
+
exc = noServiceRecordExc(address);
|
|
267
263
|
}
|
|
268
264
|
else if ((code === exports.SERVFAIL)
|
|
269
265
|
|| (code === exports.CONNREFUSED)
|
|
270
266
|
|| (code === exports.TIMEOUT)) {
|
|
271
|
-
|
|
272
|
-
prevConnectionExc = noConnectionExc({ code, hostname, message });
|
|
273
|
-
}
|
|
267
|
+
connectionExc !== null && connectionExc !== void 0 ? connectionExc : (connectionExc = noConnectionExc({ code, hostname, message }));
|
|
274
268
|
}
|
|
275
269
|
else if ((code === exports.NOTFOUND) || hostname) {
|
|
276
|
-
|
|
270
|
+
exc !== null && exc !== void 0 ? exc : (exc = domainNotFoundExc(address, { code, hostname, message }));
|
|
277
271
|
}
|
|
278
272
|
else {
|
|
279
|
-
|
|
280
|
-
prevConnectionExc = err;
|
|
281
|
-
}
|
|
273
|
+
exc !== null && exc !== void 0 ? exc : (exc = err);
|
|
282
274
|
}
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
const recValue = extractPair(txtRecords, serviceLabel);
|
|
278
|
+
if (recValue) {
|
|
279
|
+
return checkAndPrepareURL(recValue);
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
282
|
+
exc !== null && exc !== void 0 ? exc : (exc = noServiceRecordExc(address));
|
|
283
283
|
}
|
|
284
284
|
}
|
|
285
|
-
throw
|
|
285
|
+
throw exc !== null && exc !== void 0 ? exc : connectionExc;
|
|
286
286
|
};
|
|
287
287
|
}
|
|
288
288
|
/**
|