From 0ca0996493c471fb21fe767ef8074a9c84fb774e Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Mon, 16 Mar 2020 22:47:26 +0100 Subject: [PATCH] close forwarded ports when session dies (fixes #2143) --- terminus-ssh/src/api.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/terminus-ssh/src/api.ts b/terminus-ssh/src/api.ts index 56f8c1d8..3f62cf4a 100644 --- a/terminus-ssh/src/api.ts +++ b/terminus-ssh/src/api.ts @@ -87,6 +87,13 @@ export class SSHSession extends BaseSession { constructor (public connection: SSHConnection) { super() this.scripts = connection.scripts || [] + this.destroyed$.subscribe(() => { + for (const port of this.forwardedPorts) { + if (port.type === PortForwardType.Local) { + port.stopLocalListener() + } + } + }) } async start (): Promise {