Giter Club home page Giter Club logo

netaddr's People

Contributors

bensie avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

netaddr's Issues

Is this the same netaddr as http://rubygems.org/gems/netaddr?

We recently ran into a problem with this gem where rails would not auto-load it because the namespace and filenames do not follow conventions. Ex (NetAddr => net_addr.rb or netaddr.rb => Netaddr.

If you are currently maintaining the gem, would you be open to a PR to add a shim that adds support for the naming convention? Ex:

in netaddr.rb

# ...

Netaddr = NetAddr

A more radical approach would be to rename the gem to net_addr.

thanks,

aram

Netaddr.merge does not merge all overlapping/adjacent blocks

This should merge down to a /8:

irb(main):003:0> NetAddr.merge(['10.0.0.0/8','10.0.0.0/12'])
=> ["10.0.0.0/8", "10.0.0.0/12"]

As should this:

irb(main):009:0> NetAddr.merge(['10.0.0.0/8','10.0.0.0/16'])
=> ["10.0.0.0/8", "10.0.0.0/16"]

This works as expected (example from docs):

irb(main):017:0> NetAddr.merge(['192.168.1.0/26', '192.168.1.64/27',
'192.168.1.96/27', '10.1.0.0/26', '10.1.0.64/26'])
=> ["10.1.0.0/25", "192.168.1.0/25"]

This should merge the 192.168.x.x to the /16:

irb(main):019:0* NetAddr.merge(['192.168.1.0/26', '192.168.1.64/27',
'192.168.1.96/27', '10.1.0.0/26', '10.1.0.64/26', '192.168.0.0/16'])
=> ["10.1.0.0/25", "192.168.0.0/16", "192.168.1.0/25"]

Here is the same idea in perl using Net::CIDR::Set:

$ perl -MNet::CIDR::Set -e '$s =
Net::CIDR::Set->new("10.0.0.0/8","10.0.0.0/12"); printf("%s\n",
join("\n", $s->as_cidr_array()))'
10.0.0.0/8
$ perl -MNet::CIDR::Set -e '$s =
Net::CIDR::Set->new("10.0.0.0/8","10.0.0.0/16"); printf("%s\n",
join("\n", $s->as_cidr_array()))'
10.0.0.0/8
$ perl -MNet::CIDR::Set -e '$s = Net::CIDR::Set->new("192.168.1.0/26",
"192.168.1.64/27", "192.168.1.96/27", "10.1.0.0/26", "10.1.0.64/26");
printf("%s\n", join("\n", $s->as_cidr_array()))'
10.1.0.0/25
192.168.1.0/25
$ perl -MNet::CIDR::Set -e '$s = Net::CIDR::Set->new("192.168.1.0/26",
"192.168.1.64/27", "192.168.1.96/27", "10.1.0.0/26", "10.1.0.64/26",
"192.168.0.0/16"); printf("%s\n", join("\n", $s->as_cidr_array()))'
10.1.0.0/25
192.168.0.0/16

Ruby/gem info.

$ ruby --version
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
danb-laptop$ gem list netaddr

*** LOCAL GEMS ***

netaddr (1.5.0)

License

Under which license is this code?

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.