I’ve released IPAddress 0.5.0, first release to be public available.
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);
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)
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:
require ‘ip’
=> true
r = IP.new(“10.0.0.6”)…IP.new(“10.0.0.10”)
=> #<IP::V4 10.0.0.6>…#<IP::V4 10.0.0.10>
r.each { |x| p x }
#<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)
BTW, a little while ago I released a small library,GitHub - deploy2/ruby-ip: IP address manipulation library
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
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?
Not yet, I plan to introduce ranges in 0.7.0, I’m still working on a
meaningful notation.
Can one do this?
ip = 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)
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? 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)
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,
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.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.