Compare commits

...

4 Commits

Author SHA1 Message Date
5e6477720d 3.0.9 2022-07-29 15:22:32 +02:00
bad8bf0688 fix(core): update 2022-07-29 15:22:31 +02:00
4f1db106fb 3.0.8 2022-07-29 04:25:01 +02:00
d47829a8b2 fix(core): update 2022-07-29 04:25:01 +02:00
4 changed files with 23 additions and 15 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "@pushrocks/smartproxy", "name": "@pushrocks/smartproxy",
"version": "3.0.7", "version": "3.0.9",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@pushrocks/smartproxy", "name": "@pushrocks/smartproxy",
"version": "3.0.7", "version": "3.0.9",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@pushrocks/lik": "^6.0.0", "@pushrocks/lik": "^6.0.0",

View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartproxy", "name": "@pushrocks/smartproxy",
"version": "3.0.7", "version": "3.0.9",
"private": false, "private": false,
"description": "a proxy for handling high workloads of proxying", "description": "a proxy for handling high workloads of proxying",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",

View File

@ -3,6 +3,6 @@
*/ */
export const commitinfo = { export const commitinfo = {
name: '@pushrocks/smartproxy', name: '@pushrocks/smartproxy',
version: '3.0.7', version: '3.0.9',
description: 'a proxy for handling high workloads of proxying' description: 'a proxy for handling high workloads of proxying'
} }

View File

@ -117,9 +117,6 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
`, `,
}, },
async (req, res) => { async (req, res) => {
console.log('got request');
const destinationConfig = this.router.routeReq(req);
/** /**
* endRequest function * endRequest function
* can be used to prematurely end a request * can be used to prematurely end a request
@ -133,6 +130,15 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
res.end(messageArg); res.end(messageArg);
}; };
console.log('got request');
const destinationConfig = this.router.routeReq(req);
if (!destinationConfig) {
console.log(`${req.headers.host} can't be routed properly. Terminating request.`);
endRequest();
return;
}
// authentication // authentication
if (destinationConfig.authentication) { if (destinationConfig.authentication) {
const authInfo = destinationConfig.authentication; const authInfo = destinationConfig.authentication;
@ -250,26 +256,28 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
this.httpsServer.headersTimeout = 65000; this.httpsServer.headersTimeout = 65000;
this.httpsServer.on('connection', (connection: plugins.net.Socket) => { this.httpsServer.on('connection', (connection: plugins.net.Socket) => {
connection.setTimeout(120000); connection.setTimeout(10000);
this.socketMap.add(connection); this.socketMap.add(connection);
const cleanupConnection = () => { const cleanupConnection = () => {
if (this.socketMap.checkForObject(connection)) { if (this.socketMap.checkForObject(connection)) {
this.socketMap.remove(connection); this.socketMap.remove(connection);
connection.end(); connection.end(() => {
connection.removeAllListeners();
connection.destroy(); connection.destroy();
connection.removeAllListeners();
console.log(`socket successfully destroyed`);
});
} }
}; };
connection.on('close', () => { connection.addListener('close', () => {
cleanupConnection(); cleanupConnection();
}); });
connection.on('error', () => { connection.addListener('error', () => {
cleanupConnection(); cleanupConnection();
}); });
connection.on('end', () => { connection.addListener('end', () => {
cleanupConnection(); cleanupConnection();
}); });
connection.on('timeout', () => { connection.addListener('timeout', () => {
cleanupConnection(); cleanupConnection();
}); });
}); });