class ProxyUtilities::Checker
Public Class Methods
new(ip, port)
click to toggle source
# File lib/proxy_utilities/checker.rb, line 6 def initialize(ip, port) @ip = ip @port = port end
Public Instance Methods
check_amazon?()
click to toggle source
# File lib/proxy_utilities/checker.rb, line 32 def check_amazon? begin url = "http://amazon.com" proxy_connection = Net::HTTP::Proxy(@ip, @port.to_i) Timeout.timeout(3) do return proxy_connection.start(url).active? end rescue return false end end
check_any_website(websites)
click to toggle source
# File lib/proxy_utilities/checker.rb, line 44 def check_any_website(websites) result = {} proxy_connection = Net::HTTP::Proxy(@ip, @port.to_i) websites.each do |website| begin Timeout.timeout(3) do result[website] = proxy_connection.start(website).active? end rescue next end end return result end
check_google?()
click to toggle source
# File lib/proxy_utilities/checker.rb, line 20 def check_google? begin url = "http://google.com" proxy_connection = Net::HTTP::Proxy(@ip, @port.to_i) Timeout.timeout(3) do return proxy_connection.start(url).active? end rescue return false end end
check_online?()
click to toggle source
# File lib/proxy_utilities/checker.rb, line 11 def check_online? begin check = Net::Ping::External.new(host = @ip, port = @port) check.ping? rescue return false end end