diff --git a/geofeed_validator/fields/base.py b/geofeed_validator/fields/base.py index 75b145a..b9d2049 100644 --- a/geofeed_validator/fields/base.py +++ b/geofeed_validator/fields/base.py @@ -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): @@ -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(): diff --git a/pyproject.toml b/pyproject.toml index e5095fc..45cb666 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"