ip 请求次数限制20
This commit is contained in:
parent
2f61455c7c
commit
9ef5c4aa8a
|
|
@ -13,5 +13,5 @@ import java.lang.annotation.Target;
|
|||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Limiting {
|
||||
// 默认每秒放入桶中的token
|
||||
double limitNum() default 2;
|
||||
double limitNum() default 4;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue