Compare commits

...

36 Commits

Author SHA1 Message Date
48b43f9f0d 3.0.26 2022-07-30 22:29:31 +02:00
d3d476fd53 fix(core): update 2022-07-30 22:29:31 +02:00
b80b8a0a20 3.0.25 2022-07-30 22:20:31 +02:00
384943f697 fix(core): update 2022-07-30 22:20:31 +02:00
e9239ed978 3.0.24 2022-07-30 21:29:35 +02:00
baf1844866 fix(core): update 2022-07-30 21:29:34 +02:00
0b3d7f8a06 3.0.23 2022-07-30 21:28:08 +02:00
c38a2745e9 fix(core): update 2022-07-30 21:28:08 +02:00
a0f39d1c5b 3.0.22 2022-07-30 21:25:27 +02:00
c67ac868a5 fix(core): update 2022-07-30 21:25:27 +02:00
90e1a0453e 3.0.21 2022-07-30 19:28:24 +02:00
d7765fb5dc fix(core): update 2022-07-30 19:28:23 +02:00
0fdd17b430 3.0.20 2022-07-30 18:53:21 +02:00
0562de6aa1 fix(core): update 2022-07-30 18:53:21 +02:00
7b550a35aa 3.0.19 2022-07-30 18:49:14 +02:00
fb66aac6e7 fix(core): update 2022-07-30 18:49:14 +02:00
208790cfcf 3.0.18 2022-07-30 18:29:21 +02:00
5978bbaf66 fix(core): update 2022-07-30 18:29:20 +02:00
1c47eafe5f 3.0.17 2022-07-30 17:32:59 +02:00
69e3a71354 fix(core): update 2022-07-30 17:32:58 +02:00
21e92bf0c1 3.0.16 2022-07-30 17:26:36 +02:00
d732e6e7aa fix(core): update 2022-07-30 17:26:35 +02:00
5fdfcdb407 3.0.15 2022-07-30 13:30:25 +02:00
49e2e90bda fix(core): update 2022-07-30 13:30:25 +02:00
b8e53e7b42 3.0.14 2022-07-30 08:20:21 +02:00
1136841b3d fix(core): update 2022-07-30 08:20:20 +02:00
42cbc51d22 3.0.13 2022-07-30 02:07:32 +02:00
2d16403ad1 fix(core): update 2022-07-30 02:07:31 +02:00
afe847499a 3.0.12 2022-07-30 01:57:42 +02:00
f980bb70b4 fix(core): update 2022-07-30 01:57:42 +02:00
f192a8f041 3.0.11 2022-07-29 16:12:18 +02:00
64bf3aef6d fix(core): update 2022-07-29 16:12:18 +02:00
a5e3cbd05b 3.0.10 2022-07-29 15:26:03 +02:00
2f0fad999a fix(core): update 2022-07-29 15:26:02 +02:00
5e6477720d 3.0.9 2022-07-29 15:22:32 +02:00
bad8bf0688 fix(core): update 2022-07-29 15:22:31 +02:00
5 changed files with 73 additions and 48 deletions

19
package-lock.json generated
View File

