修复 导入时只有源IP或目的IP的配置 不能为0.0.0.0
同时有源IP和目的IP两个IP不能一样,仅有一个可为0.0.0.0
This commit is contained in:
@@ -138,8 +138,6 @@ public class CheckIpFormatThread implements Callable<String>{
|
||||
// doLog属性检验
|
||||
this.validDoLog(baseIpCfg,errInfo);
|
||||
|
||||
//IP校验
|
||||
this.validSrcAndDescIp(baseIpCfg.getSrcIpAddress(), baseIpCfg.getDestIpAddress(), configIpPortShow,errInfo);
|
||||
|
||||
// 特殊字段验证
|
||||
// packet ip ratelimit
|
||||
@@ -597,6 +595,20 @@ public class CheckIpFormatThread implements Callable<String>{
|
||||
String subfix=baseIpCfg.getSrcIpAddress().split("-")[1];
|
||||
baseIpCfg.setSrcIpAddress(prefix+"-"+prefix.substring(0, prefix.lastIndexOf(".")+1)+subfix);
|
||||
}
|
||||
//Tip:判断业务是否只展示源IP列,如果是,判断源IP是否是默认值,如果是默认值,提示源IP不能是默认值
|
||||
if (configIpPortShow.indexOf("1") > -1 && configIpPortShow.indexOf("3") == -1) {// 源IP必填
|
||||
String srcIpAddress = baseIpCfg.getSrcIpAddress();
|
||||
Pattern ip4 = Constants.IPV4_IP_PATTERN;
|
||||
Pattern ip6 = Constants.IPV6_IP_PATTERN;
|
||||
Matcher ip4Matcher = ip4.matcher(srcIpAddress);
|
||||
Matcher ip6Matcher = ip6.matcher(srcIpAddress);
|
||||
if ((ip4Matcher.matches() && srcIpAddress.startsWith("0.0.0.0"))
|
||||
|| (ip6Matcher.matches() && srcIpAddress.startsWith("::"))) {
|
||||
errInfo.append(prop.getProperty("client_ip")
|
||||
+ String.format(prop.getProperty("can_not_be"), prop.getProperty("default_value"))
|
||||
+ ";");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (StringUtils.isBlank(baseIpCfg.getDestIpAddress())) {
|
||||
destIpEmpty = true;
|
||||
@@ -608,6 +620,20 @@ public class CheckIpFormatThread implements Callable<String>{
|
||||
String subfix=baseIpCfg.getDestIpAddress().split("-")[1];
|
||||
baseIpCfg.setDestIpAddress(prefix+"-"+prefix.substring(0, prefix.lastIndexOf(".")+1)+subfix);
|
||||
}
|
||||
//Tip:判断业务是否只展示目的IP列,如果是,判断目的IP是否是默认值,如果是默认值,提示目的IP不能是默认值
|
||||
if (configIpPortShow.indexOf("3") > -1 && configIpPortShow.indexOf("1") == -1) {// 目的IP必填
|
||||
String destIpAddress = baseIpCfg.getDestIpAddress();
|
||||
Pattern ip4 = Constants.IPV4_IP_PATTERN;
|
||||
Pattern ip6 = Constants.IPV6_IP_PATTERN;
|
||||
Matcher ip4Matcher = ip4.matcher(destIpAddress);
|
||||
Matcher ip6Matcher = ip6.matcher(destIpAddress);
|
||||
if ((ip4Matcher.matches() && destIpAddress.startsWith("0.0.0.0"))
|
||||
|| (ip6Matcher.matches() && destIpAddress.startsWith("::"))) {
|
||||
errInfo.append(prop.getProperty("server_ip")
|
||||
+ String.format(prop.getProperty("can_not_be"), prop.getProperty("default_value"))
|
||||
+ ";");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (StringUtils.isBlank(baseIpCfg.getSrcPort())) {
|
||||
srcPortEmpty = true;
|
||||
@@ -669,6 +695,12 @@ public class CheckIpFormatThread implements Callable<String>{
|
||||
}
|
||||
baseIpCfg.setIpType(4);
|
||||
}
|
||||
//Tip:增加源IP和目的IP是否相等,如果相等,提示目的IP不能为空
|
||||
if ((configIpPortShow.indexOf("3") > -1 && configIpPortShow.indexOf("1") > -1)
|
||||
&& (baseIpCfg.getDestIpAddress().equals(baseIpCfg.getSrcIpAddress()))) {
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"),
|
||||
prop.getProperty("server_ip", "Server IP")) + ";");
|
||||
}
|
||||
}
|
||||
|
||||
} else if (srcIpEmpty) {// 源IP为空
|
||||
@@ -710,6 +742,12 @@ public class CheckIpFormatThread implements Callable<String>{
|
||||
}
|
||||
baseIpCfg.setIpType(4);
|
||||
}
|
||||
//Tip:增加源IP和目的IP是否相等,如果相等,提示源的IP不能为空
|
||||
if ((configIpPortShow.indexOf("3") > -1 && configIpPortShow.indexOf("1") > -1)
|
||||
&& (baseIpCfg.getSrcIpAddress().equals(baseIpCfg.getDestIpAddress()))) {
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"),
|
||||
prop.getProperty("client_ip", "Client IP")) + ";");
|
||||
}
|
||||
}
|
||||
} else {// 全不为空
|
||||
String srcMatchType = this.validIPAddress("client_ip", errInfo, baseIpCfg.getSrcIpAddress(), ipType,
|
||||
@@ -904,6 +942,10 @@ public class CheckIpFormatThread implements Callable<String>{
|
||||
// TODO 判断Direction的值
|
||||
this.validDirection(errInfo, baseIpCfg.getDirection(), direction);
|
||||
}
|
||||
|
||||
//IP校验
|
||||
// this.validSrcAndDescIp(baseIpCfg.getSrcIpAddress(), baseIpCfg.getDestIpAddress(), configIpPortShow,errInfo);
|
||||
|
||||
if (errInfo.toString().length() > 0) {//
|
||||
errTip.append(String.format(prop.getProperty("line"), baseIpCfg.getIndex()) + ",");
|
||||
errTip.append(errInfo);
|
||||
@@ -1331,24 +1373,4 @@ public class CheckIpFormatThread implements Callable<String>{
|
||||
public void setAsnGroupInfos(Map<Long, AsnGroupInfo> asnGroupInfos) {
|
||||
this.asnGroupInfos = asnGroupInfos;
|
||||
}
|
||||
|
||||
public void validSrcAndDescIp(String srcIp, String descIp, String configIpPortShow, StringBuffer errInfo) {
|
||||
if (configIpPortShow.contains("1") && configIpPortShow.contains("3")) {
|
||||
if (srcIp.equals(descIp)) {
|
||||
errInfo.append(
|
||||
String.format(prop.getProperty("are_the_same"), prop.getProperty("server_ip"), prop.getProperty("client_ip"))
|
||||
+ ";");
|
||||
}
|
||||
} else if (configIpPortShow.contains("1")) {
|
||||
if ("0.0.0.0".equals(srcIp)) {
|
||||
errInfo.append(
|
||||
String.format(prop.getProperty("is_in_wrong_format"), prop.getProperty("server_ip")) + ";");
|
||||
}
|
||||
} else if (configIpPortShow.contains("3")) {
|
||||
if ("0.0.0.0".equals(descIp)) {
|
||||
errInfo.append(
|
||||
String.format(prop.getProperty("is_in_wrong_format"), prop.getProperty("client_ip")) + ";");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user