querysub 0.85.0 → 0.86.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.85.0",
3
+ "version": "0.86.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",
@@ -2,6 +2,8 @@ import debugbreak from "debugbreak";
2
2
  import * as net from "net";
3
3
  import ws from "ws";
4
4
  import child_process from "child_process";
5
+ import fs from "fs";
6
+ import path from "path";
5
7
 
6
8
  // Expose the internal port, via a tcp connection that we forward to internal port, for the first time
7
9
  // externalIP connects to us.
@@ -19,8 +21,19 @@ export async function hackDevtoolsWebsocketForward(config: {
19
21
  }> {
20
22
  const forwardCode = ((configInner: typeof config) => {
21
23
  const net = require("net");
24
+ const fs = require("fs");
25
+ const path = require("path");
22
26
  const server = net.createServer();
23
27
 
28
+ const debugFile = path.join(process.env.USERPROFILE || process.env.HOME, "debug.temp");
29
+ const logPacket = (direction: "RECEIVED" | "SENT", data: Buffer) => {
30
+ const timestamp = new Date().toISOString();
31
+ fs.appendFileSync(
32
+ debugFile,
33
+ `${timestamp} ${direction} ${data.length}\n`
34
+ );
35
+ };
36
+
24
37
  // Start listening on a random available port, binding to all interfaces (0.0.0.0)
25
38
  server.listen(0, "0.0.0.0");
26
39
 
@@ -46,6 +59,7 @@ export async function hackDevtoolsWebsocketForward(config: {
46
59
  port: configInner.internalPort,
47
60
  });
48
61
  internalConnection.on("data", (data: Buffer) => {
62
+ logPacket("SENT", data);
49
63
  socket.write(data);
50
64
  });
51
65
  let first = true;
@@ -57,6 +71,7 @@ export async function hackDevtoolsWebsocketForward(config: {
57
71
  lines[1] = `Host: 127.0.0.1:${configInner.internalPort}`;
58
72
  data = Buffer.from(lines.join("\r\n"));
59
73
  }
74
+ logPacket("RECEIVED", data);
60
75
  internalConnection.write(data);
61
76
  });
62
77