Created
July 29, 2012 23:44
-
-
Save scryptonite/3202619 to your computer and use it in GitHub Desktop.
Proxy for Worgy
This file contains 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
var net = require("net"); | |
var port = 25560; // the port it listens to | |
var target_host = "127.0.0.1"; // the host that receives the data | |
var target_port = 25575; // the port that receives the data | |
server = net.createServer(function(socket){ | |
socket.pause() | |
var target = net.connect(target_port, target_host, function(){ | |
socket.resume() | |
socket.on("data", function(data){ | |
console.log("Client:\n "+ | |
data.toString("ascii").split("").map(function(c){ | |
return c.charCodeAt(0); | |
}) | |
); | |
target.write(data); | |
}) | |
target.on("data", function(data){ | |
console.log("Server:\n "+ | |
data.toString("ascii").split("").map(function(c){ | |
return c.charCodeAt(0); | |
}) | |
); | |
socket.write(data); | |
}) | |
target.on("end", function(data){ socket.end(data) }) | |
socket.on("end", function(data){ target.end(data) }) | |
}) | |
}) | |
server.listen(port, function(){ | |
console.log("Binded to port #"+port); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment