querysub 0.107.0 → 0.108.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "querysub",
3
- "version": "0.107.0",
3
+ "version": "0.108.0",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "note1": "note on node-forge fork, see https://github.com/digitalbazaar/forge/issues/744 for details",
@@ -275,7 +275,7 @@ async function getHTTPSKeyCertInner(callerIP: string) {
275
275
  console.log(magenta(`Switching from local development to production development (removing A record for 127.0.0.1, and using a real ip)`));
276
276
  promises.push(deleteRecord("A", edgeDomain, "127.0.0.1"));
277
277
  }
278
- promises.push(addRecord("A", edgeDomain, callerIP));
278
+ promises.push(addRecord("A", edgeDomain, callerIP, "proxied"));
279
279
  runInfinitePoll(timeInMinute * 1, async () => {
280
280
  let ips = await getRecords("A", edgeDomain);
281
281
  if (!ips.includes(callerIP)) {
@@ -306,18 +306,29 @@ async function edgeNodeFunction(config: {
306
306
  // We check multiple at a time, so a node being unresponsive doesn't cause lag
307
307
  let PARALLEL_FACTOR = 3;
308
308
  for (let i = 0; i < edgeNodes.length; i += PARALLEL_FACTOR) {
309
- let promises = [];
310
- for (let j = 0; j < PARALLEL_FACTOR; j++) {
311
- promises.push((async () => {
312
- let node = edgeNodes[i + j];
313
- try {
314
- let alive = await isNodeAlive(node);
315
- if (alive) return node;
316
- } catch { }
317
- return undefined;
318
- })());
319
- }
320
- let node = await Promise.race(promises);
309
+ let node = await new Promise<EdgeNodeConfig | undefined>(resolve => {
310
+ for (let j = 0; j < PARALLEL_FACTOR; j++) {
311
+ let finished = 0;
312
+ ((async () => {
313
+ try {
314
+ let node = edgeNodes[i + j];
315
+ if (!node) return;
316
+ let alive = await isNodeAlive(node);
317
+ if (alive) {
318
+ resolve(node);
319
+ }
320
+ }
321
+ catch { }
322
+ finally {
323
+ finished++;
324
+ if (finished >= PARALLEL_FACTOR) {
325
+ resolve(undefined);
326
+ }
327
+ }
328
+ return undefined;
329
+ })()).catch(() => { });
330
+ }
331
+ });
321
332
  if (node) {
322
333
  return node;
323
334
  }