diff --git a/continentmap.go b/continentmap.go index 44e8173..24cc795 100644 --- a/continentmap.go +++ b/continentmap.go @@ -1,7 +1,7 @@ package signaling // This file has been automatically generated, do not modify. -// Source: https://datahub.io/JohnSnowLabs/country-and-continent-codes-list/r/country-and-continent-codes-list-csv.json +// Source: https://datahub.io/core/country-codes/r/country-codes.json var ( ContinentMap map[string][]string = map[string][]string{ @@ -11,8 +11,7 @@ var ( "AG": {"NA"}, "AI": {"NA"}, "AL": {"EU"}, - "AM": {"EU", "AS"}, - "AN": {"NA"}, + "AM": {"AS"}, "AO": {"AF"}, "AQ": {"AN"}, "AR": {"SA"}, @@ -21,7 +20,7 @@ var ( "AU": {"OC"}, "AW": {"NA"}, "AX": {"EU"}, - "AZ": {"EU", "AS"}, + "AZ": {"AS"}, "BA": {"EU"}, "BB": {"NA"}, "BD": {"AS"}, @@ -59,8 +58,8 @@ var ( "CU": {"NA"}, "CV": {"AF"}, "CW": {"NA"}, - "CX": {"AS"}, - "CY": {"EU", "AS"}, + "CX": {"OC"}, + "CY": {"EU"}, "CZ": {"EU"}, "DE": {"EU"}, "DJ": {"AF"}, @@ -84,7 +83,7 @@ var ( "GA": {"AF"}, "GB": {"EU"}, "GD": {"NA"}, - "GE": {"EU", "AS"}, + "GE": {"AS"}, "GF": {"SA"}, "GG": {"EU"}, "GH": {"AF"}, @@ -130,7 +129,7 @@ var ( "KR": {"AS"}, "KW": {"AS"}, "KY": {"NA"}, - "KZ": {"EU", "AS"}, + "KZ": {"AS"}, "LA": {"AS"}, "LB": {"AS"}, "LC": {"NA"}, @@ -196,7 +195,7 @@ var ( "RE": {"AF"}, "RO": {"EU"}, "RS": {"EU"}, - "RU": {"EU", "AS"}, + "RU": {"EU"}, "RW": {"AF"}, "SA": {"AS"}, "SB": {"OC"}, @@ -226,18 +225,18 @@ var ( "TH": {"AS"}, "TJ": {"AS"}, "TK": {"OC"}, - "TL": {"AS"}, + "TL": {"OC"}, "TM": {"AS"}, "TN": {"AF"}, "TO": {"OC"}, - "TR": {"EU", "AS"}, + "TR": {"AS"}, "TT": {"NA"}, "TV": {"OC"}, "TW": {"AS"}, "TZ": {"AF"}, "UA": {"EU"}, "UG": {"AF"}, - "UM": {"OC", "NA"}, + "UM": {"OC"}, "US": {"NA"}, "UY": {"SA"}, "UZ": {"AS"}, @@ -250,10 +249,6 @@ var ( "VU": {"OC"}, "WF": {"OC"}, "WS": {"OC"}, - "XD": {"AS"}, - "XE": {"AS"}, - "XS": {"AS"}, - "XX": {"OC"}, "YE": {"AS"}, "YT": {"AF"}, "ZA": {"AF"}, diff --git a/geoip_test.go b/geoip_test.go index a0ef7b6..eba29f0 100644 --- a/geoip_test.go +++ b/geoip_test.go @@ -104,7 +104,7 @@ func TestGeoLookupContinent(t *testing.T) { tests := map[string][]string{ "AU": {"OC"}, "DE": {"EU"}, - "RU": {"EU", "AS"}, + "RU": {"EU"}, "": nil, "INVALID ": nil, } diff --git a/mcu_proxy_test.go b/mcu_proxy_test.go index 1232602..e518e6d 100644 --- a/mcu_proxy_test.go +++ b/mcu_proxy_test.go @@ -67,10 +67,10 @@ func Test_sortConnectionsForCountry(t *testing.T) { {conn_de, conn_jp, conn_at}, {conn_jp, conn_de, conn_at}, }, - // Partial continent match + // Continent match "RU": { {conn_us, conn_de, conn_jp, conn_at}, - {conn_de, conn_jp, conn_at, conn_us}, + {conn_de, conn_at, conn_us, conn_jp}, }, // No match "AU": { @@ -125,10 +125,10 @@ func Test_sortConnectionsForCountryWithOverride(t *testing.T) { {conn_de, conn_jp, conn_at}, {conn_jp, conn_de, conn_at}, }, - // Partial continent match + // Continent match "RU": { {conn_us, conn_de, conn_jp, conn_at}, - {conn_de, conn_jp, conn_at, conn_us}, + {conn_de, conn_at, conn_us, conn_jp}, }, // No match "AR": { diff --git a/scripts/get_continent_map.py b/scripts/get_continent_map.py index 00c45b5..1475a3d 100755 --- a/scripts/get_continent_map.py +++ b/scripts/get_continent_map.py @@ -30,7 +30,7 @@ import json import subprocess import sys -URL = 'https://datahub.io/JohnSnowLabs/country-and-continent-codes-list/r/country-and-continent-codes-list-csv.json' +URL = 'https://datahub.io/core/country-codes/r/country-codes.json' def tostr(s): if isinstance(s, bytes) and not isinstance(s, str): @@ -58,8 +58,11 @@ def generate_map(filename): data = json.loads(tostr(data)) continents = {} for entry in data: - country = entry['Two_Letter_Country_Code'] - continent = entry['Continent_Code'] + country = entry['ISO3166-1-Alpha-2'] + continent = entry['Continent'] + if country is None and continent is None: + continue + continents.setdefault(country, []).append(continent) out = StringIO()