class Subnet::IPv6::Loopback

Overview

The loopback address is a unicast localhost address. If an application in a host sends packets to this address, the IPv6 stack will loop these packets back on the same virtual interface.

Loopback addresses are expressed in the following form:

::1

or, with its appropriate prefix,

::1/128

As for the unspecified addresses, IPv6 loopbacks can be created with Subnet calling their own class:

ip = Subnet::IPv6::Loopback.new

ip.to_string
# => "::1/128"

Checking if an address is loopback is easy with the IPv6#loopback? method:

ip.loopback?
# => true

The IPv6 loopback address corresponds to 127.0.0.1 in IPv4.

Defined in:

subnet/ipv6.cr

Constructors

Instance methods inherited from class Subnet::IPv6

<=>(oth) <=>, [](index) [], []=(index, value) []=, address : String address, allocate(skip = 0) allocate, arpa arpa, bits bits, broadcast_u128 broadcast_u128, compressed : String compressed, data data, each(&) each, group(index) group, groups : Array(Int32) groups, hex_groups hex_groups, hexstring hexstring, includes?(oth) includes?, link_local? link_local?, literal literal, loopback? loopback?, mapped? mapped?, network network, network? network?, network_u128 network_u128, pred pred, prefix : Prefix128 prefix, prefix=(num) prefix=, reverse reverse, size size, succ succ, to_big_i to_big_i, to_i to_i, to_json(json : JSON::Builder) to_json, to_s : String to_s, to_string to_string, to_string_uncompressed to_string_uncompressed, to_u128 to_u128, unique_local? unique_local?, unspecified? unspecified?

Constructor methods inherited from class Subnet::IPv6

new(str : String)
new(value : JSON::PullParser) : Subnet::IPv6
new

Class methods inherited from class Subnet::IPv6

compress(str) compress, expand(str) expand, groups(str) groups, parse_data(data, prefix = 128) parse_data, parse_hex(hexstring, prefix = 128) parse_hex, parse_u128(u128, prefix = 128) parse_u128

Instance methods inherited from module Subnet

ipv4? ipv4?, ipv6? ipv6?, to_json(json : JSON::Builder) to_json

Constructor methods inherited from module Subnet

new(value : JSON::PullParser) : Subnet new, parse(str) : Subnet parse

Class methods inherited from module Subnet

deprecate(message = nil) deprecate, ntoa(uint) ntoa, valid?(addr) valid?, valid_ip?(addr) valid_ip?, valid_ipv4?(addr) valid_ipv4?, valid_ipv4_netmask?(addr) valid_ipv4_netmask?, valid_ipv4_subnet?(addr) valid_ipv4_subnet?, valid_ipv6?(addr) valid_ipv6?, valid_ipv6_subnet?(addr) valid_ipv6_subnet?

Constructor Detail

def self.new(bla = nil) #

Creates a new IPv6 loopback address

ip = Subnet::IPv6::Loopback.new

ip.to_string
# => "::1/128"

[View source]