Class: PassiveDNS::Provider::BFK

Inherits:
PassiveDNS::PassiveDB show all
Defined in:
lib/passivedns/client/provider/bfk.rb

Overview

Queries BFK.de’s passive DNS database

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ BFK

Options

Example Instantiation

options = {
  :debug => true,
  "URL" => "http://www.bfk.de/bfk_dnslogger.html?query="
}

PassiveDNS::Provider::BFK.new(options)


38
39
40
41
# File 'lib/passivedns/client/provider/bfk.rb', line 38

def initialize(options={})
	@debug = options[:debug] || false
    @base = options["URL"] || "http://www.bfk.de/bfk_dnslogger.html?query="
end

Instance Attribute Details

#debugObject

:debug enables verbose logging to standard output



23
24
25
# File 'lib/passivedns/client/provider/bfk.rb', line 23

def debug
  @debug
end

Class Method Details

.config_section_nameObject

Sets the configuration section name to “bfk”



14
15
16
# File 'lib/passivedns/client/provider/bfk.rb', line 14

def self.config_section_name
  "bfk"
end

.nameObject

Sets the modules self-reported name to “BFK.de”



10
11
12
# File 'lib/passivedns/client/provider/bfk.rb', line 10

def self.name
  "BFK.de"
end

.option_letterObject

Sets the command line database argument to “b”



18
19
20
# File 'lib/passivedns/client/provider/bfk.rb', line 18

def self.option_letter
  "b"
end

Instance Method Details

#lookup(label, limit = nil) ⇒ Object

Takes a label (either a domain or an IP address) and returns an array of PassiveDNS::PDNSResult instances with the answers to the query



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/passivedns/client/provider/bfk.rb', line 45

def lookup(label, limit=nil)	
	$stderr.puts "DEBUG: #{self.class.name}.lookup(#{label})" if @debug
	Timeout::timeout(240) {
		t1 = Time.now
		open(
			@base+label,
			"User-Agent" => "Ruby/#{RUBY_VERSION} passivedns-client rubygem v#{PassiveDNS::Client::VERSION}"
		) do |f|
			t2 = Time.now
			recs = parse(f.read,t2-t1)
        if limit
          recs[0,limit]
        else
          recs
        end
		end
	}
rescue Timeout::Error => e
	$stderr.puts "#{self.class.name} lookup timed out: #{label}"      
end