Superclass for all Dnsruby resource records.
Represents a DNS RR (resource record) [RFC1035, section 3.2]
Use Dnsruby::RR::create(…) to create a new RR record.
mx = Dnsruby::RR.create("example.com. 7200 MX 10 mailhost.example.com.") rr = Dnsruby::RR.create({:name => "example.com", :type => "MX", :ttl => 7200, :preference => 10, :exchange => "mailhost.example.com"}) s = rr.to_s # Get a String representation of the RR (in zone file format) rr_again = Dnsruby::RR.create(s)
ClassInsensitiveTypes | = | { Types::NS => NS, Types::CNAME => CNAME, Types::DNAME => DNAME, Types::DNSKEY => DNSKEY, Types::SOA => SOA, Types::PTR => PTR, Types::HINFO => HINFO, Types::MINFO => MINFO, Types::MX => MX, Types::TXT => TXT, Types::ISDN => ISDN, Types::MB => MB, Types::MG => MG, Types::MR => MR, Types::NAPTR => NAPTR, Types::NSAP => NSAP, Types::OPT => OPT, Types::RP => RP, Types::RT => RT, Types::X25 => X25, Types::KX => KX, Types::SPF => SPF, Types::CERT => CERT, Types::LOC => LOC, Types::TSIG => TSIG, Types::TKEY => TKEY, Types::ANY => ANY, Types::RRSIG => RRSIG, Types::NSEC => NSEC, Types::DS => DS, Types::NSEC3 => NSEC3, Types::NSEC3PARAM => NSEC3PARAM, Types::DLV => DLV, Types::SSHFP => SSHFP, Types::IPSECKEY => IPSECKEY, Types::HIP => HIP, Types::DHCID => DHCID |
type | -> | rr_type |
klass | [R] | The Resource class |
name | [R] | The Resource‘s domain name |
rdata | [RW] | The Resource data section |
ttl | [RW] | The Resource Time-To-Live |
type | [R] | The Resource type |
Create a new RR from the arguments, which can be either a String or a Hash. See new_from_string and new_from_hash for details
a = Dnsruby::RR.create("foo.example.com. 86400 A 10.1.2.3") mx = Dnsruby::RR.create("example.com. 7200 MX 10 mailhost.example.com.") cname = Dnsruby::RR.create("www.example.com 300 IN CNAME www1.example.com") txt = Dnsruby::RR.create('baz.example.com 3600 HS TXT "text record"') rr = Dnsruby::RR.create({:name => "example.com"}) rr = Dnsruby::RR.create({:name => "example.com", :type => "MX", :ttl => 10, :preference => 5, :exchange => "mx1.example.com"})
Create a new RR from the hash. The name is required; all other fields are optional. Type defaults to ANY and the Class defaults to IN. The TTL defaults to 0.
If the type is specified, then it is necessary to provide ALL of the resource record fields which are specific to that record; i.e. for an MX record, you would need to specify the exchange and the preference
require 'Dnsruby' rr = Dnsruby::RR.new_from_hash({:name => "example.com"}) rr = Dnsruby::RR.new_from_hash({:name => "example.com", :type => Types.MX, :ttl => 10, :preference => 5, :exchange => "mx1.example.com"})
Returns a Dnsruby::RR object of the appropriate type and initialized from the string passed by the user. The format of the string is that used in zone files, and is compatible with the string returned by Net::DNS::RR.inspect
The name and RR type are required; all other information is optional. If omitted, the TTL defaults to 0 and the RR class defaults to IN.
All names must be fully qualified. The trailing dot (.) is optional.
a = Dnsruby::RR.new_from_string("foo.example.com. 86400 A 10.1.2.3") mx = Dnsruby::RR.new_from_string("example.com. 7200 MX 10 mailhost.example.com.") cname = Dnsruby::RR.new_from_string("www.example.com 300 IN CNAME www1.example.com") txt = Dnsruby::RR.new_from_string('baz.example.com 3600 HS TXT "text record"')