ip 请求次数限制11
This commit is contained in:
parent
c188e51758
commit
81c703eacc
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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)) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue