From 035c398f825a6e59c58e1eebdc921bbe10c6b611 Mon Sep 17 00:00:00 2001 From: Miguel Jacq Date: Sun, 16 Feb 2025 10:59:16 +1100 Subject: [PATCH] Only set Censorship Circumvention bridges if we actually received some --- cli/onionshare_cli/censorship.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/cli/onionshare_cli/censorship.py b/cli/onionshare_cli/censorship.py index 4cff4862..2c0b1403 100644 --- a/cli/onionshare_cli/censorship.py +++ b/cli/onionshare_cli/censorship.py @@ -242,17 +242,18 @@ class CensorshipCircumvention(object): # Should we attempt to iterate over each type if one of them fails to connect? # But if so, how to stop it starting 3 separate Tor connection threads? # for bridges in request_bridges["settings"]: - bridges = bridge_settings["settings"][0]["bridges"] - bridge_strings = bridges["bridge_strings"] + if bridge_settings["settings"]: + bridges = bridge_settings["settings"][0]["bridges"] + bridge_strings = bridges["bridge_strings"] - self.settings.set("bridges_type", "custom") + self.settings.set("bridges_type", "custom") - # Sanity check the bridges provided from the Tor API before saving - bridges_checked = self.common.check_bridges_valid(bridge_strings) + # Sanity check the bridges provided from the Tor API before saving + bridges_checked = self.common.check_bridges_valid(bridge_strings) - if bridges_checked: - self.settings.set("bridges_custom", "\n".join(bridges_checked)) - bridges_ok = True + if bridges_checked: + self.settings.set("bridges_custom", "\n".join(bridges_checked)) + bridges_ok = True # If we got any good bridges, save them to settings and return. if bridges_ok: