Compare commits

...

4 Commits

Author SHA1 Message Date
fb76ecfd8a 1.0.30 2019-09-24 16:27:34 +02:00
6c84406574 fix(core): update 2019-09-24 16:27:34 +02:00
945065279f 1.0.29 2019-09-24 16:21:58 +02:00
07a8d9bec6 fix(websockets): now proxying websockets as well 2019-09-24 16:21:57 +02:00
5 changed files with 19 additions and 8 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartproxy",
"version": "1.0.28",
"version": "1.0.30",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

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

View File

@ -126,15 +126,17 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
});
});
const Websocket = await import('ws');
// Enable websockets
const wss = new plugins.ws.Server({ server: this.httpsServer });
wss.on('connection', function connection(ws) {
wss.on('connection', (ws: plugins.ws) => {
console.log('got connection for wsc');
const wscConnected = plugins.smartpromise.defer();
const wsc = new Websocket.default(`${ws.url}`);
const wsc = new plugins.ws(this.router.routeWs(ws), {
headers: {
Host: ws.url
}
});
wsc.on('open', () => {
wscConnected.resolve();
});

View File

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

View File

@ -1,8 +1,9 @@
// node native scope
import * as http from 'http';
import * as https from 'https';
import * as url from 'url';
export { http, https };
export { http, https, url };
// tsclass scope
import * as tsclass from '@tsclass/tsclass';
@ -18,6 +19,6 @@ import * as smartsystem from '@pushrocks/smartsystem';
export { smartrequest, smartpromise, smartspawn, smartsystem };
// third party scope
import * as ws from 'ws';
import ws from 'ws';
export { ws };