Ecosyste.ms: Packages

An open API service providing package, version and dependency metadata of many open source software ecosystems and registries.

proxy.golang.org : github.com/pchchv/goip

goip is a library for handling IP addresses and subnets, both IPv4 and IPv6. The primary goals are: - Comprehensive parsing of IPv4 and IPv6 addresses along with commonly used host name formats, and supplementary formats. - Representation of subnets by network prefix length or segment value ranges. - Decoupling address parsing from host parsing. - Configurable parsing options for allowed formats, including IPv4, IPv6, subnet formats, inet_aton formats, among others. - Generation of diverse address strings in various formats for a given IPv4 or IPv6 address and creation of collections of such strings. - Parsing of prevalent MAC Address formats and generation of strings in various MAC address formats. - Integration of MAC addresses with IPv6 via standardized conversions. - Integration of IPv4 Addresses with IPv6 through commonly used address conversions. - Emphasis on polymorphism by maintaining an address framework of interfaces for addressing independence based on type or version (IPv4, IPv6, or MAC). This enables transparent support for both IPv4 and IPv6 in the codebase. - Thread-safety and immutability with core types (e.g., host names, address strings, addresses, address sections, segments, ranges) being immutable, facilitating safe sharing among goroutines. - Address manipulation capabilities such as prefix length alterations, masking, segmentation, network and host section separation, reconstitution from segments, among other operations. - Address operations and subnetting functionalities including obtaining prefix block subnets, iterating through subnets, prefixes, blocks, or segments of subnets, incrementing and decrementing addresses, reversing address bits, set operations like subtracting subnets, intersections, merging, containment checks, and listing subnets covering specific address spans. - Sorting and comparison of host names, addresses, address strings, and subnets with all address component types being comparable. - Integration with Go language primitive types and standard library types like net.IP, net.IPAddr, net.IPMask, net.IPNet, net.TCPAddr, net.UDPAddr, net/netip.Addr, net/netip.Prefix, net/netip.AddrPort, and math/big.Int. - Simplification of address manipulations by abstracting complexities involving numeric bytes, integers, signed/unsigned values, bit manipulations, iteration, and implementation intricacies related to IPv4/v6. This library revolves around core types: - `IPAddressString` - `HostName` - `MACAddressString` These are complemented by the base type `Address` and its associated types: - `IPAddress` - `IPv4Address` - `IPv6Address` - `MACAddress` Moreover, it includes the sequential address type `SequentialRange`. #### Choosing Types Based on Representation: - For textual IP address representation, begin with `IPAddressString` or `HostName`. - For textual MAC address representation, start with `MACAddressString`. - Instances can represent either a single address or a subnet. Utilize `HostName` for addresses, host names, or items with a port or service name. - For numeric bytes or integers, initiate with `IPv4Address`, `IPv6Address`, `IPAddress`, or `MACAddress`. ### Scalability and Polymorphism - Facilitates scaling down from specific address types to more generic types and vice versa. - Polymorphism aids in ambiguous IP-version code scenarios, with the most-specific types supporting tailored method sets for the address version or type. - Scaling up to a specific version or address type requires the lower-level instance to originate from an instance of that specific type. - Conversion examples: `IPv6Address` to `IPAddress` via `IPv6Address.ToIP`, or to `Address` via `IPv6Address.ToAddressBase`. Conversion back to `IPv6Address` or `IPAddress` using `Address.ToIP` or `Address.ToIPv6`. - Limitation: Conversion back to IPv4 from `IPv6Address` necessitates the use of `IPv4AddressConverter`.

Registry - Source - Documentation - JSON
purl: pkg:golang/github.com/pchchv/goip
Keywords: go, go-library, go-module, go-package, golang, golang-library, golang-module, golang-package, ip, ipv4, ipv4-network, ipv6, ipv6-network, subnetting
License: Apache-2.0
Latest release: 5 months ago
First release: 5 months ago
Namespace: github.com/pchchv
Stars: 1 on GitHub
Forks: 0 on GitHub
See more repository details: repos.ecosyste.ms
Last synced: 28 days ago

    Loading...
    Readme
    Loading...