Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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)

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()
}
```