I'm trying to proxy remote destop(3389) to port 8889.
var net = require('net');
var client_port = 8889;
var host = '127.0.0.1';
host = '192.168.7.69';
var client = net.createServer(function(c) {
var loc = net.connect(3389, host, function() {
console.log('connet to 3389 success.');
loc.pipe(c);
c.pipe(loc);
});
}).listen(client_port, host, function(c) {
console.log('proxy opened, visit: %j',client.address());
});
then use win7's remote destop, visit myself, it fail.
update:
the remotedestop connect show "connet to 127.0.0.1:8889" for a long time, and timeout.
You are overwriting the host
variable, first assigns '127.0.0.1'
and in the line below you assing '192.168.7.69'
, maybe this is the problem
var host = '127.0.0.1',
host2 = '192.168.7.69'
solved, change the order.
var net = require('net');
var client_port = 8889;
var host = '127.0.0.1';
host = '192.168.7.69';
var client;
var loc = net.connect(3389, host, function() {
console.log('connet to 3389 success.');
client = net.createServer(function(c) {
loc.pipe(c);
c.pipe(loc);
}).listen(client_port, host, function(c) {
console.log('proxy opened, visit: %j',client.address());
});
});