ip 请求次数限制4 日志修改

This commit is contained in:
GYJ
2025-03-23 21:00:23 +08:00
parent 63aee02a16
commit 73bdb19fce
2 changed files with 1 additions and 4 deletions

View File

@@ -56,7 +56,7 @@ public class AppApiMethodAspect {
Integer maxAccessCount = Integer.parseInt(commonInfoService.findOne(935).getValue());
if (!IpAccessCounter.canAccess(requestIp, maxAccessCount)) {
log.info("一分钟内请求超过限制IP: {}, 最大访问次数: {}", requestIp, maxAccessCount);
log.info("IpAccessCounter 一分钟内请求超过限制IP: {}, 最大访问次数: {}", requestIp, maxAccessCount);
throw new LimitException("访问频率过高,请稍后再试");
}

View File

@@ -25,7 +25,6 @@ public class IpAccessCounter {
@Override
public void run() {
long currentTime = System.currentTimeMillis();
log.info("IpAccessCounter 开始清理超过一分钟的访问记录,清理前 IP_ACCESS_TIMES 大小: {}", IP_ACCESS_TIMES.size());
// 用于记录移除的 IP 集合
Set<String> removedIps = new HashSet<>();
@@ -38,9 +37,7 @@ public class IpAccessCounter {
}
}
removedIps.forEach(IP_ACCESS_TIMES::remove);
log.info("IpAccessCounter 清理完成,移除了 {} 个 IP 的访问记录,当前 IP_ACCESS_TIMES 大小: {}", removedIps.size(), IP_ACCESS_TIMES.size());
log.info("IpAccessCounter 开始清理超过十分钟的黑名单记录,清理前 BLACKLIST 大小: {}", BLACKLIST.size());
Set<String> removedBlacklistIps = new HashSet<>();
for (Map.Entry<String, Long> entry : BLACKLIST.entrySet()) {
String ip = entry.getKey();