Showing
1 changed file
with
21 additions
and
14 deletions
@@ -90,7 +90,7 @@ public class MaliciousIpServiceImpl implements MaliciousIpService { | @@ -90,7 +90,7 @@ public class MaliciousIpServiceImpl implements MaliciousIpService { | ||
90 | /** | 90 | /** |
91 | * 黑名单失效时间7*24小时 | 91 | * 黑名单失效时间7*24小时 |
92 | */ | 92 | */ |
93 | - private static final int MALICIOUS_IP_EXPIRE = 7*24 * 60 * 60; | 93 | + //private static final int MALICIOUS_IP_EXPIRE = 7*24 * 60 * 60; |
94 | 94 | ||
95 | /** | 95 | /** |
96 | *捕获的恶意ip写入运维系统的redis | 96 | *捕获的恶意ip写入运维系统的redis |
@@ -110,17 +110,20 @@ public class MaliciousIpServiceImpl implements MaliciousIpService { | @@ -110,17 +110,20 @@ public class MaliciousIpServiceImpl implements MaliciousIpService { | ||
110 | String[] ipsArray=ips.split(","); | 110 | String[] ipsArray=ips.split(","); |
111 | for(String ip:ipsArray){ | 111 | for(String ip:ipsArray){ |
112 | if(StringUtils.isNotBlank(ip)){ | 112 | if(StringUtils.isNotBlank(ip)){ |
113 | - //String key=MALICIOUS_IP + ip; | ||
114 | - awsRedisTemplate.opsForSet().add(MALICIOUS_IP_SET,ip);//.opsForValue().set(key, "0"); | ||
115 | - //awsRedisTemplate.expire(key, MALICIOUS_IP_EXPIRE, TimeUnit.SECONDS); | 113 | + String smsStr = "成功捕获恶意ip->" + ip ; |
114 | + alarmMsgService.sendSms("MaliciousIp", smsStr, mobile_yunwei); | ||
115 | + | ||
116 | try { | 116 | try { |
117 | maliciousIpMapper.insertMip(influxDBStr, ip); | 117 | maliciousIpMapper.insertMip(influxDBStr, ip); |
118 | } catch (Exception e) { | 118 | } catch (Exception e) { |
119 | - logger.error("insert sms into influxdb failed", e); | 119 | + logger.error("insert mip into influxdb failed", e); |
120 | } | 120 | } |
121 | 121 | ||
122 | - String smsStr = "成功捕获恶意ip->" + ip ; | ||
123 | - //alarmMsgService.sendSms("MaliciousIp", smsStr, mobile_yunwei); | 122 | + try { |
123 | + awsRedisTemplate.opsForSet().add(MALICIOUS_IP_SET,ip);//.opsForValue().set(key, "0"); | ||
124 | + } catch (Exception e) { | ||
125 | + logger.error("insert mip into redis failed", e); | ||
126 | + } | ||
124 | logger.info(" MaliciousIpServiceImpl writeMipsToOpsReids - "+ip); | 127 | logger.info(" MaliciousIpServiceImpl writeMipsToOpsReids - "+ip); |
125 | } | 128 | } |
126 | } | 129 | } |
@@ -150,17 +153,21 @@ public class MaliciousIpServiceImpl implements MaliciousIpService { | @@ -150,17 +153,21 @@ public class MaliciousIpServiceImpl implements MaliciousIpService { | ||
150 | String reason=jo.getString("reason"); | 153 | String reason=jo.getString("reason"); |
151 | String duration=jo.get("duration")==null?"":""+jo.get("duration"); | 154 | String duration=jo.get("duration")==null?"":""+jo.get("duration"); |
152 | if(StringUtils.isNotBlank(ip)){ | 155 | if(StringUtils.isNotBlank(ip)){ |
153 | - //String key=MALICIOUS_IP + ip; | ||
154 | - awsRedisTemplate.opsForSet().add(MALICIOUS_IP_SET,ip);//.opsForValue().set(key, "0"); | ||
155 | - //awsRedisTemplate.expire(key, MALICIOUS_IP_EXPIRE, TimeUnit.SECONDS); | 156 | + String smsStr = "成功捕获恶意ip->" + ip ; |
157 | + alarmMsgService.sendSms("MaliciousIp", smsStr, mobile_yunwei); | ||
158 | + | ||
156 | try { | 159 | try { |
157 | maliciousIpMapper.insertMipObj(influxDBStr, ip, reason, duration); | 160 | maliciousIpMapper.insertMipObj(influxDBStr, ip, reason, duration); |
158 | } catch (Exception e) { | 161 | } catch (Exception e) { |
159 | - logger.error("writeMipsObjToOpsReids insert sms into influxdb failed", e); | 162 | + logger.error("writeMipsObjToOpsReids insert mip into influxdb failed", e); |
163 | + } | ||
164 | + | ||
165 | + try { | ||
166 | + awsRedisTemplate.opsForSet().add(MALICIOUS_IP_SET,ip); | ||
167 | + } catch (Exception e) { | ||
168 | + logger.error("writeMipsObjToOpsReids insert mip into redis failed", e); | ||
160 | } | 169 | } |
161 | 170 | ||
162 | - String smsStr = "成功捕获恶意ip->" + ip ; | ||
163 | - alarmMsgService.sendSms("MaliciousIp", smsStr, mobile_yunwei); | ||
164 | logger.info("MaliciousIpServiceImpl writeMipsObjToOpsReids - "+ip); | 171 | logger.info("MaliciousIpServiceImpl writeMipsObjToOpsReids - "+ip); |
165 | } | 172 | } |
166 | 173 | ||
@@ -453,7 +460,7 @@ public class MaliciousIpServiceImpl implements MaliciousIpService { | @@ -453,7 +460,7 @@ public class MaliciousIpServiceImpl implements MaliciousIpService { | ||
453 | 460 | ||
454 | /** | 461 | /** |
455 | * 移除恶意ip | 462 | * 移除恶意ip |
456 | - * @param ips | 463 | + * @param |
457 | * @return | 464 | * @return |
458 | */ | 465 | */ |
459 | /*@Override | 466 | /*@Override |
-
Please register or login to post a comment