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

Fix support for HTTP proxies #11245

Merged
merged 4 commits into from
Jul 7, 2019
Merged

Conversation

ClearlyClaire
Copy link
Contributor

@ClearlyClaire ClearlyClaire commented Jul 6, 2019

The Request::Socket class implements its own logic for connection timeouts, to give us a bit more control, and because http.rb uses the ill-advised Timeout::timeout. That latter mechanism is bypassed entirely. Therefore, not using our Socket class means we do not have proper handling of connection timeouts.

This PR changes that by using our custom class for both direct connections and connections through a proxy—in which case the socket class is used to connect to the proxy.

Additionally, since the socket is used to connect to the proxy, it will never get used with a hidden service as host, so removed the additional check.

Also added support for IP addresses in addition to hostnames.

Hidden services can only be accessed with an HTTP proxy, in which
case the host seen by the Socket class will be the proxy, not the
target host.

Hidden services are already filtered in `Request#initialize`.
@ClearlyClaire ClearlyClaire force-pushed the fixes/http-proxy branch 4 times, most recently from 319064c to 59575f3 Compare July 6, 2019 13:42
Avoid the timeout logic being bypassed
@ClearlyClaire ClearlyClaire marked this pull request as ready for review July 6, 2019 14:10
@ClearlyClaire
Copy link
Contributor Author

ClearlyClaire commented Jul 6, 2019

I haven't tested hidden services, but I have tested access with and without an HTTP proxy, as well as reverse-proxies failing to connect (this indeed fixed hanging processes).

EDIT: requesting a review from hcmiya because they were the one to add the hidden service code in the first place

@ClearlyClaire ClearlyClaire requested a review from hcmiya July 6, 2019 14:12
@Gargron Gargron merged commit 5827671 into mastodon:master Jul 7, 2019
ClearlyClaire added a commit to ClearlyClaire/mastodon that referenced this pull request Jul 7, 2019
* Disable incorrect check for hidden services in Socket

Hidden services can only be accessed with an HTTP proxy, in which
case the host seen by the Socket class will be the proxy, not the
target host.

Hidden services are already filtered in `Request#initialize`.

* Use our Socket class to connect to HTTP proxies

Avoid the timeout logic being bypassed

* Add support for IP addresses in Request::Socket

* Refactor a bit, no need to keep the DNS resolver around
hiyuki2578 pushed a commit to ProjectMyosotis/mastodon that referenced this pull request Oct 2, 2019
* Disable incorrect check for hidden services in Socket

Hidden services can only be accessed with an HTTP proxy, in which
case the host seen by the Socket class will be the proxy, not the
target host.

Hidden services are already filtered in `Request#initialize`.

* Use our Socket class to connect to HTTP proxies

Avoid the timeout logic being bypassed

* Add support for IP addresses in Request::Socket

* Refactor a bit, no need to keep the DNS resolver around
messenjahofchrist pushed a commit to Origin-Creative/mastodon that referenced this pull request Jul 30, 2021
* Disable incorrect check for hidden services in Socket

Hidden services can only be accessed with an HTTP proxy, in which
case the host seen by the Socket class will be the proxy, not the
target host.

Hidden services are already filtered in `Request#initialize`.

* Use our Socket class to connect to HTTP proxies

Avoid the timeout logic being bypassed

* Add support for IP addresses in Request::Socket

* Refactor a bit, no need to keep the DNS resolver around
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 this pull request may close these issues.

None yet

2 participants