Class: PassiveDNS::Client
- Inherits:
-
Object
- Object
- PassiveDNS::Client
- Defined in:
- lib/passivedns/client.rb,
lib/passivedns/client/version.rb
Constant Summary collapse
- VERSION =
"2.0.2"
Instance Method Summary collapse
-
#debug=(d) ⇒ Object
initialize.
-
#initialize(pdns = ['bfk','dnsdb','virustotal','tcpiputils','cn360','mnemonic','passivetotal','CIRCL'], configfile = "#{ENV['HOME']}/.passivedns-client") ⇒ Client
constructor
A new instance of Client.
- #query(item, limit = nil) ⇒ Object
Constructor Details
#initialize(pdns = ['bfk','dnsdb','virustotal','tcpiputils','cn360','mnemonic','passivetotal','CIRCL'], configfile = "#{ENV['HOME']}/.passivedns-client") ⇒ Client
Returns a new instance of Client.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/passivedns/client.rb', line 26 def initialize(pdns=['bfk','dnsdb','virustotal','tcpiputils','cn360','mnemonic','passivetotal','CIRCL'], configfile="#{ENV['HOME']}/.passivedns-client") cp = ConfigParser.new(configfile) # this creates a map of all the PassiveDNS provider names and their classes class_map = {} PassiveDNS.constants.each do |const| if PassiveDNS.const_get(const).is_a?(Class) and PassiveDNS.const_get(const).superclass == PassiveDNS::PassiveDB class_map[PassiveDNS.const_get(const).config_section_name] = PassiveDNS.const_get(const) end end @pdnsdbs = [] pdns.uniq.each do |pd| if class_map[pd] @pdnsdbs << class_map[pd].new(cp[pd] || {}) else raise "Unknown Passive DNS provider: #{pd}" end end end |
Instance Method Details
#debug=(d) ⇒ Object
initialize
47 48 49 50 51 |
# File 'lib/passivedns/client.rb', line 47 def debug=(d) @pdnsdbs.each do |pdnsdb| pdnsdb.debug = d end end |
#query(item, limit = nil) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/passivedns/client.rb', line 53 def query(item, limit=nil) threads = [] @pdnsdbs.each do |pdnsdb| threads << Thread.new(item) do |q| pdnsdb.lookup(q, limit) 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 |