Module: Chef::Mixin::ProxifiedSocket

Includes:
ChefConfig::Mixin::FuzzyHostnameMatcher
Defined in:
lib/chef/mixin/proxified_socket.rb

Instance Method Summary collapse

Instance Method Details

#proxified_socket(host, port) ⇒ Object

This looks at the environment variables and leverages Proxifier to make the TCPSocket respect ENV['https_proxy'] or ENV['http_proxy'] if they are present



30
31
32
33
34
35
36
37
38
# File 'lib/chef/mixin/proxified_socket.rb', line 30

def proxified_socket(host, port)
  proxy = ENV["https_proxy"] || ENV["http_proxy"] || false

  if proxy && !fuzzy_hostname_match_any?(host, ENV["no_proxy"])
    Proxifier.Proxy(proxy).open(host, port)
  else
    TCPSocket.new(host, port)
  end
end