fix(core): update
This commit is contained in:
parent
5ee5147606
commit
f1a4fae704
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@pushrocks/smartproxy',
|
name: '@pushrocks/smartproxy',
|
||||||
version: '3.0.41',
|
version: '3.0.42',
|
||||||
description: 'a proxy for handling high workloads of proxying'
|
description: 'a proxy for handling high workloads of proxying'
|
||||||
}
|
}
|
||||||
|
@ -246,18 +246,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) => {
|
||||||
console.log(`got connection for wsc for ${ws.url}`);
|
console.log(`got connection for wsc for ${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 parsedUrl = plugins.url.parse(reqArg.url);
|
||||||
headers: {
|
const wsc = new plugins.wsDefault(`${this.router.routeWs(reqArg)}${parsedUrl.path}`);
|
||||||
Host: ws.url,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
wsc.on('open', () => {
|
wsc.on('open', () => {
|
||||||
wscConnectedDeferred.resolve(wsc);
|
wscConnectedDeferred.resolve(wsc);
|
||||||
|
@ -22,8 +22,8 @@ export class ProxyRouter {
|
|||||||
return correspodingReverseProxyConfig;
|
return correspodingReverseProxyConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
public routeWs(ws: plugins.wsDefault) {
|
public routeWs(wsReq: plugins.http.IncomingMessage) {
|
||||||
const originalHost = plugins.url.parse(ws.url).host;
|
const originalHost = plugins.url.parse(wsReq.url).host;
|
||||||
const correspodingReverseProxyConfig = this.reverseProxyConfigs.find((reverseConfig) => {
|
const correspodingReverseProxyConfig = this.reverseProxyConfigs.find((reverseConfig) => {
|
||||||
return reverseConfig.hostName === originalHost;
|
return reverseConfig.hostName === originalHost;
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user