@electerm/ssh2 1.4.0 → 1.5.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/lib/server.js CHANGED
@@ -189,6 +189,7 @@ class Session extends EventEmitter {
189
189
 
190
190
  this.type = 'session';
191
191
  this.subtype = undefined;
192
+ this.server = true;
192
193
  this._ending = false;
193
194
  this._channel = undefined;
194
195
  this._chanInfo = {
@@ -556,6 +557,8 @@ class Client extends EventEmitter {
556
557
  reason = CHANNEL_OPEN_FAILURE.CONNECT_FAILED;
557
558
  }
558
559
 
560
+ if (localChan !== -1)
561
+ this._chanMgr.remove(localChan);
559
562
  proto.channelOpenFail(info.sender, reason, '');
560
563
  };
561
564
  const reserveChannel = () => {
package/lib/utils.js CHANGED
@@ -32,11 +32,17 @@ function onCHANNEL_CLOSE(self, recipient, channel, err, dead) {
32
32
  onChannelOpenFailure(self, recipient, err, channel);
33
33
  return;
34
34
  }
35
- if (typeof channel !== 'object'
36
- || channel === null
37
- || channel.incoming.state === 'closed') {
35
+
36
+ if (typeof channel !== 'object' || channel === null)
37
+ return;
38
+
39
+ if (channel.incoming && channel.incoming.state === 'closed')
40
+ return;
41
+
42
+ self._chanMgr.remove(recipient);
43
+
44
+ if (channel.server && channel.constructor.name === 'Session')
38
45
  return;
39
- }
40
46
 
41
47
  channel.incoming.state = 'closed';
42
48
 
@@ -58,8 +64,6 @@ function onCHANNEL_CLOSE(self, recipient, channel, err, dead) {
58
64
  if (channel.outgoing.state === 'closing')
59
65
  channel.outgoing.state = 'closed';
60
66
 
61
- self._chanMgr.remove(recipient);
62
-
63
67
  const readState = channel._readableState;
64
68
  const writeState = channel._writableState;
65
69
  if (writeState && !writeState.ending && !writeState.finished && !dead)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@electerm/ssh2",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "author": "Brian White <mscdex@mscdex.net>",
5
5
  "description": "SSH2 client and server modules written in pure JavaScript for node.js",
6
6
  "main": "./lib/index.js",