mirror of
https://github.com/onionshare/onionshare.git
synced 2025-01-01 02:36:14 -05:00
cleanup the ephemeral hidden service when GUI server is stopped, but don't disconnect from Tor
This commit is contained in:
parent
796a4b3b5d
commit
e7dd78dba7
@ -422,7 +422,7 @@ class Onion(object):
|
|||||||
|
|
||||||
return onion_host
|
return onion_host
|
||||||
|
|
||||||
def cleanup(self):
|
def cleanup(self, stop_tor=True):
|
||||||
"""
|
"""
|
||||||
Stop onion services that were created earlier. If there's a tor subprocess running, kill it.
|
Stop onion services that were created earlier. If there's a tor subprocess running, kill it.
|
||||||
"""
|
"""
|
||||||
@ -436,18 +436,21 @@ class Onion(object):
|
|||||||
pass
|
pass
|
||||||
self.service_id = None
|
self.service_id = None
|
||||||
|
|
||||||
|
if stop_tor:
|
||||||
# Stop tor process
|
# Stop tor process
|
||||||
if self.tor_proc:
|
if self.tor_proc:
|
||||||
self.tor_proc.terminate()
|
self.tor_proc.terminate()
|
||||||
time.sleep(0.2)
|
time.sleep(0.2)
|
||||||
if not self.tor_proc.poll():
|
if not self.tor_proc.poll():
|
||||||
|
try:
|
||||||
self.tor_proc.kill()
|
self.tor_proc.kill()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
self.tor_proc = None
|
self.tor_proc = None
|
||||||
|
|
||||||
# Reset other Onion settings
|
# Reset other Onion settings
|
||||||
self.connected_to_tor = False
|
self.connected_to_tor = False
|
||||||
self.stealth = False
|
self.stealth = False
|
||||||
self.service_id = None
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Delete the temporary tor data directory
|
# Delete the temporary tor data directory
|
||||||
|
@ -355,6 +355,8 @@ class OnionShareGui(QtWidgets.QMainWindow):
|
|||||||
# Probably we had no port to begin with (Onion service didn't start)
|
# Probably we had no port to begin with (Onion service didn't start)
|
||||||
pass
|
pass
|
||||||
self.app.cleanup()
|
self.app.cleanup()
|
||||||
|
# Remove ephemeral service, but don't disconnect from Tor
|
||||||
|
self.onion.cleanup(stop_tor=False)
|
||||||
self.filesize_warning.hide()
|
self.filesize_warning.hide()
|
||||||
self.stop_server_finished.emit()
|
self.stop_server_finished.emit()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user