-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for Socks4/5 proxy in HttpClient/WebRequests #17740
Comments
The current status:
@abdullah2993, can you please share more details about the scenario? |
@ericeil can you comment on linux/mac socks4/5 proxy? |
@CIPop It would be helpful in almost all possible scenarios where you require a proxy besides socks4/5 proxies are available in abundance and most of the HTTP Stacks support them. |
It looks like CURL does support SOCKS4, 4a, and 5. It also looks like this may already be supported in the current System.Net implementation on Linux/Mac, by setting the request's Proxy property to something that returns, e.g., |
@himadrisarkar In order to support this on Windows, the underlying components (WinINet and WinHTTP) need to be changed. Please follow-up with their respective owners internally. |
Any updates? |
There are no current plans to implement this functionality. Implementing this on Window will require changes to the native HTTP stacks. A linux-only implementation might be possible. Feel free to submit a PR for this if you need it soon. |
Windows doesn't support it (we would need managed implementation or use curl). |
How about creating a pluggable proxy transport underneath the HttpWebRequest/Response? In other words, allow the user application to register a proxy scheme and have an API for implementing it. The SOCKS protocol is extremely simple but I understand you not wanting to explicitly support it. This would allow others who need it to get by with a "good enough" internal implementation that MS is not on the hook for and have a low support burden. From what I can tell this would likely involve altering ServicePointManager et al to allow custom ServicePoints. Seems relatively straightforward. |
Add https/socks5 for SocketsHttpClient. |
+1 |
+1 Please add support for socketshttpclient, and i assume clientwebsocket will automatically benefit |
Please upvote the top post - that is searchable and sortable via GitHub ;) |
how many thumbs up need? to release that |
50+ will start to be interesting ... |
Interested about this feature too. Should be possible to implement it through SocketsHttpHandler. |
There is also an implementation of this feature https://github.com/MihaZupan/HttpToSocks5Proxy |
Maybe we can ask @MihaZupan to chime in, how difficult it would be to port into our repo ... |
For people that just want to use a socks5 proxy in their .Net apps right away, the library mentioned above should work fine and should work in every scenario as it implements the IWebProxy interface. Having built-in support would be better in terms of performance overhead and resolving issues (some error information is swallowed by the library). Having looked at the code, adding support shouldn't be too difficult now that there is a common managed implementation between platforms. It also likely wouldn't affect the public API surface at all as the type of proxy (http/socks4/socks4a/socks5) can be specified in the Uri scheme. I think this is reasonable to implement as I've received a lot of requests for this functionality from the community, hence the aforementioned library. |
If any community member would like to take this and try implementing it, ping me so I can assign the issue to you. I can help out with PR review. Otherwise I will look into this in the following weeks. |
+1 |
@MihaZupan I'm interested in this because I've read socks5 spec and done some tiny implementation. |
@huoyaoyuan That's great to hear! The idea would be to allow this: var handler = new HttpClientHandler
{
Proxy = new WebProxy("socks5://127.0.0.1", 9050)
};
var httpClient = new HttpClient(handler);
Console.WriteLine(await httpClient.GetStringAsync("https://httpbin.org/ip")); Essentially allowing This will require changes in I'll be happy to assist if you need help with the implementation/in PR review. |
@MihaZupan How will this interop with |
In case of an HTTP CONNECT, we create the tunnel by asking the connection pool manager to send a new For a Socks tunnel, we would instead use the |
I'm meaning that if a user specifies both Socks proxy and |
What we do after that (socks handshake / http connect ...) stays the same, regardless of whether the callback was used. So the behavior for socks would be the same as for an http proxy - if specified, the callback is used for the connection to the proxy (as that is the only connection we're creating ourselves).
|
So, the |
Yes |
After reading implementation, I'm not sure how to carry the information from request to |
Any chances of this happening?
The text was updated successfully, but these errors were encountered: