Transition to the same tests for wireguard systemwide as for session

This commit is contained in:
SimplifiedPrivacy 2026-11-02 08:32:05 -05:00
parent 9ade83b454
commit 62d2d15858
5 changed files with 29 additions and 20 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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: