This project is read-only.

Forwarded Port Dynamic issue

Jul 15, 2013 at 3:50 PM
Hi, I'm new guy, I'm try to use Forwarded Port Dynamic as code below

SshClient client = new SshClient("myhost", "myuser", "mypass");
client .Connect();

if(client.IsConnected)
{
ForwardedPortDynamic f = new ForwardedPortDynamic("localhost", 9951); //my port
client .AddForwardedPort (f);
f.Start();

//Then I use localhost:9951 as Http proxy

HttpWebRequest rq = (HttpWebRequest)WebRequest.Create("http://google.com");

rq.Proxy = new WebProxy("localhost:9951");
HttpWebResponse rp = (HttpWebResponse)rq.GetResponse();
f.Stop();
}

My problem: I can't get response.
Sorry about my english, I'm realy new guy.
Jul 15, 2013 at 4:14 PM
Edited Jul 15, 2013 at 4:25 PM
AFAIK HttpWebRequest/HttpWebResponse does not support SOCKS-Proxies.
Check if your browser can use the forwarding as SOCKS-Proxy.

Old forum-discussion, but I think nothing changed since then:
http://social.msdn.microsoft.com/Forums/en-US/982bef6c-b9a4-4c0d-b7d5-0c64df9f610a/httpwebrequest-socks4-or-socks5-support
Jul 15, 2013 at 4:33 PM
I'm try this code, it work fine but only for one host
Same with my first post, but I'm use ForwardedPortLocal instead ForwardedPortDynamic

...
ForwardedPortLocal forward = new ForwardedPortLocal("localhost", 9951, "www.google.com", 80);
forward.Start();
....
HttpWebRequest rq = (HttpWebRequest)WebRequest.Create("http://google.com");
rq.Proxy = new WebProxy("localhost:9951");
HttpWebResponse rp = (HttpWebResponse)rq.GetResponse();

//That work but google only, how can I use the same boundHost, boundPort for an other Host ?_?
Jul 15, 2013 at 5:23 PM
OK. I see.
You should get more familiar with SSH and Forwardings.

This is a good start I think:
https://help.ubuntu.com/community/SSH/OpenSSH/PortForwarding

What you want is DynamicForwarding, but HttpWebRequest/HttpWebResponse does not support SOCKS-Proxies.
So you have to check for another way to use your DynamicForwarding in Code as proxy.
Jul 16, 2013 at 4:04 AM
many thank... ^^!