aboutsummaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorMicah Lee <micah@micahflee.com>2022-05-30 14:26:46 -0700
committerMicah Lee <micah@micahflee.com>2022-05-30 14:26:46 -0700
commitfb0e28c62bd93cdbb6904f66eace402b8dd8b245 (patch)
tree9d1284a65689df97dd65e3c881acb32013ef463b /cli
parent8dd354f03926e44fa6ab40f89cfb62e3b9643412 (diff)
downloadonionshare-fb0e28c62bd93cdbb6904f66eace402b8dd8b245.tar.gz
onionshare-fb0e28c62bd93cdbb6904f66eace402b8dd8b245.zip
Treat censorship API returning None for bridge settings the same as if it doesn't return bridge settings (#1588)
Diffstat (limited to 'cli')
-rw-r--r--cli/onionshare_cli/censorship.py25
1 files changed, 18 insertions, 7 deletions
diff --git a/cli/onionshare_cli/censorship.py b/cli/onionshare_cli/censorship.py
index 9268f578..4cff4862 100644
--- a/cli/onionshare_cli/censorship.py
+++ b/cli/onionshare_cli/censorship.py
@@ -78,6 +78,7 @@ class CensorshipCircumvention(object):
Note that this API endpoint doesn't return actual bridges,
it just returns the recommended bridge type countries.
"""
+ self.common.log("CensorshipCircumvention", "request_map", f"country={country}")
if not self.api_proxies:
return False
endpoint = "https://bridges.torproject.org/moat/circumvention/map"
@@ -126,6 +127,11 @@ class CensorshipCircumvention(object):
Optionally, a list of transports can be specified in order to
return recommended settings for just that transport type.
"""
+ self.common.log(
+ "CensorshipCircumvention",
+ "request_settings",
+ f"country={country}, transports={transports}",
+ )
if not self.api_proxies:
return False
endpoint = "https://bridges.torproject.org/moat/circumvention/settings"
@@ -155,6 +161,11 @@ class CensorshipCircumvention(object):
return False
result = r.json()
+ self.common.log(
+ "CensorshipCircumvention",
+ "request_settings",
+ f"result={result}",
+ )
if "errors" in result:
self.common.log(
@@ -167,7 +178,7 @@ class CensorshipCircumvention(object):
# There are no settings - perhaps this country doesn't require censorship circumvention?
# This is not really an error, so we can just check if False and assume direct Tor
# connection will work.
- if not "settings" in result:
+ if not "settings" in result or result["settings"] is None:
self.common.log(
"CensorshipCircumvention",
"request_settings",
@@ -218,6 +229,12 @@ class CensorshipCircumvention(object):
"""
Checks the bridges and saves them in settings.
"""
+ self.common.log(
+ "CensorshipCircumvention",
+ "save_settings",
+ f"bridge_settings: {bridge_settings}",
+ )
+
bridges_ok = False
self.settings = settings
@@ -226,11 +243,6 @@ class CensorshipCircumvention(object):
# 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"]
- self.common.log(
- "CensorshipCircumvention",
- "save_settings",
- f"Obtained bridges: {bridges}",
- )
bridge_strings = bridges["bridge_strings"]
self.settings.set("bridges_type", "custom")
@@ -260,7 +272,6 @@ class CensorshipCircumvention(object):
)
return False
-
def request_default_bridges(self):
"""
Retrieves the list of default fall-back bridges from the Tor Project.