module ProxyUtilities
Give 2 main methods, that are needed to using the game
Constants
- VERSION
Public Class Methods
check_proxy(ip, port, websites: nil, check_websites: false)
click to toggle source
params
ip ipadress of proxy server string port port of proxy server string webistes array of websites to check Array[string]
# File lib/proxy_utilities.rb, line 29 def self.check_proxy(ip, port, websites: nil, check_websites: false) proxy = ProxyUtilities::Checker.new(ip, port) result = {} if proxy.check_online? result[:status] = true if check_websites result[:websites] = {} if proxy.check_google? result[:websites][:google] = true else result[:websites][:google] = false end if proxy.check_amazon? result[:websites][:amazon] = true else result[:websites][:amazon] = false end if websites.present? result[:websites] = result[:websites].merge(proxy.check_any_website(websites)) end end else result[:status] = false end return result end
check_proxy_list(list, websites: nil, check_websites: false)
click to toggle source
params
list form of [{:ip => "0.0.0.0", :port => 80, ....}, ....] check_websites if he has to check google and amazon boolean webistes array of websites to check Array[string]
# File lib/proxy_utilities.rb, line 66 def self.check_proxy_list(list, websites: nil, check_websites: false) result = [] threads = [] poolsize = 10 jobs = Queue.new list.each{|p| jobs.push p} poolsize.times do threads << Thread.new do begin while proxy = jobs.pop(true) Thread.exit if proxy.nil? if proxy.key?(:ip) and proxy.key?(:port) begin result << ProxyUtilities.check_proxy(proxy[:ip], proxy[:port], websites: websites, check_websites: check_websites).merge({:ip => proxy[:ip], :port => proxy[:port]}) end end end rescue Thread.exit end end end threads.each(&:join) return result end
get_proxies()
click to toggle source
Say hi to the world!
Example:
>> ProxyUtilities.get_proxies => [{ip: "0.0.0.0", port: 80, country_code: "US", anonymity: elite, type: "HTTPS"}]
Arguments:
proxybroker: (String) proxybroker_limit (Integer) proxybroker_type (Array["HTTP", "HTTPS", "SOCKS4", "SOCKS5"])
# File lib/proxy_utilities.rb, line 19 def self.get_proxies() return ProxyUtilities::Getter.get_all() end