iputils

package
v0.0.0-...-25ef478 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2023 License: Apache-2.0, BSD-2-Clause Imports: 5 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidIPAddressOrHost = errors.New("invalid IP address or hostname")
View Source
var ErrNoIPAddressesFound = errors.New("could not resolve any IP address")
View Source
var ErrOriginAddrInvalidAddrChunk = errors.New("invalid address chunk in origin address")
View Source
var ErrOriginAddrInvalidPort = errors.New("invalid port in origin address")

Functions

func IPToString

func IPToString(ip net.IP) string

func IsIPv6

func IsIPv6(ip net.IP) bool

Types

type IPAddresses

type IPAddresses struct {
	IPs map[*net.IP]struct{}
}

func GetIPAddressesFromHost

func GetIPAddressesFromHost(hostname string) (*IPAddresses, error)

GetIPAddressesFromHost returns all resolvable IP addresses (*IPAddresses) from a host. If it is an IP address this IP address will be returned as *IPAddresses

func NewIPAddresses

func NewIPAddresses() *IPAddresses

func (*IPAddresses) Add

func (ips *IPAddresses) Add(ip net.IP)

func (*IPAddresses) GetPreferredAddress

func (ips *IPAddresses) GetPreferredAddress(preferIPv6 bool) net.IP

func (*IPAddresses) Len

func (ips *IPAddresses) Len() int

func (*IPAddresses) Remove

func (ips *IPAddresses) Remove(ip net.IP)

func (*IPAddresses) Union

func (ips *IPAddresses) Union(other *IPAddresses) *IPAddresses

type OriginAddress

type OriginAddress struct {
	Addr       string
	Port       uint16
	Alias      string
	PreferIPv6 bool
}

OriginAddress represents a tuple of a IP or hostname, port, alias and IPv6 preference

func ParseOriginAddress

func ParseOriginAddress(s string) (*OriginAddress, error)

func (*OriginAddress) String

func (ra *OriginAddress) String() string

Jump to

Keyboard shortcuts

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