ADDED:
* num-addrs subcommand, to get the number of hosts/addresses in a given
  prefix length
* get-net subcommand, to more easily get a single subnet from either the
  beginning or the end of a prefix. (MUCH FASTER than CIDR-splitting!)
This commit is contained in:
brent saner
2025-04-13 18:25:32 -04:00
parent c05f9c4d47
commit 860ad5842b
16 changed files with 334 additions and 78 deletions

View File

@@ -10,7 +10,6 @@ import (
`strings`
`github.com/TwiN/go-color`
`github.com/projectdiscovery/mapcidr`
`go4.org/netipx`
`r00t2.io/subnetter/netsplit`
)
@@ -423,8 +422,8 @@ func tplTablePrefixes(ipVer uint8, indent string, plain bool) (out string, err e
return
}
dummyNet = netipx.PrefixIPNet(rows[idx].NetPrefix.Masked())
rows[idx].Addresses = mapcidr.CountIPsInCIDR(true, true, dummyNet)
rows[idx].Hosts = mapcidr.CountIPsInCIDR(false, false, dummyNet)
rows[idx].Addresses = netsplit.NumAddrsNet(dummyNet, true, true)
rows[idx].Hosts = netsplit.NumAddrsNet(dummyNet, false, false)
}
colFields, colTitles, colSizes = sizeStructs(rows)