Skip to content
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

Add support for Tor HTTPTunnelPort #75

Closed
kzu opened this issue May 20, 2021 · 5 comments · Fixed by #77
Closed

Add support for Tor HTTPTunnelPort #75

kzu opened this issue May 20, 2021 · 5 comments · Fixed by #77

Comments

@kzu
Copy link
Contributor

kzu commented May 20, 2021

See https://2019.www.torproject.org/docs/tor-manual.html.en#HTTPTunnelPort

@joelverhagen
Copy link
Owner

OMG how did I not know of this? If I understand correctly, does this completely eliminate the need for Privoxy?

@joelverhagen
Copy link
Owner

From https://gitweb.torproject.org/tor.git/plain/ChangeLog, it looks like this feature was added in this release:

Changes in version 0.3.2.1-alpha - 2017-09-18

That's 2 years after I started the project. I guess I should have been staying on top of new features 😄. Thanks for the heads up!

@joelverhagen
Copy link
Owner

Okay, I've investigated the current state:

Privoxy supports both HTTP proxy and HTTP CONNECT on the same port. This is why .NET works so well with it because Privoxy can handle both modes that .NET sends.

If you know all of the URLs you're hitting with HttpClient will be HTTPS, then you don't need Privoxy at all and you can do something like this:

            using (var proxy = new TorSharpProxy(settings))
            {
                var handler = new HttpClientHandler
                {
                    Proxy = new WebProxy(new Uri("http://localhost:" + settings.TorSettings.HttpTunnelPort))
                };

                using (handler)
                using (var httpClient = new HttpClient(handler))
                {
                    await proxy.ConfigureAndStartAsync();
                    Console.WriteLine(await httpClient.GetStringAsync("https://api.ipify.org"));
                }

                proxy.Stop();
            }

In short, for the purposes of this library, this is a great addition for extensibility purposes but Privoxy is still necessary for the non-HTTPS URL case.

@kzu
Copy link
Contributor Author

kzu commented May 21, 2021

Yep, was down that rabbit whole yesterday, hehe. Interesting distinction with HTTP vs HTTPS! That was tripping me up too!

@joelverhagen
Copy link
Owner

Release in TorSharp 2.8.0. Thanks again, @kzu!
https://www.nuget.org/packages/Knapcode.TorSharp/2.8.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants