bschaatsbergen / cidr Goto Github PK
View Code? Open in Web Editor NEWCLI to perform various actions on CIDR ranges
Home Page: https://formulae.brew.sh/formula/cidr
License: MIT License
CLI to perform various actions on CIDR ranges
Home Page: https://formulae.brew.sh/formula/cidr
License: MIT License
The CIDR range division feature allow users to easily divide a given CIDR range into a specified number of smaller subnets.
Why: this enhancement is crucial for users dealing with IP address management, allowing them to efficiently and accurately divide CIDR ranges as needed. Improving this feature will enhance the overall usability of cidr
.
Example:
Introduce a divide
subcommand, where you specify both a CIDR range as well as an integer to divide it respectively.
$ cidr divide 10.0.0.0/16 9
10.0.0.0/20
10.0.16.0/20
10.0.32.0/20
10.0.48.0/20
10.0.64.0/20
10.0.80.0/20
10.0.96.0/20
10.0.112.0/20
10.0.128.0/20
h/t @steynovich for proposing this enhancement to cidr in a 1-on-1.
Integrate golangci-lint
into our CI pipeline to enhance code quality. The current CI setup focuses on tests and builds, neglecting code style. By including golangci-lint
, we aim to catch and address potential issues early, enforcing consistent coding standards.
See: https://golangci-lint.run/
Relates #77
At the moment if you run into an error on one of the subcommands you don't necessarily understand what should be provided exactly.
Existing error log:
$ cidr contains 10.0.0.0/16 10.0.14.11/1a
Provided ip is not valid
Beacuse the contains
subcommand expects an IP address as secondary argument, it would be helpful to steer users in the right direction.
Preferable error log:
$ cidr contains 10.0.0.0/16 10.0.14.11/1a
Provided IP address is not valid
Example usage: cidr contains 10.0.0.0/16 10.0.14.11
We should consider publishing cidr
to Snapcraft for improved accessibility and ease of installation.
When executing the following command:
$ cidr overlaps 10.0.14.0/22 10.0.0.0/16a
I seem to get the following error:
$ cidr overlaps 10.0.14.0/22 10.0.0.0/16a (base)
ERRO[0000] invalid CIDR address: 10.0.0.0/16a
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x4abcbe]
goroutine 1 [running]:
github.com/bschaatsbergen/cidr/pkg/core.Overlaps(0xc000122900, 0x0)
/home/runner/work/cidr/cidr/pkg/core/core.go:29 +0x1e
github.com/bschaatsbergen/cidr/cmd.overlaps(...)
/home/runner/work/cidr/cidr/cmd/overlaps.go:36
github.com/bschaatsbergen/cidr/cmd.glob..func3(0x6dd3e0?, {0xc000148160, 0x2, 0x2?})
/home/runner/work/cidr/cidr/cmd/overlaps.go:26 +0x165
github.com/spf13/cobra.(*Command).execute(0x6dd3e0, {0xc000148100, 0x2, 0x2})
/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:876 +0x67b
github.com/spf13/cobra.(*Command).ExecuteC(0x6dd660)
/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:990 +0x3bd
github.com/spf13/cobra.(*Command).Execute(...)
/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:918
github.com/bschaatsbergen/cidr/cmd.Execute()
/home/runner/work/cidr/cidr/cmd/root.go:40 +0x25
main.main()
/home/runner/work/cidr/cidr/main.go:6 +0x17
Go 1.21.4 is released on 2023-11-07, and is as of now (2023-11-30) the latest stable Go release. We should consider upgrading cidr
to this version.
Relates #62
We should consider adding a new subcommand: cidr explain
to show relevant information about a CIDR range. Think of the explain subcommand as a feature to provide detailed insights into a given CIDR range.
Introduce a new subcommand, explain
, to cidr
. When users run cidr explain <CIDR>
, the tool should output information about the specified CIDR range. This information could for example include:
Network Address: The base IP address of the CIDR range.
Subnet Mask: The subnet mask associated with the CIDR range.
CIDR Notation: The CIDR notation for the range.
Number of Hosts: The total number of usable host addresses within the CIDR range.
Usable IP Range: The range of IP addresses that can be assigned to devices on the network.
Broadcast Address: The address used to broadcast messages to all devices on the network.
$ cidr explain 10.0.0.0/16
Network Address: 10.0.0.0
Subnet Mask: 255.255.0.0
CIDR Notation: /16
Number of Hosts: 65,534
Usable IP Range: 10.0.0.1 to 10.0.255.254
Broadcast Address: 10.0.255.255
https://github.com/actions/labeler could be a fit for this, ideally this is done in a triage-ci.yaml
workflow running as part of the PR.
Relates #69
Currently we're only shipping 386 and amd64 binaries in the release, it would be nice to have arm64 binaries available.
We could prettify the output of --help
by colouring the section titles.
cidr - CLI to perform various actions on CIDR ranges
Usage: **(give this a colour)**
cidr [flags]
cidr [command]
Available Commands: **(give this a colour)**
contains Checks whether an IP address belongs to a CIDR range
count Return the count of all distinct host addresses in a given CIDR range
help Help about any command
overlaps Checks if a CIDR range overlaps with another CIDR range
Flags: **(give this a colour)**
-h, --help help for cidr
Use "cidr [command] --help" for more information about a command.
Relates #74
Functions that are exposed through the pkg
dir, e.g. pkg/core
should be documented.
Relates #79
It would be nice to have support for rfc6052
addresses, which follow a pretty weird format.
Two commands (rfc6052-pack
and rfc6052-extract
) would be handy.
Heres an at-a-glance view of how this addressing scheme works:
+--+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
|PL| 0-------------32--40--48--56--64--72--80--88--96--104---------|
+--+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
|32| prefix |v4(32) | u | suffix |
+--+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
|40| prefix |v4(24) | u |(8)| suffix |
+--+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
|48| prefix |v4(16) | u | (16) | suffix |
+--+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
|56| prefix |(8)| u | v4(24) | suffix |
+--+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
|64| prefix | u | v4(32) | suffix |
+--+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
|96| prefix | v4(32) |
+--+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
Example syntax could be:
$ cidr rfc6052-pack <prefix>/<mask> <ipv4> [<suffix>]
$ cidr rfc6052-extract <address>/<mask>
The first command would return an IPv6 address, and the second would return an IPv6 prefix, an IPv4 address, and an optional suffix. (or just error, if its invalid)
Every opened or reopened issue should be labeled with needs-triage
.
Relates #67
Relates #58
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.