Documentation ¶
Index ¶
- func NewIPMap() *ipmap
- func NewIPMapFor(r IPMapper) *ipmap
- type IPMap
- type IPMapper
- type IPSet
- func (s *IPSet) Addrs() []netip.Addr
- func (s *IPSet) Confirm(ip netip.Addr)
- func (s *IPSet) Confirmed() netip.Addr
- func (s *IPSet) Disconfirm(ip netip.Addr) (done bool)
- func (s *IPSet) Empty() bool
- func (s *IPSet) OneIPOnly() bool
- func (s *IPSet) Protected() bool
- func (s *IPSet) Reset() *IPSet
- func (s *IPSet) Seed() []string
- func (s *IPSet) Size() uint32
- type IPSetType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewIPMapFor ¶
func NewIPMapFor(r IPMapper) *ipmap
NewIPMapFor returns a fresh IPMap with r as its nameserver.
Types ¶
type IPMap ¶
type IPMap interface { IPMapper // Resolves hostOrIP and adds the resulting IPs to its IPSet. // hostOrIP may be host:port, or ip:port, or host, or ip. Add(hostOrIP string) *IPSet // Get creates an IPSet for this hostname populated with the IPs // discovered by resolving it. Subsequent calls to Get return the // same IPSet. Never returns nil. // hostOrIP may be host:port, or ip:port, or host, or ip. Get(hostOrIP string) *IPSet // GetAny creates an IPSet for this hostname, which may be empty. // Subsequent calls to GetAny return the same IPSet. Never returns nil. // hostOrIP may be host:port, or ip:port, or host, or ip. GetAny(hostOrIP string) *IPSet // MakeIPSet creates an IPSet for this hostname bootstrapped with given IPs // or IP:Ports. Subsequent calls to MakeIPSet return a new, overridden IPSet. // hostOrIP may be host:port, or ip:port, or host, or ip. MakeIPSet(hostOrIP string, ipps []string, typ IPSetType) *IPSet // With sets the default resolver to use for hostname resolution. With(r IPMapper) // Clear removes all IPSets from the map. Clear() }
IPMap maps hostnames to IPSets.
type IPMapper ¶
type IPMapper interface { Lookup(q []byte) ([]byte, error) LookupOn(q []byte, tids ...string) ([]byte, error) LookupNetIP(ctx context.Context, network, host string) ([]netip.Addr, error) LookupNetIPOn(ctx context.Context, network, host string, tids ...string) ([]netip.Addr, error) }
IPMapper is an interface for resolving hostnames to IP addresses. For internal used by firestack.
type IPSet ¶
type IPSet struct {
// 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) Addrs ¶
Addrs 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.
func (*IPSet) Confirm ¶
Confirm marks ip as the confirmed address. No-op if current confirmed IP is the same as ip. No-op if s is of type Protected and ip isn't in seed addrs. No-op if s is of type IPAddr.
func (*IPSet) Confirmed ¶
Confirmed returns the confirmed IP address, or zeroaddr if there is no such address.
func (*IPSet) Disconfirm ¶
Disconfirm sets the confirmed address to zeroaddr if the current confirmed address is the provided ip.