Comment clarity on pre-existing Connections, and support for vless and hysteria2 in the connection model
This commit is contained in:
parent
d382a2ce9e
commit
093e9aacd8
7 changed files with 25 additions and 3 deletions
|
|
@ -1 +0,0 @@
|
|||
this is june 13 version
|
||||
|
|
@ -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():
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[project]
|
||||
name = "sp-hydra-veil-core"
|
||||
version = "2.3.7"
|
||||
version = "2.3.8"
|
||||
authors = [
|
||||
{ name = "Simplified Privacy" },
|
||||
]
|
||||
|
|
|
|||
Loading…
Reference in a new issue