mirror of
https://github.com/onionshare/onionshare.git
synced 2025-12-09 21:45:43 -05:00
Merge branch 'develop' into 929_download_errors
This commit is contained in:
commit
b96b83905b
15 changed files with 294 additions and 116 deletions
|
|
@ -24,7 +24,22 @@ import shutil
|
|||
from pkg_resources import resource_filename
|
||||
|
||||
from . import strings
|
||||
from onionshare_cli.onion import Onion
|
||||
from onionshare_cli.onion import (
|
||||
Onion,
|
||||
TorErrorInvalidSetting,
|
||||
TorErrorAutomatic,
|
||||
TorErrorSocketPort,
|
||||
TorErrorSocketFile,
|
||||
TorErrorMissingPassword,
|
||||
TorErrorUnreadableCookieFile,
|
||||
TorErrorAuthError,
|
||||
TorErrorProtocolError,
|
||||
BundledTorTimeout,
|
||||
BundledTorBroken,
|
||||
TorTooOldEphemeral,
|
||||
TorTooOldStealth,
|
||||
PortNotAvailable,
|
||||
)
|
||||
|
||||
|
||||
class GuiCommon:
|
||||
|
|
@ -245,7 +260,7 @@ class GuiCommon:
|
|||
QLabel {
|
||||
text-align: center;
|
||||
color: #333333;
|
||||
font-size: 28px;
|
||||
font-size: 25px;
|
||||
}
|
||||
""",
|
||||
# Share mode and child widget styles
|
||||
|
|
@ -377,3 +392,37 @@ class GuiCommon:
|
|||
Returns the absolute path of a resource
|
||||
"""
|
||||
return resource_filename("onionshare", os.path.join("resources", filename))
|
||||
|
||||
@staticmethod
|
||||
def get_translated_tor_error(e):
|
||||
"""
|
||||
Takes an exception defined in onion.py and returns a translated error message
|
||||
"""
|
||||
if type(e) is TorErrorInvalidSetting:
|
||||
return strings._("settings_error_unknown")
|
||||
elif type(e) is TorErrorAutomatic:
|
||||
return strings._("settings_error_automatic")
|
||||
elif type(e) is TorErrorSocketPort:
|
||||
return strings._("settings_error_socket_port").format(e.args[0], e.args[1])
|
||||
elif type(e) is TorErrorSocketFile:
|
||||
return strings._("settings_error_socket_file").format(e.args[0])
|
||||
elif type(e) is TorErrorMissingPassword:
|
||||
return strings._("settings_error_missing_password")
|
||||
elif type(e) is TorErrorUnreadableCookieFile:
|
||||
return strings._("settings_error_unreadable_cookie_file")
|
||||
elif type(e) is TorErrorAuthError:
|
||||
return strings._("settings_error_auth").format(e.args[0], e.args[1])
|
||||
elif type(e) is TorErrorProtocolError:
|
||||
return strings._("error_tor_protocol_error").format(e.args[0])
|
||||
elif type(e) is BundledTorTimeout:
|
||||
return strings._("settings_error_bundled_tor_timeout")
|
||||
elif type(e) is BundledTorBroken:
|
||||
return strings._("settings_error_bundled_tor_broken").format(e.args[0])
|
||||
elif type(e) is TorTooOldEphemeral:
|
||||
return strings._("error_ephemeral_not_supported")
|
||||
elif type(e) is TorTooOldStealth:
|
||||
return strings._("error_stealth_not_supported")
|
||||
elif type(e) is PortNotAvailable:
|
||||
return strings._("error_port_not_available")
|
||||
|
||||
return None
|
||||
|
|
|
|||
|
|
@ -189,5 +189,6 @@
|
|||
"settings_error_bundled_tor_timeout": "Taking too long to connect to Tor. Maybe you aren't connected to the Internet, or have an inaccurate system clock?",
|
||||
"settings_error_bundled_tor_broken": "OnionShare could not connect to Tor:\n{}",
|
||||
"gui_rendezvous_cleanup": "Waiting for Tor circuits to close to be sure your files have successfully transferred.\n\nThis might take a few minutes.",
|
||||
"gui_rendezvous_cleanup_quit_early": "Quit Early"
|
||||
"gui_rendezvous_cleanup_quit_early": "Quit Early",
|
||||
"error_port_not_available": "OnionShare port not available"
|
||||
}
|
||||
|
|
@ -27,11 +27,31 @@ import os
|
|||
|
||||
from onionshare_cli import common
|
||||
from onionshare_cli.settings import Settings
|
||||
from onionshare_cli.onion import *
|
||||
from onionshare_cli.onion import (
|
||||
Onion,
|
||||
TorErrorInvalidSetting,
|
||||
TorErrorAutomatic,
|
||||
TorErrorSocketPort,
|
||||
TorErrorSocketFile,
|
||||
TorErrorMissingPassword,
|
||||
TorErrorUnreadableCookieFile,
|
||||
TorErrorAuthError,
|
||||
TorErrorProtocolError,
|
||||
BundledTorTimeout,
|
||||
BundledTorBroken,
|
||||
TorTooOldEphemeral,
|
||||
TorTooOldStealth,
|
||||
PortNotAvailable,
|
||||
)
|
||||
|
||||
from . import strings
|
||||
from .widgets import Alert
|
||||
from .update_checker import *
|
||||
from .update_checker import (
|
||||
UpdateCheckerCheckError,
|
||||
UpdateCheckerInvalidLatestVersion,
|
||||
UpdateChecker,
|
||||
UpdateThread,
|
||||
)
|
||||
from .tor_connection_dialog import TorConnectionDialog
|
||||
from .gui_common import GuiCommon
|
||||
|
||||
|
|
@ -142,7 +162,7 @@ class SettingsDialog(QtWidgets.QDialog):
|
|||
self.tor_geo_ip_file_path,
|
||||
self.tor_geo_ipv6_file_path,
|
||||
self.obfs4proxy_file_path,
|
||||
) = self.common.get_tor_paths()
|
||||
) = self.common.gui.get_tor_paths()
|
||||
if not self.obfs4proxy_file_path or not os.path.isfile(
|
||||
self.obfs4proxy_file_path
|
||||
):
|
||||
|
|
@ -165,7 +185,7 @@ class SettingsDialog(QtWidgets.QDialog):
|
|||
self.tor_geo_ip_file_path,
|
||||
self.tor_geo_ipv6_file_path,
|
||||
self.obfs4proxy_file_path,
|
||||
) = self.common.get_tor_paths()
|
||||
) = self.common.gui.get_tor_paths()
|
||||
if not self.obfs4proxy_file_path or not os.path.isfile(
|
||||
self.obfs4proxy_file_path
|
||||
):
|
||||
|
|
@ -698,10 +718,18 @@ class SettingsDialog(QtWidgets.QDialog):
|
|||
TorErrorUnreadableCookieFile,
|
||||
TorErrorAuthError,
|
||||
TorErrorProtocolError,
|
||||
BundledTorNotSupported,
|
||||
BundledTorTimeout,
|
||||
BundledTorBroken,
|
||||
TorTooOldEphemeral,
|
||||
TorTooOldStealth,
|
||||
PortNotAvailable,
|
||||
) as e:
|
||||
Alert(self.common, e.args[0], QtWidgets.QMessageBox.Warning)
|
||||
message = self.common.gui.get_translated_tor_error(e)
|
||||
Alert(
|
||||
self.common,
|
||||
message,
|
||||
QtWidgets.QMessageBox.Warning,
|
||||
)
|
||||
if settings.get("connection_type") == "bundled":
|
||||
self.tor_status.hide()
|
||||
self._enable_buttons()
|
||||
|
|
|
|||
|
|
@ -183,8 +183,7 @@ class Mode(QtWidgets.QWidget):
|
|||
|
||||
self.status_bar.clearMessage()
|
||||
if not self.app.autostop_timer_thread.is_alive():
|
||||
if self.autostop_timer_finished_should_stop_server():
|
||||
self.server_status.stop_server()
|
||||
self.autostop_timer_finished_should_stop_server()
|
||||
|
||||
def timer_callback_custom(self):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -53,16 +53,22 @@ class NewTabButton(QtWidgets.QPushButton):
|
|||
)
|
||||
self.image_label.setAlignment(QtCore.Qt.AlignCenter)
|
||||
self.image_label.setStyleSheet(self.common.gui.css["new_tab_button_image"])
|
||||
self.image_label.setGeometry(0, 0, self.width(), 200)
|
||||
self.image_label.setGeometry(0, 0, self.width(), 190)
|
||||
self.image_label.show()
|
||||
|
||||
# Title
|
||||
self.title_label = QtWidgets.QLabel(title, parent=self)
|
||||
self.title_label.setWordWrap(True)
|
||||
self.title_label.setAlignment(QtCore.Qt.AlignCenter)
|
||||
self.title_label.setStyleSheet(self.common.gui.css["new_tab_title_text"])
|
||||
self.title_label.setGeometry(
|
||||
(self.width() - 250) / 2, self.height() - 100, 250, 30
|
||||
)
|
||||
if self.title_label.sizeHint().width() >= 250:
|
||||
self.title_label.setGeometry(
|
||||
(self.width() - 250) / 2, self.height() - 120, 250, 60
|
||||
)
|
||||
else:
|
||||
self.title_label.setGeometry(
|
||||
(self.width() - 250) / 2, self.height() - 100, 250, 30
|
||||
)
|
||||
self.title_label.show()
|
||||
|
||||
# Text
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import os
|
|||
from PySide2 import QtCore
|
||||
|
||||
from onionshare_cli.onion import (
|
||||
TorTooOld,
|
||||
TorErrorInvalidSetting,
|
||||
TorErrorAutomatic,
|
||||
TorErrorSocketPort,
|
||||
|
|
@ -34,6 +33,10 @@ from onionshare_cli.onion import (
|
|||
TorErrorAuthError,
|
||||
TorErrorProtocolError,
|
||||
BundledTorTimeout,
|
||||
BundledTorBroken,
|
||||
TorTooOldEphemeral,
|
||||
TorTooOldStealth,
|
||||
PortNotAvailable,
|
||||
)
|
||||
|
||||
from . import strings
|
||||
|
|
@ -93,7 +96,6 @@ class OnionThread(QtCore.QThread):
|
|||
self.success.emit()
|
||||
|
||||
except (
|
||||
TorTooOld,
|
||||
TorErrorInvalidSetting,
|
||||
TorErrorAutomatic,
|
||||
TorErrorSocketPort,
|
||||
|
|
@ -103,9 +105,13 @@ class OnionThread(QtCore.QThread):
|
|||
TorErrorAuthError,
|
||||
TorErrorProtocolError,
|
||||
BundledTorTimeout,
|
||||
OSError,
|
||||
BundledTorBroken,
|
||||
TorTooOldEphemeral,
|
||||
TorTooOldStealth,
|
||||
PortNotAvailable,
|
||||
) as e:
|
||||
self.error.emit(e.args[0])
|
||||
message = self.mode.common.gui.get_translated_tor_error(e)
|
||||
self.error.emit(message)
|
||||
return
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -18,9 +18,25 @@ You should have received a copy of the GNU General Public License
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
import time
|
||||
from PySide2 import QtCore, QtWidgets, QtGui
|
||||
|
||||
from onionshare_cli.onion import *
|
||||
from onionshare_cli.onion import (
|
||||
BundledTorCanceled,
|
||||
TorErrorInvalidSetting,
|
||||
TorErrorAutomatic,
|
||||
TorErrorSocketPort,
|
||||
TorErrorSocketFile,
|
||||
TorErrorMissingPassword,
|
||||
TorErrorUnreadableCookieFile,
|
||||
TorErrorAuthError,
|
||||
TorErrorProtocolError,
|
||||
BundledTorTimeout,
|
||||
BundledTorBroken,
|
||||
TorTooOldEphemeral,
|
||||
TorTooOldStealth,
|
||||
PortNotAvailable,
|
||||
)
|
||||
|
||||
from . import strings
|
||||
from .gui_common import GuiCommon
|
||||
|
|
@ -156,9 +172,26 @@ class TorConnectionThread(QtCore.QThread):
|
|||
)
|
||||
self.canceled_connecting_to_tor.emit()
|
||||
|
||||
except Exception as e:
|
||||
self.common.log("TorConnectionThread", "run", f"caught exception: {e}")
|
||||
self.error_connecting_to_tor.emit(str(e))
|
||||
except (
|
||||
TorErrorInvalidSetting,
|
||||
TorErrorAutomatic,
|
||||
TorErrorSocketPort,
|
||||
TorErrorSocketFile,
|
||||
TorErrorMissingPassword,
|
||||
TorErrorUnreadableCookieFile,
|
||||
TorErrorAuthError,
|
||||
TorErrorProtocolError,
|
||||
BundledTorTimeout,
|
||||
BundledTorBroken,
|
||||
TorTooOldEphemeral,
|
||||
TorTooOldStealth,
|
||||
PortNotAvailable,
|
||||
) as e:
|
||||
message = self.common.gui.get_translated_tor_error(e)
|
||||
self.common.log(
|
||||
"TorConnectionThread", "run", f"caught exception: {message}"
|
||||
)
|
||||
self.error_connecting_to_tor.emit(message)
|
||||
|
||||
def _tor_status_update(self, progress, summary):
|
||||
self.tor_status_update.emit(progress, summary)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue