#493, #500 - detect if the Tor connection (bundled, TorBrowser or otherwise) has been lost while the app is open. Stop a running share if so

This commit is contained in:
Miguel Jacq 2017-12-21 09:22:53 +11:00
parent 5c390f1bd9
commit bcd4363769
No known key found for this signature in database
GPG key ID: EEA4341C6D97A0B6
3 changed files with 45 additions and 17 deletions

View file

@ -459,26 +459,31 @@ class SettingsDialog(QtWidgets.QDialog):
# If Tor isn't connected, or if Tor settings have changed, Reinitialize
# the Onion object
reboot_onion = False
if self.onion.connected_to_tor:
def changed(s1, s2, keys):
"""
Compare the Settings objects s1 and s2 and return true if any values
have changed for the given keys.
"""
for key in keys:
if s1.get(key) != s2.get(key):
return True
return False
try:
self.onion
if self.onion.is_authenticated():
def changed(s1, s2, keys):
"""
Compare the Settings objects s1 and s2 and return true if any values
have changed for the given keys.
"""
for key in keys:
if s1.get(key) != s2.get(key):
return True
return False
if changed(settings, self.old_settings, [
'connection_type', 'control_port_address',
'control_port_port', 'socks_address', 'socks_port',
'socket_file_path', 'auth_type', 'auth_password']):
if changed(settings, self.old_settings, [
'connection_type', 'control_port_address',
'control_port_port', 'socks_address', 'socks_port',
'socket_file_path', 'auth_type', 'auth_password']):
reboot_onion = True
else:
# Tor isn't connected, so try connecting
reboot_onion = True
else:
# Tor isn't connected, so try connecting
except:
# We definitely aren't connected, as the onion object had no attribute is_authenticated()
reboot_onion = True
# Do we need to reinitialize Tor?