IPAddress: new IP manipulation library

B

bluemonk

Hi,

I've released IPAddress 0.5.0, first release to be public available.

http://github.com/bluemonk/ipaddress

IPAddress is an IPv4 and IPv6 addresses manipulation library, designed
to be easy to use. It is probably the most complete and powerful IP
manipulation library available today.

Some key features:

* support for IPv4, IPv6 and IPv4-IPv6 mapped addresses;
* easy handling of networks, broadcasts, prefixes;
* classless and classful (legacy) implementation;
* full set of conversion methods (bit strings, hex, unsigned
integers);
* network design features: subnetting, summarization, supernetting;
* comprehensive documentation;

IPAddress is already available as a gem on rubygems.org:

http://rubygems.org/gems/ipaddress

Migration from IPAddr should be seamlessly and pretty straightforward.
We'll soon write a tutorial on how to perform such migration.

Regards,
Marco
 
J

Jeremy Hinegardner

Hi,

I've released IPAddress 0.5.0, first release to be public available.

http://github.com/bluemonk/ipaddress

IPAddress is an IPv4 and IPv6 addresses manipulation library, designed
to be easy to use. It is probably the most complete and powerful IP
manipulation library available today.

Some key features:

* support for IPv4, IPv6 and IPv4-IPv6 mapped addresses;
* easy handling of networks, broadcasts, prefixes;
* classless and classful (legacy) implementation;
* full set of conversion methods (bit strings, hex, unsigned
integers);
* network design features: subnetting, summarization, supernetting;
* comprehensive documentation;

IPAddress is already available as a gem on rubygems.org:

http://rubygems.org/gems/ipaddress

Migration from IPAddr should be seamlessly and pretty straightforward.
We'll soon write a tutorial on how to perform such migration.

Agreed, this is a very nice addition, thank you.

-jeremy
 
B

Brian Candler

bluemonk said:
IPAddress is an IPv4 and IPv6 addresses manipulation library, designed
to be easy to use. It is probably the most complete and powerful IP
manipulation library available today.

Looks like you've done a good job.

BTW, a little while ago I released a small library,
http://github.com/deploy2/ruby-ip
and it seems we've had some similar ideas (such as separate subclasses
for v4 and v6). I meant to add things like IP#each but never got around
to it :)

Regards,

Brian.
 
A

Aaron D. Gifford

Without having looked at your library, does it support IP ranges (i.e.
blocks of IP addresses that are contiguous but do not necessarily
exactly match a subnet boundary)? Perhaps as a separate class?

Can one do this?

ip = IPAddress.new("10.0.0.1") ## No prefix specified... will it
assume /32 IPv4 host prefix?

Also, are there methods to determine if a network (or range, if
supported) contains another IP, network, or range? Something like:

ip = IPAddress.new("10.0.0.1/32")
net = IPAddress.new("10.0.0.0/24")
puts "IP is contained by network" if net.contains?(ip) || ip.is_in?(net)

Wondering,
Aaron out.
 
C

Chuck Remes

Without having looked at your library, does it support IP ranges (i.e.
blocks of IP addresses that are contiguous but do not necessarily
exactly match a subnet boundary)? Perhaps as a separate class?

Can one do this?

ip = IPAddress.new("10.0.0.1") ## No prefix specified... will it
assume /32 IPv4 host prefix?

Also, are there methods to determine if a network (or range, if
supported) contains another IP, network, or range? Something like:

ip = IPAddress.new("10.0.0.1/32")
net = IPAddress.new("10.0.0.0/24")
puts "IP is contained by network" if net.contains?(ip) || ip.is_in?(net)

Taking two seconds to peruse the (very simple) source would have given you your answer.

http://github.com/bluemonk/ipaddress/blob/master/lib/ipaddress/ipv4.rb#L499

cr
 
B

Brian Candler

Aaron said:
Without having looked at your library, does it support IP ranges (i.e.
blocks of IP addresses that are contiguous but do not necessarily
exactly match a subnet boundary)? Perhaps as a separate class?

...or it could be just a regular Ruby range, like this:
#<IP::V4 10.0.0.6>
#<IP::V4 10.0.0.7>
#<IP::V4 10.0.0.8>
#<IP::V4 10.0.0.9>
#<IP::V4 10.0.0.10>
=> #<IP::V4 10.0.0.6>..#<IP::V4 10.0.0.10>

(It's an interesting idea that perhaps an IP object should be a
start+end range, but then you need a way to show an IP as a string when
it's not suitable for addr/len form)
 
B

bluemonk

BTW, a little while ago I released a small library,http://github.com/depl= oy2/ruby-ip
and it seems we've had some similar ideas (such as separate subclasses
for v4 and v6). I meant to add things like IP#each but never got around
to it :)

Hi Brian

I wasn't aware of your library when I started writing mine. I'm not a
fan of duplicating efforts, pity we didn't see each other :)
Very nice job BTW

Regards,
Marco
 
B

bluemonk

Without having looked at your library, does it support IP ranges (i.e.
blocks of IP addresses that are contiguous but do not necessarily
exactly match a subnet boundary)? =A0 Perhaps as a separate class?

Not yet, I plan to introduce ranges in 0.7.0, I'm still working on a
meaningful notation.
Can one do this?

ip =3D IPAddress.new("10.0.0.1") ## No prefix specified... will it
assume /32 IPv4 host prefix?

No, it will assume the classful subnet mask (/8 in this case)

http://marcoceresa.com/ipaddress/classes/IPAddress/IPv4.html#M000008

However this behaviour is currently under discussion, as it is one
major break in respect to IPAddr (the other being #to_s). It may
change in the future.
Also, are there methods to determine if a network (or range, if
supported) contains another IP, network, or range? =A0Something like:

ip =3D IPAddress.new("10.0.0.1/32")
net =3D IPAddress.new("10.0.0.0/24")
puts "IP is contained by network" if net.contains?(ip) || ip.is_in?(net)

Yes:

http://marcoceresa.com/ipaddress/classes/IPAddress/IPv4.html#M000034

Regards,
Marco
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top