diff --git a/core/cli_api.py b/core/cli_api.py index 0ac9348..ad7a8e2 100644 --- a/core/cli_api.py +++ b/core/cli_api.py @@ -13,6 +13,8 @@ SCRIPT_DIR = '/etc/hysteria/core/scripts' CONFIG_FILE = '/etc/hysteria/config.json' CONFIG_ENV_FILE = '/etc/hysteria/.configs.env' WEBPANEL_ENV_FILE = '/etc/hysteria/core/scripts/webpanel/.env' +NORMALSUB_ENV_FILE = '/etc/hysteria/core/scripts/normalsub/.env' + class Command(Enum): '''Contains path to command's script''' @@ -519,6 +521,18 @@ def edit_normalsub_subpath(new_subpath: str): run_cmd(['bash', Command.INSTALL_NORMALSUB.value, 'edit_subpath', new_subpath]) +def get_normalsub_subpath() -> str | None: + '''Retrieves the current SUBPATH for the NormalSub service from its .env file.''' + try: + if not os.path.exists(NORMALSUB_ENV_FILE): + return None + + env_vars = dotenv_values(NORMALSUB_ENV_FILE) + return env_vars.get('SUBPATH') + except Exception as e: + print(f"Error reading NormalSub .env file: {e}") + return None + def stop_normalsub(): '''Stops NormalSub.''' run_cmd(['bash', Command.INSTALL_NORMALSUB.value, 'stop'])