@ -1,17 +1,18 @@
{
"name": "@pushrocks/smartproxy",
"version": "3.0.8",
"version": "3.0.26",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@pushrocks/smartproxy",
"version": "3.0.8",
"version": "3.0.26",
"license": "MIT",
"dependencies": {
"@pushrocks/lik": "^6.0.0",
"@pushrocks/smartdelay": "^2.0.13",
"@pushrocks/smartpromise": "^3.1.7",
"@pushrocks/smartrequest": "^2.0.0",
"@pushrocks/smartrequest": "^2.0.6",
"@pushrocks/smartstring": "^4.0.2",
"@tsclass/tsclass": "^4.0.17",
"@types/ws": "^8.5.3",
@ -1554,9 +1555,9 @@
}
},
"node_modules/@pushrocks/smartrequest": {
"version": "2.0.0",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartrequest/-/smartrequest-2.0.0.tgz",
"integrity": "sha512-Xmi+2xYvy67aOMg+XO08RaIZ2QjZZonvz7lEFx5esFzu4LIbwYOzN3GEmZ6/gz9yqdGCBknUxTSLfKCO/hZgTg==",
"version": "2.0.6",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartrequest/-/smartrequest-2.0.6.tgz",
"integrity": "sha512-rfE7vSr3ZrXLddCiyddU0vpL1ok0PbwL6bpd2gPNzwpCx4+q+4khQFADMKprzykRtQ4jYdKdhplJzwJGxBMI+g==",
"license": "MIT",
"dependencies": {
"@pushrocks/smartpromise": "^3.1.7",
@ -9973,9 +9974,9 @@
}
},
"@pushrocks/smartrequest": {
"version": "2.0.0",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartrequest/-/smartrequest-2.0.0.tgz",
"integrity": "sha512-Xmi+2xYvy67aOMg+XO08RaIZ2QjZZonvz7lEFx5esFzu4LIbwYOzN3GEmZ6/gz9yqdGCBknUxTSLfKCO/hZgTg==",
"version": "2.0.6",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartrequest/-/smartrequest-2.0.6.tgz",
"integrity": "sha512-rfE7vSr3ZrXLddCiyddU0vpL1ok0PbwL6bpd2gPNzwpCx4+q+4khQFADMKprzykRtQ4jYdKdhplJzwJGxBMI+g==",
"requires": {
"@pushrocks/smartpromise": "^3.1.7",
"@pushrocks/smarturl": "^3.0.2",

View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartproxy",
"version": "3.0.8",
"version": "3.0.26",
"private": false,
"description": "a proxy for handling high workloads of proxying",
"main": "dist_ts/index.js",
@ -22,8 +22,9 @@
},
"dependencies": {
"@pushrocks/lik": "^6.0.0",
"@pushrocks/smartdelay": "^2.0.13",
"@pushrocks/smartpromise": "^3.1.7",
"@pushrocks/smartrequest": "^2.0.0",
"@pushrocks/smartrequest": "^2.0.6",
"@pushrocks/smartstring": "^4.0.2",
"@tsclass/tsclass": "^4.0.17",
"@types/ws": "^8.5.3",

View File

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

View File

@ -130,7 +130,7 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
res.end(messageArg);
};
console.log('got request');
console.log(`got request: ${req.headers.host}${plugins.url.parse(req.url).path}`);
const destinationConfig = this.router.routeReq(req);
if (!destinationConfig) {
@ -193,6 +193,15 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
req.on('end', (data) => {
request.end();
});
req.on('error', () => {
request.end();
});
req.on('close', () => {
request.end();
});
req.on('timeout', () => {
request.end();
})
}
);
res.statusCode = response.statusCode;
@ -209,6 +218,16 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
response.on('end', () => {
res.end();
});
response.on('error', () => {
res.end();
});
response.on('close', () => {
res.end();
});
response.on('timeout', () => {
res.end();
});
}
);
@ -216,54 +235,56 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
const wss = new plugins.ws.WebSocketServer({ server: this.httpsServer });
wss.on('connection', (ws: plugins.wsDefault) => {
console.log('got connection for wsc');
const wscConnected = plugins.smartpromise.defer();
const wsc = new plugins.wsDefault(this.router.routeWs(ws), {
headers: {
Host: ws.url,
},
});
wsc.on('open', () => {
wscConnected.resolve();
});
let wscConnectedDeferred: plugins.smartpromise.Deferred<plugins.wsDefault>;
ws.on('message', async (message) => {
await wscConnected.promise;
if (!wscConnectedDeferred) {
wscConnectedDeferred = plugins.smartpromise.defer();
const wsc = new plugins.wsDefault(this.router.routeWs(ws), {
headers: {
Host: ws.url,
},
});
wsc.on('open', () => {
wscConnectedDeferred.resolve(wsc);
});
}
const wsc = await wscConnectedDeferred.promise;
wsc.emit('message', message);
});
wsc.on('message', (message) => {
ws.emit('message', message);
});
wsc.on('message', (message) => {
ws.emit('message', message);
});
// handle closing
const cleanUp = () => {
ws.close();
ws.terminate();
wsc.close();
wsc.terminate();
};
ws.on('close', (message) => {
cleanUp();
});
// handle closing
const cleanUp = () => {
ws.removeAllListeners();
ws.close();
ws.terminate();
wsc.removeAllListeners();
wsc.close();
wsc.terminate();
};
ws.on('close', (message) => {
cleanUp();
});
wsc.on('close', (message) => {
cleanUp();
wsc.on('close', (message) => {
cleanUp();
});
});
});
this.httpsServer.keepAliveTimeout = 61000;
this.httpsServer.headersTimeout = 65000;
this.httpsServer.on('connection', (connection: plugins.net.Socket) => {
connection.setTimeout(120000);
this.socketMap.add(connection);
console.log(`added connection. now ${this.socketMap.getArray().length} sockets connected.`);
const cleanupConnection = () => {
if (this.socketMap.checkForObject(connection)) {
this.socketMap.remove(connection);
connection.end();
connection.removeAllListeners();
console.log(`removed connection. ${this.socketMap.getArray().length} sockets remaining.`);
connection.destroy();
console.log(`socket successfully destroyed.`);
}
};
connection.on('close', () => {
@ -277,7 +298,7 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
});
connection.on('timeout', () => {
cleanupConnection();
});
})
});
this.httpsServer.listen(this.options.port);
@ -287,6 +308,7 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
}
public async updateProxyConfigs(proxyConfigsArg: plugins.tsclass.network.IReverseProxyConfig[]) {
console.log(`got new proxy configs`);
this.proxyConfigs = proxyConfigsArg;
this.router.setNewProxyConfigs(proxyConfigsArg);
for (const hostCandidate of this.proxyConfigs) {

View File

@ -13,11 +13,12 @@ export { tsclass };
// pushrocks scope
import * as lik from '@pushrocks/lik';
import * as smartdelay from '@pushrocks/smartdelay';
import * as smartpromise from '@pushrocks/smartpromise';
import * as smartrequest from '@pushrocks/smartrequest';
import * as smartstring from '@pushrocks/smartstring';
export { lik, smartrequest, smartpromise, smartstring };
export { lik, smartdelay, smartrequest, smartpromise, smartstring };
// third party scope
import * as ws from 'ws';