diff options
author | Claire <claire.github-309c@sitedethib.com> | 2022-08-25 05:07:39 +0200 |
---|---|---|
committer | Claire <claire.github-309c@sitedethib.com> | 2022-08-25 05:07:39 +0200 |
commit | 2d1d4210f9d394ea8e7357df08f8ca2cc925384a (patch) | |
tree | a5c69693d11b59a673b1981ea2d85bbc17991c42 /app/lib | |
parent | 5a3d09dc8e30198b4d8d921ef0b1ba0a35fe01d9 (diff) | |
parent | 861b35dd54d266bc0a40b3cacb28e5b82ff6faaa (diff) |
Merge branch 'main' into glitch-soc/merge-upstream
Diffstat (limited to 'app/lib')
-rw-r--r-- | app/lib/request.rb | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/app/lib/request.rb b/app/lib/request.rb index 4289da933..f5123d776 100644 --- a/app/lib/request.rb +++ b/app/lib/request.rb @@ -31,7 +31,7 @@ class Request @url = Addressable::URI.parse(url).normalize @http_client = options.delete(:http_client) @options = options.merge(socket_class: use_proxy? ? ProxySocket : Socket) - @options = @options.merge(Rails.configuration.x.http_client_proxy) if use_proxy? + @options = @options.merge(proxy_url) if use_proxy? @headers = {} raise Mastodon::HostValidationError, 'Instance does not support hidden service connections' if block_hidden_service? @@ -141,11 +141,23 @@ class Request end def use_proxy? - Rails.configuration.x.http_client_proxy.present? + proxy_url.present? + end + + def proxy_url + if hidden_service? && Rails.configuration.x.http_client_hidden_proxy.present? + Rails.configuration.x.http_client_hidden_proxy + else + Rails.configuration.x.http_client_proxy + end end def block_hidden_service? - !Rails.configuration.x.access_to_hidden_service && /\.(onion|i2p)$/.match?(@url.host) + !Rails.configuration.x.access_to_hidden_service && hidden_service? + end + + def hidden_service? + /\.(onion|i2p)$/.match?(@url.host) end module ClientLimit |