简体   繁体   English

SSH.NET>用于端口转发的SSH客户端

[英]SSH.NET > SSH client for port forwarding

I'm using SSH.NET for coding an GUI to create a connection to a VPS. 我正在使用SSH.NET编写GUI来创建与VPS的连接。 My intention is to make a proxy server for playing online games. 我的目的是制作一个代理服务器来玩在线游戏。

I need to forward a port dynamically, to create a SOCKS Server and then, Proxifier (another program installed on my computer) can connect to this server. 我需要动态转发端口,以创建SOCKS服务器,然后,Proxifier(我的计算机上安装的另一个程序)可以连接到此服务器。

When I use PuTTY, Proxifier works well, but when I use my software, it's not working. 当我使用PuTTY时,Proxifier运行良好,但是当我使用我的软件时,它无效。

This is my code: 这是我的代码:

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);
}

And now, the log of Proxifier 现在,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.

To debug problems with forwarded port, start by handling ForwardedPort.Exception event. 要调试转发端口的问题,请先处理ForwardedPort.Exception事件。

Once you find out what exception, if any, is raised, we can help you further. 一旦您发现了什么异常(如果有的话),我们可以为您提供进一步的帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM