When using ForwardedPortDynamic() if you set your browser to send dns resolving requests to the socks server, SSH.Net will error with "An invalid IP address was specified". If you supply an IP address it works as it should.
Both the current source which I compiled with monodevelop as well as the precompiled 4.0 binary throw this error.
This discussion https://sshnet.codeplex.com/discussions/434870 also reviews the same problem, although later said the problem was fixed.
To make firefox forward dns requests, set the network.proxy.socks_remote_dns to true in about:config, and test with the supplied code.
Here is the code which I am testing with.
```
using System;
using Renci.SshNet;
namespace Testing2
{
class MainClass
{
public static void Main (string[] args)
{
SshClient client = new SshClient ("192.168.0.1", "user", "pass");
client.KeepAliveInterval = new TimeSpan(0, 0, 30);
client.ConnectionInfo.Timeout = new TimeSpan(0, 0, 20);
ForwardedPort port = new ForwardedPortDynamic("127.0.0.1", 10080);
client.ErrorOccurred += delegate(object sender, Renci.SshNet.Common.ExceptionEventArgs e)
{
Console.WriteLine("Client error : " + e.Exception.Message);
};
client.HostKeyReceived += delegate(object sender, Renci.SshNet.Common.HostKeyEventArgs arg) {
Console.WriteLine ("Conected to server");
Console.WriteLine ("Key Exchanged");
};
port.Exception += delegate(object sender, Renci.SshNet.Common.ExceptionEventArgs e) {
Console.WriteLine ("Listenport error : " + e.Exception.Message);
};
port.RequestReceived += delegate(object sender, Renci.SshNet.Common.PortForwardEventArgs arg) {
Console.WriteLine ("Requested conection to " + arg.OriginatorHost + ":" + arg.OriginatorPort);
};
client.Connect();
if (client.IsConnected)
Console.WriteLine ("Client is connected to sshd");
else
Console.WriteLine ("Client did not connect");
client.AddForwardedPort(port);
client.SendKeepAlive();
port.Start();
if (port.IsStarted)
Console.WriteLine ("Port forwarding started");
else
Console.WriteLine ("Could not start port forwarding");
for (;;) {}
}
}
}
```
Thanks
Comments: ** Comment from web user: z668 **
Both the current source which I compiled with monodevelop as well as the precompiled 4.0 binary throw this error.
This discussion https://sshnet.codeplex.com/discussions/434870 also reviews the same problem, although later said the problem was fixed.
To make firefox forward dns requests, set the network.proxy.socks_remote_dns to true in about:config, and test with the supplied code.
Here is the code which I am testing with.
```
using System;
using Renci.SshNet;
namespace Testing2
{
class MainClass
{
public static void Main (string[] args)
{
SshClient client = new SshClient ("192.168.0.1", "user", "pass");
client.KeepAliveInterval = new TimeSpan(0, 0, 30);
client.ConnectionInfo.Timeout = new TimeSpan(0, 0, 20);
ForwardedPort port = new ForwardedPortDynamic("127.0.0.1", 10080);
client.ErrorOccurred += delegate(object sender, Renci.SshNet.Common.ExceptionEventArgs e)
{
Console.WriteLine("Client error : " + e.Exception.Message);
};
client.HostKeyReceived += delegate(object sender, Renci.SshNet.Common.HostKeyEventArgs arg) {
Console.WriteLine ("Conected to server");
Console.WriteLine ("Key Exchanged");
};
port.Exception += delegate(object sender, Renci.SshNet.Common.ExceptionEventArgs e) {
Console.WriteLine ("Listenport error : " + e.Exception.Message);
};
port.RequestReceived += delegate(object sender, Renci.SshNet.Common.PortForwardEventArgs arg) {
Console.WriteLine ("Requested conection to " + arg.OriginatorHost + ":" + arg.OriginatorPort);
};
client.Connect();
if (client.IsConnected)
Console.WriteLine ("Client is connected to sshd");
else
Console.WriteLine ("Client did not connect");
client.AddForwardedPort(port);
client.SendKeepAlive();
port.Start();
if (port.IsStarted)
Console.WriteLine ("Port forwarding started");
else
Console.WriteLine ("Could not start port forwarding");
for (;;) {}
}
}
}
```
Thanks
Comments: ** Comment from web user: z668 **
This bug and now are in the library. Please do something with it. Can check for whoer.net