Module: RHACK::Proxy
- Defined in:
- lib/rhack/proxy/checker.rb
Defined Under Namespace
Classes: Checker, Interceptor
Constant Summary collapse
- PROXYLISTFILE =
'log/proxylist.txt'
- DefaultGet =
{:req => 'http://internet.yandex.ru/speed/?len=10&rnd=%s', :expect => {:body => "yandex! "}}
- DefaultDL =
{:req => 'http://internet.yandex.ru/speed/?len=100000', :expect => {:body => "yandex! "*12500}}
- DefaultPost =
{:req => [{'yandex!' => 'yandex!'}, false, 'http://internet.yandex.ru/speed/'], :expect => {:body => "hooray!"}}
Class Method Summary collapse
Class Method Details
.DOWANT(pl, opts = {}) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rhack/proxy/checker.rb', line 14 def DOWANT(pl, opts={}) opts[:div] ||= 50 opts[:timeout] ||= 5 pc = Checker pl, opts begin pc.check L.info "working proxies: #{pc.wpl.size} with average ping #{pc.wpl.values.avg}" pc.charge pc.get_by_ping(opts[:ping] || 0.5) opts[:div] = opts[:dl_div] || 5 opts[:timeout] = opts[:dl_timeout] pc.check opts L.info "fast proxies: #{pc.fpl.size} with average speed #{pc.fpl.values.avg.bytes}/s" pc.get_by_speed(opts[:speed] || 50000) rescue $pc = pc raise end end |