Skip to content

Commit 5708900

Browse files
committed
Document IPv6 support.
1 parent 9aa1023 commit 5708900

3 files changed

Lines changed: 59 additions & 3 deletions

File tree

docs/index.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,23 +69,29 @@ implements the magic method ``__contains__`` which python calls when the
6969
'127.0.0.1', # single ip
7070
'192.168/16', # CIDR network block
7171
('10.0.0.1', '10.0.0.19'), # arbitrary inclusive range
72+
'::1', # single IPv6 address
73+
'fe80::/10', # IPv6 CIDR block
7274
)
7375
7476
7577
***
7678
API
7779
***
7880

81+
iptools
82+
=======
83+
.. automodule:: iptools
84+
7985
IpRangeList
80-
===========
86+
-----------
8187
.. autoclass:: iptools.IpRangeList
8288
:members:
8389
:special-members:
8490
:show-inheritance:
8591

8692

8793
IpRange
88-
=======
94+
-------
8995
.. autoclass:: iptools.IpRange
9096
:members:
9197
:special-members:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
test_suite='tests',
2424
setup_requires=setup_requires,
2525
classifiers=[
26-
'Development Status :: 4 - Beta',
26+
'Development Status :: 5 - Production/Stable',
2727
'Environment :: Web Environment',
2828
'Intended Audience :: Developers',
2929
'License :: OSI Approved :: BSD License',

tests/iptools/iptools_test.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# -*- coding: utf-8 -*-
2+
3+
import unittest
4+
import iptools
5+
6+
7+
class IpRangeListTests(unittest.TestCase):
8+
9+
def testMixedRange(self):
10+
INTERNAL_IPS = iptools.IpRangeList(
11+
'127.0.0.1', # single ip
12+
'192.168/16', # CIDR network block
13+
('10.0.0.1', '10.0.0.19'), # arbitrary inclusive range
14+
'::1', # single IPv6 address
15+
'fe80::/10', # IPv6 CIDR block
16+
'::ffff:0:0/96', # IPv4-mapped IPv6
17+
)
18+
19+
self.assertTrue('127.0.0.1' in INTERNAL_IPS)
20+
21+
self.assertTrue('192.168.0.1' in INTERNAL_IPS)
22+
self.assertTrue('192.168.255.254' in INTERNAL_IPS)
23+
24+
self.assertTrue('10.0.0.1' in INTERNAL_IPS)
25+
self.assertTrue('10.0.0.19' in INTERNAL_IPS)
26+
27+
self.assertTrue('::1' in INTERNAL_IPS)
28+
29+
self.assertTrue('fe80::1' in INTERNAL_IPS)
30+
self.assertTrue('fe80::ffff' in INTERNAL_IPS)
31+
self.assertTrue(
32+
'fe80:ffff:ffff:ffff:ffff:ffff:ffff:ffff' in INTERNAL_IPS)
33+
34+
self.assertTrue('::ffff:172.16.11.12' in INTERNAL_IPS)
35+
36+
self.assertFalse('209.19.170.129' in INTERNAL_IPS)
37+
# end testMixedRange
38+
#end class IpRangeListTests
39+
40+
41+
class IpRangeTests(unittest.TestCase):
42+
43+
def testIPv6Range(self):
44+
fixture = iptools.IpRange('::ffff:0:0/96')
45+
self.assertTrue('::ffff:172.16.11.12' in fixture)
46+
self.assertFalse('209.19.170.129' in fixture)
47+
#end testIPv6Range
48+
#end class IpRangeTests
49+
50+
# vim:se sw=4 ts=4 sts=4 et:

0 commit comments

Comments
 (0)