routeplan

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildExpectedWireGuardRoutes

func BuildExpectedWireGuardRoutes(peers []Peer, nodesByName map[string]Node) ([]ExpectedRoute, []ExpectedRoute)

BuildExpectedWireGuardRoutes builds expected IPv4 and IPv6 WireGuard routes.

func BuildGatewayPoolRoutedCIDRSetByPool

func BuildGatewayPoolRoutedCIDRSetByPool(poolRoutedCIDRs map[string][]string) map[string]map[string]struct{}

BuildGatewayPoolRoutedCIDRSetByPool builds normalized routed CIDR destinations grouped by gateway pool.

func BuildLocalGatewayHostCIDRSetFromPodCIDRs

func BuildLocalGatewayHostCIDRSetFromPodCIDRs(podCIDRs []string) map[string]struct{}

BuildLocalGatewayHostCIDRSetFromPodCIDRs returns cbr0-style gateway host CIDRs from pod CIDRs.

func BuildNormalizedCIDRSet

func BuildNormalizedCIDRSet(cidrs []string) map[string]struct{}

BuildNormalizedCIDRSet creates a canonical set of CIDRs.

func BuildSiteNodeCIDRSetBySite

func BuildSiteNodeCIDRSetBySite(siteNodeCIDRs map[string][]string) map[string]map[string]struct{}

BuildSiteNodeCIDRSetBySite builds normalized site node CIDR destinations grouped by site.

func BuildSitePodCIDRSetBySite

func BuildSitePodCIDRSetBySite(nodesByName map[string]Node) map[string]map[string]struct{}

BuildSitePodCIDRSetBySite builds normalized pod CIDR destinations grouped by site.

func CIDRMaskSize

func CIDRMaskSize(destination string) (int, int, bool)

CIDRMaskSize returns mask size details for a normalized CIDR.

func DedupePathHops

func DedupePathHops(paths [][]PathHop) [][]PathHop

DedupePathHops removes duplicate paths while preserving deterministic ordering.

func ExpectedDestinationsForPeer

func ExpectedDestinationsForPeer(peer Peer, nodesByName map[string]Node) []string

ExpectedDestinationsForPeer computes expected route destinations for a peer.

func FilterGatewayAdvertisedRoutes

func FilterGatewayAdvertisedRoutes(
	advertisement GatewayRouteAdvertisement,
	fallback []string,
	mySiteName string,
	localGatewayPools []string,
	now time.Time,
	staleAfter time.Duration,
) ([]string, map[string]int, map[string]LearnedRoute)

FilterGatewayAdvertisedRoutes filters stale or inapplicable gateway-advertised routes.

func FirstUsableHostCIDRFromCIDR

func FirstUsableHostCIDRFromCIDR(cidr string) string

FirstUsableHostCIDRFromCIDR returns the first usable host route for a CIDR.

func HostCIDRForIP

func HostCIDRForIP(address string) string

HostCIDRForIP converts an IP string to a host CIDR form.

func NormalizeCIDR

func NormalizeCIDR(cidr string) string

NormalizeCIDR canonicalizes CIDRs and returns empty string for invalid input.

func NormalizeIP

func NormalizeIP(address string) string

NormalizeIP canonicalizes an IP string and returns empty when invalid.

func NormalizeRouteDestination

func NormalizeRouteDestination(destination string) (string, int)

NormalizeRouteDestination converts CIDR or host IP inputs to canonical CIDR form.

func PathHasHop

func PathHasHop(path []PathHop, hopType, hopName string) bool

PathHasHop reports whether a route path includes the given hop.

func RoutePathLength

func RoutePathLength(route LearnedRoute) int

RoutePathLength returns the shortest non-empty path length for a route.

Types

type ExpectedRoute

type ExpectedRoute struct {
	Destination string
	Gateway     string
	Device      string
	Distance    int
	Weight      int
	Family      int
}

ExpectedRoute describes one expected kernel route entry.

type GatewayRouteAdvertisement

type GatewayRouteAdvertisement struct {
	Name        string
	LastUpdated time.Time
	Routes      map[string]LearnedRoute
}

GatewayRouteAdvertisement captures a gateway's advertised routed CIDRs.

type LearnedRoute

type LearnedRoute struct {
	Paths [][]PathHop
}

LearnedRoute describes one destination and its learned path alternatives.

type Node

type Node struct {
	Name        string
	SiteName    string
	PodCIDRs    []string
	InternalIPs []string
	ExternalIPs []string
}

Node captures route-relevant node identity and addressing.

type PathHop

type PathHop struct {
	Type string
	Name string
}

PathHop describes one hop in a learned route path.

type Peer

type Peer struct {
	Name              string
	PeerType          string // site or gateway
	SiteName          string
	SitePeered        bool
	SkipPodCIDRRoutes bool
	Interface         string
	Endpoint          string
	PodCIDRGateways   []string
	AllowedIPs        []string
	RouteDistances    map[string]int
}

Peer captures the route-relevant view of a WireGuard peer.

type RouteInfo

type RouteInfo struct {
	ObjectName string
	ObjectType string
	RouteType  string
}

RouteInfo identifies the object and route type associated with a destination.

func ClassifyRouteInfoForPeerDestination

func ClassifyRouteInfoForPeerDestination(
	normalizedDestination string,
	peerNames []string,
	peerByName map[string]Peer,
	nodeByName map[string]Node,
	sitePodCIDRs map[string]map[string]struct{},
	siteNodeCIDRs map[string]map[string]struct{},
	gatewayPoolRoutedCIDRs map[string]map[string]struct{},
) *RouteInfo

ClassifyRouteInfoForPeerDestination classifies a destination for UI/status output.

Jump to

Keyboard shortcuts

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