]> git.ipfire.org Git - location/location-database.git/commitdiff
Skip any blocks where IP addresses could not be parsed
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 30 Jan 2018 15:47:33 +0000 (15:47 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 30 Jan 2018 15:47:33 +0000 (15:47 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
tools/base.py

index e424a82b348b8e2dc6be0be7e1fbb40dbe00f99e..f2b4bbeac8c46422722026f3a555ec52771c6dd0 100644 (file)
@@ -254,9 +254,15 @@ class RIRParser(object):
                                        return
 
                                # Convert to IP address
-                               start_address = ipaddress.ip_address(start_address)
-                               end_address   = ipaddress.ip_address(end_address)
-                               prefix        = 32
+                               try:
+                                       start_address = ipaddress.ip_address(start_address)
+                                       end_address   = ipaddress.ip_address(end_address)
+                               except ValueError:
+                                       logging.warning("Could not parse line: %s" % line)
+                                       return
+
+                               # Set prefix to default
+                               prefix = 32
 
                                # Count number of addresses in this subnet
                                num_addresses = int(end_address) - int(start_address)