Feature #12062
closedsupporting CIDR in ENV["no_proxy"]
Description
Ruby supports ENV["no_proxy"]
in lib/uri/generic.rb
Current implementation expects comma separated hostname suffix and exact IP address.
It is similar to wget
implementation.
(the difference is wget
does suffix match only no_proxy
hostname begins with period. But this difference is not so harmful.)
Current Implementation¶
Ruby doesn't support CIDR style(ex. 192.168.2.0/24
) no_proxy
instruction.
It is also mentioned too in this post.
http://unix.stackexchange.com/questions/23452/set-a-network-range-in-the-no-proxy-environment-variable
Workaround¶
And mentioned workaround is below.
printf -v no_proxy '%s,' 10.1.{1..255}.{1..255};
export no_proxy="${no_proxy%,}";
I think it is ugly solution.
If one doesn't want to use proxy in private network(it is very common in company's network)
It may require configuration like
no_proxy=10.0.0.0,10.0.0.1,10.0.0.......10.255.255.255(about 219MB)
length of ENV["no_proxy"]
will become about 219MB(!!)
It will take much more time in Ruby's URI implementation right now.
current lib/uri/generic.rb
is below.
no_proxy.scan(/([^:,]*)(?::(\d+))?/) {|host, port|
if /(\A|\.)#{Regexp.quote host}\z/i =~ self.host &&
(!port || self.port == port.to_i)
return nil
end
}
It requires regexp engine searching over 219MB string's data.
Long config file cause terrible performance suffer.
Linux standard might be wget
, but Python does not.
Python implementation in a widely used library requests is here
Suggetsion¶
I think Python's solution is cool and fast and minimize surprising.
So I wish ruby to support CIDR style no_proxy
instruction like Python.
Updated by nobu (Nobuyoshi Nakada) almost 9 years ago
- Description updated (diff)
Updated by kumagi (宏樹 熊崎) almost 9 years ago
Nobuyoshi Nakada wrote:
https://github.com/ruby/ruby/compare/trunk...nobu:feature/12062-no_proxy-CIDR
:+1:
thank you!
Updated by nobu (Nobuyoshi Nakada) almost 9 years ago
- Description updated (diff)
- Status changed from Open to Closed
Updated by vo.x (Vit Ondruch) over 8 years ago
- Related to Bug #12421: Please backport r53816, r53817 added