From cae72efee3a71e9af487dc1ee8de84f88c3425eb Mon Sep 17 00:00:00 2001 From: zenaku Date: Thu, 9 Jul 2026 09:44:08 -0500 Subject: [PATCH] feat(core): branch vless/hysteria2 immediately in ProfileController.enable() --- core/controllers/ProfileController.py | 31 +++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/core/controllers/ProfileController.py b/core/controllers/ProfileController.py index cade914..7d08a5c 100644 --- a/core/controllers/ProfileController.py +++ b/core/controllers/ProfileController.py @@ -77,6 +77,31 @@ class ProfileController: if profile.is_system_profile(): + if profile.connection.needs_operator_proxy(): + from core.controllers.ConnectionController import ConnectionController + if not profile.has_operator_proxy_session(): + ProfileController.activate_subscription(profile, connection_observer=connection_observer) + from core.services.WebServiceApiService import WebServiceApiService + operator_proxy_session = ConnectionController.with_preferred_connection( + profile.subscription.billing_code, + profile.subscription.operator_id, + profile.connection.get_protocol(), + task=WebServiceApiService.post_operator_proxy, + connection_observer=connection_observer + ) + if operator_proxy_session is None: + raise ProfileActivationError('Could not obtain operator proxy session.') + profile.attach_operator_proxy_session(operator_proxy_session) + + ok = ConnectionController.establish_encrypted_proxy_connection( + profile, socks5_port=1080, observer=connection_observer + ) + if not ok: + raise ProfileActivationError('The profile could not be enabled.') + if profile_observer is not None: + profile_observer.notify('enabled', profile) + return + try: ConnectionController.establish_connection(profile, ignore=ignore, connection_observer=connection_observer) except ConnectionError: @@ -85,6 +110,12 @@ class ProfileController: if profile_observer is not None: profile_observer.notify('enabled', profile) + @staticmethod + def run_monitor(profile: Union[SessionProfile, SystemProfile], monitor) -> None: + + if profile.is_system_profile() and profile.connection.needs_operator_proxy(): + monitor.run_blocking() + @staticmethod def disable(profile: Union[SessionProfile, SystemProfile], explicitly: bool = True, ignore: tuple[type[Exception]] = (), profile_observer: ProfileObserver = None, connection_observer: ConnectionObserver = None):