Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
703cbedad4 | |||
dd7e9e8416 |
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/smartproxy",
|
||||
"version": "2.0.4",
|
||||
"version": "2.0.5",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/smartproxy",
|
||||
"version": "2.0.4",
|
||||
"version": "2.0.5",
|
||||
"private": false,
|
||||
"description": "a proxy for handling high workloads of proxying",
|
||||
"main": "dist_ts/index.js",
|
||||
|
@ -18,6 +18,14 @@ const portProxyCalls = {
|
||||
response.end();
|
||||
});
|
||||
httpServer.listen(7999);
|
||||
const cleanUpSockets = (from: plugins.net.Socket, to: plugins.net.Socket) => {
|
||||
from.end();
|
||||
to.end();
|
||||
from.removeAllListeners();
|
||||
to.removeEventListener();
|
||||
from.unpipe();
|
||||
to.unpipe();
|
||||
}
|
||||
netServer = net
|
||||
.createServer((from) => {
|
||||
const to = net.createConnection({
|
||||
@ -27,14 +35,29 @@ const portProxyCalls = {
|
||||
from.pipe(to);
|
||||
to.pipe(from);
|
||||
from.on('error', () => {
|
||||
from.end(), to.end();
|
||||
cleanUpSockets(from, to);
|
||||
});
|
||||
to.on('error', () => {
|
||||
from.end(), to.end();
|
||||
cleanUpSockets(from, to);
|
||||
});
|
||||
from.on('close', () => {
|
||||
to.end();
|
||||
cleanUpSockets(from, to);
|
||||
});
|
||||
to.on('close', () => {
|
||||
cleanUpSockets(from, to);
|
||||
});
|
||||
from.on('timeout', () => {
|
||||
cleanUpSockets(from, to);
|
||||
});
|
||||
to.on('timeout', () => {
|
||||
cleanUpSockets(from, to);
|
||||
});
|
||||
from.on('end', () => {
|
||||
cleanUpSockets(from, to);
|
||||
})
|
||||
to.on('end', () => {
|
||||
cleanUpSockets(from, to);
|
||||
})
|
||||
})
|
||||
.listen(portArg);
|
||||
console.log(`PortProxy -> OK: Now listening on port ${portArg}`);
|
||||
|
Reference in New Issue
Block a user