Object
Servers are specified in the same manor as options, e.g.
[:tcp/:udp, address, port]
In the case of multiple servers, they will be checked in sequence.
# File lib/rubydns/resolver.rb, line 35 def initialize(servers, options = {}) @servers = servers @sequence = 0 @options = options end
Yields a list of `Resolv::IPv4` and `Resolv::IPv6` addresses for the given `name` and `resource_class`.
# File lib/rubydns/resolver.rb, line 62 def addresses_for(name, resource_class = Resolv::DNS::Resource::IN::A, &block) query(name, resource_class) do |response| # Resolv::DNS::Name doesn't retain the trailing dot. name = name.sub(/\.$/, '') case response when Message yield response.answer.select{|record| record[0].to_s == name}.collect{|record| record[2].address} else yield [] end end end
Provides the next sequence identification number which is used to keep track of DNS messages.
# File lib/rubydns/resolver.rb, line 43 def next_id! # Sequence IDs are 16-bit integers. return (@sequence += 1) % (2**16) end
Look up a named resource of the given resource_class.
# File lib/rubydns/resolver.rb, line 49 def query(name, resource_class = Resolv::DNS::Resource::IN::A, &block) message = Resolv::DNS::Message.new(next_id!) message.rd = 1 message.add_question name, resource_class send_message(message, &block) end
Generated with the Darkfish Rdoc Generator 2.