fix(PortProxy): Ensure proper cleanup on connection rejection in PortProxy

This commit is contained in:
Philipp Kunz 2025-02-22 05:41:29 +00:00
parent c2547036fd
commit 2b266ca779
3 changed files with 10 additions and 1 deletions

View File

@ -1,5 +1,10 @@
# Changelog # Changelog
## 2025-02-22 - 3.9.4 - fix(PortProxy)
Ensure proper cleanup on connection rejection in PortProxy
- Added cleanup calls after socket end in connection rejection scenarios within PortProxy
## 2025-02-21 - 3.9.3 - fix(PortProxy) ## 2025-02-21 - 3.9.3 - fix(PortProxy)
Fix handling of optional outgoing socket in PortProxy Fix handling of optional outgoing socket in PortProxy

View File

@ -3,6 +3,6 @@
*/ */
export const commitinfo = { export const commitinfo = {
name: '@push.rocks/smartproxy', name: '@push.rocks/smartproxy',
version: '3.9.3', version: '3.9.4',
description: 'a proxy for handling high workloads of proxying' description: 'a proxy for handling high workloads of proxying'
} }

View File

@ -236,16 +236,19 @@ export class PortProxy {
if (!domainConfig) { if (!domainConfig) {
console.log(`Connection rejected: No matching domain config for ${serverName} from ${remoteIP}`); console.log(`Connection rejected: No matching domain config for ${serverName} from ${remoteIP}`);
socket.end(); socket.end();
cleanupOnce();
return; return;
} }
if (!isAllowed(remoteIP, domainConfig.allowedIPs)) { if (!isAllowed(remoteIP, domainConfig.allowedIPs)) {
console.log(`Connection rejected: IP ${remoteIP} not allowed for domain ${serverName}`); console.log(`Connection rejected: IP ${remoteIP} not allowed for domain ${serverName}`);
socket.end(); socket.end();
cleanupOnce();
return; return;
} }
} else if (!isDefaultAllowed && !serverName) { } else if (!isDefaultAllowed && !serverName) {
console.log(`Connection rejected: No SNI and IP ${remoteIP} not in default allowed list`); console.log(`Connection rejected: No SNI and IP ${remoteIP} not in default allowed list`);
socket.end(); socket.end();
cleanupOnce();
return; return;
} else { } else {
console.log(`Connection allowed: IP ${remoteIP} is in default allowed list`); console.log(`Connection allowed: IP ${remoteIP} is in default allowed list`);
@ -313,6 +316,7 @@ export class PortProxy {
if (!this.settings.defaultAllowedIPs || !isAllowed(remoteIP, this.settings.defaultAllowedIPs)) { if (!this.settings.defaultAllowedIPs || !isAllowed(remoteIP, this.settings.defaultAllowedIPs)) {
console.log(`Connection rejected: IP ${remoteIP} not allowed for non-SNI connection`); console.log(`Connection rejected: IP ${remoteIP} not allowed for non-SNI connection`);
socket.end(); socket.end();
cleanupOnce();
return; return;
} }
setupConnection(''); setupConnection('');