From afc966dbbf52e29f3e9a261fa5a4fc696616ab60 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Mon, 4 Mar 2024 09:49:43 +0000 Subject: [PATCH] importer: Make translating country codes more extensible Signed-off-by: Michael Tremer --- src/scripts/location-importer.in | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/scripts/location-importer.in b/src/scripts/location-importer.in index 18cca65..4a487c9 100644 --- a/src/scripts/location-importer.in +++ b/src/scripts/location-importer.in @@ -48,6 +48,11 @@ VALID_ASN_RANGES = ( (131072, 4199999999), ) +TRANSLATED_COUNTRIES = { + # When people say UK, they mean GB + "UK" : "GB", +} + IGNORED_COUNTRIES = set(( # Formerly Yugoslavia "YU", @@ -1109,9 +1114,11 @@ class CLI(object): log.debug("Ignoring country code '%s'" % val) continue - # When people set country codes to "UK", they actually mean "GB" - if val == "UK": - val = "GB" + # Translate country codes + try: + val = TRANSLATED_COUNTRIES[val] + except KeyError: + pass inetnum[key].append(val) -- 2.39.5