Skip to content

Commit 89e174f

Browse files
committed
Ensure that even 127.*.*.* Ruby traffic is proxied
It turns out that Ruby's default URI implementation explicitly disables this, and doesn't document that. We now override the find_proxy method completely, so it *always* uses the HTK proxy.
1 parent 676d423 commit 89e174f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

overrides/gems/uri/generic.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Remove this module from LOAD_PATH, so we can load the real one
2+
gem_override_path = File.expand_path('..', __dir__) # parent dir, we're a subfolder
3+
$LOAD_PATH.reject! { |path| File.expand_path(path) == gem_override_path }
4+
5+
# Load uri/generic, and inject our proxy settings as the default for all requests
6+
require 'uri/generic'
7+
module URI
8+
class Generic
9+
def find_proxy
10+
# Real code for this avoids it in various cases, if some CGI env vars
11+
# are set, or for 127.*.*.* requests. We want to ensure we use it always.
12+
URI.parse(ENV['HTTP_PROXY'])
13+
end
14+
end
15+
end
16+
17+
# Put this override directory back on LOAD_PATH
18+
$LOAD_PATH.unshift(gem_override_path)

0 commit comments

Comments
 (0)