From ae73c0bce5e698dae907504b62c462e152e50e8d Mon Sep 17 00:00:00 2001 From: vladimir Date: Mon, 6 Jul 2026 02:59:49 +0300 Subject: [PATCH] =?UTF-8?q?refactor:=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BD?= =?UTF-8?q?=D0=BE=D1=81=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D0=B8=20=D1=80?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=82=D1=8B=20=D1=81=20=D0=BA=D0=BE=D0=BD?= =?UTF-8?q?=D1=84=D0=B8=D0=B3=D1=83=D1=80=D0=B0=D1=86=D0=B8=D1=8F=D0=BC?= =?UTF-8?q?=D0=B8=20Xray=20=D0=B8=D0=B7=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81?= =?UTF-8?q?=D0=B0=20XrayConfig=20=D0=B2=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81?= =?UTF-8?q?=D1=8B=20Outbound=20=D0=B8=20OutboundFactory?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/xray_manager/core/outbound.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) 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: ...