From f1a4fae704cf9c4800d63620623a11dfa550f5d0 Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Thu, 5 Jan 2023 15:26:36 +0100 Subject: [PATCH] fix(core): update --- ts/00_commitinfo_data.ts | 2 +- ts/smartproxy.classes.networkproxy.ts | 13 +++++-------- ts/smartproxy.classes.router.ts | 4 ++-- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 4b33a8d..39e633c 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.41', + version: '3.0.42', description: 'a proxy for handling high workloads of proxying' } diff --git a/ts/smartproxy.classes.networkproxy.ts b/ts/smartproxy.classes.networkproxy.ts index 9dc2e7e..ea152d2 100644 --- a/ts/smartproxy.classes.networkproxy.ts +++ b/ts/smartproxy.classes.networkproxy.ts @@ -245,19 +245,16 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g= ); // Enable websockets - const wss = new plugins.ws.WebSocketServer({ server: this.httpsServer }); - wss.on('connection', (ws) => { - console.log(`got connection for wsc for ${ws.url}`); + const wss = new plugins.ws.WebSocketServer({ server: this.httpsServer }); + wss.on('connection', (ws: plugins.wsDefault, reqArg) => { + console.log(`got connection for wsc for ${reqArg.url}`); let wscConnectedDeferred: plugins.smartpromise.Deferred; ws.on('message', async (message) => { if (!wscConnectedDeferred) { wscConnectedDeferred = plugins.smartpromise.defer(); - const wsc = new plugins.wsDefault(this.router.routeWs(ws), { - headers: { - Host: ws.url, - }, - }); + const parsedUrl = plugins.url.parse(reqArg.url); + const wsc = new plugins.wsDefault(`${this.router.routeWs(reqArg)}${parsedUrl.path}`); wsc.on('open', () => { wscConnectedDeferred.resolve(wsc); diff --git a/ts/smartproxy.classes.router.ts b/ts/smartproxy.classes.router.ts index 394c4db..29f7713 100644 --- a/ts/smartproxy.classes.router.ts +++ b/ts/smartproxy.classes.router.ts @@ -22,8 +22,8 @@ export class ProxyRouter { return correspodingReverseProxyConfig; } - public routeWs(ws: plugins.wsDefault) { - const originalHost = plugins.url.parse(ws.url).host; + public routeWs(wsReq: plugins.http.IncomingMessage) { + const originalHost = plugins.url.parse(wsReq.url).host; const correspodingReverseProxyConfig = this.reverseProxyConfigs.find((reverseConfig) => { return reverseConfig.hostName === originalHost; });