Class: PassiveDNS::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/passivedns/client.rb,
lib/passivedns/client/version.rb

Constant Summary collapse

VERSION =
"1.3.1"

Instance Method Summary collapse

Constructor Details

#initialize(pdns = ['bfk','certee','dnsdb','virustotal','tcpiputils']) ⇒ 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
39
40
# File 'lib/passivedns/client.rb', line 18

def initialize(pdns=['bfk','certee','dnsdb','virustotal','tcpiputils'])
	@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
      when 'tcpiputils'
			@pdnsdbs << PassiveDNS::TCPIPUtils.new
		else
			raise "Unknown Passive DNS provider: #{pd}"
		end
	end
end

Instance Method Details

#debug=(d) ⇒ Object

initialize



42
43
44
45
46
# File 'lib/passivedns/client.rb', line 42

def debug=(d)
	@pdnsdbs.each do |pdnsdb|
		pdnsdb.debug = d
	end
end

#query(item, limit = nil) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/passivedns/client.rb', line 48

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