diff --git a/changelog.md b/changelog.md index 587a915..af4ca21 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,11 @@ # 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 diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index b2b1539..cce672b 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@push.rocks/smartproxy', - version: '3.10.1', + version: '3.10.2', description: 'a proxy for handling high workloads of proxying' } diff --git a/ts/smartproxy.portproxy.ts b/ts/smartproxy.portproxy.ts index a4182b6..1d29120 100644 --- a/ts/smartproxy.portproxy.ts +++ b/ts/smartproxy.portproxy.ts @@ -355,9 +355,18 @@ export class PortProxy { 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) { + // 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) => { + // Clear the initial timeout since data has been received + socket.setTimeout(0); initialDataReceived = true; const serverName = extractSNI(chunk) || ''; console.log(`Received connection from ${remoteIP} with SNI: ${serverName}`);