fix(PortProxy): Improve socket cleanup logic to prevent potential resource leaks

This commit is contained in:
2025-02-22 13:22:26 +00:00
parent c7697eca84
commit 128f8203ac
3 changed files with 11 additions and 10 deletions

View File

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

View File

@ -149,16 +149,12 @@ export class PortProxy {
}
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) => {
from.end();
from.removeAllListeners();
from.unpipe();
from.destroy();
if (to) {
to.end();
to.removeAllListeners();
to.unpipe();
if (!from.destroyed) {
from.destroy();
}
if (to && !to.destroyed) {
to.destroy();
}
};