Class: PassiveDNS::Provider::Mnemonic
- Inherits:
-
PassiveDNS::PassiveDB
- Object
- PassiveDNS::PassiveDB
- PassiveDNS::Provider::Mnemonic
- Defined in:
- lib/passivedns/client/provider/mnemonic.rb
Overview
Queries Mnemonic’s passive DNS database
Instance Attribute Summary collapse
-
#debug ⇒ Object
:debug enables verbose logging to standard output.
Class Method Summary collapse
-
.config_section_name ⇒ Object
Sets the configuration section name to “mnemonic”.
-
.name ⇒ Object
Sets the modules self-reported name to “Mnemonic”.
-
.option_letter ⇒ Object
Sets the command line database argument to “m”.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Mnemonic
constructor
Options * :debug Sets the debug flag for the module * “APIKEY” The API key associated with Mnemonic for doing automated queries * “URL” Alternate url for testing.
-
#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.
Constructor Details
#initialize(options = {}) ⇒ Mnemonic
Options
-
:debug Sets the debug flag for the module
-
“APIKEY” The API key associated with Mnemonic for doing automated queries
-
“URL” Alternate url for testing. Defaults to “api.mnemonic.no/pdns/v3/”
Example Instantiation
= {
:debug => true,
"APIKEY" => "01234567890abcdef01234567890abcdef012345",
"URL" => "https://api.mnemonic.no/pdns/v3/"
}
PassiveDNS::Provider::Mnemonic.new()
42 43 44 45 46 47 48 49 50 |
# File 'lib/passivedns/client/provider/mnemonic.rb', line 42 def initialize(={}) @debug = [:debug] || false @timeout = [:timeout] || 20 @apikey = ["APIKEY"] @url = ["URL"] || "https://api.mnemonic.no/pdns/v3/" if @url == "https://passivedns.mnemonic.no/api1/?apikey=" @url = "https://api.mnemonic.no/pdns/v3/" end end |
Instance Attribute Details
#debug ⇒ Object
:debug enables verbose logging to standard output
26 27 28 |
# File 'lib/passivedns/client/provider/mnemonic.rb', line 26 def debug @debug end |
Class Method Details
.config_section_name ⇒ Object
Sets the configuration section name to “mnemonic”
17 18 19 |
# File 'lib/passivedns/client/provider/mnemonic.rb', line 17 def self.config_section_name "mnemonic" end |
.name ⇒ Object
Sets the modules self-reported name to “Mnemonic”
13 14 15 |
# File 'lib/passivedns/client/provider/mnemonic.rb', line 13 def self.name "Mnemonic" end |
.option_letter ⇒ Object
Sets the command line database argument to “m”
21 22 23 |
# File 'lib/passivedns/client/provider/mnemonic.rb', line 21 def self.option_letter "m" 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
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/passivedns/client/provider/mnemonic.rb', line 54 def lookup(label, limit=nil) $stderr.puts "DEBUG: #{self.class.name}.lookup(#{label})" if @debug Timeout::timeout(@timeout) { url = "#{@url}#{label}" $stderr.puts "DEBUG: #{self.class.name} url = #{url}" if @debug url = URI.parse url http = Net::HTTP.new(url.host, url.port) http.use_ssl = (url.scheme == 'https') http.verify_mode = OpenSSL::SSL::VERIFY_NONE http.verify_depth = 5 request = Net::HTTP::Get.new(url.path) request.add_field("User-Agent", "Ruby/#{RUBY_VERSION} passivedns-client rubygem v#{PassiveDNS::Client::VERSION}") if @apikey request.add_field("Argus-API-Key", @apikey) end t1 = Time.now response = http.request(request) t2 = Time.now recs = parse_json(response.body, label, t2-t1) if limit recs[0,limit] else recs end } rescue Timeout::Error => e $stderr.puts "#{self.class.name} lookup timed out: #{label}" end |