lib/sfpagent/helper.rb in sfpagent-0.4.3 vs lib/sfpagent/helper.rb in sfpagent-0.4.4
- old
+ new
@@ -62,14 +62,21 @@
path.sub!(/^\/+/, '')
URI.parse("http://#{address}:#{port}/#{path}")
end
def use_http_proxy?(uri)
- ENV['no_proxy'].to_s.split(',').each { |pattern|
- pattern.chop! if pattern[-1] == '*'
- return false if uri.host[0,pattern.length] == pattern
- }
- true
+ parts = uri.host.split('.')
+ if parts[0] == '10' or
+ (parts[0] == '172' and parts[1] == '16') or
+ (parts[0] == '192' and parts[1] == '168')
+ false
+ else
+ ENV['no_proxy'].to_s.split(',').each { |pattern|
+ pattern.chop! if pattern[-1] == '*'
+ return false if uri.host[0,pattern.length] == pattern
+ }
+ true
+ end
end
def http_request(uri, request, open_timeout=5, read_timeout=1800)
if ENV['http_proxy'].to_s.strip != '' and use_http_proxy?(uri)
proxy = URI.parse(ENV['http_proxy'])