fix(core): update

This commit is contained in:
Philipp Kunz 2023-01-06 12:53:58 +01:00
parent 759f70b84d
commit 63ce1a44a4
2 changed files with 14 additions and 14 deletions

View File

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

View File

@ -245,32 +245,32 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
);
// Enable websockets
const wss = new plugins.ws.WebSocketServer({ server: this.httpsServer });
wss.on('connection', async (ws: plugins.wsDefault, reqArg: plugins.http.IncomingMessage) => {
const wsServer = new plugins.ws.WebSocketServer({ server: this.httpsServer });
wsServer.on('connection', async (wsIncoming: plugins.wsDefault, reqArg: plugins.http.IncomingMessage) => {
console.log(`wss: got connection for wsc for https://${reqArg.headers.host}${reqArg.url}`);
let wsc: plugins.wsDefault;
let wsOutgoing: plugins.wsDefault;
try {
wsc = new plugins.wsDefault(`ws://${this.router.routeReq(reqArg).destinationIp}:${this.router.routeReq(reqArg).destinationPort}${reqArg.url}`);
wsOutgoing = new plugins.wsDefault(`ws://${this.router.routeReq(reqArg).destinationIp}:${this.router.routeReq(reqArg).destinationPort}${reqArg.url}`);
} catch (err) {
console.log(err);
ws.terminate();
wsIncoming.terminate();
return;
}
ws.on("message", (message, isBinary) => {
wsIncoming.on("message", (message, isBinary) => {
console.log("client to upstream", message);
wsc.send(message, { binary: isBinary });
wsOutgoing.send(message, { binary: isBinary });
});
wsc.on("message", (message, isBinary) => {
wsOutgoing.on("message", (message, isBinary) => {
console.log("upstream to client", message);
ws.send(message, { binary: isBinary });
wsIncoming.send(message, { binary: isBinary });
});
ws.on("error", () => wsc.terminate());
wsc.on("error", () => ws.terminate());
ws.on("close", () => wsc.terminate());
wsc.on("close", () => ws.terminate());
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;