Compare commits
30 Commits
Author | SHA1 | Date | |
---|---|---|---|
be4fd0978a | |||
4521010b82 | |||
bd1f1a4c1c | |||
d3bdd56660 | |||
c38a7c4c32 | |||
858628196a | |||
4910679058 | |||
97db2012ca | |||
0ee13b4e06 | |||
21f5882fa3 | |||
48b43f9f0d | |||
d3d476fd53 | |||
b80b8a0a20 | |||
384943f697 | |||
e9239ed978 | |||
baf1844866 | |||
0b3d7f8a06 | |||
c38a2745e9 | |||
a0f39d1c5b | |||
c67ac868a5 | |||
90e1a0453e | |||
d7765fb5dc | |||
0fdd17b430 | |||
0562de6aa1 | |||
7b550a35aa | |||
fb66aac6e7 | |||
208790cfcf | |||
5978bbaf66 | |||
1c47eafe5f | |||
69e3a71354 |
18
package-lock.json
generated
18
package-lock.json
generated
@ -1,18 +1,18 @@
|
||||
{
|
||||
"name": "@pushrocks/smartproxy",
|
||||
"version": "3.0.16",
|
||||
"version": "3.0.31",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@pushrocks/smartproxy",
|
||||
"version": "3.0.16",
|
||||
"version": "3.0.31",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@pushrocks/lik": "^6.0.0",
|
||||
"@pushrocks/smartdelay": "^2.0.13",
|
||||
"@pushrocks/smartpromise": "^3.1.7",
|
||||
"@pushrocks/smartrequest": "^2.0.5",
|
||||
"@pushrocks/smartrequest": "^2.0.6",
|
||||
"@pushrocks/smartstring": "^4.0.2",
|
||||
"@tsclass/tsclass": "^4.0.17",
|
||||
"@types/ws": "^8.5.3",
|
||||
@ -1555,9 +1555,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@pushrocks/smartrequest": {
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartrequest/-/smartrequest-2.0.5.tgz",
|
||||
"integrity": "sha512-oUvFJv1PWmvXgYjMKhmxCvJWu3SsTFpw8f3Wh/czwyAbudpB2IRQZw3fC/KaFF8zzUnvijPMP185wOcjvnQWYA==",
|
||||
"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",
|
||||
@ -9974,9 +9974,9 @@
|
||||
}
|
||||
},
|
||||
"@pushrocks/smartrequest": {
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartrequest/-/smartrequest-2.0.5.tgz",
|
||||
"integrity": "sha512-oUvFJv1PWmvXgYjMKhmxCvJWu3SsTFpw8f3Wh/czwyAbudpB2IRQZw3fC/KaFF8zzUnvijPMP185wOcjvnQWYA==",
|
||||
"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",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/smartproxy",
|
||||
"version": "3.0.16",
|
||||
"version": "3.0.31",
|
||||
"private": false,
|
||||
"description": "a proxy for handling high workloads of proxying",
|
||||
"main": "dist_ts/index.js",
|
||||
@ -24,7 +24,7 @@
|
||||
"@pushrocks/lik": "^6.0.0",
|
||||
"@pushrocks/smartdelay": "^2.0.13",
|
||||
"@pushrocks/smartpromise": "^3.1.7",
|
||||
"@pushrocks/smartrequest": "^2.0.5",
|
||||
"@pushrocks/smartrequest": "^2.0.6",
|
||||
"@pushrocks/smartstring": "^4.0.2",
|
||||
"@tsclass/tsclass": "^4.0.17",
|
||||
"@types/ws": "^8.5.3",
|
||||
|
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@pushrocks/smartproxy',
|
||||
version: '3.0.16',
|
||||
version: '3.0.31',
|
||||
description: 'a proxy for handling high workloads of proxying'
|
||||
}
|
||||
|
@ -193,6 +193,16 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
|
||||
req.on('end', (data) => {
|
||||
request.end();
|
||||
});
|
||||
req.on('error', () => {
|
||||
request.end();
|
||||
});
|
||||
req.on('close', () => {
|
||||
request.end();
|
||||
});
|
||||
req.on('timeout', () => {
|
||||
req.destroy();
|
||||
request.end();
|
||||
})
|
||||
}
|
||||
);
|
||||
res.statusCode = response.statusCode;
|
||||
@ -209,6 +219,17 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
|
||||
response.on('end', () => {
|
||||
res.end();
|
||||
});
|
||||
response.on('error', () => {
|
||||
res.end();
|
||||
});
|
||||
response.on('close', () => {
|
||||
res.end();
|
||||
});
|
||||
response.on('timeout', () => {
|
||||
res.end();
|
||||
res.destroy()
|
||||
});
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
@ -216,70 +237,53 @@ 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();
|
||||
wsc.close();
|
||||
};
|
||||
|
||||
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(10000);
|
||||
let destroyed = false;
|
||||
this.socketMap.add(connection);
|
||||
console.log(`added connection. now ${this.socketMap.getArray().length} sockets connected.`);
|
||||
const destroyConnection = () => {
|
||||
if (!destroyed) {
|
||||
destroyed = true;
|
||||
connection.destroy();
|
||||
console.log(`socket successfully destroyed.`);
|
||||
plugins.smartdelay.delayFor(1000).then(() => {
|
||||
connection.removeAllListeners();
|
||||
});
|
||||
}
|
||||
}
|
||||
const cleanupConnection = () => {
|
||||
if (this.socketMap.checkForObject(connection)) {
|
||||
this.socketMap.remove(connection);
|
||||
plugins.smartdelay.delayFor(200).then(() => {
|
||||
destroyConnection();
|
||||
});
|
||||
console.log(`removed connection. ${this.socketMap.getArray().length} sockets remaining.`);
|
||||
connection.end(() => {
|
||||
destroyConnection();
|
||||
});
|
||||
connection.destroy();
|
||||
}
|
||||
};
|
||||
connection.on('close', () => {
|
||||
@ -293,7 +297,7 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
|
||||
});
|
||||
connection.on('timeout', () => {
|
||||
cleanupConnection();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
this.httpsServer.listen(this.options.port);
|
||||
|
Reference in New Issue
Block a user