Inverse api_key and ip_address arguments in lookup method

master
Guillaume Dott 2013-01-20 01:27:37 +01:00
parent 56166bbb3c
commit 2870baff6e
3 changed files with 11 additions and 11 deletions

View File

@ -19,15 +19,16 @@ This Gem requires that you have an Http:BL API key from Project Honeypot. You ca
== Usage
require 'project_honeypot'
HTTP:BL lookups through Project Honeypot result in a Url object that gives you the risk score, last activity, and types of offenses the ip address is listed for.
The score is worse the higher it is and the last_activity is in days.
=== Example #1: Suspicious IP Address
Given an api key of "abcdefghijkl"
@listing = ProjectHoneypot.lookup("abcdefghijkl", "192.168.1.1")
@listing = ProjectHoneypot.lookup("<ip_address>", "<api_key>")
@listing.safe?
# => false
@ -60,7 +61,7 @@ Given an api key of "abcdefghijkl"
=== Example #2: Safe IP Address
@listing = ProjectHoneypot.lookup("192.168.1.1")
@listing = ProjectHoneypot.lookup("<ip_address>")
@listing.safe?
# => true

View File

@ -1 +0,0 @@
require "project_honeypot"

View File

@ -18,12 +18,12 @@ module ProjectHoneypot
end
end
def self.lookup(api_key_or_url, url=nil)
if url.nil?
url = api_key_or_url
api_key_or_url = ProjectHoneypot.api_key
end
searcher = Base.new(api_key_or_url)
def self.lookup(url, api_key=nil)
api_key ||= ProjectHoneypot.api_key
raise ArgumentError, 'Must specify an API key' unless api_key
searcher = Base.new(api_key)
searcher.lookup(url)
end
end