ssh-client-wrapper 1.8.1 → 1.8.2
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/fork.js +2 -1
- package/lib/sshExec.js +8 -3
- package/package.json +2 -2
package/lib/fork.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const debug = require("debug")("sshClientWrapper:fork");
|
|
3
3
|
const debugVerbose = require("debug")("sshClientWrapper:fork_verbose");
|
|
4
|
+
const debugMasterVerbose = require("debug")("sshClientWrapper:fork_masterPty_verbose");
|
|
4
5
|
const debugSendPty = require("debug")("sshClientWrapper:fork_sendpty");
|
|
5
6
|
const { spawn } = require("node-pty");
|
|
6
7
|
|
|
@@ -53,7 +54,7 @@ function sshLoginCallback(output, ptyProcess, pw, ph) {
|
|
|
53
54
|
function getMasterPty(hostInfo) {
|
|
54
55
|
debug("fork pty for master connection");
|
|
55
56
|
const ptyProcess = spawn(nodePtyOpt.shell, [], nodePtyOpt);
|
|
56
|
-
ptyProcess.onData(buff2String.bind(null,
|
|
57
|
+
ptyProcess.onData(buff2String.bind(null, debugMasterVerbose));
|
|
57
58
|
ptyProcess.onData((data)=>{
|
|
58
59
|
const output = data.toString();
|
|
59
60
|
sshLoginCallback(output, ptyProcess, hostInfo.password, hostInfo.passphrase);
|
package/lib/sshExec.js
CHANGED
|
@@ -80,6 +80,8 @@ async function existsMaster(hostInfo) {
|
|
|
80
80
|
const timeout = hostInfo.ConnectTimeout || 60;
|
|
81
81
|
setTimeoutPromise(timeout * 1000, "neverUsedValue", { signal })
|
|
82
82
|
.then(()=>{
|
|
83
|
+
debug(`can not finish master session check within ${timeout} sec`);
|
|
84
|
+
|
|
83
85
|
if (p.pty) {
|
|
84
86
|
p.pty.kill();
|
|
85
87
|
}
|
|
@@ -93,7 +95,6 @@ async function existsMaster(hostInfo) {
|
|
|
93
95
|
}
|
|
94
96
|
});
|
|
95
97
|
|
|
96
|
-
|
|
97
98
|
try {
|
|
98
99
|
debug(`check master session: ${sshCmd} ${args.join(" ")}`);
|
|
99
100
|
p = fork(hostInfo, sshCmd, args, cb);
|
|
@@ -131,17 +132,21 @@ async function connect(hostInfo, timeout = 60) {
|
|
|
131
132
|
const signal = ac.signal;
|
|
132
133
|
setTimeoutPromise(timeout * 1000, "neverUsedValue", { signal })
|
|
133
134
|
.then(()=>{
|
|
135
|
+
debug(`can not connect within ${timeout} sec`);
|
|
136
|
+
hostInfo.masterPty.write("\n");
|
|
137
|
+
hostInfo.masterPty.write("exit\n");
|
|
138
|
+
|
|
134
139
|
const err = new Error(`can not connect within ${timeout} sec`);
|
|
135
140
|
err.host = hostInfo.host;
|
|
136
141
|
err.user = hostInfo.user;
|
|
137
142
|
err.port = hostInfo.port;
|
|
138
|
-
hostInfo.masterPty.write("\n");
|
|
139
|
-
hostInfo.masterPty.write("exit\n");
|
|
140
143
|
throw err;
|
|
141
144
|
})
|
|
142
145
|
.catch((err)=>{
|
|
143
146
|
if (err.name === "AbortError") {
|
|
144
147
|
debug("timeout was aborted because connection check has done");
|
|
148
|
+
} else {
|
|
149
|
+
throw err;
|
|
145
150
|
}
|
|
146
151
|
});
|
|
147
152
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ssh-client-wrapper",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.2",
|
|
4
4
|
"description": "wrapper library for open ssh client and rsync",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ssh",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"debug": "^4.3.4",
|
|
38
|
-
"glob": "^10.3.
|
|
38
|
+
"glob": "^10.3.3",
|
|
39
39
|
"node-pty": "^0.10.1",
|
|
40
40
|
"nyc": "^15.1.0",
|
|
41
41
|
"promise-retry": "^2.0.1"
|