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

index 86ac474406be54162fff2ce18d3e0da211cbf0ab..a129f60d6601a99aa2cf44a8dc58b9031a737275 100644 (file)
@@ -914,9 +914,13 @@ class CLI(object):
                        We will return False in case a network is not suitable for adding
                        it to our database, and True otherwise.
                """
-
-               if not network or not (isinstance(network, ipaddress.IPv4Network) or isinstance(network, ipaddress.IPv6Network)):
-                       return False
+               # Check input
+               if isinstance(network, ipaddress.IPv6Network):
+                       pass
+               elif isinstance(network, ipaddress.IPv4Network):
+                       pass
+               else:
+                       raise ValueError("Invalid network: %s (type %s)" % (network, type(network)))
 
                if not network.is_global:
                        log.debug("Skipping non-globally routable network: %s" % network)