#!/usr/bin/env python3 """ Настройка VLESS Reality inbound на ruvpn (185.130.212.192) через 3x-ui API """ import requests import json import urllib3 urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) BASE_URL = "https://185.130.212.192:37615" WEB_BASE_PATH = "/Tlvziqv5coI64Ymq5U/" USERNAME = "admin" PASSWORD = "XrayAdmin2026!" # Генерация UUID и ключей Reality import uuid import subprocess UUID = str(uuid.uuid4()) print(f"UUID: {UUID}") # Генерация пары ключей Reality через xray result = subprocess.run( ["docker", "run", "--rm", "teddysun/xray", "xray", "x25519"], capture_output=True, text=True, timeout=30 ) if result.returncode == 0: lines = result.stdout.strip().split('\n') PRIVATE_KEY = lines[0].split(': ')[1] if ': ' in lines[0] else lines[0] PUBLIC_KEY = lines[1].split(': ')[1] if len(lines) > 1 and ': ' in lines[1] else "" print(f"Private Key: {PRIVATE_KEY}") print(f"Public Key: {PUBLIC_KEY}") else: # Fallback: используем статичные тестовые ключи (в продакшене сгенерировать!) PRIVATE_KEY = "test-private-key-replace-me" PUBLIC_KEY = "test-public-key-replace-me" print("WARNING: Could not generate keys, using placeholders") SHORT_ID = uuid.uuid4().hex[:16] print(f"Short ID: {SHORT_ID}") # Сессия для API session = requests.Session() session.verify = False # Логин login_url = f"{BASE_URL}{WEB_BASE_PATH}login" login_data = { "username": USERNAME, "password": PASSWORD } print(f"\n=== Логин в 3x-ui ===") response = session.post(login_url, json=login_data) print(f"Login status: {response.status_code}") print(f"Login response: {response.text[:200]}") if response.status_code != 200 or "success" not in response.text.lower(): print("ERROR: Login failed!") exit(1) # Добавление VLESS Reality inbound print(f"\n=== Добавление VLESS Reality inbound ===") inbound_config = { "id": 0, # 0 = новый inbound "up": 0, "down": 0, "total": 0, "remark": "VLESS-Reality-Slava", "enable": True, "expiryTime": 0, "listen": "0.0.0.0", "port": 53903, "protocol": "vless", "settings": json.dumps({ "clients": [ { "id": UUID, "flow": "xtls-rprx-vision", "email": "slava@android", "limitIp": 0, "totalGB": 0, "expiryTime": 0, "enable": True, "tgId": "", "subId": "" } ], "decryption": "none", "fallbacks": [] }), "streamSettings": json.dumps({ "network": "tcp", "security": "reality", "externalProxy": [], "realitySettings": { "show": False, "xver": 0, "dest": "yahoo.com:443", "serverNames": ["yahoo.com"], "privateKey": PRIVATE_KEY, "minClientVersion": "", "maxClientVersion": "", "maxTimeDiff": 0, "shortIds": [SHORT_ID] }, "sockopt": { "acceptProxyProtocol": False, "tcpFastOpen": True } }), "tag": f"VLESS_Reality_{UUID[:8]}" } add_url = f"{BASE_URL}{WEB_BASE_PATH}panel/api/inbounds/add" response = session.post(add_url, json=inbound_config) print(f"Add inbound status: {response.status_code}") print(f"Response: {response.text[:500]}") if response.status_code == 200: print("\n✅ VLESS Reality inbound успешно добавлен!") print(f"\n📱 Конфиг для Android (v2raytun/happ):") print(f""" vless://{UUID}@185.130.212.192:53903?encryption=none&flow=xtls-rprx-vision&security=reality&fp=chrome&sni=yahoo.com&pbk={PUBLIC_KEY}&sid={SHORT_ID}&type=tcp#VLESS-Reality-Slava """) else: print(f"\n❌ Ошибка добавления inbound") print(f"Response: {response.text}")