Compare commits

...

6 Commits

Author SHA1 Message Date
b6c7f13baa 3.0.44 2023-01-05 17:00:32 +01:00
055d328bd0 fix(core): update 2023-01-05 17:00:31 +01:00
20b9a220fc 3.0.43 2023-01-05 15:53:17 +01:00
2170fe3518 fix(core): update 2023-01-05 15:53:17 +01:00
04b13e53b9 3.0.42 2023-01-05 15:26:36 +01:00
f1a4fae704 fix(core): update 2023-01-05 15:26:36 +01:00
4 changed files with 6 additions and 18 deletions

View File

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

View File

@ -245,19 +245,15 @@ 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) => { wss.on('connection', (ws: plugins.wsDefault, reqArg: plugins.http.IncomingMessage) => {
console.log(`got connection for wsc for ${ws.url}`); console.log(`got connection for wsc for https://${reqArg.headers.host}${reqArg.url}`);
let wscConnectedDeferred: plugins.smartpromise.Deferred<plugins.wsDefault>; let wscConnectedDeferred: plugins.smartpromise.Deferred<plugins.wsDefault>;
ws.on('message', async (message) => { ws.on('message', async (message) => {
if (!wscConnectedDeferred) { if (!wscConnectedDeferred) {
wscConnectedDeferred = plugins.smartpromise.defer(); wscConnectedDeferred = plugins.smartpromise.defer();
const wsc = new plugins.wsDefault(this.router.routeWs(ws), { const wsc = new plugins.wsDefault(`${this.router.routeReq(reqArg)}${reqArg.url}`);
headers: {
Host: ws.url,
},
});
wsc.on('open', () => { wsc.on('open', () => {
wscConnectedDeferred.resolve(wsc); wscConnectedDeferred.resolve(wsc);

View File

@ -21,12 +21,4 @@ export class ProxyRouter {
}); });
return correspodingReverseProxyConfig; return correspodingReverseProxyConfig;
} }
public routeWs(ws: plugins.wsDefault) {
const originalHost = plugins.url.parse(ws.url).host;
const correspodingReverseProxyConfig = this.reverseProxyConfigs.find((reverseConfig) => {
return reverseConfig.hostName === originalHost;
});
return correspodingReverseProxyConfig.destinationIp;
}
} }