ipaddress

package
v6.18.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 3, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IPAddress

type IPAddress struct {
	// The IP address
	Address net.IP `json:"address"`
	// The TransIP DNS resolvers you can use
	DNSResolvers []net.IP `json:"dnsResolvers,omitempty"`
	// Gateway
	Gateway net.IP `json:"gateway,omitempty"`
	// Reverse DNS, also known as the PTR record
	ReverseDNS string `json:"reverseDns"`
	// Subnet mask
	SubnetMask SubnetMask `json:"subnetMask,omitempty"`
}

IPAddress struct for an IPAddress

type IPAddressesWrapper

type IPAddressesWrapper struct {
	// array of IP Addresses
	IPAddresses []IPAddress `json:"ipAddresses,omitempty"`
}

IPAddressesWrapper struct wraps an IPAddress struct, this is mainly used in other subpackages that need to unmarshal a ipAddresses: [] server response

type IPRange

type IPRange struct {
	net.IPNet
}

IPRange is a wrapper around IPNet as it has no default marshallers

func (*IPRange) MarshalText

func (r *IPRange) MarshalText() ([]byte, error)

MarshalText MarshalText implements the encoding.TextMarshaler interface. The encoding is the same as returned by net.IPNet.String

func (*IPRange) UnmarshalText

func (r *IPRange) UnmarshalText(input []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface. The IPRange is expected in a form accepted by net.ParseCIDR function e.g.: '192.168.0.1/24' or '2a01::1/48' for IPv6

type SubnetMask

type SubnetMask struct {
	IPType int
	net.IPMask
}

SubnetMask is a wrapper around net.IPMask. This is needed as the transip api returns subnetmask strings that are not unmarshallable by default. So we need to do a little bit of magic to unmarshal either '255.255.255.0' and '/48' as net.IPMask type

func (*SubnetMask) MarshalText

func (mask *SubnetMask) MarshalText() ([]byte, error)

MarshalText MarshalText implements the encoding.TextMarshaler interface. The encoding is the same as returned by net.IPMask.String

func (*SubnetMask) UnmarshalText

func (mask *SubnetMask) UnmarshalText(input []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface. The SubnetMask is expected in a form accepted by parseIPv6Mask or net.ParseIP e.g.: '255.255.255.0' or '/48' for IPv6

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL