"eladmin-system/vscode:/vscode.git/clone" did not exist on "17820dec633243fd15550f5cd848c808164e9873"
Commit 182b9e2b authored by 季圣华's avatar 季圣华
Browse files

增加防御代码,防止恶意攻击(优化)

parent d21e6a4f
...@@ -30,6 +30,7 @@ public interface LogMapperEx { ...@@ -30,6 +30,7 @@ public interface LogMapperEx {
@Param("content") String content); @Param("content") String content);
Long getCountByIpAndDate( Long getCountByIpAndDate(
@Param("moduleName") String moduleName,
@Param("clientIp") String clientIp, @Param("clientIp") String clientIp,
@Param("createTime") String createTime); @Param("createTime") String createTime);
} }
\ No newline at end of file
...@@ -150,7 +150,7 @@ public class LogService { ...@@ -150,7 +150,7 @@ public class LogService {
if(userId!=null) { if(userId!=null) {
String clientIp = getLocalIp(request); String clientIp = getLocalIp(request);
String createTime = Tools.getNow3(); String createTime = Tools.getNow3();
Long count = logMapperEx.getCountByIpAndDate(clientIp, createTime); Long count = logMapperEx.getCountByIpAndDate(moduleName, clientIp, createTime);
if(count > 0) { if(count > 0) {
//如果某1个IP在同1秒内连续操作两遍,此时需要删除该redis记录,使其退出,防止恶意攻击 //如果某1个IP在同1秒内连续操作两遍,此时需要删除该redis记录,使其退出,防止恶意攻击
redisService.deleteObjectByKeyAndIp("clientIp", clientIp, "userId"); redisService.deleteObjectByKeyAndIp("clientIp", clientIp, "userId");
......
...@@ -72,6 +72,6 @@ ...@@ -72,6 +72,6 @@
</select> </select>
<select id="getCountByIpAndDate" resultType="java.lang.Long"> <select id="getCountByIpAndDate" resultType="java.lang.Long">
select count(1) from jsh_log where client_ip=#{clientIp} and create_time=#{createTime} select count(1) from jsh_log where operation=#{moduleName} and client_ip=#{clientIp} and create_time=#{createTime}
</select> </select>
</mapper> </mapper>
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment