From b8e797049b82dd0eec42fa46e5da442801ae8dc8 Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Thu, 29 Dec 2016 10:03:29 -0800 Subject: [PATCH] Display information about tor when testing settings is successful --- onionshare/onion.py | 8 +++----- onionshare_gui/settings_dialog.py | 3 ++- resources/locale/en.json | 3 ++- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/onionshare/onion.py b/onionshare/onion.py index df74ffde..03dfde2c 100644 --- a/onionshare/onion.py +++ b/onionshare/onion.py @@ -167,16 +167,14 @@ class Onion(object): except UnreadableCookieFile: raise TorErrorUnreadableCookieFile(strings._('settings_error_unreadable_cookie_file')) + # get the tor version + self.tor_version = self.c.get_version().version_str # do the versions of stem and tor that I'm using support ephemeral onion services? - tor_version = self.c.get_version().version_str list_ephemeral_hidden_services = getattr(self.c, "list_ephemeral_hidden_services", None) - self.supports_ephemeral = callable(list_ephemeral_hidden_services) and tor_version >= '0.2.7.1' + self.supports_ephemeral = callable(list_ephemeral_hidden_services) and self.tor_version >= '0.2.7.1' # do the versions of stem and tor that I'm using support stealth onion services? - self.check_for_stealth_support() - - def check_for_stealth_support(self): try: res = self.c.create_ephemeral_hidden_service({1:1}, basic_auth={'onionshare':None}, await_publication=False) tmp_service_id = res.content()[0][2].split('=')[1] diff --git a/onionshare_gui/settings_dialog.py b/onionshare_gui/settings_dialog.py index 6116d2a5..24cecbb3 100644 --- a/onionshare_gui/settings_dialog.py +++ b/onionshare_gui/settings_dialog.py @@ -214,9 +214,10 @@ class SettingsDialog(QtWidgets.QDialog): onion = Onion(settings=settings) # If an exception hasn't been raised yet, the Tor settings work + Alert(strings._('settings_test_success', True).format(onion.tor_version, onion.supports_ephemeral, onion.supports_stealth)) except (TorErrorInvalidSetting, TorErrorSocketPort, TorErrorSocketFile, TorErrorMissingPassword, TorErrorUnreadableCookieFile) as e: - Alert(e.args[0]) + Alert(e.args[0], QtWidgets.QMessageBox.Warning) def save_clicked(self): """ diff --git a/resources/locale/en.json b/resources/locale/en.json index f48b90ed..c69fbab8 100644 --- a/resources/locale/en.json +++ b/resources/locale/en.json @@ -83,5 +83,6 @@ "settings_error_socket_port": "Can't connect to Tor controller on address {} with port {}.", "settings_error_socket_file": "Can't connect to Tor controller using socket file {}.", "settings_error_missing_password": "Connected to Tor controller, but it requires a password to authenticate.", - "settings_error_unreadable_cookie_file": "Connected to Tor controller, but can't authenticate because your password may be wrong, and your user doesn't have permission to read the cookie file." + "settings_error_unreadable_cookie_file": "Connected to Tor controller, but can't authenticate because your password may be wrong, and your user doesn't have permission to read the cookie file.", + "settings_test_success": "Congratulations, OnionShare can connect to the Tor controller.\n\nTor version: {}\nSupports ephemeral onion services: {}\nSupports stealth onion services: {}" }