Compare commits

...

8 Commits

Author SHA1 Message Date
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
3 changed files with 26 additions and 40 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartproxy", "name": "@pushrocks/smartproxy",
"version": "3.0.49", "version": "3.0.53",
"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.49', version: '3.0.53',
description: 'a proxy for handling high workloads of proxying' description: 'a proxy for handling high workloads of proxying'
} }

View File

@ -246,46 +246,32 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
// Enable websockets // Enable websockets
const wss = new plugins.ws.WebSocketServer({ server: this.httpsServer }); const wss = new plugins.ws.WebSocketServer({ server: this.httpsServer });
wss.on('connection', (ws: plugins.wsDefault, reqArg: plugins.http.IncomingMessage) => { wss.on('connection', async (ws: plugins.wsDefault, reqArg: plugins.http.IncomingMessage) => {
console.log(`got connection for wsc for https://${reqArg.headers.host}${reqArg.url}`); console.log(`wss: got connection for wsc for https://${reqArg.headers.host}${reqArg.url}`);
let wscConnectedDeferred: plugins.smartpromise.Deferred<plugins.wsDefault>;
ws.on('message', async (message) => { let wsc: plugins.wsDefault;
if (!wscConnectedDeferred) { try {
wscConnectedDeferred = plugins.smartpromise.defer(); wsc = new plugins.wsDefault(`ws://${this.router.routeReq(reqArg).destinationIp}:${this.router.routeReq(reqArg).destinationPort}${reqArg.url}`);
let wsc; } catch (err) {
try { console.log(err);
wsc = new plugins.wsDefault(`ws://${this.router.routeReq(reqArg).destinationIp}:${this.router.routeReq(reqArg).destinationPort}${reqArg.url}`); ws.terminate();
} catch (err) { return;
console.log(err); }
ws.terminate();
return;
}
wsc.on('open', () => { ws.on("message", (message, isBinary) => {
wscConnectedDeferred.resolve(wsc); console.log("client to upstream", message);
}); wsc.send(message, { binary: isBinary });
}
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();
});
}); });
wsc.on("message", (message, isBinary) => {
console.log("upstream to client", message);
ws.send(message, { binary: isBinary });
});
ws.on("error", () => wsc.terminate());
wsc.on("error", () => ws.terminate());
ws.on("close", () => wsc.terminate());
wsc.on("close", () => ws.terminate());
}); });
this.httpsServer.keepAliveTimeout = 600 * 1000; this.httpsServer.keepAliveTimeout = 600 * 1000;
this.httpsServer.headersTimeout = 600 * 1000; this.httpsServer.headersTimeout = 600 * 1000;