From 4a2e1b7d3f84c53dc26b860a6d17a35ba546d291 Mon Sep 17 00:00:00 2001 From: ReturnFI <151555003+ReturnFI@users.noreply.github.com> Date: Thu, 6 Nov 2025 19:36:11 +0000 Subject: [PATCH] fix(limit): Ensure IP removal on disconnect for all users --- core/scripts/hysteria2/limit.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/core/scripts/hysteria2/limit.sh b/core/scripts/hysteria2/limit.sh index 46b2a0e..2fe8476 100644 --- a/core/scripts/hysteria2/limit.sh +++ b/core/scripts/hysteria2/limit.sh @@ -121,16 +121,6 @@ check_expired_blocks() { check_ip_limit() { local username="$1" - - local is_unlimited - is_unlimited=$(mongosh "$DB_NAME" --quiet --eval " - db.users.findOne({_id: '$username'}, {_id: 0, unlimited_user: 1})?.unlimited_user || false; - ") - - if [ "$is_unlimited" == "true" ]; then - log_message "INFO" "User $username is exempt from IP limit. Skipping check." - return - fi local ip_count ip_count=$(mongosh "$DB_NAME" --quiet --eval " @@ -160,7 +150,17 @@ parse_log_line() { fi else add_ip_to_db "$username" "$ip_address" - check_ip_limit "$username" + + local is_unlimited + is_unlimited=$(mongosh "$DB_NAME" --quiet --eval " + db.users.findOne({_id: '$username'}, {_id: 0, unlimited_user: 1})?.unlimited_user || false; + ") + + if [ "$is_unlimited" == "true" ]; then + log_message "INFO" "User $username is exempt from IP limit. Skipping check." + else + check_ip_limit "$username" + fi fi elif echo "$log_line" | grep -q "client disconnected"; then remove_ip_from_db "$username" "$ip_address"