Skip to content

Commit 795cfdd

Browse files
Merge pull request #5 from mandatoryprogrammer/potential-crash-fix
Potential fix for crash
2 parents a9ae299 + 31c112b commit 795cfdd

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

anyproxy/lib/requestHandler.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,16 +282,15 @@ function getUserReqHandler(userRule, recorder) {
282282
var remote_port_key = req.socket.remotePort;
283283
var proxy_authentication_header = false;
284284

285-
// Automatically clean up the entry from the table once the
286-
// socket is properly terminated.
287-
req.socket.on('close', () => {
288-
delete global.proxyAuthPassthru[req.socket.remotePort];
289-
});
290-
291285
//console.log(`Source port for HTTPS connecting to us: ${req.socket.remotePort}`);
292286

293287
if(global.proxyAuthPassthru && remote_port_key in global.proxyAuthPassthru) {
294288
proxy_authentication_header = global.proxyAuthPassthru[remote_port_key]['proxy_authorization'];
289+
// Automatically clean up the entry from the table once the
290+
// socket is properly terminated.
291+
req.socket.on('close', () => {
292+
delete global.proxyAuthPassthru[remote_port_key];
293+
});
295294
}
296295

297296
if(proxy_authentication_header) {

0 commit comments

Comments
 (0)