Project

General

Profile

Actions

Feature #12062

closed

supporting CIDR in ENV["no_proxy"]

Added by kumagi (宏樹 熊崎) almost 9 years ago. Updated almost 9 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:73769]

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.


Related issues 1 (0 open1 closed)

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

Updated by nobu (Nobuyoshi Nakada) almost 9 years ago

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

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

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

Also available in: Atom PDF

Like0
Like0Like0Like0Like0