module Net # :nodoc: module DNS class RR #------------------------------------------------------------ # RR type SOA #------------------------------------------------------------ class SOA < RR attr_reader :mname, :rname, :serial, :refresh, :retry, :expire, :minimum private def build_pack @soa_pack = pack_name(@mname) @soa_pack += pack_name(@rname) @soa_pack += [@serial,@refresh,@retry,@expire,@minimum].pack("N5") @rdlength = @soa_pack.size end def get_data @soa_pack end def get_inspect "#@mname #@rname #@serial #@refresh #@retry #@expire #@minimum" end def subclass_new_from_hash(args) if args.has_key? :rdata subclass_new_from_string(args[:rdata]) else [:mname,:rname,:serial,:refresh,:retry,:expire,:minimum].each do |key| raise ArgumentError, "Missing field :#{key}" unless args.has_key? key end @mname = args[:mname] if valid? args[:mname] @rname = args[:rname] if rname? args[:rname] @serial = args[:serial] if number? args[:serial] @refresh = args[:refresh] if number? args[:refresh] @retry = args[:retry] if number? args[:retry] @expire = args[:expire] if number? args[:expire] @minimum = args[:minimum] if number? args[:minimum] end end def number?(num) if num.kind_of? Integer and num > 0 true else false end end def rname?(name) mailbox, domain = name.split(/(?