actually stage the bgp_path.py half of the international-loop fix

This commit is contained in:
Andrew Pimenov 2026-08-10 21:18:42 +03:00
parent 938c715a04
commit a21197f83b

View file

@ -62,12 +62,8 @@ def colo_location(code: str | None) -> tuple[str | None, str | None]:
return COLO_LOCATIONS.get(code.upper(), (None, None)) return COLO_LOCATIONS.get(code.upper(), (None, None))
def detect_international_loop( def detect_international_loop(client_country: str | None, edge_country: str | None) -> tuple[bool, list[str]]:
client_country: str | None, ip_country: str | None, edge_country: str | None if not client_country or not edge_country or edge_country == client_country:
) -> tuple[bool, list[str]]:
if not client_country or not ip_country or client_country != ip_country:
return False, []
if not edge_country or edge_country == client_country:
return False, [] return False, []
return True, [edge_country] return True, [edge_country]
@ -79,7 +75,7 @@ def build_path_diversity(client_country: str | None, hops: list[AnycastHop]) ->
international_loop = False international_loop = False
detour_countries: list[str] = [] detour_countries: list[str] = []
for hop in hops: for hop in hops:
is_loop, countries = detect_international_loop(client_country, hop.ip_country, hop.edge_country) is_loop, countries = detect_international_loop(client_country, hop.edge_country)
if is_loop: if is_loop:
international_loop = True international_loop = True
for country in countries: for country in countries: