diff --git a/core/controllers/ProfileController.py b/core/controllers/ProfileController.py index 28ad10a..fa24b50 100644 --- a/core/controllers/ProfileController.py +++ b/core/controllers/ProfileController.py @@ -332,29 +332,6 @@ class ProfileController: def has_proxy_configuration(profile: Union[SessionProfile, SystemProfile]): profile.has_proxy_configuration() - # @staticmethod - # def register_wireguard_session(profile: Union[SessionProfile, SystemProfile], connection_observer: Optional[ConnectionObserver] = None): - - # from core.controllers.ConnectionController import ConnectionController - - # if not profile.has_subscription(): - # raise MissingSubscriptionError() - - # if not profile.has_location(): - # raise MissingLocationError() - - # wireguard_keys = ProfileController.__generate_wireguard_keys() - - # wireguard_configuration = ConnectionController.with_preferred_connection(profile.location.country_code, profile.location.code, profile.subscription.billing_code, wireguard_keys.get('public'), task=WebServiceApiService.post_wireguard_session, connection_observer=connection_observer) - - # if wireguard_configuration is None: - # raise InvalidSubscriptionError() - - # expression = re.compile(r'^(PrivateKey =)\s?$', re.MULTILINE) - # wireguard_configuration = re.sub(expression, r'\1 ' + wireguard_keys.get('private'), wireguard_configuration) - - # profile.attach_wireguard_configuration(wireguard_configuration) - @staticmethod def get_wireguard_configuration_path(profile: Union[SessionProfile, SystemProfile]): return profile.get_wireguard_configuration_path() @@ -362,66 +339,3 @@ class ProfileController: @staticmethod def has_wireguard_configuration(profile: Union[SessionProfile, SystemProfile]): return profile.has_wireguard_configuration() - - # @staticmethod - # def verify_wireguard_endpoint(profile: Union[SessionProfile, SystemProfile], ignore: tuple[type[Exception]] = ()): - - # try: - # ProfileController.__verify_wireguard_endpoint(profile) - - # except EndpointVerificationError as error: - - # if not EndpointVerificationError in ignore: - - # profile.address_security_incident() - # raise error - - # @staticmethod - # def __verify_wireguard_endpoint(profile: Union[SessionProfile, SystemProfile]): - - # from cryptography.hazmat.primitives.asymmetric import ed25519 - # import base64 - - # signature = profile.get_wireguard_configuration_metadata('Signature') - # wireguard_public_keys = profile.get_wireguard_public_keys() - # operator = profile.location.operator - - # if signature is None: - # raise EndpointVerificationError('The WireGuard endpoint\'s signature could not be determined.') - - # if not wireguard_public_keys: - # raise EndpointVerificationError('The WireGuard endpoint\'s public key could not be determined.') - - # if operator is None: - # raise EndpointVerificationError('The WireGuard endpoint\'s operator could not be determined.') - - # try: - - # operator_public_key = ed25519.Ed25519PublicKey.from_public_bytes(bytes.fromhex(operator.public_key)) - - # for wireguard_public_key in wireguard_public_keys: - # operator_public_key.verify(base64.b64decode(signature), wireguard_public_key.encode('utf-8')) - - # except Exception: - # raise EndpointVerificationError('The WireGuard endpoint could not be verified.') - - # @staticmethod - # def __generate_wireguard_keys(): - - # from cryptography.hazmat.primitives import serialization - # from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey - - # raw_private_key = X25519PrivateKey.generate() - - # public_key = raw_private_key.public_key().public_bytes( - # encoding=serialization.Encoding.Raw, format=serialization.PublicFormat.Raw - # ) - - # private_key = raw_private_key.private_bytes( - # encoding=serialization.Encoding.Raw, format=serialization.PrivateFormat.Raw, encryption_algorithm=serialization.NoEncryption() - # ) - - # return dict( - # private=base64.b64encode(private_key).decode(), - # public=base64.b64encode(public_key).decode() - # )