Skip to content

Instantly share code, notes, and snippets.

@marcelog
Last active December 17, 2015 01:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcelog/5526738 to your computer and use it in GitHub Desktop.
Save marcelog/5526738 to your computer and use it in GitHub Desktop.
Quick and small tcp proxy written in nodejs. Opens a socket and listens for incoming connections. For every new incoming connection, it will open a connection to the proxied host, and send whatever it gets from either side to the other.
#!/usr/bin/env node
var port_to = 6379;
var port_from = 63790;
var net = require('net');
var server = net.createServer(function(clientSocket) {
var targetSocket = net.connect({port: port_to});
targetSocket.on('data', function(data) {
clientSocket.write(data);
});
clientSocket.on('data', function(data) {
targetSocket.write(data);
})
});
server.listen(port_from);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment