test: добавление файла для проверки работоспособности VlessOutbound
This commit is contained in:
@@ -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)
|
||||
Reference in New Issue
Block a user