socket-function 0.54.0 → 0.56.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": "socket-function",
3
- "version": "0.54.0",
3
+ "version": "0.56.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",
@@ -75,7 +75,6 @@ export async function startSocketServer(
75
75
  ca: getTrustedCertificates(),
76
76
  // Attempt to disable sessions, because they make SNI significantly harder to parse.
77
77
  secureOptions: require("node:constants").SSL_OP_NO_TICKET,
78
- keepAlive: false,
79
78
  };
80
79
  if (!httpsServerLast) {
81
80
  httpsServerLast = https.createServer(lastOptions);
@@ -158,6 +157,10 @@ export async function startSocketServer(
158
157
  // so it is easy to read, and consistent.
159
158
  let options: https.ServerOptions = {
160
159
  ...config,
160
+ // Keep alive causes problems with our HTTP requests. AND... almost all of our data uses
161
+ // our websockets, so... we really don't need to keep alive our HTTP requests
162
+ // (and our images go through cloudflare, so we don't even need keep alive for that)
163
+ keepAlive: false,
161
164
  };
162
165
  if (!config.cert) {
163
166
  throw new Error("No cert specified");
@@ -186,10 +189,10 @@ export async function startSocketServer(
186
189
 
187
190
  let realServer = net.createServer(socket => {
188
191
  //console.log("Received TCP connection from " + socket.remoteAddress);
189
- const remoteAddress = socket.remoteAddress;
192
+ const debug = socket.remoteAddress + ":" + socket.remotePort;
190
193
  function handleTLSHello(buffer: Buffer, packetCount: number): void | "more" {
191
194
  if (!SocketFunction.silent) {
192
- console.log(`Received TCP header packet from ${remoteAddress}, have ${buffer.length} bytes so far, ${packetCount} packets`);
195
+ console.log(`Received TCP header packet from ${debug}, have ${buffer.length} bytes so far, ${packetCount} packets`);
193
196
  }
194
197
  // All HTTPS requests start with 22, and no HTTP requests start with 22,
195
198
  // so we just need to read the first byte.
@@ -206,7 +209,7 @@ export async function startSocketServer(
206
209
  console.log(`Received TCP connection with SNI ${JSON.stringify(sni)}`);
207
210
  }
208
211
  if (!sni) {
209
- console.warn(`No SNI found in TLS hello from ${remoteAddress}, using main server. Packets ${packetCount}`);
212
+ console.warn(`No SNI found in TLS hello from ${debug}, using main server. Packets ${packetCount}`);
210
213
  console.log(buffer.toString("base64"));
211
214
  }
212
215
  server = sniServers.get(sni) || mainHTTPSServer;
@@ -231,7 +234,7 @@ export async function startSocketServer(
231
234
  }
232
235
  getNextData();
233
236
  socket.on("error", (e) => {
234
- console.error(`Socket error for ${remoteAddress}, ${e.stack}`);
237
+ console.error(`Socket error for ${debug}, ${e.stack}`);
235
238
  });
236
239
  });
237
240