From 093e9aacd8a4fdc7a538aaea4b90be9be0da49d8 Mon Sep 17 00:00:00 2001 From: SimplifiedPrivacy Date: Fri, 3 Jul 2026 17:24:49 -0400 Subject: [PATCH] Comment clarity on pre-existing Connections, and support for vless and hysteria2 in the connection model --- core/.metadata.md | 1 - core/controllers/ConnectionController.py | 5 +++++ core/controllers/SubscriptionPlanController.py | 13 +++++++++++++ core/models/BaseConnection.py | 2 ++ core/models/session/SessionConnection.py | 2 ++ core/models/system/SystemConnection.py | 3 ++- pyproject.toml | 2 +- 7 files changed, 25 insertions(+), 3 deletions(-) delete mode 100644 core/.metadata.md diff --git a/core/.metadata.md b/core/.metadata.md deleted file mode 100644 index 86fc4bb..0000000 --- a/core/.metadata.md +++ /dev/null @@ -1 +0,0 @@ -this is june 13 version diff --git a/core/controllers/ConnectionController.py b/core/controllers/ConnectionController.py index 28a4202..82be36c 100644 --- a/core/controllers/ConnectionController.py +++ b/core/controllers/ConnectionController.py @@ -56,6 +56,8 @@ class ConnectionController: connection = profile.connection + # needs_proxy_configuration comes from the child connection models + # for the system it returns false blindly. for the session is checks if the connection type is masked. if connection.needs_proxy_configuration() and not profile.has_proxy_configuration(): if profile.has_subscription(): @@ -73,6 +75,8 @@ class ConnectionController: else: raise MissingSubscriptionError() + # The needs_wireguard_configuration comes from the connection model, and can be transitioned to get it directly from the object's data + # The has_wireguard_configuration comes from each polymorph object doing an os check on if the wg config exists if connection.needs_wireguard_configuration() and not profile.has_wireguard_configuration(): if profile.has_subscription(): @@ -136,6 +140,7 @@ class ConnectionController: port_number = None proxy_port_number = None + # this is a check from SessionConnection of if there's a systemwide with mask if profile.connection.is_unprotected(): if not ConnectionController.system_uses_wireguard_interface(): diff --git a/core/controllers/SubscriptionPlanController.py b/core/controllers/SubscriptionPlanController.py index f7d9b93..2180662 100644 --- a/core/controllers/SubscriptionPlanController.py +++ b/core/controllers/SubscriptionPlanController.py @@ -9,10 +9,23 @@ class SubscriptionPlanController: @staticmethod def get(connection: Union[SessionConnection, SystemConnection], duration: int): + """ + Called by: + GUI in worker.py + + Purpose: + confirm the subscription's length is valid + """ return SubscriptionPlan.find(connection, duration) @staticmethod def get_all(connection: Optional[Union[SessionConnection, SystemConnection]] = None): + """ + Not used. Good candidate to be cut. + + GUI's create_interface_elements + inside duration selection page actually has hardcoded amounts + """ return SubscriptionPlan.all(connection) @staticmethod diff --git a/core/models/BaseConnection.py b/core/models/BaseConnection.py index c394b52..edc7021 100644 --- a/core/models/BaseConnection.py +++ b/core/models/BaseConnection.py @@ -7,6 +7,7 @@ from dataclasses_json import dataclass_json class BaseConnection: code: str + # called by: connection controller for basic type checks on wireguard code def needs_wireguard_configuration(self): return self.code == 'wireguard' @@ -15,3 +16,4 @@ class BaseConnection: def is_system_connection(self): return type(self).__name__ == 'SystemConnection' + diff --git a/core/models/session/SessionConnection.py b/core/models/session/SessionConnection.py index 026a9d2..d1f7df7 100644 --- a/core/models/session/SessionConnection.py +++ b/core/models/session/SessionConnection.py @@ -11,6 +11,8 @@ class SessionConnection(BaseConnection): if self.code not in ('system', 'tor', 'wireguard'): raise ValueError('Invalid connection code.') + # called by connection controller + # doesn't even make sense, it's checking if the Session is code system. this will always be false. def is_unprotected(self): return self.code == 'system' and self.masked is False diff --git a/core/models/system/SystemConnection.py b/core/models/system/SystemConnection.py index 8122b76..732441a 100644 --- a/core/models/system/SystemConnection.py +++ b/core/models/system/SystemConnection.py @@ -5,9 +5,10 @@ from dataclasses import dataclass @dataclass class SystemConnection (BaseConnection): + def __post_init__(self): - if self.code != 'wireguard': + if self.code not in ('vless', 'hysteria2', 'wireguard'): raise ValueError('Invalid connection code.') @staticmethod diff --git a/pyproject.toml b/pyproject.toml index aa23979..86c8a15 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "sp-hydra-veil-core" -version = "2.3.7" +version = "2.3.8" authors = [ { name = "Simplified Privacy" }, ]