ipmap

package
v0.0.0-...-4cf4c4f Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IPMap

type IPMap interface {
	// Get creates an IPSet for this hostname populated with the IPs
	// discovered by resolving it.  Subsequent calls to Get return the
	// same IPSet.
	Get(hostname string) *IPSet
}

IPMap maps hostnames to IPSets.

func NewIPMap

func NewIPMap(r *net.Resolver) IPMap

NewIPMap returns a fresh IPMap. `r` will be used to resolve any hostnames passed to `Get` or `Add`.

type IPSet

type IPSet struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

IPSet represents an unordered collection of IP addresses for a single host. One IP can be marked as confirmed to be working correctly.

func (*IPSet) Add

func (s *IPSet) Add(hostname string)

Add one or more IP addresses to the set. The hostname can be a domain name or an IP address.

func (*IPSet) Confirm

func (s *IPSet) Confirm(ip net.IP)

Confirm marks ip as the confirmed address.

func (*IPSet) Confirmed

func (s *IPSet) Confirmed() net.IP

Confirmed returns the confirmed IP address, or nil if there is no such address.

func (*IPSet) Disconfirm

func (s *IPSet) Disconfirm(ip net.IP)

Disconfirm sets the confirmed address to nil if the current confirmed address is the provided ip.

func (*IPSet) Empty

func (s *IPSet) Empty() bool

Empty reports whether the set is empty.

func (*IPSet) GetAll

func (s *IPSet) GetAll() []net.IP

GetAll returns a copy of the IP set as a slice in random order. The slice is owned by the caller, but the elements are owned by the set.

Jump to

Keyboard shortcuts

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