Class: Net::DNS::RR::SOA

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

Overview

NAME

Net::DNS::RR::SOA - DNS SOA resource record

DESCRIPTION

Class for DNS Start of Authority (SOA) 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.13

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

#expireObject

Returns the zone’s expire interval.

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


75
76
77
# File 'lib/Net/DNS/RR/SOA.rb', line 75

def expire
  @expire
end

#minimumObject

Returns the minimum (default) TTL for records in this zone.

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


80
81
82
# File 'lib/Net/DNS/RR/SOA.rb', line 80

def minimum
  @minimum
end

#mnameObject

Returns the domain name of the original or primary nameserver for this zone.

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


49
50
51
# File 'lib/Net/DNS/RR/SOA.rb', line 49

def mname
  @mname
end

#refreshObject

Returns the zone’s refresh interval.

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


65
66
67
# File 'lib/Net/DNS/RR/SOA.rb', line 65

def refresh
  @refresh
end

#retryObject

Returns the zone’s retry interval.

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


70
71
72
# File 'lib/Net/DNS/RR/SOA.rb', line 70

def retry
  @retry
end

#rnameObject

Returns a domain name that specifies the mailbox for the person responsible for this zone.

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


55
56
57
# File 'lib/Net/DNS/RR/SOA.rb', line 55

def rname
  @rname
end

#serialObject

Returns the zone’s serial number.

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


60
61
62
# File 'lib/Net/DNS/RR/SOA.rb', line 60

def serial
  @serial
end

Instance Method Details

#_canonicalRdataObject



178
179
180
181
182
183
184
185
186
187
188
189
190
191
# File 'lib/Net/DNS/RR/SOA.rb', line 178

def _canonicalRdata
  rdata = "";
  
  # Assume that if one field exists, they all exist.  Script will
  # print a warning otherwise.
  
  if (defined?@mname)
    rdata += _name2wire(@mname);		
    rdata += _name2wire(@rname);
    rdata += [@serial, @refresh, @retry, @expire, @minimum].pack("N5");
  end
  
  return rdata;
end

#get_next_param(s) ⇒ Object



135
136
137
138
139
140
141
# File 'lib/Net/DNS/RR/SOA.rb', line 135

def get_next_param(s) 
  s =~ /(\S+)/
  param = $1
  string = s[param.length, s.length-param.length]
  string.sub!(/\s*/, "")
  return param, string
end

#new_from_data(data, offset) ⇒ Object



81
82
83
84
85
86
87
88
# File 'lib/Net/DNS/RR/SOA.rb', line 81

def new_from_data(data, offset)
  if (@rdlength > 0)
   (@mname, offset) = Net::DNS::Packet::dn_expand(data, offset);
   (@rname, offset) = Net::DNS::Packet::dn_expand(data, offset);
    
     (@serial, @refresh, @retry, @expire, @minimum) = data.unpack("\@#{offset} N5");
  end
end

#new_from_hash(values) ⇒ Object



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/Net/DNS/RR/SOA.rb', line 90

def new_from_hash(values)
  if values.has_key?(:mname)
    @mname = values[:mname]
  end
  if values.has_key?(:rname)
    @rname = values[:rname]
  end
  if values.has_key?(:serial)
    @serial = values[:serial]
  end
  if values.has_key?(:refresh)
    @refresh = values[:refresh]
  end
  if values.has_key?(:retry)
    @retry = values[:retry]
  end
  if values.has_key?(:expire)
    @expire = values[:expire]
  end
  if values.has_key?(:minimum)
    @minimum = values[:minimum]
  end
end

#new_from_string(s) ⇒ Object



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/Net/DNS/RR/SOA.rb', line 114

def new_from_string(s)
  if (s!= nil)
    #            string =~ tr/()//d;
    string = s.tr("()", "")
    
    # XXX do we need to strip out comments here now that RR.pm does it?
    string.gsub!(/;.*$/, "");
    
    @mname, string = get_next_param(string)
    @rname, string = get_next_param(string)
    @serial, string = get_next_param(string)
    @refresh, string = get_next_param(string)
    @retry, string = get_next_param(string)
    @expire, string = get_next_param(string)
    @minimum, string = get_next_param(string)
    
    @mname.sub!(/\.+$/, "");
    @rname.sub!(/\.+$/, "");
  end
end

#rdatastrObject



143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/Net/DNS/RR/SOA.rb', line 143

def rdatastr
  rdatastr="";
  
  if (defined?@mname)
    rdatastr  = "#{@mname}. #{@rname}. (\n";
    rdatastr += "\t\t\t\t\t" + "#{@serial}\t; Serial\n";
    rdatastr += "\t\t\t\t\t" + "#{@refresh}\t; Refresh\n";
    rdatastr += "\t\t\t\t\t" + "#{@retry}\t; Retry\n";
    rdatastr += "\t\t\t\t\t" + "#{@expire}\t; Expire\n";
    rdatastr += "\t\t\t\t\t" + "#{@minimum} )\t; Minimum TTL";
  else
    rdatastr = '';
  end
  
  return rdatastr;
end

#rr_rdata(packet, offset) ⇒ Object



160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/Net/DNS/RR/SOA.rb', line 160

def rr_rdata(packet, offset)
  rdata = "";
  
  # Assume that if one field exists, they all exist.  Script will
  # print a warning otherwise.
  
  if (defined?@mname)
    rdata += packet.dn_comp(@mname, offset);
    rdata += packet.dn_comp(@rname,  offset + rdata.length);
    
    rdata += [@serial, @refresh, @retry, @expire, @minimum].pack("N5");
  end
  
  return rdata;
end