From 9987500ac0065bdbf6dadde31d546baeec54c4f7 Mon Sep 17 00:00:00 2001 From: Lev Date: Thu, 16 Apr 2026 22:27:18 +0300 Subject: [PATCH] fix --- .gitignore | 2 +- API/utils/xui.py | 15 ++++++++++----- configs/config/params.conf | 7 ------- configs/systemd/spectralvpn_api.service | 16 ---------------- docker-compose.yml | 6 +++--- 5 files changed, 14 insertions(+), 32 deletions(-) delete mode 100644 configs/config/params.conf delete mode 100644 configs/systemd/spectralvpn_api.service diff --git a/.gitignore b/.gitignore index f9861ea..9c86c17 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,4 @@ API/__pycache__ API/models/__pycache__ API/routers/__pycache__ API/schemas/__pycache__ -API/utils/__pycache__ \ No newline at end of file +API/utils/__pycache__ diff --git a/API/utils/xui.py b/API/utils/xui.py index c80114b..c37ecb9 100644 --- a/API/utils/xui.py +++ b/API/utils/xui.py @@ -123,13 +123,18 @@ class XUIClient: async def get_client_traffic(self, client_email: str) -> int: await self._login() try: - resp = await self.session.post( - f"{self.base_url}/panel/inbound/getClientTraffics/{client_email}" - ) + resp = await self.session.post(f"{self.base_url}/panel/inbound/list") resp.raise_for_status() data = resp.json() - obj = data.get("obj", {}) - return obj.get("down", 0) + obj.get("up", 0) + inbounds = data.get("obj") + for inbound in inbounds: + client_stats = inbound.get("clientStats") + for stat in client_stats: + if stat.get("email") == client_email: + up = stat.get("up") + down = stat.get("down") + return up + down + return 0 except: return 0 diff --git a/configs/config/params.conf b/configs/config/params.conf deleted file mode 100644 index 422f9ef..0000000 --- a/configs/config/params.conf +++ /dev/null @@ -1,7 +0,0 @@ -[api] -path = spectralvpn.db -host = -username = -password = -inbaund_id = 0 -inbaund_url = spectralvpn.ru:442 \ No newline at end of file diff --git a/configs/systemd/spectralvpn_api.service b/configs/systemd/spectralvpn_api.service deleted file mode 100644 index eb515f6..0000000 --- a/configs/systemd/spectralvpn_api.service +++ /dev/null @@ -1,16 +0,0 @@ -[Unit] -Description=API SpectralVPN -After=network.target -Wants=network.target - -[Service] -User = root -WorkingDirectory=/etc/spectralvpn_api -Environment="PATH=/etc/spectralvpn_api/.venv/bin" -ExecStart=/etc/spectralvpn_api/.venv/bin/uvicorn main:app -Restart=always -RestartSec=3 -KillMode=control-group - -[Install] -WantedBy=multi-user.target \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 52fc2e5..07b627b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -29,13 +29,13 @@ services: POSTGRES_PASSWORD: ${DB_PASSWORD} healthcheck: test: ["CMD", "pg_isready", "-U", "${DB_USER}", "-d", "${DB_NAME}"] - interval: 10s + interval: 5s timeout: 5s - retries: 5 + retries: 10 volumes: - db-data:/var/lib/postgresql ports: - 5432:5432 volumes: - db-data: \ No newline at end of file + db-data: