reset traffic

This commit is contained in:
Vladless
2024-11-10 03:31:19 +03:00
parent adaae41826
commit 4bf5b3a87d
3 changed files with 48 additions and 9 deletions
+29 -3
View File
@@ -59,6 +59,29 @@ async def add_client(
return None
async def reset_client_traffic(session, server_id: str, email: str) -> bool:
"""Сбрасывает трафик клиента на сервере"""
api_url = SERVERS[server_id]["API_URL"]
url = f"{api_url}/panel/api/inbounds/1/resetClientTraffic/{email}"
headers = {"Accept": "application/json"}
try:
async with session.post(url, headers=headers) as response:
if response.status == 200:
logger.info(
f"Трафик клиента {email} успешно сброшен на сервере {server_id}")
return True
else:
logger.error(
f"Ошибка при сбросе трафика клиента {email} на сервере {server_id}: {response.status} - {await response.text()}"
)
return False
except Exception as e:
logger.error(
f"Ошибка при попытке сброса трафика клиента {email} на сервере {server_id}: {e}")
return False
async def extend_client_key(
session, server_id: str, tg_id, client_id, email: str, new_expiry_time: int
) -> bool:
@@ -113,7 +136,8 @@ async def extend_client_key(
),
}
headers = {"Content-Type": "application/json", "Accept": "application/json"}
headers = {"Content-Type": "application/json",
"Accept": "application/json"}
try:
async with session.post(
@@ -122,7 +146,8 @@ async def extend_client_key(
headers=headers,
) as response:
logger.info(f"POST {response.url} Status: {response.status}")
logger.info(f"POST Request Data: {json.dumps(payload, indent=2)}")
logger.info(
f"POST Request Data: {json.dumps(payload, indent=2)}")
response_text = await response.text()
logger.info(f"POST Response: {response_text}")
@@ -165,7 +190,8 @@ async def extend_client_key_admin(
),
}
headers = {"Content-Type": "application/json", "Accept": "application/json"}
headers = {"Content-Type": "application/json",
"Accept": "application/json"}
try:
async with session.post(