package ippool
import "tailscale.com/cmd/natc/ippool"
ippool implements IP address storage, creation, and retrieval for cmd/natc
Index ¶
- Variables
- type ConsensusIPPool
- func NewConsensusIPPool(ipSet *netipx.IPSet) *ConsensusIPPool
- func (ipp *ConsensusIPPool) Apply(l *raft.Log) any
- func (ipp *ConsensusIPPool) DomainForIP(from tailcfg.NodeID, addr netip.Addr, updatedAt time.Time) (string, bool)
- func (ipp *ConsensusIPPool) IPForDomain(nid tailcfg.NodeID, domain string) (netip.Addr, error)
- func (ipp *ConsensusIPPool) Restore(rc io.ReadCloser) error
- func (ipp *ConsensusIPPool) Snapshot() (raft.FSMSnapshot, error)
- func (ipp *ConsensusIPPool) StartConsensus(ctx context.Context, ts *tsnet.Server, clusterTag string, clusterStateDir string) error
- func (ipp *ConsensusIPPool) StopConsensus(ctx context.Context) error
- type IPPool
- type SingleMachineIPPool
Variables ¶
Types ¶
type ConsensusIPPool ¶
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 ¶
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:
- will not be called concurrently with any other command
- the FSM must discard all previous state before restoring
func (*ConsensusIPPool) Snapshot ¶
func (ipp *ConsensusIPPool) Snapshot() (raft.FSMSnapshot, error)
Snapshot is part of the raft.FSM interface. According to the docs it:
- should return quickly
- will not be called concurrently with Apply
- the snapshot returned will have Persist called on it concurrently with Apply (so it should not contain pointers to the original data that's being mutated)
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 ¶
func (*SingleMachineIPPool) DomainForIP ¶
func (ipp *SingleMachineIPPool) DomainForIP(from tailcfg.NodeID, addr netip.Addr, _ time.Time) (string, bool)
func (*SingleMachineIPPool) IPForDomain ¶
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.