mirror of
https://github.com/onionshare/onionshare.git
synced 2025-08-16 01:55:21 -04:00
Refactor to CensorshipCircumvention and Meek classes. Use Meek domain fronting when requesting bridges in frontend
This commit is contained in:
parent
bcf697574e
commit
5b4d77c363
6 changed files with 202 additions and 79 deletions
|
@ -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
|
||||
|
|
|
@ -34,13 +34,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")))
|
||||
|
@ -108,7 +110,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()
|
||||
|
@ -130,6 +132,7 @@ class MoatDialog(QtWidgets.QDialog):
|
|||
# BridgeDB check
|
||||
self.t_check = MoatThread(
|
||||
self.common,
|
||||
self.meek,
|
||||
"check",
|
||||
{"challenge": self.challenge, "solution": self.solution_lineedit.text()},
|
||||
)
|
||||
|
@ -209,17 +212,20 @@ class MoatThread(QtCore.QThread):
|
|||
captcha_ready = QtCore.Signal(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
|
||||
self.meek.start()
|
||||
|
||||
if self.action == "fetch":
|
||||
self.common.log("MoatThread", "run", f"starting fetch")
|
||||
|
@ -228,6 +234,7 @@ 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": [
|
||||
{
|
||||
|
@ -280,6 +287,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": [
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
||||
|
@ -48,6 +49,8 @@ class TorSettingsDialog(QtWidgets.QDialog):
|
|||
|
||||
self.common.log("TorSettingsDialog", "__init__")
|
||||
|
||||
self.meek = Meek(common)
|
||||
|
||||
self.setModal(True)
|
||||
self.setWindowTitle(strings._("gui_tor_settings_window_title"))
|
||||
self.setWindowIcon(QtGui.QIcon(GuiCommon.get_resource_path("images/logo.png")))
|
||||
|
@ -78,6 +81,7 @@ class TorSettingsDialog(QtWidgets.QDialog):
|
|||
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"))
|
||||
|
@ -497,7 +501,7 @@ class TorSettingsDialog(QtWidgets.QDialog):
|
|||
"""
|
||||
self.common.log("TorSettingsDialog", "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_()
|
||||
|
||||
|
@ -577,9 +581,7 @@ class TorSettingsDialog(QtWidgets.QDialog):
|
|||
return
|
||||
|
||||
onion = Onion(
|
||||
self.common,
|
||||
use_tmp_dir=True,
|
||||
get_tor_paths=self.common.gui.get_tor_paths,
|
||||
self.common, use_tmp_dir=True, get_tor_paths=self.common.gui.get_tor_paths
|
||||
)
|
||||
|
||||
tor_con = TorConnectionDialog(self.common, settings, True, onion)
|
||||
|
@ -781,10 +783,7 @@ class TorSettingsDialog(QtWidgets.QDialog):
|
|||
Alert(self.common, strings._("gui_settings_moat_bridges_invalid"))
|
||||
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", "")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue