参考了 用nodejs实现反向代理远程桌面(外网连接局域网内机器实现远程)http://yoyo.play175.com/p/proxyrdp.html
写了一段简单的实验:
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('本地远程桌面 3389 连接成功!');
loc.pipe(c);
c.pipe(loc);
});
}).listen(client_port, host, function(c) {
console.log('代理已开启,托管为: %j',client.address());
});
执行后输出:
E:\Workspace\Code\SmartDoor>node test.js 代理已开启,托管为: {"address":"192.168.7.69","family":"IPv4","port":8889} 本地远程桌面 3389 连接成功!
但是用win自带的远程桌面,连接一直超时。 本机远程桌面已开,本机连接本机也上不了。 请教下是哪步遗漏了?
1 回复
多谢YOYO的指点, 解决了. 调换下顺序即可.
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());
});
});