diff --git a/core/services/networking/general_connection_tools/connection_enable.py b/core/services/networking/general_connection_tools/connection_enable.py index 0fc7295..a350f30 100644 --- a/core/services/networking/general_connection_tools/connection_enable.py +++ b/core/services/networking/general_connection_tools/connection_enable.py @@ -3,6 +3,7 @@ from core.services.networking.systemwide.systemwide_wireguard import establish_s from core.services.keys_and_verifications.wireguard_keys import register_wireguard_session from core.models.session.SessionConnection import SessionConnectionTypes from core.models.system.SystemConnection import SystemConnectionTypes +from core.services.subscriptions.subscriptions import activate_subscription from core.errors.logger import logger from core.errors.exceptions import * @@ -13,7 +14,6 @@ from core.Errors import ConnectionTerminationError, InvalidSubscriptionError from core.services.WebServiceApiService import WebServiceApiService from core.controllers.ConnectionController import ConnectionController from core.models.BaseProfile import ProfileType -from core.services.subscriptions.subscriptions import activate_subscription from core.observers.ConnectionObserver import ConnectionObserver from core.controllers.SystemStateController import SystemStateController @@ -27,7 +27,7 @@ def establish_connection( """Establish a connection for the given profile.""" logger.info(f"[CONNECTION] Checking subscription..") - _ensure_subscription_ready(profile, connection_observer) + activate_subscription(profile, connection_observer) logger.info(f"[CONNECTION] Checking proxy configuration..") _ensure_proxy_configured(profile, connection_observer) @@ -43,14 +43,6 @@ def establish_connection( return _establish_with_renegotiation(profile, establish_fn, ignore, connection_observer) -def _ensure_subscription_ready( - profile: Union[SessionProfile, SystemProfile], - connection_observer: Optional[ConnectionObserver], -): - """Activate subscription (idempotent).""" - activate_subscription(profile, connection_observer=connection_observer) - - def _ensure_proxy_configured( profile: Union[SessionProfile, SystemProfile], connection_observer: Optional[ConnectionObserver], @@ -61,7 +53,7 @@ def _ensure_proxy_configured( if not profile.has_proxy_configuration(): logger.info(f"[CONNECTION] You need a new proxy configuration") - _ensure_subscription_ready(profile, connection_observer) + activate_subscription(profile, connection_observer) logger.info(f"[CONNECTION] Getting a proxy config from web service..") proxy_config = ConnectionController.with_preferred_connection( @@ -95,7 +87,7 @@ def _ensure_wireguard_configured( except ConnectionTerminationError as e: logger.error(f"[CONNECTION] Previous Systemwide Wireguard connection could not be disabled. {e}") - _ensure_subscription_ready(profile, connection_observer) + activate_subscription(profile, connection_observer) logger.info(f"[CONNECTION] Checking if the profile already has a wg config..") if not profile.has_wireguard_configuration(): logger.info(f"[CONNECTION] Profile does NOT have WG keys and it needs it. Registering a NEW wg session..")