Class: PassiveDNS::Provider::Circl
- Inherits:
-
PassiveDNS::PassiveDB
- Object
- PassiveDNS::PassiveDB
- PassiveDNS::Provider::Circl
- Defined in:
- lib/passivedns/client/provider/circl.rb
Overview
Queries CIRCL.LU’s passive DNS database Circl is aliased by CIRCL
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 “circl”.
-
.name ⇒ Object
Sets the modules self-reported name to “CIRCL”.
-
.option_letter ⇒ Object
Sets the command line database argument to “c”.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Circl
constructor
You should either have a username+password or an authorization token to use this service.
-
#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 = {}) ⇒ Circl
You should either have a username+password or an authorization token to use this service
Example Instantiation
= {
:debug => true,
"USERNAME" => "circl_user",
"PASSWORD" => "circl_pass",
"URL" => "https://www.circl.lu/pdns/query"
}
PassiveDNS::Provider::CIRCL.new()
48 49 50 51 52 53 54 |
# File 'lib/passivedns/client/provider/circl.rb', line 48 def initialize(={}) @debug = [:debug] || false @username = ["USERNAME"] @password = ["PASSWORD"] @auth_token = ["AUTH_TOKEN"] @url = ["URL"] || "https://www.circl.lu/pdns/query" end |
Instance Attribute Details
#debug ⇒ Object
:debug enables verbose logging to standard output
27 28 29 |
# File 'lib/passivedns/client/provider/circl.rb', line 27 def debug @debug end |
Class Method Details
.config_section_name ⇒ Object
Sets the configuration section name to “circl”
18 19 20 |
# File 'lib/passivedns/client/provider/circl.rb', line 18 def self.config_section_name "circl" end |
.name ⇒ Object
Sets the modules self-reported name to “CIRCL”
14 15 16 |
# File 'lib/passivedns/client/provider/circl.rb', line 14 def self.name "CIRCL" end |
.option_letter ⇒ Object
Sets the command line database argument to “c”
22 23 24 |
# File 'lib/passivedns/client/provider/circl.rb', line 22 def self.option_letter "c" 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
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/passivedns/client/provider/circl.rb', line 58 def lookup(label, limit=nil) $stderr.puts "DEBUG: #{self.class.name}.lookup(#{label})" if @debug Timeout::timeout(240) { 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.request_uri) request.add_field("User-Agent", "Ruby/#{RUBY_VERSION} passivedns-client rubygem v#{PassiveDNS::Client::VERSION}") if @username request.basic_auth(@username, @password) end if @auth_token request.add_field("Authorization", @auth_token) 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 |