Display information about tor when testing settings is successful

This commit is contained in:
Micah Lee 2016-12-29 10:03:29 -08:00
parent 19d020f245
commit b8e797049b
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73
3 changed files with 7 additions and 7 deletions

View File

@ -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]

View File

@ -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):
"""

View File

@ -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: {}"
}