Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
04b13e53b9 | |||
f1a4fae704 | |||
5ee5147606 | |||
748c6e14e4 |
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/smartproxy",
|
||||
"version": "3.0.40",
|
||||
"version": "3.0.42",
|
||||
"private": false,
|
||||
"description": "a proxy for handling high workloads of proxying",
|
||||
"main": "dist_ts/index.js",
|
||||
|
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@pushrocks/smartproxy',
|
||||
version: '3.0.40',
|
||||
version: '3.0.42',
|
||||
description: 'a proxy for handling high workloads of proxying'
|
||||
}
|
||||
|
@ -245,19 +245,16 @@ 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) => {
|
||||
console.log(`got connection for wsc for ${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,
|
||||
},
|
||||
});
|
||||
const parsedUrl = plugins.url.parse(reqArg.url);
|
||||
const wsc = new plugins.wsDefault(`${this.router.routeWs(reqArg)}${parsedUrl.path}`);
|
||||
|
||||
wsc.on('open', () => {
|
||||
wscConnectedDeferred.resolve(wsc);
|
||||
|
@ -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;
|
||||
});
|
||||
|
Reference in New Issue
Block a user