class Net::DNS::RR::AAAA

IPv6 Address Record (AAAA) ↑

Class for DNS IPv6 Address (AAAA) resource records.

Public Instance Methods

address() click to toggle source

Gets the current IPv6 address for this record.

Returns an instance of IPAddr.

# File lib/net/dns/rr/aaaa.rb, line 15
def address
  @address
end
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 28
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 38
def value
  address.to_s
end

Private Instance Methods

build_pack() click to toggle source
# File lib/net/dns/rr/aaaa.rb, line 90
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 73
def check_address(input)
  address = case input
    when IPAddr
      input
    when String
      IPAddr.new(input)
    else
      raise ArgumentError, "Invalid IP address `#{input}'"
  end

  if !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 95
def get_data
  @address_pack
end
get_inspect() click to toggle source
# File lib/net/dns/rr/aaaa.rb, line 68
def get_inspect
  value
end
set_type() click to toggle source
# File lib/net/dns/rr/aaaa.rb, line 64
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 57
def subclass_new_from_binary(data, offset)
  tokens = data.unpack("@#{offset} n8")
  @address = IPAddr.new(sprintf("%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 45
def subclass_new_from_hash(options)
  if options.has_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 53
def subclass_new_from_string(str)
  @address = check_address(str)
end