def find_all_roots(args)
root = args[:root] || 'localhost'
rootip = args[:rootip] || '127.0.0.1'
aaaa = args[:aaaa] || false
types = aaaa ? TYPE_ARRAY_AAAA : TYPE_ARRAY_A
Log.debug { "find_roots entry #{root}" }
@resolver.nameserver = rootip
msg = @resolver.query('', 'NS')
raise msg if msg.is_a? Exception
msg_validate(msg, :qname => '', :qtype => 'NS')
msg_comment(msg, :want_recursion => false)
ns = msg_answers?(msg, :qname => '', :qtype => 'NS')
return nil unless ns
roots = Array.new
for rr in ns do
ips = []
for type in types do
iprrs = msg_additional?(msg, :qname => rr.domainname, :qtype => type)
if iprrs then
ips.concat iprrs.map {|iprr| iprr.address.to_s }
end
end
unless ips then
Log.debug { "Locally resolving root #{rr.domainname}" }
for type in types do
msg = @lresolver.query(rr.domainname, type)
msg_validate(msg, :qname => rr.domainname, :qtype => type)
msg_comment(msg, :want_recursion => true)
iprrs = msg_answers?(msg, :qname => rr.domainname, :qtype => type)
if iprrs then
ips.concat iprrs.map {|iprr| iprr.address.to_s }
end
end
end
unless ips.size > 0 then
Log.warn { "Failed to resolve #{rr.domainname} type #{qtype}" }
next
end
roots.push({ :name => rr.domainname, :ips => ips })
end
Log.debug { "find_roots exit, #{roots.map { |x| x[:name] }.join(', ') }" }
return roots
end