summaryrefslogtreecommitdiff
path: root/onionshare/onion.py
diff options
context:
space:
mode:
Diffstat (limited to 'onionshare/onion.py')
-rw-r--r--onionshare/onion.py22
1 files changed, 14 insertions, 8 deletions
diff --git a/onionshare/onion.py b/onionshare/onion.py
index 887650c9..068648ba 100644
--- a/onionshare/onion.py
+++ b/onionshare/onion.py
@@ -488,8 +488,8 @@ class Onion(object):
auth_cookie = list(res.client_auth.values())[0]
self.auth_string = 'HidServAuth {} {}'.format(onion_host, auth_cookie)
- self.settings.save()
if onion_host is not None:
+ self.settings.save()
return onion_host
else:
raise TorErrorProtocolError(strings._('error_tor_protocol_error'))
@@ -500,13 +500,19 @@ class Onion(object):
"""
common.log('Onion', 'cleanup')
- # Cleanup the ephemeral onion service
- if self.service_id:
- try:
- self.c.remove_ephemeral_hidden_service(self.service_id)
- except:
- pass
- self.service_id = None
+ # Cleanup the ephemeral onion services, if we have any
+ try:
+ onions = self.c.list_ephemeral_hidden_services()
+ for onion in onions:
+ try:
+ common.log('Onion', 'cleanup', 'trying to remove onion {}'.format(onion))
+ self.c.remove_ephemeral_hidden_service(onion)
+ except:
+ common.log('Onion', 'cleanup', 'could not remove onion {}.. moving on anyway'.format(onion))
+ pass
+ except:
+ pass
+ self.service_id = None
if stop_tor:
# Stop tor process