From 7ac981e0556100218d130e2ee11ca967dfa44e42 Mon Sep 17 00:00:00 2001 From: vladimir Date: Sat, 4 Jul 2026 05:11:56 +0300 Subject: [PATCH] =?UTF-8?q?test:=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=84=D0=B0=D0=B9=D0=BB=D0=B0=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA?= =?UTF-8?q?=D0=B8=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BE=D1=81=D0=BF=D0=BE?= =?UTF-8?q?=D1=81=D0=BE=D0=B1=D0=BD=D0=BE=D1=81=D1=82=D0=B8=20VlessOutboun?= =?UTF-8?q?d?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/sandbox/vless_outbound.py | 95 +++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 tests/sandbox/vless_outbound.py diff --git a/tests/sandbox/vless_outbound.py b/tests/sandbox/vless_outbound.py new file mode 100644 index 0000000..8071ece --- /dev/null +++ b/tests/sandbox/vless_outbound.py @@ -0,0 +1,95 @@ +from xray_manager.core import ( + OutboundFactory, + ProfileStorage, + Target, + TargetStorage, + VlessOutbound, + XrayManagerConfig, +) + +inbound = { + "tag": "in-vless", + "listen": "127.0.0.1", + "port": 443, + "protocol": "vless", + "settings": { + "clients": [ + { + "email": "test-fr1", + "id": "0eb7a1a8-c24f-4eb2-9f89-8023a10ed070", + "flow": "xtls-rprx-vision", + }, + { + "email": "test2-us2", + "id": "7b6da4ce-bb10-4127-a0c6-243618c62edd", + "flow": "xtls-rprx-vision", + }, + ], + "decryption": "none", + }, + "streamSettings": { + "network": "tcp", + "security": "reality", + "realitySettings": { + "show": False, + "dest": "google.com:443", + "xver": 0, + "serverNames": ["google.com"], + "privateKey": "yHJQq57MNRi-0UQm7ymiy2DI17iO_Ovu2HF5EV1ViGg", + "minClientVer": "", + "maxClientVer": "", + "maxTimeDiff": 0, + "shortIds": ["91e7c34ea2c07723", "0419a64d06467571"], + }, + }, +} + + +def test_from_scratch(target_storage: TargetStorage) -> VlessOutbound: + target = target_storage.load_by_id("fr1") + outbound = VlessOutbound.from_scratch(target, "localhost", inbound) + print("Test from scratch") + print(outbound) + return outbound + + +def test_to_link(outbound: VlessOutbound) -> str: + link = outbound.to_link() + print("Test to link") + print(link) + return link + + +def test_from_link(target_storage: TargetStorage, link: str): + outbound = VlessOutbound.from_link(target_storage, link) + print("Test from link") + print(outbound) + + +def test_from_inbound(target_storage: TargetStorage): + client = { + "email": "test-fr1", + "id": "0eb7a1a8-c24f-4eb2-9f89-8023a10ed070", + "flow": "xtls-rprx-vision", + } + + username, outbound = VlessOutbound.from_inbound( + target_storage, "localhost", client, inbound + ) + + print("Test from inbound") + print(username) + print(outbound) + + +if __name__ == "__main__": + DEV_CONFIG_PATH = "tests/mock_data/etc/xray-manager/config.json" + xray_manager_config = XrayManagerConfig(DEV_CONFIG_PATH) + profile_storage = ProfileStorage(xray_manager_config) + target_storage = TargetStorage(xray_manager_config) + + outbound = test_from_scratch(target_storage) + link = test_to_link(outbound) + test_from_link(target_storage, link) + + test_from_inbound(target_storage)