diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 7646a21..913d70f 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -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' } diff --git a/ts/smartproxy.classes.networkproxy.ts b/ts/smartproxy.classes.networkproxy.ts index 4c3f518..692a4f0 100644 --- a/ts/smartproxy.classes.networkproxy.ts +++ b/ts/smartproxy.classes.networkproxy.ts @@ -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;