Class: Net::DNS::RR::CNAME

Inherits:
Net::DNS::RR show all
Defined in:
lib/Net/DNS/RR/CNAME.rb

Overview

NAME

Net::DNS::RR::CNAME - DNS CNAME resource record

DESCRIPTION

Class for DNS Canonical Name (CNAME) resource records.

COPYRIGHT

Copyright © 1997-2002 Michael Fuhr.

Portions Copyright © 2002-2004 Chris Reinhardt.

Ruby version Copyright © 2006 AlexD (Nominet UK)

All rights reserved. This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

Net::DNS, Net::DNS::Resolver, Net::DNS::Packet, Net::DNS::Header, Net::DNS::Question, Net::DNS::RR, RFC 1035 Section 3.3.1

Constant Summary

Constants inherited from Net::DNS::RR

RRS

Instance Attribute Summary collapse

Attributes inherited from Net::DNS::RR

#name, #rdata, #rdlength, #rrclass, #ttl, #type

Instance Method Summary collapse

Methods inherited from Net::DNS::RR

#_canonicaldata, _get_subclass, _name2wire, #_name2wire, build_regex, create, #create_rrsort_func, #data, #get_rrsort_func, #init, #init_rrsort_func, #inspect, new_from_data, new_from_hash, new_from_string, #set_rrsort_func

Instance Attribute Details

#cnameObject

Returns the RR’s canonical name.

print "cname = ", rr.cname, "\n"


48
49
50
# File 'lib/Net/DNS/RR/CNAME.rb', line 48

def cname
  @cname
end

Instance Method Details

#_canonicalRdataObject

rdata contains a compressed domainname… we should not have that.



83
84
85
# File 'lib/Net/DNS/RR/CNAME.rb', line 83

def _canonicalRdata
  return _name2wire(@cname);
end

#new_from_data(data, offset) ⇒ Object



49
50
51
52
53
# File 'lib/Net/DNS/RR/CNAME.rb', line 49

def new_from_data(data, offset)
  if (@rdlength > 0)
    @cname = Net::DNS::Packet::dn_expand(data, offset)[0];
  end
end

#new_from_hash(values) ⇒ Object



62
63
64
65
66
# File 'lib/Net/DNS/RR/CNAME.rb', line 62

def new_from_hash(values)
  if values.has_key?(:cname)
    @cname = values[:cname]
  end
end

#new_from_string(s) ⇒ Object



55
56
57
58
59
60
# File 'lib/Net/DNS/RR/CNAME.rb', line 55

def new_from_string(s)
  if (s!=nil)
    string = s.sub(/\.+$/o, "");
    @cname = string;
  end
end

#rdatastrObject



68
69
70
# File 'lib/Net/DNS/RR/CNAME.rb', line 68

def rdatastr
  return @cname ? "#{@cname}." : '';
end

#rr_rdata(packet, offset) ⇒ Object



72
73
74
75
76
77
78
79
80
# File 'lib/Net/DNS/RR/CNAME.rb', line 72

def rr_rdata(packet, offset)
  rdata = "";
  
  if (defined?@cname)
    rdata = packet.dn_comp(@cname, offset);
  end
  
  return rdata;
end