Class: PassiveDNS::Client
- Inherits:
-
Object
- Object
- PassiveDNS::Client
- Defined in:
- lib/passivedns/client.rb,
lib/passivedns/client/version.rb
Constant Summary collapse
- VERSION =
"1.1.1"
Instance Method Summary collapse
-
#debug=(d) ⇒ Object
initialize.
-
#initialize(pdns = ['bfk','certee','dnsparse','dnsdb','virustotal']) ⇒ Client
constructor
A new instance of Client.
- #query(item) ⇒ Object
Constructor Details
#initialize(pdns = ['bfk','certee','dnsparse','dnsdb','virustotal']) ⇒ Client
Returns a new instance of Client.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/passivedns/client.rb', line 18 def initialize(pdns=['bfk','certee','dnsparse','dnsdb','virustotal']) @pdnsdbs = [] pdns.uniq.each do |pd| case pd when 'bfk' @pdnsdbs << PassiveDNS::BFK.new when 'certee' @pdnsdbs << PassiveDNS::CERTEE.new when 'dnsparse' @pdnsdbs << PassiveDNS::DNSParse.new when 'dnsdb' @pdnsdbs << PassiveDNS::DNSDB.new when 'isc' @pdnsdbs << PassiveDNS::DNSDB.new when 'virustotal' @pdnsdbs << PassiveDNS::VirusTotal.new else raise "Unknown Passive DNS provider: #{pd}" end end end |
Instance Method Details
#debug=(d) ⇒ Object
initialize
40 41 42 43 44 |
# File 'lib/passivedns/client.rb', line 40 def debug=(d) @pdnsdbs.each do |pdnsdb| pdnsdb.debug = d end end |
#query(item) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/passivedns/client.rb', line 46 def query(item) threads = [] @pdnsdbs.each do |pdnsdb| threads << Thread.new(item) do |q| pdnsdb.lookup(q) end end results = [] threads.each do |thr| rv = thr.join.value if rv rv.each do |r| if ["A","AAAA","NS","CNAME","PTR"].index(r.rrtype) results << r end end end end return results end |