diff --git a/package-lock.json b/package-lock.json index 63cba90..fa4ad45 100644 --- a/package-lock.json +++ b/package-lock.json @@ -93,9 +93,9 @@ } }, "@pushrocks/lik": { - "version": "3.0.10", - "resolved": "https://verdaccio.lossless.one/@pushrocks%2flik/-/lik-3.0.10.tgz", - "integrity": "sha512-iWG06QsrL6AAnjPRWMVz4bRaRE0jJt/HgEK0YeLqaSBLY8ju4ps1j4lEN8VrUlXGZyPB6UGQfcreesO24buYhQ==", + "version": "3.0.11", + "resolved": "https://verdaccio.lossless.one/@pushrocks%2flik/-/lik-3.0.11.tgz", + "integrity": "sha512-SDKRPj9+xBTqozlDPcA7O6BcccM1Tw/sXPVP+OnhNxCubDZ/L2kGNpPpqm43NJUoNxSSo5wdBw4N7MAFYCGdVg==", "requires": { "@pushrocks/smartdelay": "^2.0.3", "@pushrocks/smartpromise": "^3.0.2", diff --git a/package.json b/package.json index 4f91687..9270f00 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "tslint-config-prettier": "^1.15.0" }, "dependencies": { + "@pushrocks/lik": "^3.0.11", "@pushrocks/smartnetwork": "^1.1.14", "@pushrocks/smartpromise": "^3.0.5", "@pushrocks/smartrequest": "^1.1.35", diff --git a/ts/smartproxy.classes.proxyworker.ts b/ts/smartproxy.classes.proxyworker.ts index ae8c8fd..3d6187d 100644 --- a/ts/smartproxy.classes.proxyworker.ts +++ b/ts/smartproxy.classes.proxyworker.ts @@ -7,6 +7,7 @@ export class ProxyWorker { public httpsServer: plugins.https.Server; // | plugins.http.Server; public port = 8001; public router = new SmartproxyRouter(); + public socketMap = new plugins.lik.Objectmap(); /** * starts the proxyInstance @@ -168,6 +169,14 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g= }); this.httpsServer.keepAliveTimeout = 61000; this.httpsServer.headersTimeout = 65000; + + this.httpsServer.on('connection', connection => { + this.socketMap.add(connection); + connection.on('close', () => { + this.socketMap.remove(connection); + }); + }); + this.httpsServer.listen(this.port); console.log(`OK: now listening for new connections on port ${this.port}`); } @@ -191,6 +200,9 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g= this.httpsServer.close(() => { done.resolve(); }); + await this.socketMap.forEach(async (socket) => { + socket.destroy(); + }); await done.promise; } } diff --git a/ts/smartproxy.plugins.ts b/ts/smartproxy.plugins.ts index 3e28f97..285ddc0 100644 --- a/ts/smartproxy.plugins.ts +++ b/ts/smartproxy.plugins.ts @@ -1,9 +1,10 @@ // node native scope import * as http from 'http'; import * as https from 'https'; +import * as net from 'net'; import * as url from 'url'; -export { http, https, url }; +export { http, https, net, url }; // tsclass scope import * as tsclass from '@tsclass/tsclass'; @@ -11,12 +12,13 @@ import * as tsclass from '@tsclass/tsclass'; export { tsclass }; // pushrocks scope +import * as lik from '@pushrocks/lik'; import * as smartpromise from '@pushrocks/smartpromise'; import * as smartrequest from '@pushrocks/smartrequest'; import * as smartspawn from '@pushrocks/smartspawn'; import * as smartsystem from '@pushrocks/smartsystem'; -export { smartrequest, smartpromise, smartspawn, smartsystem }; +export { lik, smartrequest, smartpromise, smartspawn, smartsystem }; // third party scope import * as ws from 'ws';