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

Update for netaddr 1.0.0 #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
9 changes: 8 additions & 1 deletion geofeed_validator/fields/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class NetworkField(Field):
ERROR_PRIVATE = "Private network not allowed"
ERROR_RESERVED = "Reserved network not allowed"
ERROR_MULTICAST = "Multicast network not allowed"
ERROR_LINKLOCAL = "Link-local network not allowed"
NAME = "network"

def _check_errors(self, value):
Expand All @@ -124,10 +125,16 @@ def _check_errors(self, value):
except:
return True

ip = netaddr.IPAddress(net.network)

if net.is_loopback():
return self.ERROR_LOOPBACK
elif net.is_private():
elif ip.is_ipv4_private_use():
return self.ERROR_PRIVATE
elif ip.is_ipv6_unique_local():
return self.ERROR_PRIVATE
elif ip.is_link_local():
return self.ERROR_LINKLOCAL
elif net.is_reserved():
return self.ERROR_RESERVED
elif net.is_multicast():
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ include = [
[tool.poetry.dependencies]
python = ">=3.6.2,<4"
pycountry = ">=20.7.3"
netaddr = ">=0.8.0"
netaddr = ">=1.0.0"

[tool.poetry.dev-dependencies]
coverage = ">=5.5.0"
Expand Down