diff --git a/core/infrastructure/global_state.py b/core/infrastructure/global_state.py index 85701ac..e474990 100644 --- a/core/infrastructure/global_state.py +++ b/core/infrastructure/global_state.py @@ -70,7 +70,7 @@ class ProfileStateRepository: if self.global_state.session_profiles[each_profile_id][ProcessType.ACTIVE] is True: active_list.append(each_profile_id) except KeyError: - print(f"active doesn't exist yet for profile id {each_profile_id}") + print(f"active doesn't exist yet for profile id {each_profile_id}. Setting to False:") continue return active_list diff --git a/core/models/ConnectionRecovery.py b/core/models/ConnectionRecovery.py index a80ce74..81e1479 100644 --- a/core/models/ConnectionRecovery.py +++ b/core/models/ConnectionRecovery.py @@ -26,19 +26,12 @@ class ConnectionRecovery(StatePersistenceMixin): # PORT prompted_for_port: bool = False - # port_changed: bool = False - # port_changed_to: int|None = None - # port_change_worked: bool = False # MTU mtu_initially_tested: bool = False - # mtu_changed: bool = False - # asked_to_change_mtu: bool = False # WG KEY asked_to_change_wg_key: bool = False - # wg_key_confirmed: bool = False - # wg_key_changed: bool = False # Overall state attempts: int = 0 diff --git a/core/services/networking/general_connection_tools/location_evaluation.py b/core/services/networking/general_connection_tools/location_evaluation.py index 6d2c824..1aeb34f 100644 --- a/core/services/networking/general_connection_tools/location_evaluation.py +++ b/core/services/networking/general_connection_tools/location_evaluation.py @@ -87,3 +87,20 @@ def check_if_location_is_up(profile: Profile, connection_observer: ConnectionObs else: error_msg = f"The {location_name} node is currently down." return Result(valid=False, backoff_strategy=BackoffStrategy.NO_RETRY, error_type=ResultError.NODE_ERROR, message=error_msg) + + + + +def evaluate_location_and_internet(profile: Profile, connection_observer: ConnectionObserver) -> Result: + """Provides a Public API & Notifications, to check if a location is up and return the backoff strategy.""" + + notification = "Checking If Location is Up.." + Notifications.emit(EventType.STATUS_UPDATE, notification) + logger.info(notification) + + location_result = check_if_location_is_up(profile=profile, connection_observer=connection_observer) + + if location_result.backoff_strategy == BackoffStrategy.RETRY_IMMEDIATE: + Notifications.emit(EventType.STATUS_UPDATE, "Retrying after Location Check") + + return location_result diff --git a/core/services/networking/session/session_networking.py b/core/services/networking/session/session_networking.py index 7550657..605c1fa 100644 --- a/core/services/networking/session/session_networking.py +++ b/core/services/networking/session/session_networking.py @@ -44,7 +44,6 @@ def start_session_networking( ) -> Result: protocol = ProtocolChoice(profile.connection.code) - print(f"protocol is {protocol}") session_directory = tempfile.mkdtemp(prefix='hv-') session_state = SessionStateController.get_or_new(profile.id) @@ -53,7 +52,7 @@ def start_session_networking( proxy_port_number = None port_number = ConnectionService.get_random_available_port_number() - print(f"Openning on port {port_number}") + print(f"on port {port_number}") #-------------------------------- # TOR diff --git a/core/services/networking/systemwide/systemwide_wireguard.py b/core/services/networking/systemwide/systemwide_wireguard.py index deb7137..0b8e4a3 100644 --- a/core/services/networking/systemwide/systemwide_wireguard.py +++ b/core/services/networking/systemwide/systemwide_wireguard.py @@ -5,7 +5,7 @@ from core.services.networking.mtu.mtu_orchestrator import passed_initial_mtu_scr # from core.services.keys_and_verifications.wireguard_keys import get_mtu from core.models.BaseProfile import BaseProfile as Profile -from core.services.networking.general_connection_tools.location_evaluation import check_if_location_is_up +from core.services.networking.general_connection_tools.location_evaluation import evaluate_location_and_internet from core.services.networking.api_requests.ApiResponseModel import BackoffStrategy from core.models.enum_models import ProtocolChoice, SINGBOX_PROTOCOLS from core.controllers.profile_state.get_profile_data import get_protocol_enum @@ -235,18 +235,18 @@ def change_port_then_reconnect( # return message -def evaluate_location_and_internet(profile: SystemProfile, connection_observer: ConnectionObserver) -> Result: - """Checks if location is up and returns the backoff strategy.""" - notification = "Checking If Location is Up.." - Notifications.emit(EventType.STATUS_UPDATE, notification) - logger.info(notification) +# def evaluate_location_and_internet(profile: SystemProfile, connection_observer: ConnectionObserver) -> Result: +# """Checks if location is up and returns the backoff strategy.""" +# notification = "Checking If Location is Up.." +# Notifications.emit(EventType.STATUS_UPDATE, notification) +# logger.info(notification) - location_result = check_if_location_is_up(profile=profile, connection_observer=connection_observer) +# location_result = check_if_location_is_up(profile=profile, connection_observer=connection_observer) - if location_result.backoff_strategy == BackoffStrategy.RETRY_IMMEDIATE: - Notifications.emit(EventType.STATUS_UPDATE, "Retrying after Location Check") +# if location_result.backoff_strategy == BackoffStrategy.RETRY_IMMEDIATE: +# Notifications.emit(EventType.STATUS_UPDATE, "Retrying after Location Check") - return location_result +# return location_result def _finish_success(final_result: Result, profile_id: int) -> Result: