class Net::DNS::RR::AAAA

IPv6 Address Record (AAAA)

Class for DNS IPv6 Address (AAAA) resource records.

Attributes

address[R]

Gets the current IPv6 address for this record.

Returns an instance of IPAddr.

Public Instance Methods

address=(string_or_ipaddr) click to toggle source

Assigns a new IPv6 address to this record, which can be in the form of a String or an IPAddr object.

Examples

a.address = "192.168.0.1"
a.address = IPAddr.new("10.0.0.1")

Returns the new allocated instance of IPAddr.

# File lib/net/dns/rr/aaaa.rb, line 24
def address=(string_or_ipaddr)
  @address = check_address(string_or_ipaddr)
  build_pack
  @address
end
value() click to toggle source

Gets the standardized value for this record, represented by the value of address.

Returns a String.

# File lib/net/dns/rr/aaaa.rb, line 34
def value
  address.to_s
end

Private Instance Methods

build_pack() click to toggle source
# File lib/net/dns/rr/aaaa.rb, line 83
def build_pack
  @address_pack = @address.hton
  @rdlength = @address_pack.size
end
check_address(input) click to toggle source
# File lib/net/dns/rr/aaaa.rb, line 66
def check_address(input)
  address = case input
  when IPAddr
    input
  when String
    IPAddr.new(input)
  else
    raise ArgumentError, "Invalid IP address `#{input}'"
  end

  unless address.ipv6?
    raise(ArgumentError, "Must specify an IPv6 address")
  end

  address
end
get_data() click to toggle source
# File lib/net/dns/rr/aaaa.rb, line 88
def get_data
  @address_pack
end
get_inspect() click to toggle source
# File lib/net/dns/rr/aaaa.rb, line 62
def get_inspect
  value
end
set_type() click to toggle source
# File lib/net/dns/rr/aaaa.rb, line 58
def set_type
  @type = Net::DNS::RR::Types.new("AAAA")
end
subclass_new_from_binary(data, offset) click to toggle source
# File lib/net/dns/rr/aaaa.rb, line 52
def subclass_new_from_binary(data, offset)
  tokens = data.unpack("@#{offset} n8")
  @address = IPAddr.new(format("%x:%x:%x:%x:%x:%x:%x:%x", *tokens))
  offset + 16
end
subclass_new_from_hash(options) click to toggle source
# File lib/net/dns/rr/aaaa.rb, line 40
def subclass_new_from_hash(options)
  if options.key?(:address)
    @address = check_address(options[:address])
  else
    raise ArgumentError, ":address field is mandatory"
  end
end
subclass_new_from_string(str) click to toggle source
# File lib/net/dns/rr/aaaa.rb, line 48
def subclass_new_from_string(str)
  @address = check_address(str)
end