diff --git a/src/xray_manager/core/outbound.py b/src/xray_manager/core/outbound.py index 28d1075..0dd3ff9 100644 --- a/src/xray_manager/core/outbound.py +++ b/src/xray_manager/core/outbound.py @@ -60,6 +60,7 @@ class OutboundFactory: outbound_cls = cls._scheme_registry[scheme] return outbound_cls.from_link(target_storage, link) + # устаревший метод, удалить после рефакторинга @classmethod def from_inbound( cls, @@ -79,6 +80,19 @@ class OutboundFactory: ) return username, outbound + @classmethod + def from_xray_inbound( + cls, ts: TargetStorage, client: dict, inbound: dict + ) -> Outbound: + protocol = inbound.get("protocol") + + if protocol not in cls._registry: + raise ValueError(f"Unsupported protocol: {protocol}") + + outbound_cls = cls._registry[protocol] + outbound = outbound_cls.from_xray_inbound(ts, client, inbound) + return outbound + @classmethod def from_spec( cls, @@ -121,6 +135,12 @@ class Outbound(ABC): inbound: dict, ) -> tuple[str, Outbound]: ... + @classmethod + @abstractmethod + def from_xray_inbound( + cls, ts: TargetStorage, client: dict, inbound: dict + ) -> Outbound: ... + @classmethod @abstractmethod def from_scratch( @@ -145,8 +165,8 @@ class Outbound(ABC): @staticmethod def split_client_email(email: str) -> tuple[str, str]: - username, target = email.rsplit("-", 1) - return username, target + username, target_id = email.rsplit("-", 1) + return username, target_id @abstractmethod def __hash__(self) -> int: ...