From 9554ab4ffae24ec7e1125b3f54c8f936be939e51 Mon Sep 17 00:00:00 2001 From: codeking Date: Sat, 15 Mar 2025 21:49:57 +0100 Subject: [PATCH] Add support for API base URL and ping URL overrides --- core/Constants.py | 3 ++- core/controllers/ConnectionController.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/core/Constants.py b/core/Constants.py index ad5a85b..d6f8134 100644 --- a/core/Constants.py +++ b/core/Constants.py @@ -6,7 +6,8 @@ import os @dataclass(frozen=True) class Constants: - SP_API_BASE_URL: Final[str] = 'https://api.simplifiedprivacy.is/api/v1' + SP_API_BASE_URL: Final[str] = os.environ.get('SP_API_BASE_URL') or 'https://api.simplifiedprivacy.is/api/v1' + PING_URL: Final[str] = os.environ.get('PING_URL') or 'https://api.simplifiedprivacy.is/api/v1/health' HV_CLIENT_PATH: Final[str] = os.environ.get('HV_CLIENT_PATH') HV_CLIENT_VERSION_NUMBER: Final[str] = os.environ.get('HV_CLIENT_VERSION_NUMBER') diff --git a/core/controllers/ConnectionController.py b/core/controllers/ConnectionController.py index c9082c7..9d6274c 100644 --- a/core/controllers/ConnectionController.py +++ b/core/controllers/ConnectionController.py @@ -397,7 +397,7 @@ class ConnectionController: proxies = ConnectionController.get_proxies(port_number) try: - requests.get(f'{Constants.SP_API_BASE_URL}/health', timeout=timeout, proxies=proxies) + requests.get(Constants.PING_URL, timeout=timeout, proxies=proxies) except requests.exceptions.RequestException: raise ConnectionError('The connection could not be established.')