querysub 0.71.0 → 0.73.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.71.0",
3
+ "version": "0.73.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",
@@ -178,13 +178,13 @@ export async function publishMachineARecords() {
178
178
  await setRecord("A", "*." + machineAddress, ip);
179
179
  }
180
180
 
181
- export const verifyServicesAlive = lazy(() => {
182
-
183
- // NOTE: Our DNS TTL of 1 minute means we can't avoid downtime of 1 minute,
184
- // so shorter polling intervals will have very little benefit.
185
- runInfinitePoll(1000 * 60, removeDeadARecords);
181
+ const runEdgeDomainAliveLoop = lazy(() => {
182
+ // NOTE: Our DNS TTL is 1 minute, which means no matter how fast we poll,
183
+ // we can't get below that. Of course the worst case is that + our poll rate,
184
+ // but still, this means there is less and less benefit the lower this value is.
185
+ runInfinitePoll(1000 * 60, checkEdgeDomainsAlive);
186
186
  });
187
- async function removeDeadARecords() {
187
+ async function checkEdgeDomainsAlive() {
188
188
  if (isNoNetwork()) return;
189
189
  if (publicPort === -1) return;
190
190
  const edgeDomain = getDomain();
@@ -193,23 +193,29 @@ async function removeDeadARecords() {
193
193
  // and it will be removed when we leave development
194
194
  ips = ips.filter(ip => ip !== "127.0.0.1");
195
195
 
196
+ console.log(`Checking for dead records ${JSON.stringify(ips)}`);
197
+
196
198
  let results = await Promise.all(ips.map(async ip => {
197
199
  return await testTCPIsListening(ip, publicPort);
198
200
  }));
199
201
 
200
202
  let deadIPs = ips.filter((ip, i) => !results[i]);
203
+ if (deadIPs.length > 0) {
204
+ console.log(`Found dead IPs for ${edgeDomain}:${publicPort}, removing their A records: ${JSON.stringify(deadIPs)}`);
205
+ }
201
206
  for (let deadIP of deadIPs) {
202
207
  await deleteRecord("A", edgeDomain, deadIP);
203
208
  }
204
209
  }
205
210
 
206
211
  async function getHTTPSKeyCertInner(callerIP: string) {
212
+ runEdgeDomainAliveLoop();
207
213
  const edgeDomain = getDomain();
208
214
  if (callerIP) {
209
215
  try {
210
216
  let promises: Promise<void>[] = [];
211
217
  let existingIPs = await getRecords("A", edgeDomain);
212
- if (callerIP === "127.0.0.1") {
218
+ if (!isPublic()) {
213
219
  if (existingIPs.length === 0) {
214
220
  promises.push(addRecord("A", edgeDomain, callerIP));
215
221
  } else if (existingIPs.length === 1 && existingIPs[0] === "127.0.0.1") {
package/src/server.ts CHANGED
@@ -5,7 +5,7 @@ import { deepCloneJSON, isBufferType, isNode, isNodeTrue } from "socket-function
5
5
  import { SocketFunction } from "socket-function/SocketFunction";
6
6
  import { getOwnMachineId, getThreadKeyCert } from "./-a-auth/certs";
7
7
  import { logErrors } from "./errors";
8
- import { publishMachineARecords, verifyServicesAlive } from "./-e-certs/EdgeCertController";
8
+ import { publishMachineARecords } from "./-e-certs/EdgeCertController";
9
9
  import { getPathStr, getPathStr1, prependToPathStr, rootPathStr } from "./path";
10
10
  import { authorityStorage, debugCoreMode, debugRejections, enableDebugRejections, pathValueArchives } from "./0-path-value-core/pathValueCore";
11
11
  import { listenOnDebugger } from "./diagnostics/listenOnDebugger";
@@ -67,7 +67,5 @@ async function main() {
67
67
  autoForwardPort: true,
68
68
  });
69
69
 
70
- verifyServicesAlive();
71
-
72
70
  await publishMachineARecords();
73
71
  }