(1)细化IPV4掩码范围验证的提示
(2)IP不能为xxxx的提示前方加入空格 (3)DNS响应策略导入模板,导入功能提交
This commit is contained in:
@@ -60,6 +60,7 @@ import com.nis.domain.configuration.template.ComplexStringAllTemplate;
|
||||
import com.nis.domain.configuration.template.DdosIpTemplate;
|
||||
import com.nis.domain.configuration.template.DnsComplexStringTemplate;
|
||||
import com.nis.domain.configuration.template.DnsIpTemplate;
|
||||
import com.nis.domain.configuration.template.DnsResStrategyTemplate;
|
||||
import com.nis.domain.configuration.template.IpAllTemplate;
|
||||
import com.nis.domain.configuration.template.IpCfgTemplate;
|
||||
import com.nis.domain.configuration.template.IpPayloadTemplate;
|
||||
@@ -79,6 +80,7 @@ import com.nis.util.DateUtils;
|
||||
import com.nis.util.DictUtils;
|
||||
import com.nis.util.JsonMapper;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.util.excel.ExcelField;
|
||||
import com.nis.util.excel.ExportExcel;
|
||||
import com.nis.util.excel.ImportExcel;
|
||||
import com.nis.web.dao.configuration.IpCfgDao;
|
||||
@@ -1064,7 +1066,7 @@ public class BaseController {
|
||||
}
|
||||
return stringList;
|
||||
}
|
||||
|
||||
|
||||
public List<ComplexkeywordCfg> checkComplexStringCfg(FunctionServiceDict serviceDict, FunctionRegionDict regionDict,
|
||||
List<?> list) throws ServiceException {
|
||||
List<ComplexkeywordCfg> stringList = new ArrayList<ComplexkeywordCfg>();
|
||||
@@ -1622,7 +1624,7 @@ public class BaseController {
|
||||
baseIpCfg.setIpPattern(2);
|
||||
if (baseIpCfg.getSrcIpAddress()
|
||||
.startsWith(Constants.IPV6_DEFAULT_IP_RANGE_VALUE.split("-")[0])) {
|
||||
errInfo.append(prop.getProperty("client_ip")
|
||||
errInfo.append(prop.getProperty("client_ip")+" "
|
||||
+ String.format(prop.getProperty("can_not_be"),
|
||||
Constants.IPV6_DEFAULT_IP_RANGE_VALUE.split("-")[0])
|
||||
+ ";");
|
||||
@@ -1634,7 +1636,7 @@ public class BaseController {
|
||||
if (baseIpCfg.getSrcIpAddress()
|
||||
.startsWith(Constants.IPV6_DEFAULT_IP_SUBNET_VALUE.split("/")[0])) {
|
||||
errInfo.append(
|
||||
prop.getProperty("client_ip")
|
||||
prop.getProperty("client_ip")+" "
|
||||
+ String.format(prop.getProperty("can_not_be"),
|
||||
Constants.IPV6_DEFAULT_IP_SUBNET_VALUE.split("/")[0])
|
||||
+ ";");
|
||||
@@ -1644,7 +1646,7 @@ public class BaseController {
|
||||
baseIpCfg.setDestIpAddress(Constants.IPV6_DEFAULT_IP_VALUE);
|
||||
baseIpCfg.setIpPattern(3);
|
||||
if (baseIpCfg.getSrcIpAddress().equals(Constants.IPV6_DEFAULT_IP_VALUE)) {
|
||||
errInfo.append(prop.getProperty("client_ip") + String.format(
|
||||
errInfo.append(prop.getProperty("client_ip")+" " + String.format(
|
||||
prop.getProperty("can_not_be"), Constants.IPV6_DEFAULT_IP_VALUE) + ";");
|
||||
}
|
||||
}
|
||||
@@ -1657,7 +1659,7 @@ public class BaseController {
|
||||
baseIpCfg.setIpPattern(2);
|
||||
if (baseIpCfg.getSrcIpAddress()
|
||||
.startsWith(Constants.IPV4_DEFAULT_IP_RANGE_VALUE.split("-")[0])) {
|
||||
errInfo.append(prop.getProperty("client_ip")
|
||||
errInfo.append(prop.getProperty("client_ip")+" "
|
||||
+ String.format(prop.getProperty("can_not_be"),
|
||||
Constants.IPV4_DEFAULT_IP_RANGE_VALUE.split("-")[0])
|
||||
+ ";");
|
||||
@@ -1669,7 +1671,7 @@ public class BaseController {
|
||||
if (baseIpCfg.getSrcIpAddress()
|
||||
.startsWith(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE.split("/")[0])) {
|
||||
errInfo.append(
|
||||
prop.getProperty("client_ip")
|
||||
prop.getProperty("client_ip")+" "
|
||||
+ String.format(prop.getProperty("can_not_be"),
|
||||
Constants.IPV4_DEFAULT_IP_SUBNET_VALUE.split("/")[0])
|
||||
+ ";");
|
||||
@@ -1679,7 +1681,7 @@ public class BaseController {
|
||||
baseIpCfg.setDestIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
|
||||
baseIpCfg.setIpPattern(3);
|
||||
if (baseIpCfg.getSrcIpAddress().equals(Constants.IPV4_DEFAULT_IP_VALUE)) {
|
||||
errInfo.append(prop.getProperty("client_ip") + String.format(
|
||||
errInfo.append(prop.getProperty("client_ip")+" " + String.format(
|
||||
prop.getProperty("can_not_be"), Constants.IPV4_DEFAULT_IP_VALUE) + ";");
|
||||
}
|
||||
}
|
||||
@@ -1727,7 +1729,7 @@ public class BaseController {
|
||||
baseIpCfg.setIpPattern(2);
|
||||
if (baseIpCfg.getDestIpAddress()
|
||||
.startsWith(Constants.IPV6_DEFAULT_IP_RANGE_VALUE.split("-")[0])) {
|
||||
errInfo.append(prop.getProperty("server_ip")
|
||||
errInfo.append(prop.getProperty("server_ip")+" "
|
||||
+ String.format(prop.getProperty("can_not_be"),
|
||||
Constants.IPV6_DEFAULT_IP_RANGE_VALUE.split("-")[0])
|
||||
+ ";");
|
||||
@@ -1739,7 +1741,7 @@ public class BaseController {
|
||||
if (baseIpCfg.getDestIpAddress()
|
||||
.startsWith(Constants.IPV6_DEFAULT_IP_SUBNET_VALUE.split("/")[0])) {
|
||||
errInfo.append(
|
||||
prop.getProperty("server_ip")
|
||||
prop.getProperty("server_ip")+" "
|
||||
+ String.format(prop.getProperty("can_not_be"),
|
||||
Constants.IPV6_DEFAULT_IP_SUBNET_VALUE.split("/")[0])
|
||||
+ ";");
|
||||
@@ -1749,7 +1751,7 @@ public class BaseController {
|
||||
baseIpCfg.setSrcIpAddress(Constants.IPV6_DEFAULT_IP_VALUE);
|
||||
baseIpCfg.setIpPattern(3);
|
||||
if (baseIpCfg.getDestIpAddress().equals(Constants.IPV6_DEFAULT_IP_VALUE)) {
|
||||
errInfo.append(prop.getProperty("server_ip") + String.format(
|
||||
errInfo.append(prop.getProperty("server_ip")+" " + String.format(
|
||||
prop.getProperty("can_not_be"), Constants.IPV6_DEFAULT_IP_VALUE) + ";");
|
||||
}
|
||||
}
|
||||
@@ -1764,7 +1766,7 @@ public class BaseController {
|
||||
baseIpCfg.setIpPattern(2);
|
||||
if (baseIpCfg.getDestIpAddress()
|
||||
.startsWith(Constants.IPV4_DEFAULT_IP_RANGE_VALUE.split("-")[0])) {
|
||||
errInfo.append(prop.getProperty("server_ip")
|
||||
errInfo.append(prop.getProperty("server_ip")+" "
|
||||
+ String.format(prop.getProperty("can_not_be"),
|
||||
Constants.IPV4_DEFAULT_IP_RANGE_VALUE.split("-")[0])
|
||||
+ ";");
|
||||
@@ -1776,7 +1778,7 @@ public class BaseController {
|
||||
if (baseIpCfg.getDestIpAddress()
|
||||
.startsWith(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE.split("/")[0])) {
|
||||
errInfo.append(
|
||||
prop.getProperty("server_ip")
|
||||
prop.getProperty("server_ip")+" "
|
||||
+ String.format(prop.getProperty("can_not_be"),
|
||||
Constants.IPV4_DEFAULT_IP_SUBNET_VALUE.split("/")[0])
|
||||
+ ";");
|
||||
@@ -1786,7 +1788,7 @@ public class BaseController {
|
||||
baseIpCfg.setSrcIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
|
||||
baseIpCfg.setIpPattern(3);
|
||||
if (baseIpCfg.getDestIpAddress().equals(Constants.IPV4_DEFAULT_IP_VALUE)) {
|
||||
errInfo.append(prop.getProperty("server_ip") + String.format(
|
||||
errInfo.append(prop.getProperty("server_ip")+" " + String.format(
|
||||
prop.getProperty("can_not_be"), Constants.IPV4_DEFAULT_IP_VALUE) + ";");
|
||||
}
|
||||
}
|
||||
@@ -1924,7 +1926,85 @@ public class BaseController {
|
||||
}
|
||||
return ipList;
|
||||
}
|
||||
|
||||
public List<DnsResStrategy> checkDnsResStrategyCfg(FunctionServiceDict serviceDict, FunctionRegionDict regionDict, List<?> list)
|
||||
throws ServiceException {
|
||||
List<DnsResStrategy> dnsResStrategies=Lists.newArrayList();
|
||||
Properties prop = this.getMsgProp();
|
||||
StringBuffer errTip = new StringBuffer();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
StringBuffer errInfo = new StringBuffer();
|
||||
DnsResStrategy dnsResStrategy=new DnsResStrategy();
|
||||
BeanUtils.copyProperties(list.get(i), dnsResStrategy);
|
||||
String groupName=dnsResStrategy.getCfgDesc();
|
||||
if(StringUtils.isBlank(groupName)) {
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"),
|
||||
prop.getProperty("policy_name")) + ";");
|
||||
}
|
||||
Integer resGroup1Id=dnsResStrategy.getResGroup1Id();
|
||||
if(resGroup1Id==null) {
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"),
|
||||
prop.getProperty("group")) + ";");
|
||||
}else {
|
||||
PolicyGroupInfo info=policyGroupInfoService.getById(resGroup1Id);
|
||||
if(info==null) {
|
||||
errInfo.append(String.format(prop.getProperty("is_incorrect"),
|
||||
prop.getProperty("group")) + ";");
|
||||
}
|
||||
}
|
||||
Integer resGroup1Num=dnsResStrategy.getResGroup1Num();
|
||||
if(resGroup1Num==null) {
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"),
|
||||
prop.getProperty("res_group_num")) + ";");
|
||||
}
|
||||
String ttl=dnsResStrategy.getTtl();
|
||||
if(StringUtils.isBlank(ttl)) {
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"),
|
||||
prop.getProperty("min_ttl")) + ";");
|
||||
}else {
|
||||
Pattern p=Pattern.compile("\\d+\\-\\d+");
|
||||
Matcher m=p.matcher(ttl);
|
||||
if(!m.matches()) {
|
||||
errInfo.append(String.format(prop.getProperty("is_incorrect"),
|
||||
prop.getProperty("min_ttl")) + ";");
|
||||
}else {
|
||||
String minTtl=ttl.split("-")[0];
|
||||
String maxTtl=ttl.split("-")[1];
|
||||
Integer min=null,max=null;
|
||||
try {
|
||||
min=Integer.parseInt(minTtl);
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
errInfo.append(String.format(prop.getProperty("is_incorrect"),
|
||||
prop.getProperty("min_ttl")) + ";");
|
||||
}
|
||||
try {
|
||||
max=Integer.parseInt(maxTtl);
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
errInfo.append(String.format(prop.getProperty("is_incorrect"),
|
||||
prop.getProperty("min_ttl")) + ";");
|
||||
}
|
||||
if(min.intValue()>max.intValue())
|
||||
{errInfo.append(String.format(prop.getProperty("is_incorrect"),
|
||||
prop.getProperty("min_ttl")) + ";");
|
||||
}else {
|
||||
dnsResStrategy.setMinTtl(min);
|
||||
dnsResStrategy.setMaxTtl(max);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (errInfo.toString().length() > 0) {//
|
||||
errTip.append(String.format(prop.getProperty("line"), i + 2) + ",");
|
||||
errTip.append(errInfo);
|
||||
errTip.append("<br>");
|
||||
}
|
||||
dnsResStrategies.add(dnsResStrategy);
|
||||
}
|
||||
if (errTip.toString().length() > 0) {
|
||||
throw new ServiceException(errTip.toString());
|
||||
}
|
||||
return dnsResStrategies;
|
||||
}
|
||||
/**
|
||||
* 协议与端口验证规则
|
||||
*
|
||||
@@ -2261,6 +2341,7 @@ public class BaseController {
|
||||
throws ServiceException {
|
||||
Properties prop = this.getMsgProp();
|
||||
String matchType = "";
|
||||
Pattern ipv4IpSubnetOriginalRegexp = Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP_ORIGINAL);
|
||||
Pattern ipv4IpSubnetRegexp = Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP);
|
||||
Pattern ipv6IpSubnetRegexp = Pattern.compile(Constants.IPV6_IP_SUBNET_REGEXP);
|
||||
Pattern ipv4IpRangeRegexp = Pattern.compile(Constants.IPV4_IP_RANGE_REGEXP);
|
||||
@@ -2291,9 +2372,14 @@ public class BaseController {
|
||||
if (matcher.matches()) {
|
||||
matchType = "IPV6_IP_RANGE";
|
||||
} else {
|
||||
errInfo.append(
|
||||
String.format(prop.getProperty("is_in_wrong_format"), prop.getProperty(ipName))
|
||||
+ ";");
|
||||
matcher = ipv4IpSubnetOriginalRegexp.matcher(ip);
|
||||
if(matcher.matches()) {
|
||||
errInfo.append(prop.getProperty(ipName)+" "+prop.getProperty("ipv4_mask_range_tip")+ ";");
|
||||
}else {
|
||||
errInfo.append(
|
||||
String.format(prop.getProperty("is_in_wrong_format"), prop.getProperty(ipName))
|
||||
+ ";");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2763,68 +2849,7 @@ public class BaseController {
|
||||
* @exception @since
|
||||
* 1.0.0
|
||||
*/
|
||||
public static String checkIP(Properties prop, String ipName, String ip, String ipType, String ipPattern) {
|
||||
StringBuffer msg = new StringBuffer();
|
||||
if (StringUtils.isBlank(ip)) {
|
||||
msg.append(String.format(prop.getProperty("can_not_null"), ipName) + ";");
|
||||
} else {
|
||||
if ("ipv4".equals(ipType)) {
|
||||
if ("ip_subnet".equals(ipPattern)) {
|
||||
Pattern pattern = Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP);
|
||||
Matcher matcher = pattern.matcher(ip);
|
||||
if (!matcher.matches()) {// 完全匹配
|
||||
msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName) + ";");
|
||||
}
|
||||
} else if ("ip_range".equals(ipPattern)) {
|
||||
Pattern pattern = Pattern.compile(Constants.IPV4_IP_RANGE_REGEXP);
|
||||
Matcher matcher = pattern.matcher(ip);
|
||||
if (!matcher.matches()) {// 完全匹配
|
||||
msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName) + ";");
|
||||
}
|
||||
} else if ("ip".equals(ipPattern)) {
|
||||
Pattern pattern = Pattern.compile(Constants.IPV4_IP_REGEXP);
|
||||
Matcher matcher = pattern.matcher(ip);
|
||||
if (!matcher.matches()) {// 完全匹配
|
||||
msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName) + ";");
|
||||
}
|
||||
}
|
||||
} else if ("ipv6".equals(ipType)) {
|
||||
if ("ip_subnet".equals(ipPattern)) {
|
||||
Pattern pattern = Pattern.compile(Constants.IPV6_IP_SUBNET_REGEXP);
|
||||
Matcher matcher = pattern.matcher(ip);
|
||||
if (!matcher.matches()) {// 完全匹配
|
||||
msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName) + ";");
|
||||
}
|
||||
} else if ("ip_range".equals(ipPattern)) {
|
||||
Pattern pattern = Pattern.compile(Constants.IPV6_IP_RANGE_REGEXP);
|
||||
Matcher matcher = pattern.matcher(ip);
|
||||
if (!matcher.matches()) {// 完全匹配
|
||||
msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName) + ";");
|
||||
}
|
||||
} else if ("ip".equals(ipPattern)) {
|
||||
Pattern pattern = Pattern.compile(Constants.IPV6_IP_REGEXP);
|
||||
Matcher matcher = pattern.matcher(ip);
|
||||
if (!matcher.matches()) {// 完全匹配
|
||||
msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName) + ";");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return msg.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* checkIP(IP格式验证) (这里描述这个方法适用条件 – 可选)
|
||||
*
|
||||
* @param ipName
|
||||
* @param ip
|
||||
* @param ipType
|
||||
* @param ipPattern
|
||||
* @return String
|
||||
* @exception @since
|
||||
* 1.0.0
|
||||
*/
|
||||
@Deprecated
|
||||
public static String checkIP(Properties prop, String ipName, String ip, Integer ipType, Integer ipPattern) {
|
||||
StringBuffer msg = new StringBuffer();
|
||||
if (StringUtils.isBlank(ip)) {
|
||||
@@ -2874,7 +2899,7 @@ public class BaseController {
|
||||
}
|
||||
return msg.toString();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static String checkIp(Properties prop, String srcIpName, String srcIp, String destIpName, String destIp,
|
||||
Integer ipType, Integer ipPattern) {
|
||||
StringBuffer msg = new StringBuffer();
|
||||
@@ -3176,6 +3201,7 @@ public class BaseController {
|
||||
List<ComplexkeywordCfg> complexkeywordCfgs = new ArrayList<ComplexkeywordCfg>();
|
||||
List<CfgIndexInfo> cfgIndexInfos = new ArrayList<CfgIndexInfo>();
|
||||
List<AppPolicyCfg> appPolicyCfgs = new ArrayList<AppPolicyCfg>();
|
||||
List<DnsResStrategy> dnsResStrategies=Lists.newArrayList();
|
||||
FunctionRegionDict appRegion = null;
|
||||
if(serviceDict!=null) {
|
||||
String regionCode = serviceDict.getRegionCode();
|
||||
@@ -3253,6 +3279,12 @@ public class BaseController {
|
||||
complexkeywordCfgs = this.checkComplexStringCfg(serviceDict, regionDict, list);
|
||||
}
|
||||
|
||||
}else if (regionDict.getRegionType().equals(6)) {// 回调类
|
||||
if (regionDict.getFunctionId().equals(400)) {
|
||||
List<DnsResStrategyTemplate> list = ei.getDataList(DnsResStrategyTemplate.class,
|
||||
this.getMsgProp(),regionDict);
|
||||
dnsResStrategies = this.checkDnsResStrategyCfg(serviceDict, regionDict, list);
|
||||
}
|
||||
}
|
||||
Date date = new Date();
|
||||
String specServiceId = request.getParameter("appId");
|
||||
@@ -3542,6 +3574,42 @@ public class BaseController {
|
||||
if(regionDict.getDictId().intValue()==11) {
|
||||
websiteCfgService.saveHttpResHeadCfg(complexkeywordCfgs);
|
||||
}
|
||||
}else if(regionDict.getRegionType().equals(6)) {
|
||||
if(regionDict.getFunctionId().equals(400)) {
|
||||
List<Integer> compileIds=Lists.newArrayList();
|
||||
try {
|
||||
compileIds = ConfigServiceUtil.getId(1,dnsResStrategies.size());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.info("获取编译ID出错");
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
|
||||
}
|
||||
int ind=0;
|
||||
for(DnsResStrategy cfg:dnsResStrategies) {
|
||||
cfg.setAction(serviceDict.getAction());
|
||||
cfg.setAuditorId(UserUtils.getUser().getId());
|
||||
cfg.setAuditTime(date);
|
||||
cfg.setCfgRegionCode(regionDict.getConfigRegionCode());
|
||||
cfg.setCfgType(regionDict.getConfigRegionValue());
|
||||
cfg.setCreateTime(date);
|
||||
cfg.setCreatorId(UserUtils.getUser().getId());
|
||||
cfg.setDoLog(1);
|
||||
cfg.setFunctionId(regionDict.getFunctionId());
|
||||
cfg.setIsAudit(0);
|
||||
cfg.setIsValid(0);
|
||||
cfg.setIsAreaEffective(0);
|
||||
cfg.setAttribute("0");
|
||||
cfg.setClassify("0");
|
||||
cfg.setLable("0");
|
||||
cfg.setRequestId(StringUtil.isEmpty(requestId) ? 0 : requestId);
|
||||
cfg.setServiceId(serviceDict.getServiceId());
|
||||
cfg.setCompileId(compileIds.get(ind));
|
||||
ind++;
|
||||
}
|
||||
if(dnsResStrategies.size()>0) {
|
||||
dnsResStrategyService.saveDnsResStrategies(dnsResStrategies);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cfgIndexInfos != null && cfgIndexInfos.size() > 0) {
|
||||
ipCfgService.saveCfgIndexOf(cfgIndexInfos);
|
||||
|
||||
Reference in New Issue
Block a user