ipx.

Dependency-free IP networking toolkit for Go, built on net/netip. CIDR math, ranges, set algebra, longest-prefix match, ACLs, allocation and SSRF-safe dialing.

API reference GitHub Releases
go get github.com/bakhod1r/ipx
go install github.com/bakhod1r/ipx/cmd/ipx@latest

Features

Parse & classify

Strict parsing, IANA special-purpose registry, IsPublic, IsPrivate, Special.

CIDR math

Split (lazy), supernet, parent/children, masks, usable hosts, VLSM PlanSubnets.

Ranges & sets

Immutable IPSet: union, intersect, difference, complement, Aggregate.

Longest-prefix match

Path-compressed Table[V], zero-alloc lookup, SyncTable.

ACL

Allow/deny rules, longest-prefix or first-match, priorities and groups.

Allocator

Sequential, reverse and random allocation with reserve / release.

SSRF guard

IsInternal + SafeDialer: sees through mapped, NAT64 and 6to4 forms; no DNS rebinding.

HTTP

httpip: client IP behind explicitly trusted proxies, middleware.

DNS & endpoints

PTR names, reverse zones, RFC 2317 classless delegation, ip:port parsing.

Hierarchy

FindOverlaps and BuildTree for auditing address plans.

Kubernetes

ipx/k8s: pod/service/node overlap checks, node podCIDRs, service IPs.

SQL & cloud

sqlip Scanner/Valuer for Postgres inet/cidr and MySQL; cloud AWS/GCP/Cloudflare range index.

Integrations

Gin, Echo, Fiber v3 middleware and MaxMind GeoIP as separate modules — core stays dependency-free.

CLI

plan, alloc, split, diff… with --json output.

Example

var rt ipx.Table[string]
rt.Insert(netip.MustParsePrefix("10.0.0.0/8"), "corp")
rt.Insert(netip.MustParsePrefix("10.10.10.0/24"), "lab")
p, v, _ := rt.Lookup(netip.MustParseAddr("10.10.10.50")) // 10.10.10.0/24 lab

ipx.Aggregate(prefixes)             // minimal CIDR cover
ipx.IsInternal(addr)                // SSRF check
client := &http.Client{Transport: &http.Transport{
    DialContext: (&ipx.SafeDialer{}).DialContext,
}}

CLI

$ ipx split 192.168.1.0/24 26
$ ipx diff 10.0.0.0/24 10.0.0.0/25
10.0.0.128/25
$ ipx plan 10.0.0.0/24 hosts:100 hosts:50 27
$ ipx --json cidr 10.0.0.0/22

Guarantees