Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/lib/net/dns/rr/soa.rb
Views: 11784
# -*- coding: binary -*-1##2#3# Net::DNS::RR::SOA4#5# $Id: SOA.rb,v 1.4 2006/07/28 07:33:36 bluemonk Exp $6#7##89module Net10module DNS11class RR1213#------------------------------------------------------------14# RR type SOA15#------------------------------------------------------------16class SOA < RR17attr_reader :mname, :rname, :serial, :refresh, :retry, :expire, :minimum1819private2021def build_pack22@soa_pack = pack_name(@mname)23@soa_pack += pack_name(@rname)24@soa_pack += [@serial,@refresh,@retry,@expire,@minimum].pack("N5")25end2627def set_type28@type = Net::DNS::RR::Types.new("SOA")29end3031def get_data32@soa_pack33end3435def get_inspect36"#@mname #@rname #@serial #@refresh #@retry #@expire #@minimum"37end3839def subclass_new_from_hash(args)40if args.has_key? :rdata41subclass_new_from_string(args[:rdata])42else43[:mname,:rname,:serial,:refresh,:retry,:expire,:minimum].each do |key|44raise RRArgumentError, "Missing field :#{key}" unless args.has_key? key45end46@mname = args[:mname] if valid? args[:mname]47@rname = args[:rname] if valid? args[:rname]48@serial = args[:serial] if number? args[:serial]49@refresh = args[:refresh] if number? args[:refresh]50@retry = args[:retry] if number? args[:retry]51@expire = args[:expire] if number? args[:expire]52@minimum = args[:minimum] if number? args[:minimum]53end54end5556def number?(num)57if num.kind_of? Integer and num > 058true59else60raise RRArgumentError, "Wrong format field: #{num} not a number or less than zero"61end62end6364def subclass_new_from_string(str)65mname,rname,serial,refresh,ret,expire,minimum = str.strip.split(" ")66@mname = mname if valid? mname67@rname = rname if valid? rname68@serial,@refresh,@retry,@expire,@minimum = [serial,refresh,ret,expire,minimum].collect do |i|69i.to_i if valid? i.to_i70end71end7273def subclass_new_from_binary(data,offset)74@mname,offset = dn_expand(data,offset)75@rname,offset = dn_expand(data,offset)76@serial,@refresh,@retry,@expire,@minimum = data.unpack("@#{offset} N5")77return offset + 5*Net::DNS::INT32SZ78end7980end # class SOA8182end # class RR83end # module DNS84end # module Net858687