mirror of
https://github.com/onionshare/onionshare.git
synced 2024-12-26 07:49:48 -05:00
Fixed various issues introduced by creating an singleton Onion object and passing it into the OnionShare object
This commit is contained in:
parent
adc450c971
commit
dc23946fe8
@ -128,6 +128,7 @@ def main(cwd=None):
|
||||
finally:
|
||||
# Shutdown
|
||||
app.cleanup()
|
||||
onion.cleanup()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
@ -52,6 +52,7 @@ class OnionShare(object):
|
||||
"""
|
||||
Start the onionshare onion service.
|
||||
"""
|
||||
# Choose a random port
|
||||
self.port = helpers.get_available_port(17600, 17650)
|
||||
|
||||
if self.local_only:
|
||||
@ -74,7 +75,3 @@ class OnionShare(object):
|
||||
elif os.path.isdir(filename):
|
||||
shutil.rmtree(filename)
|
||||
self.cleanup_filenames = []
|
||||
|
||||
# cleanup the onion
|
||||
if self.onion:
|
||||
self.onion.cleanup()
|
||||
|
@ -105,7 +105,7 @@ def main():
|
||||
|
||||
# Start the OnionShare app
|
||||
web.set_stay_open(stay_open)
|
||||
app = OnionShare(debug, local_only, stay_open)
|
||||
app = OnionShare(onion, debug, local_only, stay_open)
|
||||
|
||||
# Clean up when app quits
|
||||
def shutdown():
|
||||
|
@ -22,6 +22,7 @@ from PyQt5 import QtCore, QtWidgets, QtGui
|
||||
|
||||
from onionshare import strings, helpers, web
|
||||
from onionshare.settings import Settings
|
||||
from onionshare.onion import *
|
||||
|
||||
from .menu import Menu
|
||||
from .file_selection import FileSelection
|
||||
@ -145,36 +146,23 @@ class OnionShareGui(QtWidgets.QMainWindow):
|
||||
web.error404_count = 0
|
||||
web.set_gui_mode()
|
||||
|
||||
# pick an available local port for the http service to listen on
|
||||
self.app.choose_port()
|
||||
|
||||
# start onionshare http service in new thread
|
||||
t = threading.Thread(target=web.start, args=(self.app.port, self.app.stay_open))
|
||||
t.daemon = True
|
||||
t.start()
|
||||
# wait for modules in thread to load, preventing a thread-related cx_Freeze crash
|
||||
time.sleep(0.2)
|
||||
|
||||
# start the onion service in a new thread
|
||||
def start_onion_service(self):
|
||||
try:
|
||||
# Show Tor connection status if connection type is bundled tor
|
||||
if settings.get('connection_type') == 'bundled':
|
||||
def bundled_tor_func(message):
|
||||
self.status_bar.showMessage(message)
|
||||
if 'Done' in message:
|
||||
self.status_bar.showMessage(strings._('gui_starting_server1', True))
|
||||
else:
|
||||
self.status_bar.showMessage(strings._('gui_starting_server1', True))
|
||||
bundled_tor_func = None
|
||||
|
||||
self.app.start_onion_service(bundled_tor_func)
|
||||
self.app.start_onion_service()
|
||||
self.starting_server_step2.emit()
|
||||
|
||||
except (onionshare.onion.TorTooOld, onionshare.onion.TorErrorInvalidSetting, onionshare.onion.TorErrorAutomatic, onionshare.onion.TorErrorSocketPort, onionshare.onion.TorErrorSocketFile, onionshare.onion.TorErrorMissingPassword, onionshare.onion.TorErrorUnreadableCookieFile, onionshare.onion.TorErrorAuthError, onionshare.onion.TorErrorProtocolError, onionshare.onion.BundledTorTimeout) as e:
|
||||
except (TorTooOld, TorErrorInvalidSetting, TorErrorAutomatic, TorErrorSocketPort, TorErrorSocketFile, TorErrorMissingPassword, TorErrorUnreadableCookieFile, TorErrorAuthError, TorErrorProtocolError, BundledTorTimeout) as e:
|
||||
self.starting_server_error.emit(e.args[0])
|
||||
return
|
||||
|
||||
# start onionshare http service in new thread
|
||||
t = threading.Thread(target=web.start, args=(self.app.port, self.app.stay_open))
|
||||
t.daemon = True
|
||||
t.start()
|
||||
# wait for modules in thread to load, preventing a thread-related cx_Freeze crash
|
||||
time.sleep(0.2)
|
||||
|
||||
t = threading.Thread(target=start_onion_service, kwargs={'self': self})
|
||||
t.daemon = True
|
||||
t.start()
|
||||
|
Loading…
Reference in New Issue
Block a user