From 6ff58c55f570c6e618de85751446b9b132a0083a Mon Sep 17 00:00:00 2001 From: Bill Church Date: Mon, 14 Oct 2024 19:33:50 +0000 Subject: [PATCH] chore: update debug messages --- app/socket.js | 13 +++++++++++-- app/ssh.js | 8 ++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/app/socket.js b/app/socket.js index b5328e5a..f2011acd 100644 --- a/app/socket.js +++ b/app/socket.js @@ -191,11 +191,20 @@ class WebSSH2Socket extends EventEmitter { stream.on("data", data => { this.socket.emit("data", data.toString("utf-8")) }) - stream.stderr.on("data", data => debug(`STDERR: ${data}`)) + // stream.stderr.on("data", data => debug(`STDERR: ${data}`)) // needed for shell.exec stream.on("close", (code, signal) => { + debug("close: SSH Stream closed") this.handleConnectionClose(code, signal) }) + stream.on("end", () => { + debug("end: SSH Stream ended") + }) + + stream.on("error", (err) => { + debug("error: SSH Stream error %O", err) + }) + this.socket.on("data", data => { stream.write(data) }) @@ -206,7 +215,7 @@ class WebSSH2Socket extends EventEmitter { this.handleResize(data) }) }) - .catch(err => this.handleError("SHELL ERROR", err)) + .catch(err => this.handleError("createShell: ERROR", err)) } handleResize(data) { diff --git a/app/ssh.js b/app/ssh.js index 414b21aa..dc812a4a 100644 --- a/app/ssh.js +++ b/app/ssh.js @@ -48,6 +48,14 @@ class SSHConnection extends EventEmitter { resolve(this.conn) }) + this.conn.on("end", () => { + debug(`connect: end: `) + }) + + this.conn.on("close", () => { + debug(`connect: close: `) + }) + this.conn.on("error", err => { const error = new SSHConnectionError(`${err.message}`) handleError(error)