addrspace

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: Apache-2.0 Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package addrspace provides policy-agnostic address-space primitives for comparing route CIDRs and deriving site IDs from Tailscale 4via6 prefixes. It knows nothing about ACL policy text or live device inventories: tail-acl and tailnet-audit supply their own CIDR strings and classify the results.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsViaPrefix

func IsViaPrefix(cidr string) bool

IsViaPrefix reports whether cidr, once masked to its own prefix length, lies within the Tailscale 4via6 "via" range. cidr must be a full CIDR string (a bare or bracketed address without an explicit prefix length is rejected, unlike Overlaps/OverlappingPairs). It requires cidr to be no wider than the via range itself (/64), but deliberately does not validate a prefix length of at least /96 or the embedded site ID, allowing callers to distinguish a malformed via prefix from an ordinary route.

func OverlappingPairs

func OverlappingPairs(cidrs []string) ([][2]int, map[int]error)

OverlappingPairs returns the index pairs (i, j), i < j, of cidrs entries that overlap, and any per-entry parse errors keyed by index. A malformed entry is reported in the returned error map and excluded from every pairwise comparison rather than aborting the whole call, so one bad entry in a larger set never hides the overlaps among the rest. A nil error map means every entry parsed. Pairs are returned sorted ascending by (i, j); downstream callers such as tail-ipam's subnet-pool registry overlap validation depend on this ordering for deterministic error messages.

func Overlaps

func Overlaps(a, b string) (bool, error)

Overlaps reports whether a and b share any address. Each argument may be a CIDR prefix or a bare address (optionally bracketed, as Tailscale IPv6 addresses sometimes are). It returns an error if either argument fails to parse as either form.

func SiteID

func SiteID(cidr string) (uint32, bool)

SiteID extracts the 4via6 site ID embedded in a Tailscale "via" IPv6 prefix. cidr must be a full CIDR string (a bare or bracketed address without an explicit prefix length is rejected, unlike Overlaps/OverlappingPairs). ok is false if cidr is outside the via range, has a prefix length shorter than /96, contains a site ID above 65535, or is not a CIDR.

Types

This section is empty.

Jump to

Keyboard shortcuts

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