querysub 0.280.0 → 0.281.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.280.0",
3
+ "version": "0.281.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",
@@ -403,8 +403,8 @@ export class ArchivesBackblaze {
403
403
  }
404
404
 
405
405
  let desiredCorsRules = this.config.public ? [{
406
- corsRuleName: "onlyCurrentOrigin",
407
- allowedOrigins: ["*"],
406
+ corsRuleName: "allowAll",
407
+ allowedOrigins: ["https"],
408
408
  allowedOperations: ["b2_download_file_by_id", "b2_download_file_by_name"],
409
409
  allowedHeaders: ["range"],
410
410
  exposeHeaders: ["x-bz-content-sha1"],
@@ -21,7 +21,7 @@ import { addRecord, deleteRecord, getRecords, hasDNSWritePermissions, setRecord
21
21
  import { SocketServerConfig } from "socket-function/src/webSocketServer";
22
22
  import debugbreak from "debugbreak";
23
23
  import { delay, runInfinitePoll, runInfinitePollCallAtStart } from "socket-function/src/batching";
24
- import { getDomain, isNoNetwork, isPublic } from "../config";
24
+ import { getDomain, isBootstrapOnly, isNoNetwork, isPublic } from "../config";
25
25
  import { requiresNetworkTrustHook } from "../-d-trust/NetworkTrust2";
26
26
  import { getExternalIP, testTCPIsListening } from "../misc/networking";
27
27
  import { magenta, yellow } from "socket-function/src/formatting/logColors";
@@ -250,7 +250,7 @@ async function getHTTPSKeyCertInner(callerIP: string) {
250
250
  // with our A record public while we create our cert.
251
251
  runEdgeDomainAliveLoop();
252
252
  const edgeDomain = getDomain();
253
- if (callerIP) {
253
+ if (callerIP && !isBootstrapOnly()) {
254
254
  try {
255
255
  let promises: Promise<void>[] = [];
256
256
  let existingIPs = await getRecords("A", edgeDomain);
@@ -773,7 +773,7 @@ export class Querysub {
773
773
  }
774
774
  }
775
775
 
776
- await SocketFunction.mount({
776
+ let mountedNodeId = await SocketFunction.mount({
777
777
  public: isPublic(),
778
778
  port: config.port,
779
779
  autoForwardPort: true,
@@ -785,42 +785,15 @@ export class Querysub {
785
785
  },
786
786
  allowHostnames,
787
787
  });
788
+ let port = getNodeIdLocation(mountedNodeId)?.port;
788
789
 
789
790
  let { ip, ipDomain } = await publishMachineARecords();
790
791
 
791
792
  if (!isBootstrapOnly()) {
792
793
  await registerEdgeNode({
793
- host: ipDomain + ":" + config.port,
794
+ host: ipDomain + ":" + port,
794
795
  entryPaths,
795
796
  });
796
- } else {
797
- // bootstraponly mode. Setup cloudflare proxy. If they are developing (localhost), we can't proxy, so don't (but still setup domain). Using the cloudflare proxy should prevent the site from entirely breaking if the bootstrapper goes down.
798
- let ip = await getHostedIP();
799
- let existingRecords = await getRecords("A", getDomain());
800
- if (ip !== "127.0.0.1") {
801
- let validRecords: string[] = [];
802
- // Ignore ourself, we want OTHER records.
803
- existingRecords = existingRecords.filter(x => x !== ip);
804
- await Promise.all(existingRecords.map(async (record) => {
805
- let isListening = await timeoutToUndefined(timeInSecond * 10, testTCPIsListening(record, 443));
806
- if (isListening) {
807
- validRecords.push(record);
808
- }
809
- }));
810
- // It's hard to manage multiple bootstrappers, so... just don't.
811
- if (validRecords.length > 0) {
812
- console.error(`Found existing bootstrapper at ${JSON.stringify(validRecords)}, so why are we even running? Terminating shortly`);
813
- // Give logs time to write
814
- await shutdown();
815
- }
816
- await setRecord("A", getDomain(), ip, "proxied");
817
- } else {
818
- if (existingRecords.length === 0) {
819
- await setRecord("A", ip, getDomain());
820
- } else {
821
- console.log(`Not clobbering existing A record for ${getDomain()} of ${JSON.stringify(existingRecords)}`);
822
- }
823
- }
824
797
  }
825
798
  }
826
799
  private static async addSourceMapCheck(config: {
@@ -1319,4 +1292,5 @@ import { blue } from "socket-function/src/formatting/logColors";
1319
1292
  import { MachineController } from "../deployManager/machineController";
1320
1293
  import { getRecords, setRecord } from "../-b-authorities/dnsAuthority";
1321
1294
  import { testTCPIsListening } from "socket-function/src/networking";
1295
+ import { getNodeId, getNodeIdLocation } from "socket-function/src/nodeCache";
1322
1296
 
@@ -1,3 +1,9 @@
1
+ OH! the bootstrap root index file has CORS issues
2
+ - We didn't notice this before because the cached value always worked?
3
+
4
+ The actual http registration isn't working? And our edgeNode file is so messy it's hard to see if it's there or not... ugh...
5
+
6
+
1
7
  8) Use a special service for the HTTP bootstrapper, and then have 2 others that are on other ports
2
8
  --bootstraponly is added, and should work?
3
9