Skip to content

Instantly share code, notes, and snippets.

@scryptonite
Created July 29, 2012 23:44
Show Gist options
  • Save scryptonite/3202619 to your computer and use it in GitHub Desktop.
Save scryptonite/3202619 to your computer and use it in GitHub Desktop.
Proxy for Worgy
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