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 +1 -1
- package/src/-e-certs/EdgeCertController.ts +13 -7
- package/src/server.ts +1 -3
package/package.json
CHANGED
|
@@ -178,13 +178,13 @@ export async function publishMachineARecords() {
|
|
|
178
178
|
await setRecord("A", "*." + machineAddress, ip);
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
//
|
|
184
|
-
//
|
|
185
|
-
runInfinitePoll(1000 * 60,
|
|
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
|
|
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 (
|
|
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
|
|
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
|
}
|