Class: ProjectHoneypot::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/project_honeypot/base.rb

Instance Method Summary collapse

Constructor Details

#initialize(api_key) ⇒ Base

Returns a new instance of Base.



3
4
5
# File 'lib/project_honeypot/base.rb', line 3

def initialize(api_key)
  @api_key = api_key
end

Instance Method Details

#lookup(ip_address) ⇒ Object



7
8
9
10
11
12
# File 'lib/project_honeypot/base.rb', line 7

def lookup(ip_address)
  ip_address = url_to_ip(ip_address)
  reversed_ip = ip_address.split(".").reverse.join(".")
  honeypot_score = extract_ip_address(Net::DNS::Resolver.start("#{@api_key}.#{reversed_ip}.dnsbl.httpbl.org"))
  Url.new(ip_address, honeypot_score)
end