Comment clarity on pre-existing Connections, and support for vless and hysteria2 in the connection model

This commit is contained in:
SimplifiedPrivacy 2026-07-03 17:24:49 -04:00
parent d382a2ce9e
commit 093e9aacd8
7 changed files with 25 additions and 3 deletions

View file

@ -1 +0,0 @@
this is june 13 version

View file

@ -56,6 +56,8 @@ class ConnectionController:
connection = profile.connection 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 connection.needs_proxy_configuration() and not profile.has_proxy_configuration():
if profile.has_subscription(): if profile.has_subscription():
@ -73,6 +75,8 @@ class ConnectionController:
else: else:
raise MissingSubscriptionError() 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 connection.needs_wireguard_configuration() and not profile.has_wireguard_configuration():
if profile.has_subscription(): if profile.has_subscription():
@ -136,6 +140,7 @@ class ConnectionController:
port_number = None port_number = None
proxy_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 profile.connection.is_unprotected():
if not ConnectionController.system_uses_wireguard_interface(): if not ConnectionController.system_uses_wireguard_interface():

View file

@ -9,10 +9,23 @@ class SubscriptionPlanController:
@staticmethod @staticmethod
def get(connection: Union[SessionConnection, SystemConnection], duration: int): 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) return SubscriptionPlan.find(connection, duration)
@staticmethod @staticmethod
def get_all(connection: Optional[Union[SessionConnection, SystemConnection]] = None): 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) return SubscriptionPlan.all(connection)
@staticmethod @staticmethod

View file

@ -7,6 +7,7 @@ from dataclasses_json import dataclass_json
class BaseConnection: class BaseConnection:
code: str code: str
# called by: connection controller for basic type checks on wireguard code
def needs_wireguard_configuration(self): def needs_wireguard_configuration(self):
return self.code == 'wireguard' return self.code == 'wireguard'
@ -15,3 +16,4 @@ class BaseConnection:
def is_system_connection(self): def is_system_connection(self):
return type(self).__name__ == 'SystemConnection' return type(self).__name__ == 'SystemConnection'

View file

@ -11,6 +11,8 @@ class SessionConnection(BaseConnection):
if self.code not in ('system', 'tor', 'wireguard'): if self.code not in ('system', 'tor', 'wireguard'):
raise ValueError('Invalid connection code.') 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): def is_unprotected(self):
return self.code == 'system' and self.masked is False return self.code == 'system' and self.masked is False

View file

@ -5,9 +5,10 @@ from dataclasses import dataclass
@dataclass @dataclass
class SystemConnection (BaseConnection): class SystemConnection (BaseConnection):
def __post_init__(self): def __post_init__(self):
if self.code != 'wireguard': if self.code not in ('vless', 'hysteria2', 'wireguard'):
raise ValueError('Invalid connection code.') raise ValueError('Invalid connection code.')
@staticmethod @staticmethod

View file

@ -1,6 +1,6 @@
[project] [project]
name = "sp-hydra-veil-core" name = "sp-hydra-veil-core"
version = "2.3.7" version = "2.3.8"
authors = [ authors = [
{ name = "Simplified Privacy" }, { name = "Simplified Privacy" },
] ]