fix
This commit is contained in:
parent
0e71fe7abe
commit
9987500ac0
5 changed files with 14 additions and 32 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -4,4 +4,4 @@ API/__pycache__
|
|||
API/models/__pycache__
|
||||
API/routers/__pycache__
|
||||
API/schemas/__pycache__
|
||||
API/utils/__pycache__
|
||||
API/utils/__pycache__
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
[api]
|
||||
path = spectralvpn.db
|
||||
host =
|
||||
username =
|
||||
password =
|
||||
inbaund_id = 0
|
||||
inbaund_url = spectralvpn.ru:442
|
||||
|
|
@ -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
|
||||
|
|
@ -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:
|
||||
db-data:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue