fix(PortProxy): Fix connection handling to include timeouts for SNI-enabled connections.

This commit is contained in:
2025-02-23 11:43:21 +00:00
parent e47436608f
commit f2f4e47893
3 changed files with 17 additions and 2 deletions

View File

@ -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'
}

View File

@ -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}`);