Feature #12062

supporting CIDR in ENV["no_proxy"]

Added by kumagi (宏樹 熊崎) over 4 years ago. Updated over 4 years ago.

Target version:


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. no_proxy instruction.

It is also mentioned too in this post.


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....... 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 =~ &&
    (!port || self.port == port.to_i)
      return nil

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


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.

Related issues

Related to Ruby master - Bug #12421: Please backport r53816, r53817ClosedActions

Updated by nobu (Nobuyoshi Nakada) over 4 years ago

  • Description updated (diff)
  • Status changed from Open to Closed

Updated by vo.x (Vit Ondruch) over 4 years ago

  • Related to Bug #12421: Please backport r53816, r53817 added

Also available in: Atom PDF