fix(limit): Ensure IP removal on disconnect for all users
This commit is contained in:
@ -122,16 +122,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 "
|
||||
db.getCollection('$CONNECTIONS_COLLECTION').findOne({_id: '$username'})?.ips?.length || 0;
|
||||
@ -160,8 +150,18 @@ parse_log_line() {
|
||||
fi
|
||||
else
|
||||
add_ip_to_db "$username" "$ip_address"
|
||||
|
||||
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"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user