Git Product home page Git Product logo

cidr's People

Contributors

bschaatsbergen avatar cloudcosmonaut avatar danielrieske avatar dependabot[bot] avatar euanwm avatar kvanzuijlen avatar mmourick avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cidr's Issues

Add the ability to divide a CIDR range into smaller ranges

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.

Extend CI with `golangci-lint`

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

Add usage examples to error logs

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

invalid memory address or nil pointer dereference on `overlaps`

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

Bump `cidr` to go1.21.4

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

Add the total number of IPs and the total number of available IPs

When calculating 10.23.9.130/30, the output Address Count: 2
image
However, there are 4 IPs in this address segment, including the base address and the broadcast address.
So I want to be able to output the number of all IP addresses with the number of available IP addresses.

[Feature]: `cidr explain`

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.

Proposal:

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.

Example Usage:

$ 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

Add arm64 binaries to release

Currently we're only shipping 386 and amd64 binaries in the release, it would be nice to have arm64 binaries available.

Add colours to `--help`

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

[Feature Request] rfc6052 support

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.