Compare commits

...

22 Commits

Author SHA1 Message Date
32c6d77178 3.0.51 2023-01-05 19:33:16 +01:00
2c4316d2d3 fix(core): update 2023-01-05 19:33:15 +01:00
62e6387c1d 3.0.50 2023-01-05 19:21:03 +01:00
7fe22e962a fix(core): update 2023-01-05 19:21:02 +01:00
3f1f718308 3.0.49 2023-01-05 18:31:55 +01:00
ce94d283c1 fix(core): update 2023-01-05 18:31:55 +01:00
a1c4f3c341 3.0.48 2023-01-05 18:05:36 +01:00
8087bab197 fix(core): update 2023-01-05 18:05:36 +01:00
db63e7bf79 3.0.47 2023-01-05 18:00:51 +01:00
2615a0ebd4 fix(core): update 2023-01-05 18:00:50 +01:00
d5d77af98d 3.0.46 2023-01-05 17:28:55 +01:00
1f1bf77807 fix(core): update 2023-01-05 17:28:54 +01:00
d4269d290d 3.0.45 2023-01-05 17:21:42 +01:00
e05e5ede55 fix(core): update 2023-01-05 17:21:41 +01:00
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
5ee5147606 3.0.41 2023-01-05 14:57:55 +01:00
748c6e14e4 fix(core): update 2023-01-05 14:57:54 +01:00
4 changed files with 17 additions and 20 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartproxy",
"version": "3.0.40",
"version": "3.0.51",
"private": false,
"description": "a proxy for handling high workloads of proxying",
"main": "dist_ts/index.js",

View File

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

View File

@ -245,28 +245,33 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
);
// Enable websockets
const wss = new plugins.ws.WebSocketServer({ server: this.httpsServer });
wss.on('connection', (ws: plugins.wsDefault) => {
console.log('got connection for wsc');
const wss = new plugins.ws.WebSocketServer({ server: this.httpsServer });
wss.on('connection', (ws: plugins.wsDefault, reqArg: plugins.http.IncomingMessage) => {
console.log(`got connection for wsc for https://${reqArg.headers.host}${reqArg.url}`);
let wscConnectedDeferred: plugins.smartpromise.Deferred<plugins.wsDefault>;
ws.on('message', async (message) => {
if (!wscConnectedDeferred) {
wscConnectedDeferred = plugins.smartpromise.defer();
const wsc = new plugins.wsDefault(this.router.routeWs(ws), {
headers: {
Host: ws.url,
},
});
let wsc: plugins.wsDefault;
try {
wsc = new plugins.wsDefault(`ws://${this.router.routeReq(reqArg).destinationIp}:${this.router.routeReq(reqArg).destinationPort}${reqArg.url}`, {
headers: reqArg.headers
});
} catch (err) {
console.log(err);
ws.terminate();
return;
}
wsc.on('open', () => {
wscConnectedDeferred.resolve(wsc);
});
}
const wsc = await wscConnectedDeferred.promise;
wsc.emit('message', message);
wsc.send(message);
wsc.on('message', (message) => {
ws.emit('message', message);
ws.send(message);
});
// handle closing

View File

@ -21,12 +21,4 @@ export class ProxyRouter {
});
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;
}
}