Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Missing Comma and Extend Private IPv6 Prefix List #100

Merged
merged 3 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,12 @@ IPWARE_PRIVATE_IP_PREFIX = getattr(settings,
'240.', '241.', '242.', '243.', '244.', '245.', '246.', '247.', '248.',
'249.', '250.', '251.', '252.', '253.', '254.', '255.', # reserved
'::', # Unspecified address
'::ffff:', '2001:10:', '2001:20:' # messages to software
'::ffff:', '2001:10:', '2001:20:', # messages to software
'2001::', # TEREDO
'2001:2::', # benchmarking
'2001:db8:', # reserved for documentation and example code
'fc00:', # IPv6 private block
'fc', # IPv6 ULA (RFC4193) - NOTE: Reserved for future use, not currently in widespread use.
'fd', # IPv6 ULA (RFC4193) - Mainly used for private network addressing
'fe80:', # link-local unicast
'ff00:', # IPv6 multicast
)
Expand Down
5 changes: 3 additions & 2 deletions ipware/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,12 @@
'240.', '241.', '242.', '243.', '244.', '245.', '246.', '247.', '248.',
'249.', '250.', '251.', '252.', '253.', '254.', '255.', # reserved
'::', # Unspecified address
'::ffff:', '2001:10:', '2001:20:' # messages to software
'::ffff:', '2001:10:', '2001:20:', # messages to software
'2001::', # TEREDO
'2001:2::', # benchmarking
'2001:db8:', # reserved for documentation and example code
'fc00:', # IPv6 private block
'fc', # IPv6 ULA (RFC4193) - NOTE: Reserved for future use, not currently in widespread use.
'fd', # IPv6 ULA (RFC4193) - Mainly used for private network addressing
'fe80:', # link-local unicast
'ff00:', # IPv6 multicast
)
Expand Down
13 changes: 13 additions & 0 deletions ipware/tests/tests_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,16 @@ def test_get_ip_info(self):
ip = '74dc::02ba'
result = util.get_ip_info(ip)
self.assertTrue(result, (ip, True))

def test_is_ipv6_private_block(self):
ip = 'fc00::1'
self.assertTrue(util.is_private_ip(ip))

ip = 'fd00::1'
self.assertTrue(util.is_private_ip(ip))

# Test an address that is outside the fc00::/7 private block range
ip = 'fb00::1'
self.assertFalse(util.is_private_ip(ip))
ip = 'fe00::1'
self.assertFalse(util.is_private_ip(ip))