ip 请求次数限制11

This commit is contained in:
GYJ 2025-03-23 23:18:07 +08:00
parent c188e51758
commit 81c703eacc
2 changed files with 6 additions and 6 deletions

View File

@ -54,11 +54,11 @@ public class AppApiMethodAspect {
HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
String requestIp = IPUtils.getIpAddr(request);
Integer maxAccessCount = Integer.parseInt(commonInfoService.findOne(935).getValue());
if (!IpAccessCounter.canAccess(requestIp, maxAccessCount)) {
log.info("IpAccessCounter 一分钟内请求超过限制IP: {}, 最大访问次数: {}", requestIp, maxAccessCount);
throw new LimitException("访问频率过高,请稍后再试");
}
// Integer maxAccessCount = Integer.parseInt(commonInfoService.findOne(935).getValue());
// if (!IpAccessCounter.canAccess(requestIp, maxAccessCount)) {
// log.info("IpAccessCounter 一分钟内请求超过限制IP: {}, 最大访问次数: {}", requestIp, maxAccessCount);
// throw new LimitException("访问频率过高,请稍后再试");
// }
String params = new Gson().toJson(args);

View File

@ -88,7 +88,7 @@ public class IpAccessCounter {
// 检查 IP 是否可以访问
public static boolean canAccess(String ip, Integer maxAccessCount) {
removeCount.getAndIncrement();
if (removeCount.get() > 200) {
if (removeCount.get() > 300) {
removeOldInfo();
}
if (isBlacklisted(ip)) {