Quantcast
Channel: sshnet Discussions Rss Feed
Viewing all articles
Browse latest Browse all 1729

New Post: Dynamic PortForward Problem

$
0
0
Hi, I'm using sshnet-22965 to build dynamic portforward application. The application runs fine except when when i use it with browser, it thrown "An invalid IP address was specified" exception for every site. and here is my code
 var listenport = new ForwardedPortDynamic("127.0.0.1", Convert.ToUInt16(textBox8.Text));
            connectionInfo = new PasswordConnectionInfo(tbSSHHost.Text, int.Parse(tbSSHPort.Text), tbSSHUser.Text, tbSSHPassword.Text, ProxyTypes.Http, textBox7.Text, int.Parse(textBox6.Text)); //(tbSSHHost.Text, Convert.ToInt16(tbSSHPort.Text), tbSSHUser.Text, tbSSHPassword.Text, ProxyTypes.Http, textBox7.Text, Convert.ToInt16(textBox6.Text), textBox5.Text, textBox4.Text, textBox3.Text);
            connectionInfo.Timeout = new TimeSpan(0, 0, 10);
            client = new SshClient(connectionInfo);
            client.ErrorOccurred += delegate(object sender, Renci.SshNet.Common.ExceptionEventArgs e)
            {
                newdisplay.DisplayData("Client error : " + e.Exception.Message);
            };
            client.HostKeyReceived += delegate(object sender, Renci.SshNet.Common.HostKeyEventArgs arg)
            {
                newdisplay.DisplayData("Conected to : " + tbSSHHost.Text + ":" + tbSSHPort.Text + ". " + connectionInfo.ServerVersion);
                newdisplay.DisplayData("Key Exchange : " + connectionInfo.CurrentKeyExchangeAlgorithm + ". ");
            };
            listenport.Exception += delegate(object sender, Renci.SshNet.Common.ExceptionEventArgs e)
            {
                newdisplay.DisplayData("Listenport error : " + e.Exception.Message);//Assert.Fail(e.Exception.ToString());
            };
            listenport.RequestReceived += delegate(object sender, Renci.SshNet.Common.PortForwardEventArgs arg)
            {
                newdisplay.DisplayData("Requested conection to " + arg.OriginatorHost + ":" + arg.OriginatorPort);
            };
            client.KeepAliveInterval = new TimeSpan(0, 0, 30);
            
            try
            {
                client.Connect();
                client.AddForwardedPort(listenport);
                client.SendKeepAlive();
                listenport.Start();
                if (listenport.IsStarted)
                {
                    newdisplay.DisplayData("Listening on " + listenport.BoundHost + ":" + listenport.BoundPort);
                }
                tsslStatus.Text = "Connected";
                while (connected)
                {
                    System.Threading.Thread.Sleep(500);
                }
                listenport.Stop();
                client.RemoveForwardedPort(listenport);
                client.Disconnect();
                tsslStatus.Text = "Disconnected";

            }
please help and thanks in advance

Viewing all articles
Browse latest Browse all 1729

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>