diff options
author | Salim Alam <salam@chef.io> | 2016-03-17 14:04:53 -0700 |
---|---|---|
committer | Salim Alam <salam@chef.io> | 2016-03-21 21:23:08 -0700 |
commit | 88e05318bc4409b24e9e5ac45403cfde21ad7006 (patch) | |
tree | f72e23329332cee559e3cd1484a7700735bddefc /chef-config | |
parent | b22d5d03a3d26e274f8f33aacea3666681f02116 (diff) | |
download | chef-88e05318bc4409b24e9e5ac45403cfde21ad7006.tar.gz |
Override no_proxy with internal matcher
Diffstat (limited to 'chef-config')
-rw-r--r-- | chef-config/lib/chef-config/config.rb | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/chef-config/lib/chef-config/config.rb b/chef-config/lib/chef-config/config.rb index 9da69a1867..53799e9ee1 100644 --- a/chef-config/lib/chef-config/config.rb +++ b/chef-config/lib/chef-config/config.rb @@ -27,6 +27,7 @@ require "chef-config/windows" require "chef-config/path_helper" require "mixlib/shellout" require "uri" +require "fuzzyurl" require "openssl" module ChefConfig @@ -864,8 +865,13 @@ module ChefConfig end excludes = ENV["no_proxy"].to_s.split(/\s*,\s*/).compact - excludes = excludes.map { |exclude| exclude =~ /:\d+$/ ? exclude : "#{exclude}:*" } - return proxy unless excludes.any? { |exclude| File.fnmatch(exclude, "#{host}:#{port}") } + return proxy unless excludes.any? { |exclude| fuzzy_hostname_match?(exclude, host) } + end + + def self.fuzzy_hostname_match?(match, hostname) + # Do greedy matching by adding wildcard if it is not specified + match = "*" + match if !match.start_with?("*") + Fuzzyurl.matches?(Fuzzyurl.mask(hostname: match), hostname) end # Chef requires an English-language UTF-8 locale to function properly. We attempt |