Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
a0f39d1c5b | |||
c67ac868a5 | |||
90e1a0453e | |||
d7765fb5dc | |||
0fdd17b430 | |||
0562de6aa1 |
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartproxy",
|
"name": "@pushrocks/smartproxy",
|
||||||
"version": "3.0.19",
|
"version": "3.0.22",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@pushrocks/smartproxy",
|
"name": "@pushrocks/smartproxy",
|
||||||
"version": "3.0.19",
|
"version": "3.0.22",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/lik": "^6.0.0",
|
"@pushrocks/lik": "^6.0.0",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartproxy",
|
"name": "@pushrocks/smartproxy",
|
||||||
"version": "3.0.19",
|
"version": "3.0.22",
|
||||||
"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",
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@pushrocks/smartproxy',
|
name: '@pushrocks/smartproxy',
|
||||||
version: '3.0.19',
|
version: '3.0.22',
|
||||||
description: 'a proxy for handling high workloads of proxying'
|
description: 'a proxy for handling high workloads of proxying'
|
||||||
}
|
}
|
||||||
|
@ -201,6 +201,7 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
|
|||||||
});
|
});
|
||||||
req.on('timeout', () => {
|
req.on('timeout', () => {
|
||||||
request.end();
|
request.end();
|
||||||
|
request.destroy();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -226,6 +227,7 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
|
|||||||
});
|
});
|
||||||
response.on('timeout', () => {
|
response.on('timeout', () => {
|
||||||
res.end();
|
res.end();
|
||||||
|
res.destroy();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -234,67 +236,64 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
|
|||||||
const wss = new plugins.ws.WebSocketServer({ server: this.httpsServer });
|
const wss = new plugins.ws.WebSocketServer({ server: this.httpsServer });
|
||||||
wss.on('connection', (ws: plugins.wsDefault) => {
|
wss.on('connection', (ws: plugins.wsDefault) => {
|
||||||
console.log('got connection for wsc');
|
console.log('got connection for wsc');
|
||||||
const wscConnected = plugins.smartpromise.defer();
|
let wscConnectedDeferred: plugins.smartpromise.Deferred<plugins.wsDefault>;
|
||||||
|
|
||||||
const wsc = new plugins.wsDefault(this.router.routeWs(ws), {
|
|
||||||
headers: {
|
|
||||||
Host: ws.url,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
wsc.on('open', () => {
|
|
||||||
wscConnected.resolve();
|
|
||||||
});
|
|
||||||
|
|
||||||
ws.on('message', async (message) => {
|
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.emit('message', message);
|
||||||
});
|
wsc.on('message', (message) => {
|
||||||
wsc.on('message', (message) => {
|
ws.emit('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
|
wsc.on('close', (message) => {
|
||||||
const cleanUp = () => {
|
cleanUp();
|
||||||
ws.close();
|
});
|
||||||
ws.terminate();
|
|
||||||
ws.removeAllListeners();
|
|
||||||
wsc.close();
|
|
||||||
wsc.terminate();
|
|
||||||
wsc.removeAllListeners();
|
|
||||||
};
|
|
||||||
|
|
||||||
ws.on('close', (message) => {
|
|
||||||
cleanUp();
|
|
||||||
});
|
|
||||||
wsc.on('close', (message) => {
|
|
||||||
cleanUp();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
this.httpsServer.keepAliveTimeout = 61000;
|
this.httpsServer.keepAliveTimeout = 61000;
|
||||||
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(60000);
|
connection.setTimeout(60000);
|
||||||
let destroyed = false;
|
|
||||||
this.socketMap.add(connection);
|
this.socketMap.add(connection);
|
||||||
console.log(`added connection. now ${this.socketMap.getArray().length} sockets connected.`);
|
console.log(`added connection. now ${this.socketMap.getArray().length} sockets connected.`);
|
||||||
const destroyConnection = () => {
|
const destroyConnection = () => {
|
||||||
if (!destroyed) {
|
|
||||||
destroyed = true;
|
|
||||||
connection.destroy();
|
|
||||||
console.log(`socket successfully destroyed.`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
const cleanupConnection = () => {
|
const cleanupConnection = () => {
|
||||||
if (this.socketMap.checkForObject(connection)) {
|
if (this.socketMap.checkForObject(connection)) {
|
||||||
this.socketMap.remove(connection);
|
this.socketMap.remove(connection);
|
||||||
plugins.smartdelay.delayFor(200).then(() => {
|
|
||||||
destroyConnection();
|
|
||||||
});
|
|
||||||
console.log(`removed connection. ${this.socketMap.getArray().length} sockets remaining.`);
|
console.log(`removed connection. ${this.socketMap.getArray().length} sockets remaining.`);
|
||||||
connection.end(() => {
|
connection.end();
|
||||||
destroyConnection();
|
connection.destroy();
|
||||||
});
|
console.log(`socket successfully destroyed.`);
|
||||||
|
/* plugins.smartdelay.delayFor(10000).then(() => {
|
||||||
|
connection.removeAllListeners();
|
||||||
|
}) */
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
connection.on('close', () => {
|
connection.on('close', () => {
|
||||||
|
Reference in New Issue
Block a user