Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
e51c2a88cc | |||
7f8112930d | |||
b5c83b5c75 | |||
63ce1a44a4 |
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartproxy",
|
"name": "@pushrocks/smartproxy",
|
||||||
"version": "3.0.53",
|
"version": "3.0.55",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "a proxy for handling high workloads of proxying",
|
"description": "a proxy for handling high workloads of proxying",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@pushrocks/smartproxy',
|
name: '@pushrocks/smartproxy',
|
||||||
version: '3.0.53',
|
version: '3.0.55',
|
||||||
description: 'a proxy for handling high workloads of proxying'
|
description: 'a proxy for handling high workloads of proxying'
|
||||||
}
|
}
|
||||||
|
@ -245,32 +245,33 @@ JNj2Dr5H0XoLFFnvuvzcRbhlJ9J67JzR+7g=
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Enable websockets
|
// Enable websockets
|
||||||
const wss = new plugins.ws.WebSocketServer({ server: this.httpsServer });
|
const wsServer = new plugins.ws.WebSocketServer({ server: this.httpsServer });
|
||||||
wss.on('connection', async (ws: plugins.wsDefault, reqArg: plugins.http.IncomingMessage) => {
|
wsServer.on('connection', async (wsIncoming: plugins.wsDefault, reqArg: plugins.http.IncomingMessage) => {
|
||||||
console.log(`wss: got connection for wsc for https://${reqArg.headers.host}${reqArg.url}`);
|
console.log(`wss proxy: got connection for wsc for https://${reqArg.headers.host}${reqArg.url}`);
|
||||||
|
|
||||||
let wsc: plugins.wsDefault;
|
let wsOutgoing: plugins.wsDefault;
|
||||||
try {
|
try {
|
||||||
wsc = new plugins.wsDefault(`ws://${this.router.routeReq(reqArg).destinationIp}:${this.router.routeReq(reqArg).destinationPort}${reqArg.url}`);
|
wsOutgoing = new plugins.wsDefault(`ws://${this.router.routeReq(reqArg).destinationIp}:${this.router.routeReq(reqArg).destinationPort}${reqArg.url}`);
|
||||||
|
console.log('wss proxy: initiated outgoing proxy')
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
ws.terminate();
|
wsIncoming.terminate();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ws.on("message", (message, isBinary) => {
|
wsIncoming.on("message", (message, isBinary) => {
|
||||||
console.log("client to upstream", message);
|
console.log("client to upstream", message);
|
||||||
wsc.send(message, { binary: isBinary });
|
wsOutgoing.send(message, { binary: isBinary });
|
||||||
});
|
});
|
||||||
|
|
||||||
wsc.on("message", (message, isBinary) => {
|
wsOutgoing.on("message", (message, isBinary) => {
|
||||||
console.log("upstream to client", message);
|
console.log("upstream to client", message);
|
||||||
ws.send(message, { binary: isBinary });
|
wsIncoming.send(message, { binary: isBinary });
|
||||||
});
|
});
|
||||||
ws.on("error", () => wsc.terminate());
|
wsIncoming.on("error", () => wsOutgoing.terminate());
|
||||||
wsc.on("error", () => ws.terminate());
|
wsOutgoing.on("error", () => wsIncoming.terminate());
|
||||||
ws.on("close", () => wsc.terminate());
|
wsIncoming.on("close", () => wsOutgoing.terminate());
|
||||||
wsc.on("close", () => ws.terminate());
|
wsOutgoing.on("close", () => wsIncoming.terminate());
|
||||||
|
|
||||||
});
|
});
|
||||||
this.httpsServer.keepAliveTimeout = 600 * 1000;
|
this.httpsServer.keepAliveTimeout = 600 * 1000;
|
||||||
|
Reference in New Issue
Block a user