Skip to content

@gleicon /tcp_proxy.js
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
var net = require('net');
var sys = require('sys');
function repr(wot) {
sys.puts(sys.inspect(wot));
}
net.createServer(function (socket) {
//repr(socket);
client = net.createConnection(8888);
socket.setEncoding('utf-8');
client.setEncoding('utf-8');
socket.addListener("connect", function () {
sys.log("Connection from " + socket.remoteAddress+" Port: " + socket.remotePort);
});
client.addListener("data", function (data) {
sys.log("outgoing: " + data);
socket.write(data);
});
socket.addListener("data", function (data) {
sys.log("incoming: " + data);
client.write(data);
});
socket.addListener("end", function () {
sys.log("Connection from " + socket.remoteAddress+" Port: " + socket.remotePort +" has ended");
socket.end();
});
}).listen(9000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.