我正在使用 SSH.NET 对 GUI 进行编码以创建与 VPS 的连接。我的目的是做一个玩网络游戏的代理服务器。
我需要动态转发一个端口,创建一个 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.