Method: Dnsruby::Recursor#query
- Defined in:
- lib/Dnsruby/Recursor.rb
#query(name, type = Types.A, klass = Classes.IN, no_validation = false) ⇒ Object
This method is much like the normal query() method except it disables the recurse flag in the packet and explicitly performs the recursion.
packet = res.query( "www.netscape.com.", "A")
packet = res.query( "www.netscape.com.", "A", "IN", true) # no validation
The Recursor maintains a cache of known nameservers. DNSSEC validation is performed unless true is passed as the fourth parameter.
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 |
# File 'lib/Dnsruby/Recursor.rb', line 390 def query(name, type=Types.A, klass=Classes.IN, no_validation = false) # @TODO@ PROVIDE AN ASYNCHRONOUS SEND WHICH RETURNS MESSAGE WITH ERROR!!! # Make sure the hint servers are initialized. @@mutex.synchronize { self.hints=(Hash.new) unless @@hints } @resolver.recurse=(0) # Make sure the authority cache is clean. # It is only used to store A and AAAA records of # the suposedly authoritative name servers. # TTLs are respected @@mutex.synchronize { if (!@@zones_cache) Recursor.clear_caches(@resolver) end } # So we have normal hashes, but the array of addresses at the end is now an AddressCache # which respects the ttls of the A/AAAA records # Now see if we already know the zone in question # Otherwise, see if we know any of its parents (will know at least ".") known_zone, = (name) # ".", @hints if nothing else # Seed name servers with the closest known authority # ret = _dorecursion( name, type, klass, ".", @hints, 0) ret = _dorecursion( name, type, klass, known_zone, , 0, no_validation) Dnssec.validate(ret) if !no_validation # print "\n\nRESPONSE:\n#{ret}\n" return ret end |