Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bourgeoisbear/range2cidr
De-aggregates an IP address range into a list of network prefixes (CIDR blocks)
https://github.com/bourgeoisbear/range2cidr
cidr cidr-range deaggreagtion golang golang-library ipcalc ipcalculator ipv4-address ipv6-address netip networking
Last synced: about 2 months ago
JSON representation
De-aggregates an IP address range into a list of network prefixes (CIDR blocks)
- Host: GitHub
- URL: https://github.com/bourgeoisbear/range2cidr
- Owner: BourgeoisBear
- License: mit
- Created: 2023-02-25T13:57:10.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-11T07:19:27.000Z (5 months ago)
- Last Synced: 2024-11-01T07:02:35.621Z (2 months ago)
- Topics: cidr, cidr-range, deaggreagtion, golang, golang-library, ipcalc, ipcalculator, ipv4-address, ipv6-address, netip, networking
- Language: Go
- Homepage:
- Size: 58.6 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# range2cidr
[![GoDoc](https://img.shields.io/badge/pkg.go.dev-doc-blue)](https://pkg.go.dev/github.com/BourgeoisBear/range2cidr)
Aggregate() merges a list of IP ranges into a minimal set of covering ranges.
Deaggregate() breaks a single IP range into a list of covering network prefixes.
A number of address helper functions are exposed for convenience.
This library usually operates on addresses as [16]byte values, as returned by netip.Addr.As16().
To convert a netip.Addr into [16]byte:
```go
addr.As16()
```To unmap an address back into IPv4 format:
```go
if addr.Is4In6() {
return addr.Unmap()
}
```