Esempio n. 1
0
    def start_server(self):
        """
        Start the onionshare server. This uses multiple threads to start the Tor onion
        server and the web app.
        """
        common.log('OnionShareGui', 'start_server')

        self.set_server_active(True)

        self.app.set_stealth(self.settings.get('use_stealth'))

        # Hide and reset the downloads if we have previously shared
        self.downloads_container.hide()
        self.downloads.reset_downloads()
        self.reset_info_counters()
        self.status_bar.clearMessage()
        self.server_share_status_label.setText('')

        # Reset web counters
        web.download_count = 0
        web.error404_count = 0
        web.set_gui_mode()

        # start the onion service in a new thread
        def start_onion_service(self):
            try:
                self.app.start_onion_service()
                self.starting_server_step2.emit()

            except (TorTooOld, TorErrorInvalidSetting, TorErrorAutomatic,
                    TorErrorSocketPort, TorErrorSocketFile,
                    TorErrorMissingPassword, TorErrorUnreadableCookieFile,
                    TorErrorAuthError, TorErrorProtocolError,
                    BundledTorTimeout, OSError) as e:
                self.starting_server_error.emit(e.args[0])
                return

            self.app.stay_open = not self.settings.get(
                'close_after_first_download')

            # start onionshare http service in new thread
            t = threading.Thread(target=web.start,
                                 args=(self.app.port, self.app.stay_open,
                                       self.settings.get('slug')))
            t.daemon = True
            t.start()
            # wait for modules in thread to load, preventing a thread-related cx_Freeze crash
            time.sleep(0.2)

        common.log('OnionshareGui', 'start_server', 'Starting an onion thread')
        self.t = OnionThread(function=start_onion_service,
                             kwargs={'self': self})
        self.t.daemon = True
        self.t.start()
Esempio n. 2
0
    def start_server(self):
        """
        Start the onionshare server. This uses multiple threads to start the Tor onion
        server and the web app.
        """
        # Reset web counters
        web.download_count = 0
        web.error404_count = 0
        web.set_gui_mode()

        # pick an available local port for the http service to listen on
        self.app.choose_port()

        # disable the stealth option
        self.options.set_advanced_enabled(False)

        # start onionshare http service in new thread
        t = threading.Thread(
            target=web.start, args=(self.app.port, self.app.stay_open, self.app.transparent_torification)
        )
        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):
            self.status_bar.showMessage(strings._("gui_starting_server1", True))
            try:
                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,
            ) as e:
                self.starting_server_error.emit(e.args[0])
                return

        t = threading.Thread(target=start_onion_service, kwargs={"self": self})
        t.daemon = True
        t.start()
Esempio n. 3
0
    def start_server(self):
        """
        Start the onionshare server. This uses multiple threads to start the Tor onion
        server and the web app.
        """
        common.log('OnionShareGui', 'start_server')

        self.set_server_active(True)

        self.app.set_stealth(self.settings.get('use_stealth'))

        # Hide and reset the downloads if we have previously shared
        self.downloads_container.hide()
        self.downloads.reset_downloads()
        self.reset_info_counters()
        self.status_bar.clearMessage()
        self.server_share_status_label.setText('')

        # Reset web counters
        web.download_count = 0
        web.error404_count = 0
        web.set_gui_mode()

        # start the onion service in a new thread
        def start_onion_service(self):
            try:
                self.app.start_onion_service()
                self.starting_server_step2.emit()

            except (TorTooOld, TorErrorInvalidSetting, TorErrorAutomatic, TorErrorSocketPort, TorErrorSocketFile, TorErrorMissingPassword, TorErrorUnreadableCookieFile, TorErrorAuthError, TorErrorProtocolError, BundledTorTimeout, OSError) as e:
                self.starting_server_error.emit(e.args[0])
                return


            self.app.stay_open = not self.settings.get('close_after_first_download')

            # start onionshare http service in new thread
            t = threading.Thread(target=web.start, args=(self.app.port, self.app.stay_open, self.settings.get('slug')))
            t.daemon = True
            t.start()
            # wait for modules in thread to load, preventing a thread-related cx_Freeze crash
            time.sleep(0.2)

        common.log('OnionshareGui', 'start_server', 'Starting an onion thread')
        self.t = OnionThread(function=start_onion_service, kwargs={'self': self})
        self.t.daemon = True
        self.t.start()
Esempio n. 4
0
    def start_server(self):
        """
        Start the onionshare server. This uses multiple threads to start the Tor onion
        server and the web app.
        """
        # Reset web counters
        web.download_count = 0
        web.error404_count = 0
        web.set_gui_mode()

        # pick an available local port for the http service to listen on
        self.app.choose_port()

        # disable the stealth option
        self.options.set_advanced_enabled(False)

        # start onionshare http service in new thread
        t = threading.Thread(target=web.start,
                             args=(self.app.port, self.app.stay_open,
                                   self.app.transparent_torification))
        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):
            self.status_bar.showMessage(strings._('gui_starting_server1',
                                                  True))
            try:
                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) as e:
                self.starting_server_error.emit(e.args[0])
                return

        t = threading.Thread(target=start_onion_service, kwargs={'self': self})
        t.daemon = True
        t.start()
Esempio n. 5
0
    def start_server(self):
        """
        Start the onionshare server. This uses multiple threads to start the Tor onion
        server and the web app.
        """
        # Reset web counters
        web.download_count = 0
        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,
                                   self.app.transparent_torification))
        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):
            self.status_bar.showMessage(strings._('gui_starting_server1',
                                                  True))
            try:
                self.app.start_onion_service()
                self.starting_server_step2.emit()

            except onionshare.onion.NoTor as e:
                self.starting_server_error.emit(e.args[0])
                return

        t = threading.Thread(target=start_onion_service, kwargs={'self': self})
        t.daemon = True
        t.start()
Esempio n. 6
0
    def start_server(self):
        """
        Start the onionshare server. This uses multiple threads to start the Tor onion
        server and the web app.
        """
        # First, load settings and configure
        settings = Settings()
        settings.load()
        self.app.set_stealth(settings.get('use_stealth'))
        web.set_stay_open(not settings.get('close_after_first_download'))

        # Reset web counters
        web.download_count = 0
        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,
                                   self.app.transparent_torification))
        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.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:
                self.starting_server_error.emit(e.args[0])
                return

        t = threading.Thread(target=start_onion_service, kwargs={'self': self})
        t.daemon = True
        t.start()