]> git.ipfire.org Git - location/libloc.git/commitdiff
importer: Ignore certain country codes
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 4 Mar 2024 09:48:19 +0000 (09:48 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 4 Mar 2024 09:48:19 +0000 (09:48 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/scripts/location-importer.in

index 7689993798e1667a7e20c992ed504c5aea964ffc..18cca656272a6a2652574154fa9b9cdbe4fec487 100644 (file)
@@ -48,6 +48,14 @@ VALID_ASN_RANGES = (
        (131072, 4199999999),
 )
 
+IGNORED_COUNTRIES = set((
+       # Formerly Yugoslavia
+       "YU",
+
+       # Some people use ZZ to say "no country" or to hide the country
+       "ZZ",
+))
+
 # Configure the CSV parser for ARIN
 csv.register_dialect("arin", delimiter=",", quoting=csv.QUOTE_ALL, quotechar="\"")
 
@@ -1096,6 +1104,11 @@ class CLI(object):
                                                # ... but keep this list distinct...
                                                continue
 
+                               # Ignore certain country codes
+                               if val in IGNORED_COUNTRIES:
+                                       log.debug("Ignoring country code '%s'" % val)
+                                       continue
+
                                # When people set country codes to "UK", they actually mean "GB"
                                if val == "UK":
                                        val = "GB"