/* Port forwarding
 To forward from localhost:9001 => localhost:80

$ node proxy.js 9001 80
Or localhost:9001 => otherhost:80

$ node proxy.js 9001 otherhost:80
*/

//To use the HTTP server and client one must require('http').
var http = require('http');
/*The net module provides you with an asynchronous network wrapper. 
It contains methods for creating both servers and clients (called streams). 
You can include this module with require('net');
*/
var net = require('net');

// parse "80" and "localhost:80" or even "42mEANINg-life.com:80"
var addrRegex = /^(([a-zA-Z\-\.0-9]+):)?(\d+)$/;

var addr = {
    from: addrRegex.exec(process.argv[2]),
    to: addrRegex.exec(process.argv[3])
};

if (!addr.from || !addr.to) {
    console.log('Usage: <from> <to>');
    return;
}

net.createServer(function(from) {
    var to = net.createConnection({
        host: addr.to[2],
        port: addr.to[3]
    });
    from.pipe(to);
    to.pipe(from);
}).listen(addr.from[3], addr.from[2]);

@@ -687,12 +687,66 @@
 %5B3%5D)
-%0A%7D;%0A
+, %0A    timeout: process.argv%5B4%5D%0A%7D;%0A%0A// Timeout is optional
 %0Aif 
@@ -807,16 +807,39 @@
 om%3E %3Cto%3E
+ %5B%3Ctimeout-in-seconds%3E%5D
 ');%0A    
@@ -978,16 +978,178 @@
     %7D);%0A
+    var timeout = addr.timeout;%0A    if (timeout == null) %7B%0A        timeout = 0;%0A    %7D%0A    console.log(%22timeout is %22 + timeout );%0A%0A    setTimeout(function() %7B%0A    
     from
@@ -1163,16 +1163,20 @@
 o);%0A    
+   
+ 
 to.pipe(
@@ -1182,16 +1182,49 @@
 (from);%0A
+    %7D, timeout * 1000);%0A   %0A    %0A
 %7D).liste

add latency