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 = { export const commitinfo = {
name: '@pushrocks/smartproxy', name: '@pushrocks/smartproxy',
version: '3.0.53', version: '3.0.54',
description: 'a proxy for handling high workloads of proxying' description: 'a proxy for handling high workloads of proxying'
} }

View File

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