From 525cbef68f4e424bc1cf7fb9cde63a933bbe4a39 Mon Sep 17 00:00:00 2001 From: chaos-zhu Date: Sat, 17 Aug 2024 00:18:12 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E4=BF=AE=E5=A4=8D=E7=BB=88=E7=AB=AF?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5=E5=A4=B1=E8=B4=A5=E5=BC=82=E5=B8=B8=E6=8A=9B?= =?UTF-8?q?=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/app/socket/terminal.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/app/socket/terminal.js b/server/app/socket/terminal.js index 3353476..455a2bf 100644 --- a/server/app/socket/terminal.js +++ b/server/app/socket/terminal.js @@ -128,11 +128,11 @@ module.exports = (httpServer) => { function listenerInput(key) { if (sshClient._sock.writable === false) return consola.info('终端连接已关闭,禁止输入') - stream.write(key) + stream && stream.write(key) } function resizeShell({ rows, cols }) { // consola.info('更改tty终端行&列: ', { rows, cols }) - stream.setWindow(rows, cols) + stream && stream.setWindow(rows, cols) } socket.on('input', listenerInput) socket.on('resize', resizeShell) @@ -144,6 +144,7 @@ module.exports = (httpServer) => { sshClient?.end() sshClient?.destroy() sshClient = null + stream = null setTimeout(async () => { // 初始化新的SSH客户端对象 sshClient = new SSHClient()