(1)ip导入调整,子类的同名字段覆盖父类的,用于某些字段的注解重写
(2)新建package template,将IP的template入 (3)IP复用策略配置导入模板调整,由于界面只有IP,端口,所以模板的注解进行了响应调整 (4)配置文件加入了IP和端口的默认值设置 (5)导入IP加入了IP复用策略和限速比例的验证
This commit is contained in:
@@ -32,6 +32,7 @@ import com.beust.jcommander.internal.Lists;
|
||||
import com.nis.domain.FunctionRegionDict;
|
||||
import com.nis.domain.FunctionServiceDict;
|
||||
import com.nis.domain.SysDataDictionaryItem;
|
||||
import com.nis.domain.basics.PolicyGroupInfo;
|
||||
import com.nis.domain.basics.ServiceDictInfo;
|
||||
import com.nis.domain.basics.SysDictInfo;
|
||||
import com.nis.domain.configuration.AreaBean;
|
||||
@@ -39,7 +40,7 @@ import com.nis.domain.configuration.AreaIpCfg;
|
||||
import com.nis.domain.configuration.BaseCfg;
|
||||
import com.nis.domain.configuration.BaseIpCfg;
|
||||
import com.nis.domain.configuration.ComplexStringCfgTemplate;
|
||||
import com.nis.domain.configuration.IpCfgTemplate;
|
||||
import com.nis.domain.configuration.template.IpCfgTemplate;
|
||||
import com.nis.domain.configuration.RequestInfo;
|
||||
import com.nis.domain.configuration.StringCfgTemplate;
|
||||
import com.nis.domain.log.BaseLogEntity;
|
||||
@@ -584,6 +585,38 @@ public class BaseController {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void importCfgTemplate(HttpServletRequest request,HttpServletResponse response,
|
||||
RedirectAttributes redirectAttributes,Integer functionId,Integer cfgRegionCode,Class clazz){
|
||||
Properties msgProp = getMsgProp();
|
||||
try {
|
||||
List<FunctionRegionDict> dictList = DictUtils.getFunctionRegionDictList(functionId);
|
||||
for(FunctionRegionDict dict:dictList){
|
||||
if(dict.getConfigRegionCode()==cfgRegionCode){
|
||||
String fileName = dict.getConfigRegionValue()+".xlsx";
|
||||
if(dict.getRegionType()==1){
|
||||
List<IpCfgTemplate> list = Lists.newArrayList();
|
||||
list.add((IpCfgTemplate)clazz.newInstance());
|
||||
new ExportExcel(msgProp,null, clazz, 2).setDataList(msgProp,list,null).
|
||||
write(request,response, fileName).dispose();
|
||||
}else if(dict.getRegionType()==2){
|
||||
List<StringCfgTemplate> list = Lists.newArrayList();
|
||||
list.add(new StringCfgTemplate());
|
||||
new ExportExcel(msgProp,null, clazz, 2).setDataList(msgProp,list,null).
|
||||
write(request,response, fileName).dispose();
|
||||
}else if(dict.getRegionType()==3){
|
||||
List<ComplexStringCfgTemplate> list = Lists.newArrayList();
|
||||
list.add(new ComplexStringCfgTemplate());
|
||||
new ExportExcel(msgProp,null, clazz, 2).setDataList(msgProp,list,null).
|
||||
write(request,response, fileName).dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
msgProp = null;
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void setLogAction(BaseLogEntity log) {
|
||||
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId());
|
||||
@@ -706,20 +739,67 @@ public class BaseController {
|
||||
// ip_pattern check end
|
||||
//client_ip check start
|
||||
String srcIp=value.getSrcIpAddress();
|
||||
String _msg=checkIP(prop,prop.getProperty("client_ip"),srcIp,ipTypeString,ipPatternString);
|
||||
String _msg="";
|
||||
if("ipmulitiplex".equals(specialItem)) {
|
||||
_msg=checkIP(prop,prop.getProperty("IP"),srcIp,ipTypeString,ipPatternString);
|
||||
}else {
|
||||
_msg=checkIP(prop,prop.getProperty("client_ip"),srcIp,ipTypeString,ipPatternString);
|
||||
}
|
||||
if(StringUtils.isNotBlank(_msg)){
|
||||
errInfo.append(_msg);
|
||||
}
|
||||
//client_ip check end
|
||||
//server_ip check start
|
||||
String destIp=value.getDestIpAddress();
|
||||
if(srcIp.equals(destIp)){
|
||||
String info=String.format(prop.getProperty("are_the_same"),prop.getProperty("client_ip"),prop.getProperty("server_ip"));
|
||||
errInfo.append(info+";");
|
||||
}
|
||||
_msg=checkIP(prop,prop.getProperty("server_ip"),destIp,ipTypeString,ipPatternString);
|
||||
if(StringUtils.isNotBlank(_msg)){
|
||||
errInfo.append(_msg);
|
||||
if("ipmulitiplex".equals(specialItem)) {//set 默认值
|
||||
if(ipPattern!=null&&ipType!=null) {
|
||||
if("ip_subnet".equals(ipPatternString)) {
|
||||
if("ipv4".equals(ipTypeString)) {
|
||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE);
|
||||
}else if("ipv6".equals(ipTypeString)) {
|
||||
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_SUBNET_VALUE);
|
||||
}else if("4over6".equals(ipTypeString)) {
|
||||
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_SUBNET_VALUE);
|
||||
}else if("6over4".equals(ipTypeString)) {
|
||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE);
|
||||
}else if("all".equals(ipTypeString)) {
|
||||
|
||||
}
|
||||
}else if("ip_range".equals(ipPatternString)) {
|
||||
if("ipv4".equals(ipTypeString)) {
|
||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_RANGE_VALUE);
|
||||
}else if("ipv6".equals(ipTypeString)) {
|
||||
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_RANGE_VALUE);
|
||||
}else if("4over6".equals(ipTypeString)) {
|
||||
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_RANGE_VALUE);
|
||||
}else if("6over4".equals(ipTypeString)) {
|
||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_RANGE_VALUE);
|
||||
}else if("all".equals(ipTypeString)) {
|
||||
|
||||
}
|
||||
}else if("ip".equals(ipPatternString)) {
|
||||
if("ipv4".equals(ipTypeString)) {
|
||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
|
||||
}else if("ipv6".equals(ipTypeString)) {
|
||||
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_VALUE);
|
||||
}else if("4over6".equals(ipTypeString)) {
|
||||
value.setDestIpAddress(Constants.IPV6_DEFAULT_IP_VALUE);
|
||||
}else if("6over4".equals(ipTypeString)) {
|
||||
value.setDestIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
|
||||
}else if("all".equals(ipTypeString)) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}else {
|
||||
if(srcIp.equals(destIp)){
|
||||
String info=String.format(prop.getProperty("are_the_same"),prop.getProperty("client_ip"),prop.getProperty("server_ip"));
|
||||
errInfo.append(info+";");
|
||||
}
|
||||
_msg=checkIP(prop,prop.getProperty("server_ip"),destIp,ipTypeString,ipPatternString);
|
||||
if(StringUtils.isNotBlank(_msg)){
|
||||
errInfo.append(_msg);
|
||||
}
|
||||
}
|
||||
//server_ip check end
|
||||
//port_pattern check start
|
||||
@@ -743,14 +823,29 @@ public class BaseController {
|
||||
//port_pattern check end
|
||||
//src_port check start
|
||||
String srcPort=value.getSrcPort();
|
||||
_msg=checkPort(prop,prop.getProperty("client_port"), srcPort, portPatternString);
|
||||
if("ipmulitiplex".equals(specialItem)) {
|
||||
_msg=checkPort(prop,prop.getProperty("port"), srcPort, portPatternString);
|
||||
}else {
|
||||
_msg=checkPort(prop,prop.getProperty("client_port"), srcPort, portPatternString);
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(_msg)){
|
||||
errInfo.append(_msg);
|
||||
}
|
||||
//src_port check end
|
||||
//dest_port check start
|
||||
String destPort=value.getDestPort();
|
||||
_msg=checkPort(prop,prop.getProperty("server_port"), destPort, portPatternString);
|
||||
if("ipmulitiplex".equals(specialItem)) {//set 默认值
|
||||
if(portPattern!=null) {
|
||||
if("port_mask".equals(portPatternString)) {
|
||||
value.setDestPort(Constants.PORT_MASK_DEFAULT);
|
||||
}else if("port".equals(portPatternString)) {
|
||||
value.setDestPort(Constants.PORT_DEFAULT);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
_msg=checkPort(prop,prop.getProperty("server_port"), destPort, portPatternString);
|
||||
}
|
||||
if(StringUtils.isNotBlank(_msg)){
|
||||
errInfo.append(_msg);
|
||||
}
|
||||
@@ -899,6 +994,46 @@ public class BaseController {
|
||||
errInfo.append(String.format(prop.getProperty("num_split_by_comma"), prop.getProperty("label"))+";");
|
||||
}
|
||||
}
|
||||
//group and ir_type check start
|
||||
if("ipmulitiplex".equals(specialItem)) {
|
||||
List<SysDataDictionaryItem> irTypeList = DictUtils.getDictList("IR_TYPE");
|
||||
Integer irType= value.getIrType();
|
||||
if(irType==null) {
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("ir_type"))+";");
|
||||
}else {
|
||||
boolean has=false;
|
||||
for(SysDataDictionaryItem irTypeItem:irTypeList){
|
||||
if(Integer.parseInt(irTypeItem.getItemCode())==protocol.intValue()){
|
||||
has=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!has){
|
||||
errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("ir_type"))+";");
|
||||
}
|
||||
}
|
||||
Integer dnsStrategyId=value.getDnsStrategyId();
|
||||
if(dnsStrategyId==null) {
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("group_name"))+";");
|
||||
}else {
|
||||
PolicyGroupInfo group=policyGroupInfoService.getById(dnsStrategyId.intValue());
|
||||
if(group==null) {
|
||||
errInfo.append(String.format(prop.getProperty("id_not_exists"),dnsStrategyId, prop.getProperty("group_name"))+";");
|
||||
}else if(group.getIsValid()==Constants.VALID_DEL||group.getIsValid()==Constants.VALID_NO) {
|
||||
errInfo.append(String.format(prop.getProperty("id_not_valid"),dnsStrategyId, prop.getProperty("group_name"))+";");
|
||||
}
|
||||
}
|
||||
}
|
||||
if("ipratelimit".equals(specialItem)) {
|
||||
Integer ratelimit=value.getRatelimit();
|
||||
if(ratelimit==null) {
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("ratelimit"))+";");
|
||||
}else {
|
||||
if(ratelimit.intValue()<0||ratelimit.intValue()>100) {
|
||||
errInfo.append(prop.getProperty("ratelimit_limit")+";");
|
||||
}
|
||||
}
|
||||
}
|
||||
//attribute check end
|
||||
if(StringUtils.isNotBlank(errInfo.toString())){
|
||||
msg.append(lineStart).append(errInfo);
|
||||
@@ -906,6 +1041,7 @@ public class BaseController {
|
||||
msg.append("<br/>");
|
||||
}
|
||||
}
|
||||
//group and ir_type check end
|
||||
line++;
|
||||
}
|
||||
if(StringUtils.isNotBlank(msg.toString())){
|
||||
|
||||
Reference in New Issue
Block a user