ip 请求次数限制7

This commit is contained in:
GYJ 2025-03-23 21:16:20 +08:00
parent a9478221eb
commit 61bc2206bf
1 changed files with 0 additions and 1 deletions

View File

@ -61,7 +61,6 @@ public class IpAccessCounter {
long currentTime = System.currentTimeMillis();
List<Long> accessTimes = IP_ACCESS_TIMES.computeIfAbsent(ip, k -> new ArrayList<>());
// 移除超过一分钟的访问时间记录
accessTimes.removeIf(time -> currentTime - time > ONE_MINUTE);
if (accessTimes.size() + 1 > maxAccessCount) {
addToBlacklist(ip);
log.info("IP {} 因一分钟内访问次数超过 {} 次,被加入黑名单", ip, maxAccessCount);