def proxy_required(uri)
use_proxy = true
if @bot.config["http.proxy_exclude"].empty? && @bot.config["http.proxy_include"].empty?
return use_proxy
end
list = [uri.host]
begin
list.concat Resolv.getaddresses(uri.host)
rescue StandardError => err
warning "couldn't resolve host uri.host"
end
unless @bot.config["http.proxy_exclude"].empty?
re = @bot.config["http.proxy_exclude"].collect{|r| Regexp.new(r)}
re.each do |r|
list.each do |item|
if r.match(item)
use_proxy = false
break
end
end
end
end
unless @bot.config["http.proxy_include"].empty?
re = @bot.config["http.proxy_include"].collect{|r| Regexp.new(r)}
re.each do |r|
list.each do |item|
if r.match(item)
use_proxy = true
break
end
end
end
end
debug "using proxy for uri #{uri}?: #{use_proxy}"
return use_proxy
end