Authored by qinchao

恶意ip

... ... @@ -90,7 +90,7 @@ public class MaliciousIpServiceImpl implements MaliciousIpService {
/**
* 黑名单失效时间7*24小时
*/
private static final int MALICIOUS_IP_EXPIRE = 7*24 * 60 * 60;
//private static final int MALICIOUS_IP_EXPIRE = 7*24 * 60 * 60;
/**
*捕获的恶意ip写入运维系统的redis
... ... @@ -110,17 +110,20 @@ public class MaliciousIpServiceImpl implements MaliciousIpService {
String[] ipsArray=ips.split(",");
for(String ip:ipsArray){
if(StringUtils.isNotBlank(ip)){
//String key=MALICIOUS_IP + ip;
awsRedisTemplate.opsForSet().add(MALICIOUS_IP_SET,ip);//.opsForValue().set(key, "0");
//awsRedisTemplate.expire(key, MALICIOUS_IP_EXPIRE, TimeUnit.SECONDS);
String smsStr = "成功捕获恶意ip->" + ip ;
alarmMsgService.sendSms("MaliciousIp", smsStr, mobile_yunwei);
try {
maliciousIpMapper.insertMip(influxDBStr, ip);
} catch (Exception e) {
logger.error("insert sms into influxdb failed", e);
logger.error("insert mip into influxdb failed", e);
}
String smsStr = "成功捕获恶意ip->" + ip ;
//alarmMsgService.sendSms("MaliciousIp", smsStr, mobile_yunwei);
try {
awsRedisTemplate.opsForSet().add(MALICIOUS_IP_SET,ip);//.opsForValue().set(key, "0");
} catch (Exception e) {
logger.error("insert mip into redis failed", e);
}
logger.info(" MaliciousIpServiceImpl writeMipsToOpsReids - "+ip);
}
}
... ... @@ -150,17 +153,21 @@ public class MaliciousIpServiceImpl implements MaliciousIpService {
String reason=jo.getString("reason");
String duration=jo.get("duration")==null?"":""+jo.get("duration");
if(StringUtils.isNotBlank(ip)){
//String key=MALICIOUS_IP + ip;
awsRedisTemplate.opsForSet().add(MALICIOUS_IP_SET,ip);//.opsForValue().set(key, "0");
//awsRedisTemplate.expire(key, MALICIOUS_IP_EXPIRE, TimeUnit.SECONDS);
String smsStr = "成功捕获恶意ip->" + ip ;
alarmMsgService.sendSms("MaliciousIp", smsStr, mobile_yunwei);
try {
maliciousIpMapper.insertMipObj(influxDBStr, ip, reason, duration);
} catch (Exception e) {
logger.error("writeMipsObjToOpsReids insert sms into influxdb failed", e);
logger.error("writeMipsObjToOpsReids insert mip into influxdb failed", e);
}
try {
awsRedisTemplate.opsForSet().add(MALICIOUS_IP_SET,ip);
} catch (Exception e) {
logger.error("writeMipsObjToOpsReids insert mip into redis failed", e);
}
String smsStr = "成功捕获恶意ip->" + ip ;
alarmMsgService.sendSms("MaliciousIp", smsStr, mobile_yunwei);
logger.info("MaliciousIpServiceImpl writeMipsObjToOpsReids - "+ip);
}
... ... @@ -453,7 +460,7 @@ public class MaliciousIpServiceImpl implements MaliciousIpService {
/**
* 移除恶意ip
* @param ips
* @param
* @return
*/
/*@Override
... ...