From 5dbb699f016ec9eee2444bddcc3ca29d1f209911 Mon Sep 17 00:00:00 2001 From: Thomas Kosmas Date: Tue, 2 Nov 2021 20:30:35 +0200 Subject: [PATCH] Add method to close a specific pending proxy connection --- src/server.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/server.ts b/src/server.ts index 6affc746..bb2c0710 100644 --- a/src/server.ts +++ b/src/server.ts @@ -564,6 +564,20 @@ export class Server extends EventEmitter { return result; } + /** + * Forcibly close a specific pending proxy connection. + */ + closeConnection(connectionId: unknown): void { + this.log(null, 'Closing pending socket'); + + const socket = this.connections.get(connectionId); + if (!socket) return; + + socket.destroy(); + + this.log(null, `Destroyed pending socket`); + } + /** * Forcibly closes pending proxy connections. */