IP导入加入4over6,6over4,all的判断
This commit is contained in:
@@ -784,7 +784,7 @@ public class BaseController {
|
|||||||
}else if("6over4".equals(ipTypeString)) {
|
}else if("6over4".equals(ipTypeString)) {
|
||||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE);
|
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE);
|
||||||
}else if("all".equals(ipTypeString)) {
|
}else if("all".equals(ipTypeString)) {
|
||||||
|
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE);
|
||||||
}
|
}
|
||||||
}else if("ip_range".equals(ipPatternString)) {
|
}else if("ip_range".equals(ipPatternString)) {
|
||||||
if("ipv4".equals(ipTypeString)) {
|
if("ipv4".equals(ipTypeString)) {
|
||||||
@@ -796,7 +796,7 @@ public class BaseController {
|
|||||||
}else if("6over4".equals(ipTypeString)) {
|
}else if("6over4".equals(ipTypeString)) {
|
||||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_RANGE_VALUE);
|
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_RANGE_VALUE);
|
||||||
}else if("all".equals(ipTypeString)) {
|
}else if("all".equals(ipTypeString)) {
|
||||||
|
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_RANGE_VALUE);
|
||||||
}
|
}
|
||||||
}else if("ip".equals(ipPatternString)) {
|
}else if("ip".equals(ipPatternString)) {
|
||||||
if("ipv4".equals(ipTypeString)) {
|
if("ipv4".equals(ipTypeString)) {
|
||||||
@@ -808,7 +808,7 @@ public class BaseController {
|
|||||||
}else if("6over4".equals(ipTypeString)) {
|
}else if("6over4".equals(ipTypeString)) {
|
||||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
|
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
|
||||||
}else if("all".equals(ipTypeString)) {
|
}else if("all".equals(ipTypeString)) {
|
||||||
|
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -822,6 +822,12 @@ public class BaseController {
|
|||||||
errInfo.append(_msg);
|
errInfo.append(_msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(!"ipmulitiplex".equals(specialItem)&&("4over6".equals(ipTypeString)||"6over4".equals(ipTypeString)||"all".equals(ipTypeString))) {
|
||||||
|
_msg=checkIp(prop, prop.getProperty("client_ip"), srcIp, prop.getProperty("server_ip"), destIp, ipTypeString, ipPatternString);
|
||||||
|
if(StringUtils.isNotBlank(_msg)){
|
||||||
|
errInfo.append(_msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
//server_ip check end
|
//server_ip check end
|
||||||
//port_pattern check start
|
//port_pattern check start
|
||||||
Integer portPattern=value.getPortPattern();
|
Integer portPattern=value.getPortPattern();
|
||||||
@@ -1136,6 +1142,122 @@ public class BaseController {
|
|||||||
}
|
}
|
||||||
return msg.toString();
|
return msg.toString();
|
||||||
}
|
}
|
||||||
|
public static String checkIp(Properties prop,String srcIpName,String srcIp,String destIpName,String destIp,String ipType,String ipPattern) {
|
||||||
|
StringBuffer msg=new StringBuffer();
|
||||||
|
if("4over6".equals(ipType)){
|
||||||
|
if("ip_subnet".equals(ipPattern)){
|
||||||
|
Pattern patternV4=Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP);
|
||||||
|
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_SUBNET_REGEXP);
|
||||||
|
Matcher matcherV4=patternV4.matcher(srcIp);
|
||||||
|
Matcher matcherV6=patternV6.matcher(destIp);
|
||||||
|
if(!matcherV4.matches()){//完全匹配
|
||||||
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), srcIpName)+";");
|
||||||
|
}
|
||||||
|
if(!matcherV6.matches()){//完全匹配
|
||||||
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName)+";");
|
||||||
|
}
|
||||||
|
}else if("ip_range".equals(ipPattern)){
|
||||||
|
Pattern patternV4=Pattern.compile(Constants.IPV4_IP_RANGE_REGEXP);
|
||||||
|
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_RANGE_REGEXP);
|
||||||
|
Matcher matcherV4=patternV4.matcher(srcIp);
|
||||||
|
Matcher matcherV6=patternV6.matcher(destIp);
|
||||||
|
if(!matcherV4.matches()){//完全匹配
|
||||||
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), srcIpName)+";");
|
||||||
|
}
|
||||||
|
if(!matcherV6.matches()){//完全匹配
|
||||||
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName)+";");
|
||||||
|
}
|
||||||
|
}else if("ip".equals(ipPattern)){
|
||||||
|
Pattern patternV4=Pattern.compile(Constants.IPV4_IP_REGEXP);
|
||||||
|
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_REGEXP);
|
||||||
|
Matcher matcherV4=patternV4.matcher(srcIp);
|
||||||
|
Matcher matcherV6=patternV6.matcher(destIp);
|
||||||
|
if(!matcherV4.matches()){//完全匹配
|
||||||
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), srcIpName)+";");
|
||||||
|
}
|
||||||
|
if(!matcherV6.matches()){//完全匹配
|
||||||
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName)+";");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else if("6over4".equals(ipType)) {
|
||||||
|
if("ip_subnet".equals(ipPattern)){
|
||||||
|
Pattern patternV4=Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP);
|
||||||
|
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_SUBNET_REGEXP);
|
||||||
|
Matcher matcherV4=patternV4.matcher(destIp);
|
||||||
|
Matcher matcherV6=patternV6.matcher(srcIp);
|
||||||
|
if(!matcherV4.matches()){//完全匹配
|
||||||
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName)+";");
|
||||||
|
}
|
||||||
|
if(!matcherV6.matches()){//完全匹配
|
||||||
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), srcIpName)+";");
|
||||||
|
}
|
||||||
|
}else if("ip_range".equals(ipPattern)){
|
||||||
|
Pattern patternV4=Pattern.compile(Constants.IPV4_IP_RANGE_REGEXP);
|
||||||
|
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_RANGE_REGEXP);
|
||||||
|
Matcher matcherV4=patternV4.matcher(destIp);
|
||||||
|
Matcher matcherV6=patternV6.matcher(srcIp);
|
||||||
|
if(!matcherV4.matches()){//完全匹配
|
||||||
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"),destIpName)+";");
|
||||||
|
}
|
||||||
|
if(!matcherV6.matches()){//完全匹配
|
||||||
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), srcIpName )+";");
|
||||||
|
}
|
||||||
|
}else if("ip".equals(ipPattern)){
|
||||||
|
Pattern patternV4=Pattern.compile(Constants.IPV4_IP_REGEXP);
|
||||||
|
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_REGEXP);
|
||||||
|
Matcher matcherV4=patternV4.matcher(destIp);
|
||||||
|
Matcher matcherV6=patternV6.matcher(srcIp);
|
||||||
|
if(!matcherV4.matches()){//完全匹配
|
||||||
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName)+";");
|
||||||
|
}
|
||||||
|
if(!matcherV6.matches()){//完全匹配
|
||||||
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), srcIpName)+";");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else if("all".equals(ipType)) {
|
||||||
|
if("ip_subnet".equals(ipPattern)){
|
||||||
|
Pattern patternV4=Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP);
|
||||||
|
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_SUBNET_REGEXP);
|
||||||
|
Matcher matcherSrcIpV4=patternV4.matcher(srcIp);
|
||||||
|
Matcher matcherSrcIpV6=patternV6.matcher(srcIp);
|
||||||
|
Matcher matcherDestIpV4=patternV4.matcher(destIp);
|
||||||
|
Matcher matcherDestIpV6=patternV6.matcher(destIp);
|
||||||
|
if(!matcherSrcIpV4.matches()&&!matcherSrcIpV6.matches()){//完全匹配
|
||||||
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), srcIpName)+";");
|
||||||
|
}
|
||||||
|
if(!matcherDestIpV4.matches()&&!matcherDestIpV6.matches()){//完全匹配
|
||||||
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName)+";");
|
||||||
|
}
|
||||||
|
}else if("ip_range".equals(ipPattern)){
|
||||||
|
Pattern patternV4=Pattern.compile(Constants.IPV4_IP_RANGE_REGEXP);
|
||||||
|
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_RANGE_REGEXP);
|
||||||
|
Matcher matcherSrcIpV4=patternV4.matcher(srcIp);
|
||||||
|
Matcher matcherSrcIpV6=patternV6.matcher(srcIp);
|
||||||
|
Matcher matcherDestIpV4=patternV4.matcher(destIp);
|
||||||
|
Matcher matcherDestIpV6=patternV6.matcher(destIp);
|
||||||
|
if(!matcherSrcIpV4.matches()&&!matcherSrcIpV6.matches()){//完全匹配
|
||||||
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), srcIpName)+";");
|
||||||
|
}
|
||||||
|
if(!matcherDestIpV4.matches()&&!matcherDestIpV6.matches()){//完全匹配
|
||||||
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName)+";");
|
||||||
|
}
|
||||||
|
}else if("ip".equals(ipPattern)){
|
||||||
|
Pattern patternV4=Pattern.compile(Constants.IPV4_IP_REGEXP);
|
||||||
|
Pattern patternV6=Pattern.compile(Constants.IPV6_IP_REGEXP);
|
||||||
|
Matcher matcherSrcIpV4=patternV4.matcher(srcIp);
|
||||||
|
Matcher matcherSrcIpV6=patternV6.matcher(srcIp);
|
||||||
|
Matcher matcherDestIpV4=patternV4.matcher(destIp);
|
||||||
|
Matcher matcherDestIpV6=patternV6.matcher(destIp);
|
||||||
|
if(!matcherSrcIpV4.matches()&&!matcherSrcIpV6.matches()){//完全匹配
|
||||||
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), srcIpName)+";");
|
||||||
|
}
|
||||||
|
if(!matcherDestIpV4.matches()&&!matcherDestIpV6.matches()){//完全匹配
|
||||||
|
msg.append(String.format(prop.getProperty("is_in_wrong_format"), destIpName)+";");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return msg.toString();
|
||||||
|
}
|
||||||
public static String checkPort(Properties prop,String portName,String port,String portPattern){
|
public static String checkPort(Properties prop,String portName,String port,String portPattern){
|
||||||
StringBuffer msg=new StringBuffer();
|
StringBuffer msg=new StringBuffer();
|
||||||
if(StringUtils.isBlank(port)){
|
if(StringUtils.isBlank(port)){
|
||||||
|
|||||||
Reference in New Issue
Block a user