From: @cao-fei8 Reviewed-by: @Charlie_li Signed-off-by: @Charlie_li
This commit is contained in:
commit
b978c19fcc
68
0001-Fix-for-is_loopback-behaviour-issue-222-223.patch
Normal file
68
0001-Fix-for-is_loopback-behaviour-issue-222-223.patch
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
From 606a44b62ea7032f63e359aaaaabc0057e168890 Mon Sep 17 00:00:00 2001
|
||||||
|
From: niels <nkeulen@gmail.com>
|
||||||
|
Date: Wed, 27 Jan 2021 20:44:12 +0100
|
||||||
|
Subject: [PATCH] Fix for is_loopback behaviour (issue: #222) (#223)
|
||||||
|
|
||||||
|
---
|
||||||
|
netaddr/ip/__init__.py | 4 +--
|
||||||
|
.../tests/ip/test_ip_network_categories.py | 26 +++++++++++++++++++
|
||||||
|
2 files changed, 28 insertions(+), 2 deletions(-)
|
||||||
|
create mode 100644 netaddr/tests/ip/test_ip_network_categories.py
|
||||||
|
|
||||||
|
diff --git a/netaddr/ip/__init__.py b/netaddr/ip/__init__.py
|
||||||
|
index d1232eb..9e13b29 100644
|
||||||
|
--- a/netaddr/ip/__init__.py
|
||||||
|
+++ b/netaddr/ip/__init__.py
|
||||||
|
@@ -151,7 +151,7 @@ class BaseIP(object):
|
||||||
|
if self._module.version == 4:
|
||||||
|
return self in IPV4_LOOPBACK
|
||||||
|
elif self._module.version == 6:
|
||||||
|
- return self == IPV6_LOOPBACK
|
||||||
|
+ return self in IPV6_LOOPBACK
|
||||||
|
|
||||||
|
def is_private(self):
|
||||||
|
"""
|
||||||
|
@@ -1949,7 +1949,7 @@ IPV4_RESERVED = (
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# Cached IPv6 address range lookups.
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
-IPV6_LOOPBACK = IPAddress('::1')
|
||||||
|
+IPV6_LOOPBACK = IPNetwork('::1/128')
|
||||||
|
|
||||||
|
IPV6_PRIVATE = (
|
||||||
|
IPNetwork('fc00::/7'), # Unique Local Addresses (ULA)
|
||||||
|
diff --git a/netaddr/tests/ip/test_ip_network_categories.py b/netaddr/tests/ip/test_ip_network_categories.py
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..9f9961e
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/netaddr/tests/ip/test_ip_network_categories.py
|
||||||
|
@@ -0,0 +1,26 @@
|
||||||
|
+from netaddr import IPNetwork
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+def test_is_unicast():
|
||||||
|
+ assert IPNetwork('192.0.2.0/24').is_unicast()
|
||||||
|
+ assert IPNetwork('fe80::1/48').is_unicast()
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+def test_is_multicast():
|
||||||
|
+ assert IPNetwork('239.192.0.1/24').is_multicast()
|
||||||
|
+ assert IPNetwork('ff00::/8').is_multicast()
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+def test_is_private():
|
||||||
|
+ assert IPNetwork('10.0.0.0/24').is_private()
|
||||||
|
+ assert IPNetwork('fc00::/7').is_private()
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+def test_is_reserved():
|
||||||
|
+ assert IPNetwork('240.0.0.0/24').is_reserved()
|
||||||
|
+ assert IPNetwork('0::/48').is_reserved()
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+def test_is_loopback():
|
||||||
|
+ assert IPNetwork('127.0.0.0/8').is_loopback()
|
||||||
|
+ assert IPNetwork('::1/128').is_loopback()
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
Name: python-netaddr
|
Name: python-netaddr
|
||||||
Version: 0.8.0
|
Version: 0.8.0
|
||||||
Release: 4
|
Release: 5
|
||||||
Summary: A pure Python network address representation and manipulation library
|
Summary: A pure Python network address representation and manipulation library
|
||||||
|
|
||||||
License: BSD-3-Clause
|
License: BSD-3-Clause
|
||||||
@ -9,6 +9,7 @@ Source0: https://pypi.python.org/packages/source/n/netaddr/netaddr-%{vers
|
|||||||
|
|
||||||
Patch9000: elimate-ROC-in-python-netaddr.patch
|
Patch9000: elimate-ROC-in-python-netaddr.patch
|
||||||
Patch9001: disable-test-oui-information.patch
|
Patch9001: disable-test-oui-information.patch
|
||||||
|
Patch9002: 0001-Fix-for-is_loopback-behaviour-issue-222-223.patch
|
||||||
|
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
BuildRequires: python3-devel python3-setuptools python3-sphinx python3-pytest
|
BuildRequires: python3-devel python3-setuptools python3-sphinx python3-pytest
|
||||||
@ -56,6 +57,9 @@ py.test-%{python3_version}
|
|||||||
%{_bindir}/netaddr
|
%{_bindir}/netaddr
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Jan 17 2023 caofei <caofei@xfusion.com> - 0.8.0-5
|
||||||
|
- Fix for is_loopback behaviour (issue: #222)
|
||||||
|
|
||||||
* Wed May 11 2022 wulei <wulei80@h-partners.com> - 0.8.0-4
|
* Wed May 11 2022 wulei <wulei80@h-partners.com> - 0.8.0-4
|
||||||
- License compliance rectification
|
- License compliance rectification
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user