aboutsummaryrefslogtreecommitdiff
path: root/desktop/src
diff options
context:
space:
mode:
authorMicah Lee <micah@micahflee.com>2021-10-24 20:23:38 -0700
committerMicah Lee <micah@micahflee.com>2021-10-24 20:23:38 -0700
commite33fc49815d58548488675d7c409408cb5005e65 (patch)
tree93845a5695a1e70ada4b85296534d6bb7fb1004c /desktop/src
parente6c7cc989f78a8de531a3cc7420eb9193abd9a06 (diff)
parent10147b6c6b515231e74d866216818a8590ac5822 (diff)
downloadonionshare-e33fc49815d58548488675d7c409408cb5005e65.tar.gz
onionshare-e33fc49815d58548488675d7c409408cb5005e65.zip
Merge branch 'censorship' into 1442_settings_tabs
Diffstat (limited to 'desktop/src')
-rw-r--r--desktop/src/onionshare/gui_common.py6
-rw-r--r--desktop/src/onionshare/moat_dialog.py43
-rw-r--r--desktop/src/onionshare/tor_settings_tab.py11
3 files changed, 47 insertions, 13 deletions
diff --git a/desktop/src/onionshare/gui_common.py b/desktop/src/onionshare/gui_common.py
index f2fd6ef0..b081774e 100644
--- a/desktop/src/onionshare/gui_common.py
+++ b/desktop/src/onionshare/gui_common.py
@@ -409,11 +409,13 @@ class GuiCommon:
tor_geo_ipv6_file_path = os.path.join(base_path, "geoip6")
obfs4proxy_file_path = os.path.join(base_path, "obfs4proxy")
snowflake_file_path = os.path.join(base_path, "snowflake-client")
+ meek_client_file_path = os.path.join(base_path, "meek-client")
else:
# Fallback to looking in the path
tor_path = shutil.which("tor")
obfs4proxy_file_path = shutil.which("obfs4proxy")
snowflake_file_path = shutil.which("snowflake-client")
+ meek_client_file_path = shutil.which("meek-client")
prefix = os.path.dirname(os.path.dirname(tor_path))
tor_geo_ip_file_path = os.path.join(prefix, "share/tor/geoip")
tor_geo_ipv6_file_path = os.path.join(prefix, "share/tor/geoip6")
@@ -423,6 +425,7 @@ class GuiCommon:
tor_path = os.path.join(base_path, "Tor", "tor.exe")
obfs4proxy_file_path = os.path.join(base_path, "Tor", "obfs4proxy.exe")
snowflake_file_path = os.path.join(base_path, "Tor", "snowflake-client.exe")
+ meek_client_file_path = os.path.join(base_path, "Tor", "meek-client.exe")
tor_geo_ip_file_path = os.path.join(base_path, "Data", "Tor", "geoip")
tor_geo_ipv6_file_path = os.path.join(base_path, "Data", "Tor", "geoip6")
elif self.common.platform == "Darwin":
@@ -430,6 +433,7 @@ class GuiCommon:
tor_path = os.path.join(base_path, "tor")
obfs4proxy_file_path = os.path.join(base_path, "obfs4proxy")
snowflake_file_path = os.path.join(base_path, "snowflake-client")
+ meek_client_file_path = os.path.join(base_path, "meek-client")
tor_geo_ip_file_path = os.path.join(base_path, "geoip")
tor_geo_ipv6_file_path = os.path.join(base_path, "geoip6")
elif self.common.platform == "BSD":
@@ -437,6 +441,7 @@ class GuiCommon:
tor_geo_ip_file_path = "/usr/local/share/tor/geoip"
tor_geo_ipv6_file_path = "/usr/local/share/tor/geoip6"
obfs4proxy_file_path = "/usr/local/bin/obfs4proxy"
+ meek_client_file_path = "/usr/local/bin/meek-client"
snowflake_file_path = "/usr/local/bin/snowflake-client"
return (
@@ -445,6 +450,7 @@ class GuiCommon:
tor_geo_ipv6_file_path,
obfs4proxy_file_path,
snowflake_file_path,
+ meek_client_file_path,
)
@staticmethod
diff --git a/desktop/src/onionshare/moat_dialog.py b/desktop/src/onionshare/moat_dialog.py
index 56e872b5..85b5e888 100644
--- a/desktop/src/onionshare/moat_dialog.py
+++ b/desktop/src/onionshare/moat_dialog.py
@@ -26,6 +26,7 @@ import json
from . import strings
from .gui_common import GuiCommon
+from onionshare_cli.meek import MeekNotFound
class MoatDialog(QtWidgets.QDialog):
@@ -35,13 +36,15 @@ class MoatDialog(QtWidgets.QDialog):
got_bridges = QtCore.Signal(str)
- def __init__(self, common):
+ def __init__(self, common, meek):
super(MoatDialog, self).__init__()
self.common = common
self.common.log("MoatDialog", "__init__")
+ self.meek = meek
+
self.setModal(True)
self.setWindowTitle(strings._("gui_settings_bridge_moat_button"))
self.setWindowIcon(QtGui.QIcon(GuiCommon.get_resource_path("images/logo.png")))
@@ -111,7 +114,7 @@ class MoatDialog(QtWidgets.QDialog):
self.submit_button.hide()
# BridgeDB fetch
- self.t_fetch = MoatThread(self.common, "fetch")
+ self.t_fetch = MoatThread(self.common, self.meek, "fetch")
self.t_fetch.bridgedb_error.connect(self.bridgedb_error)
self.t_fetch.captcha_ready.connect(self.captcha_ready)
self.t_fetch.start()
@@ -133,6 +136,7 @@ class MoatDialog(QtWidgets.QDialog):
# BridgeDB check
self.t_check = MoatThread(
self.common,
+ self.meek,
"check",
{
"transport": self.transport,
@@ -217,16 +221,34 @@ class MoatThread(QtCore.QThread):
captcha_ready = QtCore.Signal(str, str, str)
bridges_ready = QtCore.Signal(str)
- def __init__(self, common, action, data={}):
+ def __init__(self, common, meek, action, data={}):
super(MoatThread, self).__init__()
self.common = common
self.common.log("MoatThread", "__init__", f"action={action}")
+ self.meek = meek
+ self.transport = "obfs4"
self.action = action
self.data = data
def run(self):
- # TODO: Do all of this using domain fronting
+
+ # Start Meek so that we can do domain fronting
+ try:
+ self.meek.start()
+ except MeekNotFound:
+ self.common.log("MoatThread", "run", f"Could not find the Meek Client")
+ self.bridgedb_error.emit()
+ return
+
+ # We should only fetch bridges if we can domain front,
+ # but we can override this in local-only mode.
+ if not self.meek.meek_proxies and not self.common.gui.local_only:
+ self.common.log(
+ "MoatThread", "run", f"Could not identify meek proxies to make request"
+ )
+ self.bridgedb_error.emit()
+ return
if self.action == "fetch":
self.common.log("MoatThread", "run", f"starting fetch")
@@ -235,19 +257,20 @@ class MoatThread(QtCore.QThread):
r = requests.post(
"https://bridges.torproject.org/moat/fetch",
headers={"Content-Type": "application/vnd.api+json"},
+ proxies=self.meek.meek_proxies,
json={
"data": [
{
"version": "0.1.0",
"type": "client-transports",
- "supported": [
- "obfs4",
- "snowflake",
- ],
+ "supported": ["obfs4", "snowflake"],
}
]
},
)
+
+ self.meek.cleanup()
+
if r.status_code != 200:
self.common.log("MoatThread", "run", f"status_code={r.status_code}")
self.bridgedb_error.emit()
@@ -285,6 +308,7 @@ class MoatThread(QtCore.QThread):
r = requests.post(
"https://bridges.torproject.org/moat/check",
headers={"Content-Type": "application/vnd.api+json"},
+ proxies=self.meek.meek_proxies,
json={
"data": [
{
@@ -299,6 +323,9 @@ class MoatThread(QtCore.QThread):
]
},
)
+
+ self.meek.cleanup()
+
if r.status_code != 200:
self.common.log("MoatThread", "run", f"status_code={r.status_code}")
self.bridgedb_error.emit()
diff --git a/desktop/src/onionshare/tor_settings_tab.py b/desktop/src/onionshare/tor_settings_tab.py
index a56d360b..4f73ca66 100644
--- a/desktop/src/onionshare/tor_settings_tab.py
+++ b/desktop/src/onionshare/tor_settings_tab.py
@@ -24,6 +24,7 @@ import platform
import re
import os
+from onionshare_cli.meek import Meek
from onionshare_cli.settings import Settings
from onionshare_cli.onion import Onion
@@ -46,6 +47,8 @@ class TorSettingsTab(QtWidgets.QWidget):
self.common = common
self.common.log("TorSettingsTab", "__init__")
+ self.meek = Meek(common, get_tor_paths=self.common.gui.get_tor_paths)
+
self.system = platform.system()
self.tab_id = tab_id
@@ -73,6 +76,7 @@ class TorSettingsTab(QtWidgets.QWidget):
self.tor_geo_ipv6_file_path,
self.obfs4proxy_file_path,
self.snowflake_file_path,
+ self.meek_client_file_path,
) = self.common.gui.get_tor_paths()
bridges_label = QtWidgets.QLabel(strings._("gui_settings_tor_bridges_label"))
@@ -511,7 +515,7 @@ class TorSettingsTab(QtWidgets.QWidget):
"""
self.common.log("TorSettingsTab", "bridge_moat_button_clicked")
- moat_dialog = MoatDialog(self.common)
+ moat_dialog = MoatDialog(self.common, self.meek)
moat_dialog.got_bridges.connect(self.bridge_moat_got_bridges)
moat_dialog.exec_()
@@ -808,10 +812,7 @@ class TorSettingsTab(QtWidgets.QWidget):
)
return False
- settings.set(
- "tor_bridges_use_moat_bridges",
- moat_bridges,
- )
+ settings.set("tor_bridges_use_moat_bridges", moat_bridges)
settings.set("tor_bridges_use_custom_bridges", "")