12

According to my research whilst trying to solve this problem, it turns out that the .Net WebProxy class does not support Socks proxies - a tad annoying. I also can't seem to find any code or information which explains how to implement Socks 4/5 support via a class which can easily be used with HttpWebRequest (the Proxy property, to be exact).

I've found limited information via google on how I could do this. One suggestion involves changing internet explorer proxy settings - something I'd rather not do.

Does anyone know of anything which could do the job or have any suggestions? Any help would be much appreciated.

Community
  • 1
  • 1
JoeR
  • 1,901
  • 3
  • 25
  • 39

4 Answers4

3

I tried numerous .Net libraries which claimed to support Socks4/5 but found many of them just did not work or would error trying to connect to proxies I knew were functioning.

I've ended up using Chilkat Software's Sock/SSL component which seems to work well for me even if I do have to manually construct the HTTP requests instead of using HttpWebRequest as I would have liked.

  • Update note: Chilkat.Http (similar to the HttpWebRequest class) does inherently have support for SOCKS proxies. So don't spend time trying to code your own HTTP requests as I did; just use the Chilkat.Http.SocksHostname, Chilkat.Http.SocksPort and Chilkat.Http.SocksVersion properties.
Community
  • 1
  • 1
JoeR
  • 1,901
  • 3
  • 25
  • 39
  • Chilkat does now inherently support SOCKS. `Chilkat.Http.SocksVersion`, `Chilkat.Http.SocksHostname`, `Chilkat.Http.SocksPort`. Configuring those properties will force the HTTP connections to utilize SOCKS. Chilkat API reference: [link](http://www.chilkatsoft.com/refdoc/csHttpRef.html) – user1111380 Jul 16 '14 at 23:24
2

Changing IE's proxy settings won't help you at all-- the other poster was just observing that it works for IE. Because the .NET Framework doesn't support SOCKS, you'd have to write your own CERN-Proxy to SOCKS-Proxy converter, such that .NET talks to the CERN proxy (the type it supports) and your code converts that to a SOCKS proxy call.

FWIW, this is something I'm presently looking to add to FiddlerCore (www.fiddler2.com/core) because I already have almost all of the code. The only thing I really need is a SOCKSv4a proxy to test against.

EricLaw
  • 56,563
  • 7
  • 151
  • 196
  • The suggestion that got me to that page was to change the IE proxy and then use the WebProxy.DefaultProxy property - http://social.msdn.microsoft.com/Forums/en-US/ncl/thread/982bef6c-b9a4-4c0d-b7d5-0c64df9f610a. I'm just surprised that I can't find any class/library to implement this easily via code - it seems like such an obvious thing to want to do. Would be great if you did implement it - I'll keep an eye on the FiddlerCore project. – JoeR Oct 04 '10 at 13:44
0

Since .NET 6, socks proxies can be used natively with HttpClient. See this issue on GitHub.

KUTlime
  • 5,889
  • 1
  • 18
  • 29
-1

Use Privoxy or same to create http proxy gateway to your socks.

Add this to main config to chain Privoxy and socks:

forward-socks5 / proxy_host:port .

And something like that to enable direct access to your local network:

forward 192.168.*.*/ . forward 10.*.*.*/ . forward 127.*.*.*/ .