chenbiao 2 роки тому
батько
коміт
1f9d799ee5

+ 9 - 7
netflix-service/src/main/java/com/cyksj/service/user/impl/BadIntentionOpServiceImpl.java

@@ -27,11 +27,12 @@ public class BadIntentionOpServiceImpl implements BadIntentionOpService {
         if ("13662979985".equals(phone)) {
             throw BusinessRuntimeException.getInstance("异常手机号");
         }
-        String ip = StringUtil.getInternalAddressByIP(ServletUtil.getClientIP(request));
-        log.info("--------------获取手机验证码------- ip:{}", ip);
+        String clientIP = ServletUtil.getClientIP(request);
+        String ipAddress = StringUtil.getInternalAddressByIP(clientIP);
+        log.info("--------------获取手机验证码------- ip:{} address:{}", clientIP, ipAddress);
         String dayKey = RedisService.key.PHONE_CODE_USER_NUM_KEY_DAY.getName() + phone;
         if (redisService.hasKey(RedisService.key.PHONE_CODE_BALCK_KEY.getName() + phone)) {
-            log.error("--------------黑名单 手机号------- ip:{}", ip);
+            log.error("--------------黑名单 手机号------- ip:{} address:{}", clientIP, ipAddress);
             throw BusinessRuntimeException.getInstance("异常手机号");
         }
         if (redisService.hasKey(dayKey)) {
@@ -52,9 +53,10 @@ public class BadIntentionOpServiceImpl implements BadIntentionOpService {
 
     @Override
     public void isBadOpLoginPhone(HttpServletRequest request, String phone) {
-        String ip = StringUtil.getInternalAddressByIP(ServletUtil.getClientIP(request));
-        log.info("--------------校验ip 是否黑名单------- ip:{}", ip);
-        String blackIpKey = RedisService.key.BALCK_USER_IP_KEY + ip;
+        String clientIP = ServletUtil.getClientIP(request);
+        String ipAddress = StringUtil.getInternalAddressByIP(clientIP);
+        log.info("--------------校验ip 是否黑名单------- ip:{} ipAddress:{}", clientIP, ipAddress);
+        String blackIpKey = RedisService.key.BALCK_USER_IP_KEY + clientIP;
         if (redisService.hasKey(blackIpKey)) {
             throw BusinessRuntimeException.getInstance("检测到您操作异常,请联系客服");
         }
@@ -63,7 +65,7 @@ public class BadIntentionOpServiceImpl implements BadIntentionOpService {
             int i = Integer.parseInt(redisService.get(RetryTimeKey).toString());
             if (i >= PHONE_LOGIN_CODE_RETRY) {
                 //锁住他的ip
-                redisService.setNx(blackIpKey, ip, RedisService.key.BALCK_USER_IP_KEY.getTimeout());
+                redisService.setNx(blackIpKey, clientIP, RedisService.key.BALCK_USER_IP_KEY.getTimeout());
                 throw BusinessRuntimeException.getInstance("检测到您操作异常,请联系客服");
             } else {
                 redisService.incr(RetryTimeKey, 1l);