22 lines
709 B
Python
22 lines
709 B
Python
from core.models.BaseConnection import BaseConnection
|
|
from dataclasses import dataclass, field
|
|
from typing import Optional
|
|
|
|
@dataclass
|
|
class SystemConnection(BaseConnection):
|
|
operator_id: Optional[int] = field(default=None)
|
|
protocol: Optional[str] = field(default=None)
|
|
|
|
def __post_init__(self):
|
|
if self.code not in ('wireguard', 'operator', 'vless', 'hysteria2'):
|
|
raise ValueError('Invalid connection code.')
|
|
|
|
@staticmethod
|
|
def needs_proxy_configuration():
|
|
return False
|
|
|
|
def needs_operator_proxy(self):
|
|
return self.code in ('operator', 'vless', 'hysteria2')
|
|
|
|
def get_protocol(self):
|
|
return self.protocol if self.protocol else self.code
|