增加防御代码,防止恶意攻击(优化)
This commit is contained in:
@@ -30,6 +30,7 @@ public interface LogMapperEx {
|
||||
@Param("content") String content);
|
||||
|
||||
Long getCountByIpAndDate(
|
||||
@Param("moduleName") String moduleName,
|
||||
@Param("clientIp") String clientIp,
|
||||
@Param("createTime") String createTime);
|
||||
}
|
||||
@@ -150,7 +150,7 @@ public class LogService {
|
||||
if(userId!=null) {
|
||||
String clientIp = getLocalIp(request);
|
||||
String createTime = Tools.getNow3();
|
||||
Long count = logMapperEx.getCountByIpAndDate(clientIp, createTime);
|
||||
Long count = logMapperEx.getCountByIpAndDate(moduleName, clientIp, createTime);
|
||||
if(count > 0) {
|
||||
//如果某1个IP在同1秒内连续操作两遍,此时需要删除该redis记录,使其退出,防止恶意攻击
|
||||
redisService.deleteObjectByKeyAndIp("clientIp", clientIp, "userId");
|
||||
|
||||
Reference in New Issue
Block a user