2024-08-29 21:58:37 388 0
功能:
使用方法:
依赖Jar或者下载源码(https://github.com/ezadmin126/ezadmin/blob/main/ezadmin-core/src/main/java/top/ezadmin/web/safe/)放入项目中:
<dependency>
<groupId>io.github.ezadmin126</groupId>
<artifactId>ezadmin-core</artifactId>
<version>2.9.16</version>
</dependency>
String ip=IpUtils.getRealIp(httpServletRequest);
//request参数转为String 此处为拦截恶意请求
String p= JSONUtils.toJSONString(requestToMap(httpServletRequest));
IpActionDto ipActionDto = new IpActionDto();
ipActionDto.setIp(ip );
ipActionDto.setUri(realUrl);
ipActionDto.setP(p);
if( !top.ezadmin.web.safe.DefaultLocalFilter.isSafe(ipActionDto)){
httpServletResponse.setStatus(429);
httpServletResponse.getWriter().println("429 Too Many Requests");
return;
}