From 07089455b5f518f85a9d63b5717779fb851ff176 Mon Sep 17 00:00:00 2001 From: Alireza Ahmadi Date: Tue, 11 Apr 2023 03:14:00 +0200 Subject: [PATCH] Fix traffic exhaustion detection --- web/html/xui/inbounds.html | 2 +- web/service/tgbot.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/web/html/xui/inbounds.html b/web/html/xui/inbounds.html index f0725755..1abcad3f 100644 --- a/web/html/xui/inbounds.html +++ b/web/html/xui/inbounds.html @@ -348,7 +348,7 @@ depleted.push(client.email); } else { if ((client.expiryTime > 0 && (client.expiryTime-now < this.expireDiff)) || - (client.total > 0 && (client.total-client.up+client.down < this.trafficDiff ))) expiring.push(client.email); + (client.total > 0 && (client.total-(client.up+client.down) < this.trafficDiff ))) expiring.push(client.email); } }); } else { diff --git a/web/service/tgbot.go b/web/service/tgbot.go index 2ab3dbb0..6da0df57 100644 --- a/web/service/tgbot.go +++ b/web/service/tgbot.go @@ -536,14 +536,14 @@ func (t *Tgbot) getExhausted() string { for _, inbound := range inbounds { if inbound.Enable { if (inbound.ExpiryTime > 0 && (inbound.ExpiryTime-now < exDiff)) || - (inbound.Total > 0 && (inbound.Total-inbound.Up+inbound.Down < trDiff)) { + (inbound.Total > 0 && (inbound.Total-(inbound.Up+inbound.Down) < trDiff)) { exhaustedInbounds = append(exhaustedInbounds, *inbound) } if len(inbound.ClientStats) > 0 { for _, client := range inbound.ClientStats { if client.Enable { if (client.ExpiryTime > 0 && (client.ExpiryTime-now < exDiff)) || - (client.Total > 0 && (client.Total-client.Up+client.Down < trDiff)) { + (client.Total > 0 && (client.Total-(client.Up+client.Down) < trDiff)) { exhaustedClients = append(exhaustedClients, client) } } else {