增加http block、redirect、monit、whitelist、replace功能

修改清空配置库sql语句
修改欺骗ip策略可空
This commit is contained in:
duandongmei
2018-07-24 15:20:05 +08:00
parent 950872b5d1
commit b72db052fd
11 changed files with 464 additions and 324 deletions

View File

@@ -21,6 +21,7 @@ import com.nis.domain.configuration.HttpBodyCfg;
import com.nis.domain.configuration.HttpReqHeadCfg;
import com.nis.domain.configuration.HttpResHeadCfg;
import com.nis.domain.configuration.HttpUrlCfg;
import com.nis.domain.configuration.IpPortCfg;
import com.nis.exceptions.MaatConvertException;
import com.nis.util.Constants;
import com.nis.web.controller.BaseController;
@@ -63,15 +64,10 @@ public class HttpRedirectPolicyController extends BaseController{
HttpBodyCfg resBodyCfg = new HttpBodyCfg();
resBodyCfg.setCfgType(Constants.HTTP_REDIRECT_RES_BODY_REGION);
entity.setHttpResBody(resBodyCfg);
IpPortCfg ipPortCfg = new IpPortCfg();
ipPortCfg.setCfgType(Constants.HTTP_REDIRECT_IP_REGION);
entity.setIpPort(ipPortCfg);
int httpReqCfgNum = entity.getHttpUrlList().size()+
entity.getHttpReqBodyList().size()+
entity.getHttpReqHdrList().size();
int httpResCfgNum = entity.getHttpResHdrList().size()+
entity.getHttpResBodyList().size();
model.addAttribute("httpReqCfgNum", httpReqCfgNum);
model.addAttribute("httpResCfgNum", httpResCfgNum);
if(entity.getHttpUrlList().size()==0){
entity.getHttpUrlList().add(urlCfg);
}
@@ -87,6 +83,9 @@ public class HttpRedirectPolicyController extends BaseController{
if(entity.getHttpResBodyList().size()==0){
entity.getHttpResBodyList().add(resBodyCfg);
}
if(entity.getIpPortList().size()==0){
entity.getIpPortList().add(ipPortCfg);
}
initUpdateFormCondition(model,entity);
}else{
//设置http各类配置的配置域类型
@@ -105,6 +104,9 @@ public class HttpRedirectPolicyController extends BaseController{
HttpBodyCfg resBodyCfg = new HttpBodyCfg();
resBodyCfg.setCfgType(Constants.HTTP_REDIRECT_RES_BODY_REGION);
entity.setHttpResBody(resBodyCfg);
IpPortCfg ipPortCfg = new IpPortCfg();
ipPortCfg.setCfgType(Constants.HTTP_IP_REGION);
entity.setIpPort(ipPortCfg);
List<HttpUrlCfg> urlList=new ArrayList<HttpUrlCfg>();
urlList.add(urlCfg);
@@ -121,6 +123,10 @@ public class HttpRedirectPolicyController extends BaseController{
List<HttpBodyCfg> resBodyList=new ArrayList<HttpBodyCfg>();
resBodyList.add(resBodyCfg);
entity.setHttpResBodyList(resBodyList);
List<IpPortCfg> ipPortList=new ArrayList<IpPortCfg>();
ipPortList.add(ipPortCfg);
entity.setIpPortList(ipPortList);
initFormCondition(model,entity);
}

View File

@@ -73,6 +73,7 @@ public class HttpRedirectCfgService extends CrudService<WebsiteCfgDao,CfgIndexIn
List<HttpUrlCfg> httpUrlList = websiteCfgDao.getHttpUrlList(entity);
List<HttpReqHeadCfg> httpReqHdrList = websiteCfgDao.getHttpReqHdrList(entity);
List<HttpResHeadCfg> httpResHdrList = websiteCfgDao.getHttpResHdrList(entity);
List<IpPortCfg> ipPortCfgList = websiteCfgDao.getIpPortList(entity);
entity.setCfgType(Constants.HTTP_REDIRECT_REQ_BODY_REGION);
List<HttpBodyCfg> httpReqBodyList = websiteCfgDao.getHttpReqBodyList(entity);
entity.setCfgType(Constants.HTTP_REDIRECT_RES_BODY_REGION);
@@ -82,6 +83,7 @@ public class HttpRedirectCfgService extends CrudService<WebsiteCfgDao,CfgIndexIn
entity.setHttpResBodyList(httpResBodyList);
entity.setHttpResHdrList(httpResHdrList);
entity.setHttpUrlList(httpUrlList);
entity.setIpPortList(ipPortCfgList);
return entity;
}
@@ -143,6 +145,12 @@ public class HttpRedirectCfgService extends CrudService<WebsiteCfgDao,CfgIndexIn
websiteCfgDao.saveHttpBodyCfg(cfg);
}
}
if(entity.getIpPortList()!=null){
for(IpPortCfg cfg:entity.getIpPortList()){
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
websiteCfgDao.saveIpPortCfg(cfg);
}
}
//保存区域IP信息
if(entity.getAreaCfg()!=null){
for(AreaIpCfg cfg:entity.getAreaCfg()){
@@ -164,6 +172,7 @@ public class HttpRedirectCfgService extends CrudService<WebsiteCfgDao,CfgIndexIn
websiteCfgDao.deleteHttpReqHdrCfg(entity);
websiteCfgDao.deleteHttpResHdrCfg(entity);
websiteCfgDao.deleteHttpBodyCfg(entity);
websiteCfgDao.deleteHttpIpCfg(entity);
AreaIpCfg area = new AreaIpCfg();
area.setCompileId(entity.getCompileId());
area.setFunctionId(entity.getFunctionId());
@@ -206,6 +215,12 @@ public class HttpRedirectCfgService extends CrudService<WebsiteCfgDao,CfgIndexIn
websiteCfgDao.saveHttpBodyCfg(cfg);
}
}
if(entity.getIpPortList()!=null){
for(IpPortCfg cfg:entity.getIpPortList()){
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
websiteCfgDao.saveIpPortCfg(cfg);
}
}
//保存区域IP信息
if(entity.getAreaCfg()!=null){
for(AreaIpCfg cfg:entity.getAreaCfg()){
@@ -230,6 +245,12 @@ public class HttpRedirectCfgService extends CrudService<WebsiteCfgDao,CfgIndexIn
//查询子配置
entity = this.getHttpCfg(Long.parseLong(id));
if(entity.getIpPortList()!=null && entity.getIpPortList().size()>0){
IpPortCfg cfg = new IpPortCfg();
BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"});
cfg.setTableName(IpPortCfg.getTablename());
websiteCfgDao.updateCfgValid(cfg);
}
if(entity.getHttpUrlList()!=null && entity.getHttpUrlList().size()>0){
HttpUrlCfg cfg = new HttpUrlCfg();
BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"});
@@ -284,6 +305,20 @@ public class HttpRedirectCfgService extends CrudService<WebsiteCfgDao,CfgIndexIn
//查询子配置并修改审核状态
entity = this.getHttpCfg(entity.getCfgId());
if(entity.getIpPortList()!=null && entity.getIpPortList().size()>0){
IpPortCfg cfg = new IpPortCfg();
BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"});
cfg.setTableName(IpPortCfg.getTablename());
websiteCfgDao.auditCfg(cfg);
if(isAudit==1){
Map<String,List> map = cfgConvert(ipRegionList,entity.getIpPortList(),1,entity,groupRelationList);
groupRelationList=map.get("groupList");
ipRegionList=map.get("dstList");
if(map.get("numRegionList")!=null){
numRegionList.addAll(map.get("numRegionList"));
}
}
}
if(entity.getHttpUrlList()!=null && entity.getHttpUrlList().size()>0){
HttpUrlCfg cfg = new HttpUrlCfg();
BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"});
@@ -367,7 +402,8 @@ public class HttpRedirectCfgService extends CrudService<WebsiteCfgDao,CfgIndexIn
//判断http配置是否需要设置自定义域参数
String userRegion = "";
if(!StringUtil.isEmpty(entity.getUserRegion1())){
/*if(!StringUtil.isEmpty(entity.getUserRegion1())){
if(entity.getUserRegion1().startsWith(Constants.REDIRECT_RESPONSE_CODE_STARTWITH)){
userRegion = Constants.REDIRECT_RESPONSE_CODE_KEY+"="+entity.getUserRegion1()+
Constants.USER_REGION_SPLIT+
@@ -377,6 +413,21 @@ public class HttpRedirectCfgService extends CrudService<WebsiteCfgDao,CfgIndexIn
Constants.USER_REGION_SPLIT+
Constants.REDIRECT_CONTENT_KEY+"="+entity.getUserRegion2();
}
}*/
if(!StringUtil.isEmpty(entity.getUserRegion1())){
userRegion=userRegion+"userRegion1="+entity.getUserRegion1();
}
if(!StringUtil.isEmpty(entity.getUserRegion2())){
userRegion=userRegion+";userRegion2="+entity.getUserRegion2();
}
if(!StringUtil.isEmpty(entity.getUserRegion3())){
userRegion=userRegion+";userRegion3="+entity.getUserRegion3();
}
if(!StringUtil.isEmpty(entity.getUserRegion4())){
userRegion=userRegion+";userRegion4="+entity.getUserRegion4();
}
if(!StringUtil.isEmpty(entity.getUserRegion5())){
userRegion=userRegion+";userRegion5="+entity.getUserRegion5();
}
maatCfg.setUserRegion(userRegion);
configCompileList.add(maatCfg);