tailscale.comtailscale.com/cmd/natc/ippool Index | Files

package ippool

import "tailscale.com/cmd/natc/ippool"

ippool implements IP address storage, creation, and retrieval for cmd/natc

Index

Variables

var ErrNoIPsAvailable = errors.New("no IPs available")

Types

type ConsensusIPPool

type ConsensusIPPool struct {
	IPSet *netipx.IPSet
	// contains filtered or unexported fields
}

ConsensusIPPool implements an IPPool that is distributed among members of a cluster for high availability. Writes are directed to a leader among the cluster and are slower than reads, reads are performed locally using information replicated from the leader. The cluster maintains consistency, reads can be stale and writes can be unavailable if sufficient cluster peers are unavailable.

func NewConsensusIPPool

func NewConsensusIPPool(ipSet *netipx.IPSet) *ConsensusIPPool

func (*ConsensusIPPool) Apply

func (ipp *ConsensusIPPool) Apply(l *raft.Log) any

Apply is part of the raft.FSM interface. It takes an incoming log entry and applies it to the state.

func (*ConsensusIPPool) DomainForIP

func (ipp *ConsensusIPPool) DomainForIP(from tailcfg.NodeID, addr netip.Addr, updatedAt time.Time) (string, bool)

DomainForIP looks up the domain associated with a tailcfg.NodeID and netip.Addr pair. If there is no association, the result is empty and ok is false.

func (*ConsensusIPPool) IPForDomain

func (ipp *ConsensusIPPool) IPForDomain(nid tailcfg.NodeID, domain string) (netip.Addr, error)

IPForDomain looks up or creates an IP address allocation for the tailcfg.NodeID and domain pair. If no address association is found, one is allocated from the range of free addresses for this tailcfg.NodeID. If no more address are available, an error is returned.

func (*ConsensusIPPool) Restore

func (ipp *ConsensusIPPool) Restore(rc io.ReadCloser) error

Restore is part of the raft.FSM interface. According to the docs it:

func (*ConsensusIPPool) Snapshot

func (ipp *ConsensusIPPool) Snapshot() (raft.FSMSnapshot, error)

Snapshot is part of the raft.FSM interface. According to the docs it:

func (*ConsensusIPPool) StartConsensus

func (ipp *ConsensusIPPool) StartConsensus(ctx context.Context, ts *tsnet.Server, clusterTag string, clusterStateDir string) error

StartConsensus is part of the IPPool interface. It starts the raft background routines that handle consensus.

func (*ConsensusIPPool) StopConsensus

func (ipp *ConsensusIPPool) StopConsensus(ctx context.Context) error

StopConsensus is part of the IPPool interface. It stops the raft background routines that handle consensus.

type IPPool

type IPPool interface {
	// DomainForIP looks up the domain associated with a tailcfg.NodeID and netip.Addr pair.
	// If there is no association, the result is empty and ok is false.
	DomainForIP(tailcfg.NodeID, netip.Addr, time.Time) (string, bool)

	// IPForDomain looks up or creates an IP address allocation for the tailcfg.NodeID and domain pair.
	// If no address association is found, one is allocated from the range of free addresses for this tailcfg.NodeID.
	// If no more address are available, an error is returned.
	IPForDomain(tailcfg.NodeID, string) (netip.Addr, error)
}

IPPool allocates IPv4 addresses from a pool to DNS domains, on a per tailcfg.NodeID basis. For each tailcfg.NodeID, IPv4 addresses are associated with at most one DNS domain. Addresses may be reused across other tailcfg.NodeID's for the same or other domains.

type SingleMachineIPPool

type SingleMachineIPPool struct {
	IPSet *netipx.IPSet
	// contains filtered or unexported fields
}

func (*SingleMachineIPPool) DomainForIP

func (ipp *SingleMachineIPPool) DomainForIP(from tailcfg.NodeID, addr netip.Addr, _ time.Time) (string, bool)

func (*SingleMachineIPPool) IPForDomain

func (ipp *SingleMachineIPPool) IPForDomain(from tailcfg.NodeID, domain string) (netip.Addr, error)

Source Files

consensusippool.go consensusippoolserialize.go ippool.go ipx.go

Version
v1.86.4 (latest)
Published
Aug 7, 2025
Platform
linux/amd64
Imports
22 packages
Last checked
1 hour ago

Tools for package owners.