From 31c112b87769207a6a884fe2814ca7c86ac5604e Mon Sep 17 00:00:00 2001 From: "Matthew Bryant (mandatory)" Date: Fri, 1 May 2020 13:33:59 -0700 Subject: [PATCH] Potential fix for crash --- anyproxy/lib/requestHandler.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/anyproxy/lib/requestHandler.js b/anyproxy/lib/requestHandler.js index 032fbfd..1fbb950 100644 --- a/anyproxy/lib/requestHandler.js +++ b/anyproxy/lib/requestHandler.js @@ -282,16 +282,15 @@ function getUserReqHandler(userRule, recorder) { var remote_port_key = req.socket.remotePort; var proxy_authentication_header = false; - // Automatically clean up the entry from the table once the - // socket is properly terminated. - req.socket.on('close', () => { - delete global.proxyAuthPassthru[req.socket.remotePort]; - }); - //console.log(`Source port for HTTPS connecting to us: ${req.socket.remotePort}`); if(global.proxyAuthPassthru && remote_port_key in global.proxyAuthPassthru) { proxy_authentication_header = global.proxyAuthPassthru[remote_port_key]['proxy_authorization']; + // Automatically clean up the entry from the table once the + // socket is properly terminated. + req.socket.on('close', () => { + delete global.proxyAuthPassthru[remote_port_key]; + }); } if(proxy_authentication_header) {