convert

package
v0.0.0-...-17f6e27 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CIDRToIPRange

func CIDRToIPRange(cidrStr string) (string, string, error)

CIDRToIPRange converts a CIDR to an IP range (start and end IP addresses)

func CIDRsToIPList

func CIDRsToIPList(cidrStr string, maxCount int) ([]string, error)

CIDRsToIPList expands a CIDR block to a list of all IP addresses it contains Warning: use with caution for large CIDR blocks!

func ExpandIPRange

func ExpandIPRange(startIPStr, endIPStr string, maxCount int) ([]string, error)

ExpandIPRange returns all IPs in a range (inclusive) Warning: use with caution for large ranges!

func FormatCIDRInfo

func FormatCIDRInfo(cidrStr string) (string, error)

FormatCIDRInfo returns formatted information about a CIDR block

func FormatCIDRSize

func FormatCIDRSize(size *big.Int) string

FormatCIDRSize formats the size of a CIDR block in a human-readable way

func FormatIPRange

func FormatIPRange(startIP, endIP net.IP) string

FormatIPRange formats an IP range as a string (e.g., "192.168.1.0-192.168.1.255")

func FormatNetmask

func FormatNetmask(mask net.IPMask, ipVersion int) string

FormatNetmask formats a netmask as a string based on the IP version

func FormatWildcardMask

func FormatWildcardMask(mask net.IPMask, ipVersion int) string

FormatWildcardMask formats a wildcard mask (inverse of netmask) as a string

func IPRangeToCIDRs

func IPRangeToCIDRs(startIPStr, endIPStr string) ([]*cidr.CIDR, error)

IPRangeToCIDRs converts an IP range (start and end IP addresses) to a list of CIDR blocks

func IPsToOptimizedCIDRs

func IPsToOptimizedCIDRs(ips []string) ([]*cidr.CIDR, error)

IPsToOptimizedCIDRs converts a list of IP addresses to the most compact list of CIDR blocks

func IsValidNetmask

func IsValidNetmask(netmask string) bool

IsValidNetmask checks if a string is a valid netmask

func MergeCIDRs

func MergeCIDRs(cidrStrs []string) ([]*cidr.CIDR, error)

MergeCIDRs takes a list of CIDRs and returns the minimal set that covers the same range

func NetmaskToCIDR

func NetmaskToCIDR(ip, netmask string) (string, error)

NetmaskToCIDR converts an IP and netmask to CIDR notation

func NetmaskToPrefixLen

func NetmaskToPrefixLen(netmask string) (int, error)

NetmaskToPrefixLen converts a netmask string to a prefix length (e.g., "255.255.255.0" -> 24)

func OctetRangeToCIDRs

func OctetRangeToCIDRs(octetRange string) ([]*cidr.CIDR, error)

OctetRangeToCIDRs converts IP octet range notation (e.g., "192.168.[1-5].[0-255]") to a list of CIDR blocks Currently only supports IPv4 ranges

func ParseIPRange

func ParseIPRange(ipRangeStr string) (net.IP, net.IP, error)

ParseIPRange parses a string IP range into start and end IPs

func PrefixLenToNetmask

func PrefixLenToNetmask(prefixLen int) (string, error)

PrefixLenToNetmask converts a prefix length to a netmask string (e.g., 24 -> "255.255.255.0")

func WildcardAndRangeToCIDRs

func WildcardAndRangeToCIDRs(input string) ([]*cidr.CIDR, error)

WildcardAndRangeToCIDRs is a convenience function that tries to interpret the input as either wildcard or octet range notation and converts it to CIDR blocks

func WildcardMaskFromPrefix

func WildcardMaskFromPrefix(prefixLen int) (string, error)

WildcardMaskFromPrefix returns the wildcard mask for a given prefix length (e.g., 24 -> "0.0.0.255")

func WildcardToCIDRs

func WildcardToCIDRs(wildcard string) ([]*cidr.CIDR, error)

WildcardToCIDRs converts IP wildcard notation (e.g., "192.168.*.*") to a list of CIDR blocks Currently only supports IPv4 wildcards

Types

This section is empty.

Jump to

Keyboard shortcuts

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