node-tcp-proxy
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -5,3 +5,3 @@ { | ||
"license": "MIT", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"main": "index.js", | ||
@@ -8,0 +8,0 @@ "repository": { |
@@ -11,1 +11,17 @@ A simple TCP proxy that may be used to access a service on another network. An extensible replacement for socat when used thus | ||
``` | ||
Install node-tcp-proxy from [npm](https://www.npmjs.com/package/node-tcp-proxy) | ||
``` | ||
sudo npm install -g node-tcp-proxy | ||
``` | ||
To create a proxy in your own code | ||
```javascript | ||
var proxy = require("node-tcp-proxy"); | ||
var newProxy = proxy.createProxy(8080, "hostname", 10080); | ||
``` | ||
To end the proxy | ||
```javascript | ||
newProxy.end(); | ||
``` |
@@ -38,12 +38,26 @@ var net = require("net"); | ||
} | ||
serviceSocket.on("data", function (data) { | ||
proxySocket.write(data); | ||
}); | ||
serviceSocket.on("close", function (had_error) { | ||
console.log("service socket closed"); | ||
console.log(" ending proxy socket"); | ||
proxySocket.destroy(); | ||
}); | ||
}); | ||
serviceSocket.on("error", function (e) { | ||
console.log("service socket error"); | ||
console.log(e); | ||
console.log(" ending proxy socket"); | ||
proxySocket.destroy(); | ||
}); | ||
proxySocket.on("error", function (e) { | ||
serviceSocket.end(); | ||
console.log("proxy socket error"); | ||
console.log(e); | ||
}); | ||
serviceSocket.on("error", function (e) { | ||
console.log("Could not connect to service at host " | ||
+ proxy.serviceHost + ', port ' + proxy.servicePort); | ||
proxySocket.end(); | ||
}); | ||
@@ -57,13 +71,7 @@ proxySocket.on("data", function (data) { | ||
}); | ||
serviceSocket.on("data", function (data) { | ||
proxySocket.write(data); | ||
}); | ||
proxySocket.on("close", function (had_error) { | ||
delete proxy.proxySockets[uniqueKey(proxySocket)]; | ||
serviceSocket.end(); | ||
serviceSocket.destroy(); | ||
}); | ||
serviceSocket.on("close", function (had_error) { | ||
proxySocket.end(); | ||
}); | ||
@@ -77,3 +85,3 @@ }).listen(proxy.proxyPort) | ||
for (var key in this.proxySockets) { | ||
this.proxySockets[key].end(); | ||
this.proxySockets[key].destroy(); | ||
} | ||
@@ -80,0 +88,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5379
86
27