addressutil

package
v1.10.0-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package addressutil contains helpers working with addresses.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareAddressStatuses

func CompareAddressStatuses(comparePrefixes func(a, b netip.Prefix) int) func(a, b *network.AddressStatus) int

CompareAddressStatuses compares two address statuses with the prefix comparison func.

The comparison of AddressStatuses sorts by link name and then by address.

func CompareByAlgorithm

func CompareByAlgorithm(algorithm nethelpers.AddressSortAlgorithm) func(a, b netip.Prefix) int

CompareByAlgorithm returns a comparison function based on the given algorithm.

func ComparePrefixNew

func ComparePrefixNew(a, b netip.Prefix) int

ComparePrefixNew compares two prefixes by address family, address, and prefix length.

It prefers more specific prefixes.

func ComparePrefixesLegacy

func ComparePrefixesLegacy(a, b netip.Prefix) int

ComparePrefixesLegacy is the old way to sort prefixes.

It only compares addresses and does not take prefix length into account.

func DeduplicateIPPrefixes

func DeduplicateIPPrefixes(in []netip.Prefix) []netip.Prefix

DeduplicateIPPrefixes removes duplicates from the given list of prefixes.

The input list must be sorted. DeduplicateIPPrefixes performs in-place deduplication.

func FilterIPs

func FilterIPs(addrs []netip.Prefix, includeSubnets, excludeSubnets []netip.Prefix) []netip.Prefix

FilterIPs filters the given list of IP prefixes based on the given include and exclude subnets.

If includeSubnets is not empty, only IPs that are in one of the subnets are included. If excludeSubnets is not empty, IPs that are in one of the subnets are excluded.

Types

This section is empty.

Jump to

Keyboard shortcuts

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