package merge

import "github.com/open-policy-agent/opa/internal/cidr/merge"

Package merge provides helper functions for merging a list of IP addresses and subnets into the smallest possible list of CIDRs. Original Implementation: https://github.com/cilium/cilium

Index

Functions

func GetAddressRange

func GetAddressRange(ipNet net.IPNet) (net.IP, net.IP)

GetAddressRange returns the first and last addresses in the given CIDR range.

func GetPreviousIP

func GetPreviousIP(ip net.IP) net.IP

GetPreviousIP returns the previous IP from the given IP address.

func RangeToCIDRs

func RangeToCIDRs(firstIP, lastIP net.IP) []*net.IPNet

RangeToCIDRs converts the range of IPs covered by firstIP and lastIP to a list of CIDRs that contains all of the IPs covered by the range.

Source Files

merge.go

Version
v1.4.2 (latest)
Published
May 2, 2025
Platform
linux/amd64
Imports
4 packages
Last checked
6 hours ago

Tools for package owners.