ip limit for tariffs

This commit is contained in:
Vladless
2025-05-16 10:06:26 +03:00
parent f6a2d05b93
commit be69447178
4 changed files with 10 additions and 7 deletions
+3 -2
View File
@@ -95,13 +95,13 @@ async def process_callback_unfreeze_subscription_confirm(callback_query: Callbac
)
tariff = await session.fetchrow(
"""
SELECT t.traffic_limit
SELECT t.*
FROM tariffs t
JOIN servers s ON s.tariff_group = t.tariff_group
WHERE s.server_name = $1
ORDER BY t.duration_days DESC
LIMIT 1
""",
""",
cluster_id,
)
@@ -118,6 +118,7 @@ async def process_callback_unfreeze_subscription_confirm(callback_query: Callbac
client_id=client_id,
new_expiry_time=new_expiry_time,
total_gb=total_gb,
hwid_device_limit=tariff["device_limit"]
)
text_ok = SUBSCRIPTION_UNFROZEN_MSG
builder = InlineKeyboardBuilder()
+1 -1
View File
@@ -239,7 +239,7 @@ async def complete_key_renewal(tg_id, client_id, email, new_expiry_time, total_g
else:
cluster_id = server_id
await renew_key_in_cluster(cluster_id, email, client_id, new_expiry_time, total_gb)
await renew_key_in_cluster(cluster_id, email, client_id, new_expiry_time, total_gb, hwid_device_limit=tariff["device_limit"])
await update_key_expiry(client_id, new_expiry_time, conn)
await update_balance(tg_id, -cost, conn)
+2 -1
View File
@@ -349,7 +349,8 @@ async def renew_key_in_cluster(
tasks.append(
extend_client_key(
xui, int(inbound_id), unique_email, new_expiry_time, client_id, total_gb, sub_id, tg_id
xui, int(inbound_id), unique_email, new_expiry_time,
client_id, total_gb, sub_id, tg_id, limit_ip=hwid_device_limit
)
)
+4 -3
View File
@@ -70,7 +70,7 @@ async def add_client(xui: py3xui.AsyncApi, config: ClientConfig) -> dict[str, An
client = py3xui.Client(
id=config.client_id,
email=config.email.lower(),
limit_ip=config.limit_ip,
limit_ip=config.limit_ip if config.limit_ip is not None else 0,
total_gb=config.total_gb,
expiry_time=config.expiry_time,
enable=config.enable,
@@ -106,6 +106,7 @@ async def extend_client_key(
total_gb: int,
sub_id: str,
tg_id: int,
limit_ip: int = 0,
) -> bool | None:
try:
client = await xui.client.get_by_email(email)
@@ -121,7 +122,7 @@ async def extend_client_key(
client.sub_id = sub_id
client.total_gb = total_gb
client.enable = True
client.limit_ip
client.limit_ip = limit_ip
client.inbound_id = inbound_id
client.tg_id = tg_id
@@ -212,7 +213,7 @@ async def toggle_client(xui: py3xui.AsyncApi, inbound_id: int, email: str, clien
client.enable = enable
client.id = client_id
client.flow = "xtls-rprx-vision"
client.limit_ip
client.limit_ip = 0
client.inbound_id = inbound_id
await xui.client.update(client.id, client)