socket-function 0.72.0 → 0.74.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/SocketFunction.ts CHANGED
@@ -419,6 +419,9 @@ export class SocketFunction {
419
419
  if (isNode()) {
420
420
  throw new Error("Cannot get browser nodeId on server");
421
421
  }
422
+ if (globalThis.BOOTED_EDGE_NODE) {
423
+ return globalThis.BOOTED_EDGE_NODE.host;
424
+ }
422
425
  return SocketFunction.connect({ address: location.hostname, port: +location.port || 443 });
423
426
  }
424
427
 
@@ -431,6 +434,15 @@ export class SocketFunction {
431
434
  }
432
435
 
433
436
 
437
+ declare global {
438
+ var BOOTED_EDGE_NODE: EdgeNodeConfig | undefined;
439
+ }
440
+ type EdgeNodeConfig = {
441
+ // EX: 127-0-0-1.example.com:3334
442
+ host: string;
443
+ };
444
+
445
+
434
446
  let socketContextSeqNum = 1;
435
447
 
436
448
  export function _setSocketContext<T>(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "socket-function",
3
- "version": "0.72.0",
3
+ "version": "0.74.0",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {
@@ -214,11 +214,14 @@ export async function startSocketServer(
214
214
  console.warn(`No SNI found in TLS hello from ${debug}, using main server. Packets ${packetCount}`);
215
215
  console.log(buffer.toString("base64"));
216
216
  }
217
- if (sni) {
218
- sni = sni.split(".").slice(-2).join(".");
219
- }
217
+
220
218
  if (!sniServers.has(sni)) {
221
- console.warn(`No SNI server found for ${sni}, using main server.`);
219
+ if (sni) {
220
+ sni = sni.split(".").slice(-2).join(".");
221
+ }
222
+ if (!sniServers.has(sni)) {
223
+ console.warn(`No SNI server found for ${sni}, using main server.`);
224
+ }
222
225
  }
223
226
  server = sniServers.get(sni) || mainHTTPSServer;
224
227
  }
@@ -68,7 +68,6 @@ export function setGetTimeOffsetBase(base: () => Promise<number>) {
68
68
  getTimeOffsetBase = base;
69
69
  }
70
70
 
71
-
72
71
  async function defaultGetTimeOffset(): Promise<number> {
73
72
  if (!isNode()) {
74
73
  let sendTime = baseGetTime();