-
-
Save easierbycode/5428921 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Logging TCP proxy. Forwards traffic to the given host/port and logs | |
// everything in both directions. | |
// | |
// e.g. | |
// $ node tcpproxy 4567 www.songkick.com 80 | |
// $ curl -H 'Host: www.songkick.com' localhost:4567/ | |
var net = require('net'), | |
me = process.argv[2], | |
host = process.argv[3], | |
port = process.argv[4]; | |
net.createServer(function(conn) { | |
var forward = net.connect({host: host, port: port}); | |
conn.pipe(forward); | |
forward.pipe(conn); | |
conn.pipe(process.stdout); | |
forward.pipe(process.stdout); | |
}) | |
.listen(me); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment