forked from kenzuya/unshackle
fix(proxies): harden surfshark and windscribe selection
This commit is contained in:
@@ -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]:
|
||||
|
||||
@@ -62,7 +62,7 @@ class WindscribeVPN(Proxy):
|
||||
server_map_key = f"{query}:{city}" if city else query
|
||||
if server_map_key in self.server_map:
|
||||
hostname = self.server_map[server_map_key]
|
||||
elif query in self.server_map and not city:
|
||||
elif query in self.server_map:
|
||||
hostname = self.server_map[query]
|
||||
else:
|
||||
server_match = re.match(r"^([a-z]{2})(\d+)$", query)
|
||||
|
||||
Reference in New Issue
Block a user