Transition to the same tests for wireguard systemwide as for session
This commit is contained in:
parent
9ade83b454
commit
62d2d15858
5 changed files with 29 additions and 20 deletions
|
|
@ -70,7 +70,7 @@ class ProfileStateRepository:
|
||||||
if self.global_state.session_profiles[each_profile_id][ProcessType.ACTIVE] is True:
|
if self.global_state.session_profiles[each_profile_id][ProcessType.ACTIVE] is True:
|
||||||
active_list.append(each_profile_id)
|
active_list.append(each_profile_id)
|
||||||
except KeyError:
|
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
|
continue
|
||||||
|
|
||||||
return active_list
|
return active_list
|
||||||
|
|
|
||||||
|
|
@ -26,19 +26,12 @@ class ConnectionRecovery(StatePersistenceMixin):
|
||||||
|
|
||||||
# PORT
|
# PORT
|
||||||
prompted_for_port: bool = False
|
prompted_for_port: bool = False
|
||||||
# port_changed: bool = False
|
|
||||||
# port_changed_to: int|None = None
|
|
||||||
# port_change_worked: bool = False
|
|
||||||
|
|
||||||
# MTU
|
# MTU
|
||||||
mtu_initially_tested: bool = False
|
mtu_initially_tested: bool = False
|
||||||
# mtu_changed: bool = False
|
|
||||||
# asked_to_change_mtu: bool = False
|
|
||||||
|
|
||||||
# WG KEY
|
# WG KEY
|
||||||
asked_to_change_wg_key: bool = False
|
asked_to_change_wg_key: bool = False
|
||||||
# wg_key_confirmed: bool = False
|
|
||||||
# wg_key_changed: bool = False
|
|
||||||
|
|
||||||
# Overall state
|
# Overall state
|
||||||
attempts: int = 0
|
attempts: int = 0
|
||||||
|
|
|
||||||
|
|
@ -87,3 +87,20 @@ def check_if_location_is_up(profile: Profile, connection_observer: ConnectionObs
|
||||||
else:
|
else:
|
||||||
error_msg = f"The {location_name} node is currently down."
|
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)
|
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
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,6 @@ def start_session_networking(
|
||||||
) -> Result:
|
) -> Result:
|
||||||
|
|
||||||
protocol = ProtocolChoice(profile.connection.code)
|
protocol = ProtocolChoice(profile.connection.code)
|
||||||
print(f"protocol is {protocol}")
|
|
||||||
|
|
||||||
session_directory = tempfile.mkdtemp(prefix='hv-')
|
session_directory = tempfile.mkdtemp(prefix='hv-')
|
||||||
session_state = SessionStateController.get_or_new(profile.id)
|
session_state = SessionStateController.get_or_new(profile.id)
|
||||||
|
|
@ -53,7 +52,7 @@ def start_session_networking(
|
||||||
proxy_port_number = None
|
proxy_port_number = None
|
||||||
|
|
||||||
port_number = ConnectionService.get_random_available_port_number()
|
port_number = ConnectionService.get_random_available_port_number()
|
||||||
print(f"Openning on port {port_number}")
|
print(f"on port {port_number}")
|
||||||
|
|
||||||
#--------------------------------
|
#--------------------------------
|
||||||
# TOR
|
# TOR
|
||||||
|
|
|
||||||
|
|
@ -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.services.keys_and_verifications.wireguard_keys import get_mtu
|
||||||
from core.models.BaseProfile import BaseProfile as Profile
|
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.services.networking.api_requests.ApiResponseModel import BackoffStrategy
|
||||||
from core.models.enum_models import ProtocolChoice, SINGBOX_PROTOCOLS
|
from core.models.enum_models import ProtocolChoice, SINGBOX_PROTOCOLS
|
||||||
from core.controllers.profile_state.get_profile_data import get_protocol_enum
|
from core.controllers.profile_state.get_profile_data import get_protocol_enum
|
||||||
|
|
@ -235,18 +235,18 @@ def change_port_then_reconnect(
|
||||||
# return message
|
# return message
|
||||||
|
|
||||||
|
|
||||||
def evaluate_location_and_internet(profile: SystemProfile, connection_observer: ConnectionObserver) -> Result:
|
# def evaluate_location_and_internet(profile: SystemProfile, connection_observer: ConnectionObserver) -> Result:
|
||||||
"""Checks if location is up and returns the backoff strategy."""
|
# """Checks if location is up and returns the backoff strategy."""
|
||||||
notification = "Checking If Location is Up.."
|
# notification = "Checking If Location is Up.."
|
||||||
Notifications.emit(EventType.STATUS_UPDATE, notification)
|
# Notifications.emit(EventType.STATUS_UPDATE, notification)
|
||||||
logger.info(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:
|
# if location_result.backoff_strategy == BackoffStrategy.RETRY_IMMEDIATE:
|
||||||
Notifications.emit(EventType.STATUS_UPDATE, "Retrying after Location Check")
|
# 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:
|
def _finish_success(final_result: Result, profile_id: int) -> Result:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue