2016-04-27 146 views
0

我使用SSH.NET编写GUI来创建与VPS的连接。我的意图是制作一个用于玩在线游戏的代理服务器。SSH.NET>用于端口转发的SSH客户端

我需要动态地转发一个端口来创建一个SOCKS服务器,然后,Proxifier(我的计算机上安装的另一个程序)可以连接到这个服务器。

当我使用PuTTY时,Proxifier运行良好,但是当我使用我的软件时,它不起作用。

这是我的代码:

using (client = new SshClient("VPS_IP", "USER", "PASSWORD")) 
{ 
    client.KeepAliveInterval = new TimeSpan(0, 0, 60); 

    client.ConnectionInfo.Timeout = new TimeSpan(0, 0, 50); 

    port = new ForwardedPortDynamic("127.0.0.1", portNumber); 
    client.Connect(); 
    client.AddForwardedPort(port); 

    port.Start(); 

    if (client.IsConnected && port.IsStarted) 
    { 
     MessageBox.Show("Connected"); 
    } 

    System.Threading.Thread.Sleep(20 * 1000); 
} 

而现在,Proxifier

[48:51] Testing Started. 
Proxy Server 
Address: 127.0.0.1:port 
Protocol: SOCKS 5 
Authentication: NO 

[48:51] Starting: Test 1: Connection to the Proxy Server 
[48:51] IP Address: 127.0.0.1 
[48:51] Connection established 
[48:51] Test passed. 
[48:51] Starting: Test 2: Connection through the Proxy Server 
[48:51] Authentication was successful. 
[48:51] Error : connection to the proxy server was closed unexpectedly. 
[48:51] Test failed. 
[48:51] Testing Finished. 

回答

0

的日志调试问题转发端口,通过处理ForwardedPort.Exception事件开始。

一旦找出有什么异常,如果有的话,我们可以进一步帮助你。