From 728a6bd51c23ebd54c49c7be3b7ce57120ffb226 Mon Sep 17 00:00:00 2001 From: SimplifiedPrivacy Date: Tue, 3 Nov 2026 16:55:25 -0500 Subject: [PATCH] Improved error handling for SudoScript --- .../connection_enable.py | 7 ++++++- .../systemwide/encrypted_proxy/launch_proxy.py | 17 +++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/core/services/networking/general_connection_tools/connection_enable.py b/core/services/networking/general_connection_tools/connection_enable.py index 6aa9c99..135c7a1 100644 --- a/core/services/networking/general_connection_tools/connection_enable.py +++ b/core/services/networking/general_connection_tools/connection_enable.py @@ -19,6 +19,7 @@ from core.models.Result import Result, ResultError # wireguard_types = [SystemConnectionTypes.WIREGUARD, SessionConnectionTypes.WIREGUARD] from core.errors.logger import logger +from core.errors.exceptions import SudoScript # from core.errors.exceptions import * from core.errors.exceptions import FirewallError from typing import Union, Optional, Callable @@ -50,7 +51,11 @@ def establish_connection( # ========================================= if profile.connection.code in ("hysteria2", "vless"): logger.info("Pulling encrypted proxies off the main flow..") - return launch_encrypted_proxy(profile, connection_observer) + try: + return launch_encrypted_proxy(profile, connection_observer) + except SudoScript as e: + logger.error(str(e)) + return Result(valid=False, error_type=ResultError.SETUP_SINGBOX, message="The pre-req Singbox sudo wrappers are not setup, would you like to set it up?") # ========================================= # SOCKS5 & WIREGUARD diff --git a/core/services/networking/systemwide/encrypted_proxy/launch_proxy.py b/core/services/networking/systemwide/encrypted_proxy/launch_proxy.py index 86cb56b..e1dbbe5 100644 --- a/core/services/networking/systemwide/encrypted_proxy/launch_proxy.py +++ b/core/services/networking/systemwide/encrypted_proxy/launch_proxy.py @@ -1,3 +1,4 @@ +from core.errors.exceptions import SudoScript from core.services.helpers.install_dependencies import SUDO_SINGBOX_LOCATION from core.services.helpers.setup_sudo_scripts import is_singbox_wrapper_ready from core.services.networking.systemwide.encrypted_proxy.configure_singbox import configure_singbox @@ -74,12 +75,16 @@ def launch_encrypted_proxy( logger.info(f"Attempt {tries}: establishing connection to server {server_ip}") - connection_result = start_singbox( - profile_id=profile.id, - server_ip=server_ip, - protocol_choice=profile.connection.code, - connection_observer=connection_observer - ) + try: + connection_result = start_singbox( + profile_id=profile.id, + server_ip=server_ip, + protocol_choice=profile.connection.code, + connection_observer=connection_observer + ) + except SudoScript as e: + logger.error(str(e)) + return Result(valid=False, error_type=ResultError.SETUP_SINGBOX, message="The pre-req Singbox sudo wrappers are not setup, would you like to set it up?") if connection_result.valid: return connection_result