Class: ProxiClean::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/proxi_clean/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(debug = false) ⇒ Client

Returns a new instance of Client.



8
9
10
11
# File 'lib/proxi_clean/client.rb', line 8

def initialize(debug=false)
  @debug = debug
  public_ip
end

Instance Attribute Details

#debugObject (readonly)

Returns the value of attribute debug.



6
7
8
# File 'lib/proxi_clean/client.rb', line 6

def debug
  @debug
end

#public_ipObject (readonly)

Returns the value of attribute public_ip.



6
7
8
# File 'lib/proxi_clean/client.rb', line 6

def public_ip
  @public_ip
end

Instance Method Details

#proxied_ip(proxy_uri) ⇒ Object



31
32
33
# File 'lib/proxi_clean/client.rb', line 31

def proxied_ip(proxy_uri)
  real_ip(proxy_uri: proxy_uri)
end

#works?(proxy_uri) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/proxi_clean/client.rb', line 13

def works?(proxy_uri)
  begin
    puts 'Checking: ' + proxy_uri if @debug
    proxied_ip = proxied_ip(proxy_uri)
  rescue StandardError => e
    puts 'ERROR: ' + e.message if @debug
    # If anything goes wrong, assuming the proxy is no good
    return false
  end

  public_ip != proxied_ip
end