feat(core): branch vless/hysteria2 immediately in ProfileController.enable()

This commit is contained in:
Zenaku 2026-07-09 09:44:08 -05:00
parent 1a60511492
commit cae72efee3

View file

@ -77,6 +77,31 @@ class ProfileController:
if profile.is_system_profile(): 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: try:
ConnectionController.establish_connection(profile, ignore=ignore, connection_observer=connection_observer) ConnectionController.establish_connection(profile, ignore=ignore, connection_observer=connection_observer)
except ConnectionError: except ConnectionError:
@ -85,6 +110,12 @@ class ProfileController:
if profile_observer is not None: if profile_observer is not None:
profile_observer.notify('enabled', profile) 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 @staticmethod
def disable(profile: Union[SessionProfile, SystemProfile], explicitly: bool = True, ignore: tuple[type[Exception]] = (), profile_observer: ProfileObserver = None, connection_observer: ConnectionObserver = None): def disable(profile: Union[SessionProfile, SystemProfile], explicitly: bool = True, ignore: tuple[type[Exception]] = (), profile_observer: ProfileObserver = None, connection_observer: ConnectionObserver = None):