module Dnsruby
@TODO@ Max size for cache?
require 'Dnsruby/iana_ports'
This class does verification/validation from a single point - signed root, DLV, trust anchors. Dnssec
controls a set of these to perform validation for the client. This class should only be used by Dnsruby
This class provides the facility to load a zone file. It can either process one line at a time, or return an entire zone as a list of records.
Dnsruby
library¶ ↑
Dnsruby
is a thread-aware DNS
stub resolver library written in Ruby.
It is based on resolv.rb, the standard Ruby DNS
implementation, but gives a complete DNS
implementation, including DNSSEC.
The Resolv
class can be used to resolve addresses using /etc/hosts and /etc/resolv.conf, or the DNS
class can be used to make DNS
queries. These interfaces will attempt to apply the default domain and searchlist when resolving names.
The Resolver
and SingleResolver
interfaces allow finer control of individual messages. The Resolver
class sends queries to multiple resolvers using various retry mechanisms. The SingleResolver
class is used by Resolver
to send individual Messages to individual resolvers.
Resolver
queries return Dnsruby::Message
objects. Message
objects have five sections:
-
The header section, a
Dnsruby::Header
object. -
The question section, a list of
Dnsruby::Question
objects. -
The answer section, a list of Dnsruby::Resource objects.
-
The authority section, a list of Dnsruby::Resource objects.
-
The additional section, a list of Dnsruby::Resource objects.
example¶ ↑
res = Dnsruby::Resolver.new # System default ret = res.query("example.com") print "#{ret.anwer.length} answer records returned, #{ret.answer.rrsets.length} RRSets returned in aswer section\n" p Dnsruby::Resolv.getaddress("www.ruby-lang.org") p Dnsruby::Resolv.getname("210.251.121.214") Dnsruby::DNS.open {|dns| p dns.getresources("www.ruby-lang.org", Dnsruby::Types.A).collect {|r| r.address} p dns.getresources("ruby-lang.org", 'MX').collect {|r| [r.exchange.to_s, r.preference]} }
exceptions¶ ↑
-
ResolvError
< StandardError -
ResolvTimeout
< TimeoutError
I/O¶ ↑
Dnsruby
implements a pure Ruby event loop to perform I/O. Support for EventMachine has been deprecated.
DNSSEC¶ ↑
Dnsruby
supports DNSSEC and NSEC(3). DNSSEC support is on by default - but no trust anchors are configured by default. See Dnsruby::Dnssec
for more details.
Bugs¶ ↑
-
NIS is not supported.
-
/etc/nsswitch.conf is not supported.
-
NSEC3 validation still TBD
Constants
- VERSION
@TODO@ Remember to update version in dnsruby.gemspec!
Public Class Methods
Get the log for Dnsruby
Use this to set the log level e.g. Dnsruby.log
.level = Logger::INFO
# File lib/dnsruby.rb, line 117 def Dnsruby.log @@logger end
# File lib/dnsruby.rb, line 108 def Dnsruby.version return VERSION end