diff --git a/core/models/Result.py b/core/models/Result.py index a83b9a4..2f23c22 100644 --- a/core/models/Result.py +++ b/core/models/Result.py @@ -16,6 +16,7 @@ class ResultError(Enum): MISSING_DEPENDENCY = "missing_dependency" MISSING_DATA = "missing_data" MISSING_SOFTWARE = "missing_software" + SETUP_SINGBOX = "setup_singbox" FILE_SYSTEM = "filesystem" CONNECTION = "connection" DATABASE = "database" diff --git a/core/services/networking/systemwide/encrypted_proxy/launch_proxy.py b/core/services/networking/systemwide/encrypted_proxy/launch_proxy.py index 736d51f..86cb56b 100644 --- a/core/services/networking/systemwide/encrypted_proxy/launch_proxy.py +++ b/core/services/networking/systemwide/encrypted_proxy/launch_proxy.py @@ -1,6 +1,9 @@ +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 from core.services.networking.systemwide.encrypted_proxy.singbox_runner import start_singbox from core.utils.basic_operations.write_or_read_from_json import get_value_from_json_file +from core.utils.basic_operations.does_file_exist import does_file_exist from core.observers.ConnectionObserver import ConnectionObserver from core.models.BaseProfile import BaseProfile as Profile from core.models.Result import Result, ResultError @@ -40,7 +43,19 @@ def launch_encrypted_proxy( connection_observer: Optional[ConnectionObserver] ) -> Result: """Launch & Setup an Encrypted proxy with a single-refresh retry policy.""" - + + logger.info("Preparing to launch encrypted proxy..") + + # Pre-reqs + if not is_singbox_wrapper_ready(): + logger.info("Missing singbox wrapper") + 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 not does_file_exist(SUDO_SINGBOX_LOCATION): + logger.info("Missing singbox binary") + return Result(valid=False, error_type=ResultError.SETUP_SINGBOX, message="The pre-req software Singbox is not setup, would you like to set it up?") + + server_ip = get_existing_server_ip(profile) has_refreshed = False # Tracks if we have already fetched a new config this session