bdy 1.22.66-master → 1.22.67-master

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bdy",
3
3
  "preferGlobal": false,
4
- "version": "1.22.66-master",
4
+ "version": "1.22.67-master",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "scripts": {
@@ -33,6 +33,7 @@ class ServerSsh extends events_1.default {
33
33
  login;
34
34
  password;
35
35
  server;
36
+ injected = 0;
36
37
  constructor(agent, login, password, hostKey) {
37
38
  super();
38
39
  this.agent = agent;
@@ -82,8 +83,14 @@ class ServerSsh extends events_1.default {
82
83
  this.server = null;
83
84
  }
84
85
  handleSshTunnel(stream) {
85
- if (this.server)
86
+ if (this.server) {
87
+ this.injected += 1;
88
+ logger_1.default.debug(`injectSocket: ${this.injected} concurrent injected connection(s)`);
89
+ stream.once('close', () => {
90
+ this.injected -= 1;
91
+ });
86
92
  this.server.injectSocket(stream);
93
+ }
87
94
  }
88
95
  checkValueSafe(input, allowed) {
89
96
  const autoReject = input.length !== allowed.length;
@@ -73,16 +73,19 @@ class SshClient extends events_1.default {
73
73
  s.once('readable', resolve);
74
74
  });
75
75
  }
76
- async readStreamBytes(s, toRead) {
76
+ async readStreamBytes(s, toRead, reads = 0) {
77
77
  await this.waitForStreamReadable(s);
78
78
  const data = s.read(toRead) ?? s.read();
79
79
  if (data === null) {
80
- return this.readStreamBytes(s, toRead);
80
+ return this.readStreamBytes(s, toRead, reads + 1);
81
81
  }
82
82
  const newToRead = toRead - data.length;
83
- if (newToRead <= 0)
83
+ if (newToRead <= 0) {
84
+ if (reads > 0)
85
+ logger_1.default.debug(`handshake read took ${reads + 1} reads`);
84
86
  return data;
85
- const newData = await this.readStreamBytes(s, newToRead);
87
+ }
88
+ const newData = await this.readStreamBytes(s, newToRead, reads + 1);
86
89
  return Buffer.concat([data, newData]);
87
90
  }
88
91
  async processStream(stream, info) {
@@ -150,6 +153,7 @@ class SshClient extends events_1.default {
150
153
  }
151
154
  if (type === tunnel_1.TUNNEL_SOCKET_TYPE.SSH) {
152
155
  logger_1.default.debug((0, texts_1.LOG_DETECTED_STREAM)('SSH'));
156
+ logger_1.default.debug(`SSH handoff: ${stream.readableLength} leftover bytes buffered at injectSocket`);
153
157
  triggerStream(tunnel_1.TUNNEL_SSH_EVENT.STREAM_SSH, ip);
154
158
  return;
155
159
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bdy",
3
3
  "preferGlobal": false,
4
- "version": "1.22.66-master",
4
+ "version": "1.22.67-master",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "scripts": {