From 1ee9cad027e910b36bd4191ef2339d02e6711a32 Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 13 Feb 2016 08:31:12 +0000 Subject: CIDR in no_proxy * lib/uri/generic.rb (URI::Generic#find_proxy): support CIDR in no_proxy. [ruby-core:73769] [Feature#12062] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53817 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/uri/generic.rb | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb index f2a2d567e3..3c4cb6e530 100644 --- a/lib/uri/generic.rb +++ b/lib/uri/generic.rb @@ -1547,9 +1547,18 @@ module URI name = 'no_proxy' if no_proxy = ENV[name] || ENV[name.upcase] no_proxy.scan(/(?!\.)([^:,\s]+)(?::(\d+))?/) {|host, port| - if /(\A|\.)#{Regexp.quote host}\z/i =~ self.host && - (!port || self.port == port.to_i) - return nil + if (!port || self.port == port.to_i) + if /(\A|\.)#{Regexp.quote host}\z/i =~ self.host + return nil + else + require 'ipaddr' + return nil if + begin + IPAddr.new(host) + rescue IPAddr::InvalidAddressError + next + end.include?(self.host) + end end } end -- cgit v1.2.3