From b5b11afd160fdf6c9209998683a068520f3ca115 Mon Sep 17 00:00:00 2001 From: thomas510111 Date: Mon, 2 May 2022 11:30:07 +0300 Subject: [PATCH] feat: `closeConnection` by id (#176) --- src/server.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/server.ts b/src/server.ts index b5eaf075..3431d674 100644 --- a/src/server.ts +++ b/src/server.ts @@ -570,6 +570,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. */