Fixes for the edge case where Tor connection dialog is canceled, but the Tor process remains open in the background, which was causing onion.is_authenticated() to True. Remove excessive alerts

This commit is contained in:
Miguel Jacq 2017-12-21 14:08:13 +11:00
parent b442b5d41b
commit 6f4d7f7f44
No known key found for this signature in database
GPG Key ID: EEA4341C6D97A0B6
5 changed files with 15 additions and 8 deletions

View File

@ -380,7 +380,7 @@ class Onion(object):
"""
Returns True if the Tor connection is still working, or False otherwise.
"""
if self.c:
if self.c is not None:
return self.c.is_authenticated()
else:
return False

View File

@ -176,6 +176,7 @@ class OnionShareGui(QtWidgets.QMainWindow):
quit, or open settings.
"""
common.log('OnionShareGui', '_tor_connection_canceled')
self.timer.stop()
def ask():
a = Alert(strings._('gui_tor_connection_ask', True), QtWidgets.QMessageBox.Question, buttons=QtWidgets.QMessageBox.NoButton, autostart=False)
@ -394,11 +395,14 @@ class OnionShareGui(QtWidgets.QMainWindow):
"""
self.update()
# Has the Tor Connection dialog finished, but we've since lost connection to Tor somehow?
if not self.onion.is_authenticated() and self.tor_con.t.isFinished():
self.timer.stop()
self.start_server_error(strings._('error_tor_protocol_error'))
self._tor_connection_canceled()
# Have we lost connection to Tor somehow?
if self.tor_con.t.isFinished():
if not self.onion.is_authenticated():
self.timer.stop()
if self.server_status.status != self.server_status.STATUS_STOPPED:
self.server_status.stop_server()
self.status_bar.clearMessage()
self._tor_connection_canceled()
# scroll to the bottom of the dl progress bar log pane
# if a new download has been added

View File

@ -460,6 +460,7 @@ class SettingsDialog(QtWidgets.QDialog):
# the Onion object
reboot_onion = False
if self.onion.is_authenticated():
common.log('SettingsDialog', 'save_clicked', 'Connected to Tor')
def changed(s1, s2, keys):
"""
Compare the Settings objects s1 and s2 and return true if any values
@ -478,6 +479,7 @@ class SettingsDialog(QtWidgets.QDialog):
reboot_onion = True
else:
common.log('SettingsDialog', 'save_clicked', 'Not connected to Tor')
# Tor isn't connected, so try connecting
reboot_onion = True

View File

@ -86,6 +86,7 @@ class TorConnectionDialog(QtWidgets.QProgressDialog):
def _canceled_connecting_to_tor(self):
common.log('TorConnectionDialog', '_canceled_connecting_to_tor')
self.active = False
self.onion.cleanup()
# Cancel connecting to Tor
QtCore.QTimer.singleShot(1, self.cancel)
@ -126,7 +127,7 @@ class TorConnectionThread(QtCore.QThread):
# Connect to the Onion
try:
self.onion.connect(self.settings, False, self._tor_status_update)
if self.onion.is_authenticated():
if self.onion.connected_to_tor:
self.connected_to_tor.emit()
else:
self.canceled_connecting_to_tor.emit()

View File

@ -114,7 +114,7 @@
"update_error_check_error": "Error checking for updates: Maybe you're not connected to Tor, or maybe the OnionShare website is down.",
"update_error_invalid_latest_version": "Error checking for updates: The OnionShare website responded saying the latest version is '{}', but that doesn't appear to be a valid version string.",
"update_not_available": "You are running the latest version of OnionShare.",
"gui_tor_connection_ask": "Would you like to open OnionShare settings to troubleshoot connecting to Tor?",
"gui_tor_connection_ask": "Tor isn't running.\n\nWould you like to open OnionShare settings to troubleshoot connecting to Tor?",
"gui_tor_connection_ask_open_settings": "Open Settings",
"gui_tor_connection_ask_quit": "Quit",
"gui_tor_connection_error_settings": "Try adjusting how OnionShare connects to the Tor network in Settings.",