fix(PortProxy): Update activity timestamp during TLS renegotiation to prevent connection timeouts

Ensures that TLS renegotiation packets properly update the connection's activity timestamp even when no SNI is present or when there are errors processing the renegotiation. This prevents connections from being closed due to inactivity during legitimate TLS renegotiation.

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Philipp Kunz 2025-03-11 02:40:08 +00:00
parent 99d28eafd1
commit 2bdd6f8c1f

View File

@ -867,6 +867,8 @@ export class PortProxy {
`[${connectionId}] Rehandshake detected without SNI, allowing it through.`
);
}
// Update the activity timestamp - critical for keeping the connection alive during renegotiation
this.updateActivity(record);
// Let it pass through - this is critical for Chrome's TLS handling
return;
}
@ -940,10 +942,14 @@ export class PortProxy {
);
this.initiateCleanupOnce(record, 'sni_mismatch');
}
} else if (newSNI && this.settings.enableDetailedLogging) {
console.log(
`[${connectionId}] Rehandshake detected with same SNI: ${newSNI}. Allowing.`
);
} else if (newSNI) {
if (this.settings.enableDetailedLogging) {
console.log(
`[${connectionId}] Rehandshake detected with same SNI: ${newSNI}. Allowing.`
);
}
// Update the activity timestamp
this.updateActivity(record);
}
} catch (err) {
// Always allow the renegotiation to continue if we encounter an error
@ -951,6 +957,8 @@ export class PortProxy {
console.log(
`[${connectionId}] Error processing potential renegotiation: ${err}. Allowing connection to continue.`
);
// Update the activity timestamp even on error
this.updateActivity(record);
}
}
});