26号之前的asn ip导入版本,区分ipv4和ipv6,v4和v6互不影响

This commit is contained in:
duandongmei
2019-01-29 09:22:33 +06:00
parent 32d4ad3cd7
commit 2abffe2e34
5 changed files with 42 additions and 35 deletions

View File

@@ -27,6 +27,7 @@ import com.nis.domain.configuration.template.IpRateLimitTemplate;
//import com.nis.util.AsnCacheUtils;
import com.nis.util.Constants;
import com.nis.util.DictUtils;
import com.nis.util.StringUtil;
public class CheckIpFormatThread implements Callable<String>{
private Logger logger=Logger.getLogger(CheckIpFormatThread.class);
@@ -259,11 +260,7 @@ public class CheckIpFormatThread implements Callable<String>{
}
if (regionDict.getFunctionId().equals(600)) {//asn
String organization=baseIpCfg.getOrganization();
if(StringUtils.isBlank(organization)) {
errInfo.append(
String.format(prop.getProperty("can_not_null"), prop.getProperty("organization","Organization"))
+ ";");
}else {
if(!StringUtils.isBlank(organization)) {
if(organization.length() > 1024){
errInfo.append(prop.getProperty("asn_name")+prop.getProperty("length_error")+" "+String.format(prop.getProperty("max_length")+":1024") + ";");
}else {
@@ -272,14 +269,9 @@ public class CheckIpFormatThread implements Callable<String>{
}
baseIpCfg.setOrganization(organization.trim().toUpperCase());
}
}
String country=baseIpCfg.getCountry();
if(StringUtils.isBlank(country)) {
errInfo.append(
String.format(prop.getProperty("can_not_null"), prop.getProperty("country"))
+ ";");
}else {
if(!StringUtils.isBlank(country)) {
if(country.length() > 512){
errInfo.append(prop.getProperty("country_code")+prop.getProperty("length_error")+" "+String.format(prop.getProperty("max_length")+":512") + ";");
}else {
@@ -287,11 +279,7 @@ public class CheckIpFormatThread implements Callable<String>{
}
}
String detail=baseIpCfg.getDetail();
if(StringUtils.isBlank(detail)) {
errInfo.append(
String.format(prop.getProperty("can_not_null"), prop.getProperty("detail"))
+ ";");
}else {
if(!StringUtils.isBlank(detail)) {
if(detail.length() > 1024||detail.length()<4){
errInfo.append(prop.getProperty("details")+prop.getProperty("length_error")+" "+String.format(prop.getProperty("min_length")+":4,"+prop.getProperty("max_length")+":1024") + ";");
}else {
@@ -303,7 +291,7 @@ public class CheckIpFormatThread implements Callable<String>{
if(StringUtils.isBlank(userRegion1)) {
errInfo.append(
String.format(prop.getProperty("can_not_null"), prop.getProperty("asn_no"))
+ ";");
+ ";org:"+baseIpCfg.getOrganization()+ ";asn:"+baseIpCfg.getOrganization()+ ";ip:"+baseIpCfg.getDestIpAddress());
}else {
try {
Long asnNo=Long.parseLong(userRegion1);
@@ -312,17 +300,21 @@ public class CheckIpFormatThread implements Callable<String>{
String.format(prop.getProperty("must_between"),"1","4294967295" )
+ ";");
}else {
if(StringUtil.isEmpty(baseIpCfg.getOrganization())){
baseIpCfg.setOrganization(asnNo.toString());
baseIpCfg.setCfgDesc(asnNo.toString());
}
// ConfigGroupInfo configGroupInfo=asnIpCfgService.getConfigGroupInfoByAsnNo(asnNo);
if(asnNos!=null) {
AsnGroupInfo configGroupInfo=asnGroupInfos==null?null:asnGroupInfos.get(asnNo);//从缓存中取
//缓存中没有
if(configGroupInfo==null) {
synchronized (Constants.IMPORT_LOCK) {
if(StringUtils.isNotBlank(baseIpCfg.getOrganization())&&StringUtils.isNotBlank(baseIpCfg.getCountry())) {
if(StringUtils.isNotBlank(baseIpCfg.getOrganization())) {
AsnGroupInfo groupInfo=new AsnGroupInfo();
groupInfo.setOrganization(baseIpCfg.getOrganization().trim().toUpperCase());
groupInfo.setCountry(baseIpCfg.getCountry().trim().toUpperCase());
groupInfo.setDetail(baseIpCfg.getDetail().trim());
groupInfo.setCountry(StringUtil.isEmpty(baseIpCfg.getCountry()) ? "":baseIpCfg.getCountry().trim().toUpperCase());
groupInfo.setDetail(StringUtil.isEmpty(baseIpCfg.getDetail()) ? "":baseIpCfg.getDetail().trim());
groupInfo.setIsValid(0);
groupInfo.setAsnId(asnNo);
if(asnNos.get(0).containsKey(asnNo)) {
@@ -353,12 +345,8 @@ public class CheckIpFormatThread implements Callable<String>{
if(!configGroupInfo.getOrganization().equalsIgnoreCase(baseIpCfg.getOrganization().trim())) {
errInfo.append(prop.getProperty("organization","Organization")+" "+prop.getProperty("mismatch","Mismatch"));
}
if(!configGroupInfo.getCountry().equalsIgnoreCase(baseIpCfg.getCountry().trim())) {
errInfo.append(prop.getProperty("country","Country")+" "+prop.getProperty("mismatch","Mismatch"));
}
if(!configGroupInfo.getDetail().equalsIgnoreCase(baseIpCfg.getDetail().trim())) {
errInfo.append(prop.getProperty("detail","Detail")+" "+prop.getProperty("mismatch","Mismatch"));
}
configGroupInfo.setDetail(baseIpCfg.getDetail());
configGroupInfo.setCountry(baseIpCfg.getCountry());
if(StringUtils.isBlank(errInfo.toString())) {
asnNos.get(1).put(asnNo,configGroupInfo);
}