Compare commits

...

4 Commits

4 changed files with 28 additions and 12 deletions

View File

@ -1,5 +1,16 @@
# Changelog # Changelog
## 2025-02-23 - 3.10.2 - fix(PortProxy)
Fix connection handling to include timeouts for SNI-enabled connections.
- Added initial data timeout for SNI-enabled connections to improve connection handling.
- Cleared timeout once data is received to prevent premature socket closure.
## 2025-02-22 - 3.10.1 - fix(PortProxy)
Improve socket cleanup logic to prevent potential resource leaks
- Updated socket cleanup in PortProxy to ensure sockets are forcefully destroyed if not already destroyed.
## 2025-02-22 - 3.10.0 - feat(smartproxy.portproxy) ## 2025-02-22 - 3.10.0 - feat(smartproxy.portproxy)
Enhance PortProxy with detailed connection statistics and termination tracking Enhance PortProxy with detailed connection statistics and termination tracking

View File

@ -1,6 +1,6 @@
{ {
"name": "@push.rocks/smartproxy", "name": "@push.rocks/smartproxy",
"version": "3.10.0", "version": "3.10.2",
"private": false, "private": false,
"description": "a proxy for handling high workloads of proxying", "description": "a proxy for handling high workloads of proxying",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",

View File

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

View File

@ -149,16 +149,12 @@ export class PortProxy {
} }
public async start() { public async start() {
// Adjusted cleanUpSockets to allow an optional outgoing socket. // Adjusted cleanUpSockets: forcefully destroy both sockets if they haven't been destroyed.
const cleanUpSockets = (from: plugins.net.Socket, to?: plugins.net.Socket) => { const cleanUpSockets = (from: plugins.net.Socket, to?: plugins.net.Socket) => {
from.end(); if (!from.destroyed) {
from.removeAllListeners(); from.destroy();
from.unpipe(); }
from.destroy(); if (to && !to.destroyed) {
if (to) {
to.end();
to.removeAllListeners();
to.unpipe();
to.destroy(); to.destroy();
} }
}; };
@ -359,9 +355,18 @@ export class PortProxy {
to!.on('end', handleClose('outgoing')); to!.on('end', handleClose('outgoing'));
}; };
// For SNI-enabled connections, peek at the first chunk. // For SNI-enabled connections, set an initial data timeout before waiting for data.
if (this.settings.sniEnabled) { if (this.settings.sniEnabled) {
// Set an initial timeout for receiving data (e.g., 5 seconds)
socket.setTimeout(5000, () => {
console.log(`Initial data timeout for ${remoteIP}`);
socket.end();
cleanupOnce();
});
socket.once('data', (chunk: Buffer) => { socket.once('data', (chunk: Buffer) => {
// Clear the initial timeout since data has been received
socket.setTimeout(0);
initialDataReceived = true; initialDataReceived = true;
const serverName = extractSNI(chunk) || ''; const serverName = extractSNI(chunk) || '';
console.log(`Received connection from ${remoteIP} with SNI: ${serverName}`); console.log(`Received connection from ${remoteIP} with SNI: ${serverName}`);