Compare commits
20 Commits
Author | SHA1 | Date | |
---|---|---|---|
759f70b84d | |||
45ce56b118 | |||
0cc7184e58 | |||
392e241208 | |||
32c6d77178 | |||
2c4316d2d3 | |||
62e6387c1d | |||
7fe22e962a | |||
3f1f718308 | |||
ce94d283c1 | |||
a1c4f3c341 | |||
8087bab197 | |||
db63e7bf79 | |||
2615a0ebd4 | |||
d5d77af98d | |||
1f1bf77807 | |||
d4269d290d | |||
e05e5ede55 | |||
b6c7f13baa | |||
055d328bd0 |
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/smartproxy",
|
||||
"version": "3.0.43",
|
||||
"version": "3.0.53",
|
||||
"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.43',
|
||||
version: '3.0.53',
|
||||
description: 'a proxy for handling high workloads of proxying'
|
||||
}
|
||||
|
@ -246,39 +246,32 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
|
||||
|
||||
// Enable websockets
|
||||
const wss = new plugins.ws.WebSocketServer({ server: this.httpsServer });
|
||||
wss.on('connection', (ws: plugins.wsDefault, reqArg) => {
|
||||
console.log(`got connection for wsc for https://${req.get('host')}${reqArg.url}`);
|
||||
let wscConnectedDeferred: plugins.smartpromise.Deferred<plugins.wsDefault>;
|
||||
wss.on('connection', async (ws: plugins.wsDefault, reqArg: plugins.http.IncomingMessage) => {
|
||||
console.log(`wss: got connection for wsc for https://${reqArg.headers.host}${reqArg.url}`);
|
||||
|
||||
let wsc: plugins.wsDefault;
|
||||
try {
|
||||
wsc = new plugins.wsDefault(`ws://${this.router.routeReq(reqArg).destinationIp}:${this.router.routeReq(reqArg).destinationPort}${reqArg.url}`);
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
ws.terminate();
|
||||
return;
|
||||
}
|
||||
|
||||
ws.on('message', async (message) => {
|
||||
if (!wscConnectedDeferred) {
|
||||
wscConnectedDeferred = plugins.smartpromise.defer();
|
||||
const wsc = new plugins.wsDefault(`${this.router.routeReq(reqArg)}${reqArg.url}`);
|
||||
|
||||
wsc.on('open', () => {
|
||||
wscConnectedDeferred.resolve(wsc);
|
||||
});
|
||||
}
|
||||
const wsc = await wscConnectedDeferred.promise;
|
||||
wsc.emit('message', message);
|
||||
wsc.on('message', (message) => {
|
||||
ws.emit('message', message);
|
||||
});
|
||||
|
||||
// handle closing
|
||||
const cleanUp = () => {
|
||||
ws.terminate();
|
||||
wsc.terminate();
|
||||
};
|
||||
|
||||
ws.on('close', (message) => {
|
||||
cleanUp();
|
||||
});
|
||||
|
||||
wsc.on('close', (message) => {
|
||||
cleanUp();
|
||||
});
|
||||
ws.on("message", (message, isBinary) => {
|
||||
console.log("client to upstream", message);
|
||||
wsc.send(message, { binary: isBinary });
|
||||
});
|
||||
|
||||
wsc.on("message", (message, isBinary) => {
|
||||
console.log("upstream to client", message);
|
||||
ws.send(message, { binary: isBinary });
|
||||
});
|
||||
ws.on("error", () => wsc.terminate());
|
||||
wsc.on("error", () => ws.terminate());
|
||||
ws.on("close", () => wsc.terminate());
|
||||
wsc.on("close", () => ws.terminate());
|
||||
|
||||
});
|
||||
this.httpsServer.keepAliveTimeout = 600 * 1000;
|
||||
this.httpsServer.headersTimeout = 600 * 1000;
|
||||
|
Reference in New Issue
Block a user