querysub 0.87.0 → 0.89.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.87.0",
3
+ "version": "0.89.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",
@@ -25,30 +25,18 @@ export async function hackDevtoolsWebsocketForward(config: {
25
25
  const path = require("path") as typeof import("path");
26
26
  const server = net.createServer();
27
27
 
28
- const debugFile = path.join(process.env.USERPROFILE || process.env.HOME || "", "debug.temp");
29
- //fs.writeFileSync(debugFile, "");
30
- const logPacket = (message: string, data?: Buffer) => {
31
- // const timestamp = new Date().toISOString();
32
- // fs.appendFileSync(
33
- // debugFile,
34
- // `${timestamp} ${message} ${data?.length}\n`
35
- // );
36
- };
37
-
38
28
  // Start listening on a random available port, binding to all interfaces (0.0.0.0)
39
29
  server.listen(0, "0.0.0.0");
40
30
 
41
31
  server.on("connection", (socket) => {
42
32
  const clientIP = socket.remoteAddress;
43
33
 
44
-
45
34
  if (clientIP !== configInner.externalIP) {
46
- logPacket(`Rejected connection attempt from unauthorized IP: ${clientIP}`);
47
35
  console.error(`Rejected connection attempt from unauthorized IP: ${clientIP}`);
48
36
  socket.destroy();
49
37
  return;
50
38
  }
51
- logPacket(`Accepted connection from ${clientIP}`);
39
+ console.log(`Accepted connection from ${clientIP}`);
52
40
 
53
41
  const address = server.address();
54
42
  if (!address || typeof address === "string") {
@@ -63,7 +51,6 @@ export async function hackDevtoolsWebsocketForward(config: {
63
51
  port: configInner.internalPort,
64
52
  });
65
53
  internalConnection.on("data", (data: Buffer) => {
66
- logPacket("SENT", data);
67
54
  socket.write(data);
68
55
  });
69
56
  let first = true;
@@ -75,25 +62,20 @@ export async function hackDevtoolsWebsocketForward(config: {
75
62
  lines[1] = `Host: 127.0.0.1:${configInner.internalPort}`;
76
63
  data = Buffer.from(lines.join("\r\n"));
77
64
  }
78
- logPacket("RECEIVED", data);
79
65
  internalConnection.write(data);
80
66
  });
81
67
 
82
68
  // Handle socket closure
83
69
  socket.on("close", () => {
70
+ console.log("Socket closed");
84
71
  internalConnection.destroy();
85
- logPacket("SENT");
72
+ //testing
86
73
  // IMPORTANT! We terminate when the connection is closed, which is what makes this safe.
87
- process.exit();
88
- });
89
- socket.on("error", (err: Error) => {
90
- internalConnection.destroy();
74
+ //process.exit();
91
75
  });
92
76
 
93
77
  internalConnection.on("close", () => {
94
- socket.destroy();
95
- });
96
- internalConnection.on("error", (err: Error) => {
78
+ console.log("Internal connection closed");
97
79
  socket.destroy();
98
80
  });
99
81
  });