From 2540f5321c38aee23bc84243f3d7268543125c3d Mon Sep 17 00:00:00 2001 From: Iam54r1n4 Date: Fri, 7 Feb 2025 05:17:55 +0000 Subject: [PATCH] Implement fucntions to get/set hysteria config file --- core/cli_api.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/core/cli_api.py b/core/cli_api.py index af44026..095daae 100644 --- a/core/cli_api.py +++ b/core/cli_api.py @@ -9,6 +9,7 @@ import traffic DEBUG = False SCRIPT_DIR = '/etc/hysteria/core/scripts' +CONFIG_FILE = '/etc/hysteria/config.json' class Command(Enum): @@ -169,6 +170,18 @@ def enable_hysteria2_masquerade(domain: str): def disable_hysteria2_masquerade(): '''Disables masquerade for Hysteria2.''' run_cmd(['bash', Command.MASQUERADE_SCRIPT.value, '2']) + + +def get_hysteria2_config_file() -> dict[str, Any]: + with open(CONFIG_FILE, 'r') as f: + return json.loads(f.read()) + + +def set_hysteria2_config_file(data: dict[str, Any]): + content = json.dumps(data, indent=4) + + with open(CONFIG_FILE, 'w') as f: + f.write(content) # endregion # region User