Skip to content

Instantly share code, notes, and snippets.

@stash
Created January 20, 2014 22:31
Show Gist options
  • Select an option

  • Save stash/8530627 to your computer and use it in GitHub Desktop.

Select an option

Save stash/8530627 to your computer and use it in GitHub Desktop.
Port-forwarding in < 10 lines of node.js
var net = require('net');
var listen = process.argv[2] || 443;
var forwardTo = process.argv[3] || 4443;
net.createServer(function(conn) {
var fwd = net.createConnection({ host: '127.0.0.1', port: forwardTo });
conn.pipe(fwd);
fwd.pipe(conn);
}).listen(listen);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment