Version: v1.0.1 Latest Latest

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

Go to latest
Published: Nov 24, 2020 License: Apache-2.0, BSD-2-Clause Imports: 5 Imported by: 0




This section is empty.


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")


func IPToString

func IPToString(ip net.IP) string

func IsIPv6

func IsIPv6(ip net.IP) bool


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

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL