Commit 389c9022 authored by richard's avatar richard

修改ip拦截策略

parent 3da06fe4
...@@ -39,9 +39,9 @@ public interface Constants { ...@@ -39,9 +39,9 @@ public interface Constants {
String REDIS_PASSWORD_ERROR_COUNT = "password_error_count:"; String REDIS_PASSWORD_ERROR_COUNT = "password_error_count:";
String REDIS_PASSWORD_ERROR_COUNT_FOR_IPV4 = "password_error_count_4_ipv4:"; String REDIS_PASSWORD_ERROR_COUNT_FOR_IPV4 = "password_error_count_4_ipv4:";
String IPV4_LOCK = "lock_ipv4:"; String IPV4_LOCK = "lock_ipv4:";
Long IPV4_LOCK_MINUTES = 30L; Long IPV4_LOCK_MINUTES = 3 * 60L;
Long IPV4_COUNT_MINUTES = 1L; Long IPV4_COUNT_MINUTES = 1L;
Long IPV4_LOCK_ON_COUNTS = 200L; Long IPV4_LOCK_ON_COUNTS = 150L;
int DANGEROUS_TIME_START = 22; int DANGEROUS_TIME_START = 22;
int DANGEROUS_TIME_END = 6; int DANGEROUS_TIME_END = 6;
String CLEAR_LOCK_FOR_IPV4 = "x-clear-lock-11241842-y"; String CLEAR_LOCK_FOR_IPV4 = "x-clear-lock-11241842-y";
......
...@@ -21,6 +21,7 @@ import org.springframework.web.context.request.ServletRequestAttributes; ...@@ -21,6 +21,7 @@ import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.*; import java.util.*;
import java.util.regex.Pattern;
/** /**
* 密码错误限次的校验 * 密码错误限次的校验
...@@ -60,6 +61,9 @@ public class PasswordErrorFiniteValidateAdvisor { ...@@ -60,6 +61,9 @@ public class PasswordErrorFiniteValidateAdvisor {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
// 客户端IP // 客户端IP
String clientIp = getIp(request); String clientIp = getIp(request);
if (StringUtils.startsWith(clientIp, "139.198.")){
return pjp.proceed();
}
String lockIpv4Key = getLockIpv4Key(clientIp); String lockIpv4Key = getLockIpv4Key(clientIp);
String lock = redisTemplate.opsForValue().get(lockIpv4Key); String lock = redisTemplate.opsForValue().get(lockIpv4Key);
if (Objects.equals(Boolean.TRUE.toString(), lock)){ if (Objects.equals(Boolean.TRUE.toString(), lock)){
......
Markdown is supported
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