Giter Site home page Giter Site logo

brotherpowers / ipsubnet Goto Github PK

View Code? Open in Web Editor NEW
59.0 3.0 17.0 10 KB

Network calculator for subnet mask and other classless (CIDR) network information. ( GO )

License: MIT License

Go 100.00%
golang ip subnet ipv4-calculator network-calculator

ipsubnet's Issues

Incorrect output for /32

/32 networks (single host) get weird output from some of the calls. Admittedly some of the function calls don't necessarily make sense for /32, but the output doesn't seem to be what one would expect:

sub := ipsubnet.SubnetCalculator("8.8.8.8", "32")
sub.GetNumberIPAddresses() // 0
sub.GetNumberAddressableHosts() // 1
sub.GetIPAddressRange()[0] // 8.8.8.8
sub.GetIPAddressRange()[1] // 263.263.263.263
sub.GetBroadcastAddress() // 263.263.263.263
  • GetNumberIPAddresses: I would think this would return 1 since /32 generally means just a single IP address, though I can see how 0 might result from masking operations.
  • GetNumberAddressableHosts: I'm not sure if this should return 1 or 0, but 1 is probably preferred and is what is currently returned
  • GetIPAddressRange()[1]: This should just return the single IP address. The return value isn't valid
  • GetBroadcastAddress(): I would think this would just return the single IP address as well. The return value isn't valid.

Does not compile for 32 bit architecture

I encountered an issue when compiling a project with this library with the GOARCH=386.

vendor/github.com/brotherpowers/ipsubnet/ip.go:16:27: constant 4294967295 overflows int

This is the line in question:

ipsubnet/ip.go

Line 16 in 30bc98f

subnet_mask: 0xFFFFFFFF << uint(32-networkSize),

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.