IPRange Support

58 views
Skip to first unread message

frogstarr78

unread,
May 4, 2012, 6:01:19 PM5/4/12
to ipaddr-py-dev
Is there any interest here with creating a class for arbitrary, non
subnet, ip ranges? I created a patch that I'd like to re-contribute to
the project, unless I'm the only one requiring this feature.
Message has been deleted

frogstarr78

unread,
May 10, 2012, 6:27:33 PM5/10/12
to ipaddr-py-dev
On May 4, 3:01 pm, frogstarr78 <frogstar...@gmail.com> wrote:
> Is there any interest here with creating a class for arbitrary, non
> subnet, ip ranges? I created a patch that I'd like to re-contribute to
> the project, unless I'm the onHere's an example:

r = IPRange.parse('127.0.0.2-127.0.0.5')

print IPAddress('127.0.0.1') in r # False
print IPAddress('127.0.0.2') in r # True
print IPAddress('127.0.0.5') in r # True
print IPAddress('127.0.0.6') in r # False

for ip in r:
print str(r)

# 127.0.0.2
# 127.0.0.3
# 127.0.0.4
# 127.0.0.5

Claudio Freire

unread,
May 10, 2012, 9:51:56 PM5/10/12
to frogstarr78, ipaddr-py-dev
On Thu, May 10, 2012 at 7:24 PM, frogstarr78 <frogs...@gmail.com> wrote:
> Here's an example:
>
> r = IPRange.parse('127.0.0.2-127.0.0.5')

What about ipv6?

I imagine support should be complete to be accepted (though I'm not
the one accepting).

frogstarr78

unread,
May 11, 2012, 10:41:09 AM5/11/12
to ipaddr-py-dev
On May 10, 6:51 pm, Claudio Freire <klaussfre...@gmail.com> wrote:
> On Thu, May 10, 2012 at 7:24 PM, frogstarr78 <frogstar...@gmail.com> wrote:
> > Here's an example:
>
> > r = IPRange.parse('127.0.0.2-127.0.0.5')
>
> What about ipv6?
>
> I imagine support should be complete to be accepted (though I'm not
> the one accepting).

Indeed. Although my use didn't require it so I didn't include it.
Suppose it could be added to another branch, with the idea that it
would eventually be merged into the master branch.?

Peter Moody

unread,
May 14, 2012, 1:25:03 PM5/14/12
to frogstarr78, ipaddr-py-dev
Sorry, I meant to reply to this last week.

I think that this is possibly useful, but I don't necessarily think
that inclusion with ipaddr/ipaddress is the right thing to do. My
reasoning is that, as much as is possible (and as much as makes
sense), I want the module to contain the minimal functionality
required for manipulating/inspecting v4 and v6 addresses.

In my mind, this seems more appropriate for a contrib or third_party
subdirectory inclusion and if there were more functionality to add, I
wouldn't feel foolish for suggesting it.

Thoughts?
--
Peter Moody      Google    1.650.253.7306
Security Engineer  pgp:0xC3410038

frogstarr78

unread,
May 19, 2012, 12:43:57 PM5/19/12
to ipaddr...@googlegroups.com, frogstarr78
That makes sense. Although, it would be nice to have some duck typing so you don't have to know that a value is already one of either IP Address or IP Network type. This would help when parsing values from input. In this way you could support at least some of the functionality of an Address or Network without forcing a valid type. Obviously there are drawbacks with this approach. Some of the drawbacks are, you may not want non-specific IP types operated on; with a generic range, you can't support all the functions that a specific IP type can handle. And I'm sure there are more drawbacks that I'm not comming up with at the moment.

Fragbait14

unread,
Aug 7, 2013, 8:28:04 PM8/7/13
to ipaddr...@googlegroups.com, frogstarr78
Hi,

Is it possible to share the code?

I am interested in having a contribution for IPRangeCheck.. Just wanted to check if an IP lies in a IPRange.

Thanks.

frogstarr78

unread,
Aug 10, 2013, 5:25:42 PM8/10/13
to ipaddr...@googlegroups.com, frogstarr78
Certainly, here you go.
ipaddr_range.py
Reply all
Reply to author
Forward
0 new messages