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",
|
"name": "@pushrocks/smartproxy",
|
||||||
"version": "2.0.4",
|
"version": "2.0.5",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartproxy",
|
"name": "@pushrocks/smartproxy",
|
||||||
"version": "2.0.4",
|
"version": "2.0.5",
|
||||||
"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",
|
||||||
|
@ -18,6 +18,14 @@ const portProxyCalls = {
|
|||||||
response.end();
|
response.end();
|
||||||
});
|
});
|
||||||
httpServer.listen(7999);
|
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
|
netServer = net
|
||||||
.createServer((from) => {
|
.createServer((from) => {
|
||||||
const to = net.createConnection({
|
const to = net.createConnection({
|
||||||
@ -27,14 +35,29 @@ const portProxyCalls = {
|
|||||||
from.pipe(to);
|
from.pipe(to);
|
||||||
to.pipe(from);
|
to.pipe(from);
|
||||||
from.on('error', () => {
|
from.on('error', () => {
|
||||||
from.end(), to.end();
|
cleanUpSockets(from, to);
|
||||||
});
|
});
|
||||||
to.on('error', () => {
|
to.on('error', () => {
|
||||||
from.end(), to.end();
|
cleanUpSockets(from, to);
|
||||||
});
|
});
|
||||||
from.on('close', () => {
|
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);
|
.listen(portArg);
|
||||||
console.log(`PortProxy -> OK: Now listening on port ${portArg}`);
|
console.log(`PortProxy -> OK: Now listening on port ${portArg}`);
|
||||||
|
Reference in New Issue
Block a user