class Proxy
Attributes
timeout[R]
type[R]
Public Class Methods
new(host="localhost",port=8080,options={},credentials={})
click to toggle source
# File lib/proxy.rb, line 10 def initialize(host="localhost",port=8080,options={},credentials={}) @host = host @port = port @type = options[:type] || "http" @timeout = options[:timeout].to_i || 10 @credentials = credentials @config = options end
Public Instance Methods
change_ip()
click to toggle source
# File lib/proxy.rb, line 23 def change_ip if @config[:tor] if @node.nil? @node = Tor::Controller.new(:host => @credentials[:telnet_host], :port => @credentials[:telnet_port]) end if !@node.authenticated? @node.authenticate(@credentials[:telnet_passwd]) end @node.signal("NEWNYM") end end
get_ip()
click to toggle source
# File lib/proxy.rb, line 38 def get_ip Typhoeus::Config.user_agent = UserAgents.rand() response = Typhoeus::Request.new("http://checkip.amazonaws.com/", timeout: @timeout, proxy: self.url, proxytype: @type).run return response.response_body.gsub("\n", '').strip end
url()
click to toggle source
# File lib/proxy.rb, line 19 def url return @host.to_s+":"+@port.to_s end