fix(proxies): harden surfshark and windscribe selection

This commit is contained in:
Andy
2026-02-07 20:34:31 -07:00
parent 71adee4ec6
commit 984a8b9efa
2 changed files with 11 additions and 6 deletions

View File

@@ -142,12 +142,17 @@ class SurfsharkVPN(Proxy):
)
# Get connection names from filtered servers
connection_names = [x["connectionName"] for x in servers]
if not servers:
raise ValueError(f"Could not get random server for country '{country_id}': no servers found.")
try:
return random.choice(connection_names)
except (IndexError, KeyError):
raise ValueError(f"Could not get random server for country '{country_id}'.")
# Only include servers that actually have a connection name to avoid KeyError.
connection_names = [x["connectionName"] for x in servers if "connectionName" in x]
if not connection_names:
raise ValueError(
f"Could not get random server for country '{country_id}': no servers with connectionName found."
)
return random.choice(connection_names)
@staticmethod
def get_countries() -> list[dict]: