ip 请求次数限制20
This commit is contained in:
@@ -13,5 +13,5 @@ import java.lang.annotation.Target;
|
|||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
public @interface Limiting {
|
public @interface Limiting {
|
||||||
// 默认每秒放入桶中的token
|
// 默认每秒放入桶中的token
|
||||||
double limitNum() default 2;
|
double limitNum() default 4;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,11 +54,11 @@ public class AppApiMethodAspect {
|
|||||||
HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
|
HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
|
||||||
String requestIp = IPUtils.getIpAddr(request);
|
String requestIp = IPUtils.getIpAddr(request);
|
||||||
|
|
||||||
Integer maxAccessCount = Integer.parseInt(commonInfoService.findOne(935).getValue());
|
// Integer maxAccessCount = Integer.parseInt(commonInfoService.findOne(935).getValue());
|
||||||
if (!IpAccessCounter.canAccess(requestIp, maxAccessCount)) {
|
// if (!IpAccessCounter.canAccess(requestIp, maxAccessCount)) {
|
||||||
log.info("IpAccessCounter 一分钟内请求超过限制,IP: {}, 最大访问次数: {}", requestIp, maxAccessCount);
|
// log.info("IpAccessCounter 一分钟内请求超过限制,IP: {}, 最大访问次数: {}", requestIp, maxAccessCount);
|
||||||
throw new LimitException("访问频率过高,请稍后再试");
|
// throw new LimitException("访问频率过高,请稍后再试");
|
||||||
}
|
// }
|
||||||
|
|
||||||
String params = new Gson().toJson(args);
|
String params = new Gson().toJson(args);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user