Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-tcp-proxy

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-tcp-proxy - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

2

package.json

@@ -5,3 +5,3 @@ {

"license": "MIT",
"version": "0.0.3",
"version": "0.0.4",
"main": "index.js",

@@ -8,0 +8,0 @@ "repository": {

@@ -9,3 +9,3 @@ A simple TCP proxy that may be used to access a service on another network. An extensible replacement for socat when used thus

```
node tcpproxy.js --proxyPort [port1] --serviceHost [host] --servicePort [port2]
node tcpproxy.js --proxyPort [port1] --serviceHost [host] --servicePort [port2] [--q]
```

@@ -18,3 +18,3 @@

To create a proxy in your own code
To create a proxy in your own code.
```javascript

@@ -29,1 +29,3 @@ var proxy = require("node-tcp-proxy");

```
Console output may be silenced through an optional `{quiet: true}` fourth `createProxy` argument.

@@ -5,8 +5,13 @@ #!/usr/bin/env node

var argv = require("optimist")
.usage('Usage: $0 --proxyPort [port] --serviceHost [host] --servicePort [port]')
.usage('Usage: $0 --proxyPort [port] --serviceHost [host] --servicePort [port] [--q]')
.demand(['proxyPort', 'serviceHost', 'servicePort'])
.boolean('q')
.argv;
var newProxy = proxy.createProxy(argv.proxyPort, argv.serviceHost, argv.servicePort);
var options = {
quiet: argv.q
};
var newProxy = proxy.createProxy(argv.proxyPort, argv.serviceHost, argv.servicePort, options);
process.on("uncaughtException", function (err) {

@@ -13,0 +18,0 @@ console.info(err);

@@ -8,13 +8,14 @@ var net = require("net");

function Proxy(proxyPort, serviceHost, servicePort) {
function Proxy(proxyPort, serviceHost, servicePort, options) {
this.proxyPort = proxyPort;
this.serviceHost = serviceHost;
this.servicePort = servicePort;
this.options = options;
this.proxySockets = {};
this.createProxy();
console.log("Proxy listening at port " + this.proxyPort);
}
Proxy.prototype.createProxy = function () {
this.log("Proxy listening at port " + this.proxyPort);
var proxy = this;

@@ -25,3 +26,3 @@

var key = uniqueKey(proxySocket);
console.log("Client connected from " + key);
proxy.log("Client connected from " + key);
proxy.proxySockets[key] = proxySocket;

@@ -46,4 +47,4 @@

serviceSocket.on("close", function (had_error) {
console.log("service socket closed");
console.log(" ending proxy socket");
proxy.log("service socket closed");
proxy.log(" ending proxy socket");
proxySocket.destroy();

@@ -54,5 +55,5 @@ });

serviceSocket.on("error", function (e) {
console.log("service socket error");
console.log(e);
console.log(" ending proxy socket");
proxy.log("service socket error");
proxy.log(e);
proxy.log(" ending proxy socket");
proxySocket.destroy();

@@ -63,4 +64,4 @@ });

proxySocket.on("error", function (e) {
console.log("proxy socket error");
console.log(e);
proxy.log("proxy socket error");
proxy.log(e);
});

@@ -81,7 +82,7 @@

}).listen(proxy.proxyPort)
}).listen(proxy.proxyPort);
}
Proxy.prototype.end = function () {
console.log("Terminating proxy");
this.log("Terminating proxy");
this.server.close();

@@ -93,4 +94,13 @@ for (var key in this.proxySockets) {

exports.createProxy = function(proxyPort, serviceHost, servicePort) {
return new Proxy(proxyPort, serviceHost, servicePort);
Proxy.prototype.log = function (msg) {
try {
if (!this.options || !this.options.quiet) {
console.log(msg);
}
} catch(e) {
}
}
exports.createProxy = function(proxyPort, serviceHost, servicePort, options) {
return new Proxy(proxyPort, serviceHost, servicePort, options);
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc