Sha256: 1f2c442e3e6b9f7f3b9540a791915d533e5adb03e5858f19bd9178290fdbe247
Contents?: true
Size: 1.96 KB
Versions: 2
Compression:
Stored size: 1.96 KB
Contents
require 'ipaddr' module Net module DNS class RR # # RR type AAAA # class AAAA < RR attr_reader :address # Assign to the RR::AAAA object a new IPv6 address, which can be in the # form of a string or an IPAddr object # # a.address = "::1" # a.address = IPAddr.new("::1") # def address=(addr) @address = check_address addr build_pack end # address= private def check_address(addr) address = "" case addr when String address = IPAddr.new addr when IPAddr address = addr else raise ArgumentError, "Unknown address type: #{addr.inspect}" end raise ArgumentError, "Must specify an IPv6 address" unless address.ipv6? address rescue ArgumentError raise ArgumentError, "Invalid address #{addr.inspect}" end def build_pack @address_pack = @address.hton @rdlength = @address_pack.size end def get_data @address_pack end def get_inspect "#@address" end def subclass_new_from_hash(args) if args.has_key? :address @address = check_address args[:address] else raise ArgumentError, ":address field is mandatory but missing" end end def subclass_new_from_string(str) @address = check_address(str) end def subclass_new_from_binary(data,offset) arr = data.unpack("@#{offset} n8") @address = IPAddr.new sprintf("%x:%x:%x:%x:%x:%x:%x:%x",*arr) return offset + 16 end private def set_type @type = Net::DNS::RR::Types.new("AAAA") end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
net-dns-0.6.1 | lib/net/dns/rr/aaaa.rb |
net-dns-0.6.0 | lib/net/dns/rr/aaaa.rb |