added react frontend

This commit is contained in:
Vyacheslav K
2025-05-21 14:24:31 +03:00
parent 96ea504b10
commit d3e7607d15
18 changed files with 3620 additions and 145 deletions

View File

@@ -3,6 +3,7 @@ import sys
import os
V2RAY_VPN_ENABLED = False
# Добавляем родительскую директорию в sys.path
parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
@@ -48,6 +49,7 @@ class V2rayAController:
async def enable_proxy(self):
"""Включение прокси"""
global V2RAY_VPN_ENABLED
if not self.token:
print("Не выполнен вход. Пожалуйста, сначала выполните аутентификацию")
return False
@@ -60,18 +62,20 @@ class V2rayAController:
async with self.session.post(url, headers=headers, json=data) as response:
if response.status == 200:
print("Прокси успешно включен")
V2RAY_VPN_ENABLED = True
await show_notification({"title":"✅ V2Ray proxy","message":"Прокси успешно включен"})
return True
else:
print(f"Ошибка при включении прокси: {response.status}")
return False
except Exception as e:
raise OSError("Failed to enable proxy")
print(f"Ошибка при включении прокси: {e}")
raise OSError("Failed to enable proxy")
return False
async def disable_proxy(self):
"""Выключение прокси"""
global V2RAY_VPN_ENABLED
if not self.token:
print("Не выполнен вход. Пожалуйста, сначала выполните аутентификацию")
return False
@@ -84,14 +88,15 @@ class V2rayAController:
async with self.session.delete(url, headers=headers, json=data) as response:
if response.status == 200:
print("Прокси успешно выключен")
V2RAY_VPN_ENABLED = False
await show_notification({"title":"🔴 V2Ray proxy","message":"Прокси успешно выключен"})
return True
else:
print(f"Ошибка при выключении прокси: {response.status}")
return False
except Exception as e:
raise OSError("Failed to disable proxy")
print(f"Ошибка при выключении прокси: {e}")
raise OSError("Failed to disable proxy")
return False
async def close(self):
@@ -133,3 +138,10 @@ async def disable_vpn(args):
await controller.close()
else:
raise OSError("Config unset")
async def is_vpn_enabled(args):
global V2RAY_VPN_ENABLED
return {
"vpn_enabled": V2RAY_VPN_ENABLED
}