gaissmai / extnetip

Package extnetip extends the stdlib with a few missing but important auxiliary functions for converting IP-prefixes to IP-ranges and vice versa.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

package extnetip

Go Reference GitHub release (latest SemVer) CI Go Report Card Coverage Status License: MIT Stand With Ukraine

Package extnetip is an extension to net/netip with a few missing but important auxiliary functions for converting IP-prefixes to IP-ranges and vice versa.

With these extensions to net/netip, third-party IP-range libraries become easily possible.

API

import "github.com/gaissmai/extnetip"

func Range(p netip.Prefix) (first, last netip.Addr)

func Prefix(first, last netip.Addr) (prefix netip.Prefix, ok bool)

func Prefixes(first, last netip.Addr) []netip.Prefix

func PrefixesAppend(dst []netip.Prefix, first, last netip.Addr) []netip.Prefix

Future

Hopefully some day these tiny helper functions are added to netip by the stdlib maintainers, currently (2022) they refused the proposal.

About

Package extnetip extends the stdlib with a few missing but important auxiliary functions for converting IP-prefixes to IP-ranges and vice versa.

License:MIT License


Languages

Language:Go 100.0%