Compare commits

...

20 Commits

Author SHA1 Message Date
e51c2a88cc 3.0.55 2023-01-06 12:56:51 +01:00
7f8112930d fix(core): update 2023-01-06 12:56:51 +01:00
b5c83b5c75 3.0.54 2023-01-06 12:53:58 +01:00
63ce1a44a4 fix(core): update 2023-01-06 12:53:58 +01:00
759f70b84d 3.0.53 2023-01-06 11:57:11 +01:00
45ce56b118 fix(core): update 2023-01-06 11:57:11 +01:00
0cc7184e58 3.0.52 2023-01-05 20:15:17 +01:00
392e241208 fix(core): update 2023-01-05 20:15:16 +01:00
32c6d77178 3.0.51 2023-01-05 19:33:16 +01:00
2c4316d2d3 fix(core): update 2023-01-05 19:33:15 +01:00
62e6387c1d 3.0.50 2023-01-05 19:21:03 +01:00
7fe22e962a fix(core): update 2023-01-05 19:21:02 +01:00
3f1f718308 3.0.49 2023-01-05 18:31:55 +01:00
ce94d283c1 fix(core): update 2023-01-05 18:31:55 +01:00
a1c4f3c341 3.0.48 2023-01-05 18:05:36 +01:00
8087bab197 fix(core): update 2023-01-05 18:05:36 +01:00
db63e7bf79 3.0.47 2023-01-05 18:00:51 +01:00
2615a0ebd4 fix(core): update 2023-01-05 18:00:50 +01:00
d5d77af98d 3.0.46 2023-01-05 17:28:55 +01:00
1f1bf77807 fix(core): update 2023-01-05 17:28:54 +01:00
3 changed files with 28 additions and 34 deletions

View File

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

View File

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

View File

@ -245,40 +245,34 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
);
// Enable websockets
const wss = new plugins.ws.WebSocketServer({ server: this.httpsServer });
wss.on('connection', (ws: plugins.wsDefault, reqArg: plugins.http.IncomingMessage) => {
console.log(`got connection for wsc for https://${reqArg.headers.host}${reqArg.url}`);
let wscConnectedDeferred: plugins.smartpromise.Deferred<plugins.wsDefault>;
const wsServer = new plugins.ws.WebSocketServer({ server: this.httpsServer });
wsServer.on('connection', async (wsIncoming: plugins.wsDefault, reqArg: plugins.http.IncomingMessage) => {
console.log(`wss proxy: got connection for wsc for https://${reqArg.headers.host}${reqArg.url}`);
let wsOutgoing: plugins.wsDefault;
try {
wsOutgoing = new plugins.wsDefault(`ws://${this.router.routeReq(reqArg).destinationIp}:${this.router.routeReq(reqArg).destinationPort}${reqArg.url}`);
console.log('wss proxy: initiated outgoing proxy')
} catch (err) {
console.log(err);
wsIncoming.terminate();
return;
}
ws.on('message', async (message) => {
if (!wscConnectedDeferred) {
wscConnectedDeferred = plugins.smartpromise.defer();
const wsc = new plugins.wsDefault(`wss://${this.router.routeReq(reqArg).destinationIp}${reqArg.url}`);
wsc.on('open', () => {
wscConnectedDeferred.resolve(wsc);
});
}
const wsc = await wscConnectedDeferred.promise;
wsc.emit('message', message);
wsc.on('message', (message) => {
ws.emit('message', message);
});
// handle closing
const cleanUp = () => {
ws.terminate();
wsc.terminate();
};
ws.on('close', (message) => {
cleanUp();
});
wsc.on('close', (message) => {
cleanUp();
});
wsIncoming.on("message", (message, isBinary) => {
console.log("client to upstream", message);
wsOutgoing.send(message, { binary: isBinary });
});
wsOutgoing.on("message", (message, isBinary) => {
console.log("upstream to client", message);
wsIncoming.send(message, { binary: isBinary });
});
wsIncoming.on("error", () => wsOutgoing.terminate());
wsOutgoing.on("error", () => wsIncoming.terminate());
wsIncoming.on("close", () => wsOutgoing.terminate());
wsOutgoing.on("close", () => wsIncoming.terminate());
});
this.httpsServer.keepAliveTimeout = 600 * 1000;
this.httpsServer.headersTimeout = 600 * 1000;