Make it so when selecting moat tor actually uses those bridges, and improve tor settings dialog

This commit is contained in:
Micah Lee 2021-10-17 15:47:11 -07:00
parent 40cb55894a
commit a89412e79d
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73
4 changed files with 23 additions and 5 deletions

View File

@ -333,9 +333,19 @@ class Onion(object):
for line in o: for line in o:
f.write(line) f.write(line)
if self.settings.get("tor_bridges_use_custom_bridges"): elif self.settings.get("tor_bridges_use_moat"):
f.write(self.settings.get("tor_bridges_use_custom_bridges") + "\n") for line in self.settings.get("tor_bridges_use_moat_bridges").split(
f.write("\nUseBridges 1") "\n"
):
f.write(f"Bridge {line}\n")
f.write("\nUseBridges 1\n")
elif self.settings.get("tor_bridges_use_custom_bridges"):
for line in self.settings.get(
"tor_bridges_use_custom_bridges"
).split("\n"):
f.write(f"Bridge {line}\n")
f.write("\nUseBridges 1\n")
# Execute a tor subprocess # Execute a tor subprocess
start_ts = time.time() start_ts = time.time()

View File

@ -172,6 +172,7 @@ class MoatDialog(QtWidgets.QDialog):
self.label.setText(strings._("moat_captcha_label")) self.label.setText(strings._("moat_captcha_label"))
self.captcha.show() self.captcha.show()
self.solution_lineedit.setText("")
self.solution_lineedit.show() self.solution_lineedit.show()
self.reload_button.show() self.reload_button.show()
self.submit_button.show() self.submit_button.show()

View File

@ -67,9 +67,10 @@
"gui_settings_bridge_none_radio_option": "Don't use a bridge", "gui_settings_bridge_none_radio_option": "Don't use a bridge",
"gui_settings_meek_lite_expensive_warning": "Warning: The meek-azure bridges are very costly for the Tor Project to run.<br><br>Only use them if unable to connect to Tor directly, via obfs4 transports, or other normal bridges.", "gui_settings_meek_lite_expensive_warning": "Warning: The meek-azure bridges are very costly for the Tor Project to run.<br><br>Only use them if unable to connect to Tor directly, via obfs4 transports, or other normal bridges.",
"gui_settings_bridge_moat_radio_option": "Request a bridge from torproject.org", "gui_settings_bridge_moat_radio_option": "Request a bridge from torproject.org",
"gui_settings_bridge_moat_button": "Request a New Bridge...", "gui_settings_bridge_moat_button": "Request a New Bridge",
"gui_settings_bridge_custom_radio_option": "Provide a bridge you learned about from a trusted source", "gui_settings_bridge_custom_radio_option": "Provide a bridge you learned about from a trusted source",
"gui_settings_bridge_custom_placeholder": "type address:port (one per line)", "gui_settings_bridge_custom_placeholder": "type address:port (one per line)",
"gui_settings_moat_bridges_invalid": "You have not requested a bridge from torproject.org yet.",
"gui_settings_tor_bridges_invalid": "None of the bridges you added work.\nDouble-check them or add others.", "gui_settings_tor_bridges_invalid": "None of the bridges you added work.\nDouble-check them or add others.",
"gui_settings_button_save": "Save", "gui_settings_button_save": "Save",
"gui_settings_button_cancel": "Cancel", "gui_settings_button_cancel": "Cancel",

View File

@ -775,9 +775,15 @@ class TorSettingsDialog(QtWidgets.QDialog):
settings.set("tor_bridges_use_snowflake", False) settings.set("tor_bridges_use_snowflake", False)
settings.set("tor_bridges_use_moat", True) settings.set("tor_bridges_use_moat", True)
moat_bridges = self.bridge_moat_textbox.toPlainText()
if moat_bridges.strip() == "":
Alert(self.common, strings._("gui_settings_moat_bridges_invalid"))
return False
settings.set( settings.set(
"tor_bridges_use_moat_bridges", "tor_bridges_use_moat_bridges",
self.bridge_moat_textbox.toPlainText(), moat_bridges,
) )
settings.set("tor_bridges_use_custom_bridges", "") settings.set("tor_bridges_use_custom_bridges", "")