IP Range导入自动格式转换0.0.0.1-2转换为0.0.0.1-0.0.0.2
This commit is contained in:
@@ -62,6 +62,8 @@ public final class Constants {
|
||||
public static final String IPV4_IP_SUBNET_REGEXP=Configurations.getStringProperty("ipv4_ip_subnet_regexp", "*");
|
||||
public static final String IPV6_IP_SUBNET_REGEXP=Configurations.getStringProperty("ipv6_ip_subnet_regexp", "*");
|
||||
public static final String IPV4_IP_RANGE_REGEXP=Configurations.getStringProperty("ipv4_ip_range_regexp", "*");
|
||||
//0.0.0.1-2这种格式
|
||||
public static final String IPV4_IP_RANGE_REGEXP_NEW=Configurations.getStringProperty("ipv4_ip_range_regexp_new", "*");
|
||||
public static final String IPV6_IP_RANGE_REGEXP=Configurations.getStringProperty("ipv6_ip_range_regexp", "*");
|
||||
public static final String IPV4_IP_REGEXP=Configurations.getStringProperty("ipv4_ip_regexp", "*");
|
||||
public static final String IPV6_IP_REGEXP=Configurations.getStringProperty("ipv6_ip_regexp", "*");
|
||||
|
||||
@@ -1480,11 +1480,28 @@ public class BaseController {
|
||||
boolean destIpEmpty = false;
|
||||
boolean srcPortEmpty = false;
|
||||
boolean destPortEmpty = false;
|
||||
Pattern ipv4IpRangeRegexpNew = Pattern.compile(Constants.IPV4_IP_RANGE_REGEXP_NEW);
|
||||
if (StringUtil.isEmpty(baseIpCfg.getSrcIpAddress())) {
|
||||
srcIpEmpty = true;
|
||||
}else {
|
||||
//处理0.0.0.1-2这种格式,转换为0.0.0.1-0.0.0.2
|
||||
Matcher m=ipv4IpRangeRegexpNew.matcher(baseIpCfg.getSrcIpAddress());
|
||||
if(m.matches()) {
|
||||
String prefix=baseIpCfg.getSrcIpAddress().split("-")[0];
|
||||
String subfix=baseIpCfg.getSrcIpAddress().split("-")[1];
|
||||
baseIpCfg.setSrcIpAddress(prefix+"-"+prefix.substring(0, prefix.lastIndexOf(".")+1)+subfix);
|
||||
}
|
||||
}
|
||||
if (StringUtil.isEmpty(baseIpCfg.getDestIpAddress())) {
|
||||
destIpEmpty = true;
|
||||
}else {
|
||||
//处理0.0.0.1-2这种格式,转换为0.0.0.1-0.0.0.2
|
||||
Matcher m=ipv4IpRangeRegexpNew.matcher(baseIpCfg.getDestIpAddress());
|
||||
if(m.matches()) {
|
||||
String prefix=baseIpCfg.getDestIpAddress().split("-")[0];
|
||||
String subfix=baseIpCfg.getDestIpAddress().split("-")[1];
|
||||
baseIpCfg.setDestIpAddress(prefix+"-"+prefix.substring(0, prefix.lastIndexOf(".")+1)+subfix);
|
||||
}
|
||||
}
|
||||
if (StringUtil.isEmpty(baseIpCfg.getSrcPort())) {
|
||||
srcPortEmpty = true;
|
||||
|
||||
Reference in New Issue
Block a user