about summary refs log tree commit diff
path: root/config/initializers
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-08-25 05:07:39 +0200
committerClaire <claire.github-309c@sitedethib.com>2022-08-25 05:07:39 +0200
commit2d1d4210f9d394ea8e7357df08f8ca2cc925384a (patch)
treea5c69693d11b59a673b1981ea2d85bbc17991c42 /config/initializers
parent5a3d09dc8e30198b4d8d921ef0b1ba0a35fe01d9 (diff)
parent861b35dd54d266bc0a40b3cacb28e5b82ff6faaa (diff)
Merge branch 'main' into glitch-soc/merge-upstream
Diffstat (limited to 'config/initializers')
-rw-r--r--config/initializers/http_client_proxy.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/config/initializers/http_client_proxy.rb b/config/initializers/http_client_proxy.rb
index 7a9b7b86d..b29e9edd7 100644
--- a/config/initializers/http_client_proxy.rb
+++ b/config/initializers/http_client_proxy.rb
@@ -18,5 +18,22 @@ Rails.application.configure do
     }.compact
   end
 
+  if ENV['http_hidden_proxy'].present?
+    proxy = URI.parse(ENV['http_hidden_proxy'])
+
+    raise "Unsupported proxy type: #{proxy.scheme}" unless %w(http https).include? proxy.scheme
+    raise "No proxy host" unless proxy.host
+
+    host = proxy.host
+    host = host[1...-1] if host[0] == '[' # for IPv6 address
+
+    config.x.http_client_hidden_proxy[:proxy] = {
+      proxy_address: host,
+      proxy_port: proxy.port,
+      proxy_username: proxy.user,
+      proxy_password: proxy.password,
+    }.compact
+  end
+
   config.x.access_to_hidden_service = ENV['ALLOW_ACCESS_TO_HIDDEN_SERVICE'] == 'true'
 end