]> git.ipfire.org Git - location/libloc.git/commitdiff
importer: Improve checks for unspecified networks
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 4 Mar 2024 10:22:22 +0000 (10:22 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 4 Mar 2024 10:22:22 +0000 (10:22 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/scripts/location-importer.in

index a129f60d6601a99aa2cf44a8dc58b9031a737275..4b340374226a0d70b971ccc354a4a55311dc7717 100644 (file)
@@ -922,10 +922,16 @@ class CLI(object):
                else:
                        raise ValueError("Invalid network: %s (type %s)" % (network, type(network)))
 
+               # Ignore anything that isn't globally routable
                if not network.is_global:
                        log.debug("Skipping non-globally routable network: %s" % network)
                        return False
 
+               # Ignore anything that is unspecified IP range (See RFC 5735 for IPv4 or RFC 2373 for IPv6)
+               elif network.is_unspecified:
+                       log.debug("Skipping unspecified network: %s" % network)
+                       return False
+
                if network.version == 4:
                        if network.prefixlen < 7:
                                log.debug("Skipping too big IP chunk: %s" % network)
@@ -935,10 +941,6 @@ class CLI(object):
                                log.debug("Skipping network too small to be publicly announced: %s" % network)
                                return False
 
-                       if str(network.network_address) == "0.0.0.0":
-                               log.debug("Skipping network based on 0.0.0.0: %s" % network)
-                               return False
-
                elif network.version == 6:
                        if network.prefixlen < 10:
                                log.debug("Skipping too big IP chunk: %s" % network)
@@ -948,15 +950,6 @@ class CLI(object):
                                log.debug("Skipping network too small to be publicly announced: %s" % network)
                                return False
 
-                       if str(network.network_address) == "::":
-                               log.debug("Skipping network based on '::': %s" % network)
-                               return False
-
-               else:
-                       # This should not happen...
-                       log.warning("Skipping network of unknown family, this should not happen: %s" % network)
-                       return False
-
                # In case we have made it here, the network is considered to
                # be suitable for libloc consumption...
                return True