| 
									
										
										
										
											2013-01-04 10:05:37 +01:00
										 |  |  | require 'net/dns' | 
					
						
							|  |  |  | require "project_honeypot/url" | 
					
						
							|  |  |  | require "project_honeypot/base" | 
					
						
							|  |  |  | require "project_honeypot/rack/header" | 
					
						
							|  |  |  | require "project_honeypot/rack/forbidden" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module ProjectHoneypot | 
					
						
							|  |  |  |   class << self | 
					
						
							| 
									
										
										
										
											2013-01-04 17:22:00 +01:00
										 |  |  |     attr_accessor :api_key, :score, :last_activity, :offenses | 
					
						
							| 
									
										
										
										
											2013-01-04 10:05:37 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def api_key | 
					
						
							|  |  |  |       raise "ProjectHoneypot really needs its api_key set to work" unless @api_key | 
					
						
							|  |  |  |       @api_key | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def configure(&block) | 
					
						
							|  |  |  |         class_eval(&block) | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-01-20 01:27:37 +01:00
										 |  |  |   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) | 
					
						
							| 
									
										
										
										
											2013-01-04 10:05:37 +01:00
										 |  |  |     searcher.lookup(url) | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |