aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiguel Jacq <mig@mig5.net>2022-03-22 14:22:16 +1100
committerMiguel Jacq <mig@mig5.net>2022-03-22 14:29:02 +1100
commit21243fd9bd43bfa3c193d9794d9dc9655fdb0725 (patch)
treeb6414cabbe7c045c9e39d6a8dad26227b6971a50
parentd59328d99cc7f5f34046a57174a10e74c3bd7e2c (diff)
downloadonionshare-21243fd9bd43bfa3c193d9794d9dc9655fdb0725.tar.gz
onionshare-21243fd9bd43bfa3c193d9794d9dc9655fdb0725.zip
More verbose and consistent Meek exception logging
-rw-r--r--cli/onionshare_cli/censorship.py17
-rw-r--r--cli/onionshare_cli/meek.py18
-rw-r--r--desktop/onionshare/connection_tab.py5
-rw-r--r--desktop/onionshare/moat_dialog.py12
4 files changed, 29 insertions, 23 deletions
diff --git a/cli/onionshare_cli/censorship.py b/cli/onionshare_cli/censorship.py
index 4ab5c366..058f0f35 100644
--- a/cli/onionshare_cli/censorship.py
+++ b/cli/onionshare_cli/censorship.py
@@ -19,8 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
import requests
-from .meek import MeekNotRunning
-
class CensorshipCircumventionError(Exception):
"""
@@ -47,15 +45,12 @@ class CensorshipCircumvention(object):
self.api_proxies = {}
if meek:
self.meek = meek
- if not self.meek.meek_proxies:
- raise MeekNotRunning()
- else:
- self.common.log(
- "CensorshipCircumvention",
- "__init__",
- "Using Meek with CensorshipCircumvention API",
- )
- self.api_proxies = self.meek.meek_proxies
+ self.common.log(
+ "CensorshipCircumvention",
+ "__init__",
+ "Using Meek with CensorshipCircumvention API",
+ )
+ self.api_proxies = self.meek.meek_proxies
if onion:
self.onion = onion
if not self.onion.is_authenticated:
diff --git a/cli/onionshare_cli/meek.py b/cli/onionshare_cli/meek.py
index 777c0ab6..81ef6c6e 100644
--- a/cli/onionshare_cli/meek.py
+++ b/cli/onionshare_cli/meek.py
@@ -69,7 +69,7 @@ class Meek(object):
if self.meek_client_file_path is None or not os.path.exists(
self.meek_client_file_path
):
- raise MeekNotFound()
+ raise MeekNotFound(self.common)
# Start the Meek Client as a subprocess.
self.common.log("Meek", "start", "Starting meek client")
@@ -128,7 +128,7 @@ class Meek(object):
if "CMETHOD-ERROR" in line:
self.cleanup()
- raise MeekNotRunning()
+ raise MeekNotRunning(self.common, line)
break
if self.meek_port:
@@ -137,9 +137,8 @@ class Meek(object):
"https": f"socks5h://{self.meek_host}:{self.meek_port}",
}
else:
- self.common.log("Meek", "start", "Could not obtain the meek port")
self.cleanup()
- raise MeekNotRunning()
+ raise MeekNotRunning(self.common, "Could not obtain the meek port")
def cleanup(self):
"""
@@ -182,8 +181,19 @@ class MeekNotRunning(Exception):
number it started on, in order to do domain fronting.
"""
+ def __init__(self, common, info=None):
+ self.common = common
+ msg = "Meek experienced an error starting up"
+ if info:
+ msg = msg + f": {info}"
+ self.common.log("MeekNotRunning", "__init__", msg)
+
class MeekNotFound(Exception):
"""
We were unable to find the Meek Client binary.
"""
+
+ def __init__(self, common):
+ self.common = common
+ self.common.log("MeekNotFound", "__init__", "Could not find the meek binary")
diff --git a/desktop/onionshare/connection_tab.py b/desktop/onionshare/connection_tab.py
index 1cf3c376..b9a16a3b 100644
--- a/desktop/onionshare/connection_tab.py
+++ b/desktop/onionshare/connection_tab.py
@@ -181,6 +181,11 @@ class AutoConnectTab(QtWidgets.QWidget):
self.tor_con.start(self.curr_settings)
def _got_no_bridges(self):
+ self.common.log(
+ "AutoConnectTab",
+ "_got_no_bridges",
+ "Could not obtain bridges, so falling back to trying built-in obfs4 bridges",
+ )
# If we got no bridges, try connecting again using built-in obfs4 bridges
self.curr_settings.set("bridges_type", "built-in")
self.curr_settings.set("bridges_builtin_pt", "obfs4")
diff --git a/desktop/onionshare/moat_dialog.py b/desktop/onionshare/moat_dialog.py
index fd04ee9c..db4bdf29 100644
--- a/desktop/onionshare/moat_dialog.py
+++ b/desktop/onionshare/moat_dialog.py
@@ -236,14 +236,10 @@ class MoatThread(QtCore.QThread):
# Start Meek so that we can do domain fronting
try:
self.meek.start()
- except MeekNotFound:
- self.common.log("MoatThread", "run", f"Could not find meek-client")
- self.bridgedb_error.emit()
- return
- except MeekNotRunning:
- self.common.log(
- "MoatThread", "run", f"Ran meek-client, but there was an error"
- )
+ except (
+ MeekNotFound,
+ MeekNotRunning,
+ ):
self.bridgedb_error.emit()
return