proxy intercept ip功能完成
http\dns\ssl\mail dolog添加
This commit is contained in:
@@ -94,6 +94,12 @@ public class InterceptCfgService extends CrudService<WebsiteCfgDao,CfgIndexInfo>
|
||||
*/
|
||||
|
||||
public void saveInterceptIpCfg(CfgIndexInfo entity){
|
||||
if(!entity.getAction().equals(Constants.REPLACE_ACTION)){
|
||||
entity.setInterceptPktBinList(null);
|
||||
}
|
||||
|
||||
entity.setIsValid(0);
|
||||
|
||||
//设置区域运营商信息
|
||||
setAreaEffectiveIds(entity);
|
||||
if(entity.getCfgId()==null){
|
||||
@@ -102,7 +108,12 @@ public class InterceptCfgService extends CrudService<WebsiteCfgDao,CfgIndexInfo>
|
||||
List<Integer> idList = ConfigServiceUtil.getId(1, 1);
|
||||
if(idList!=null && idList.size()>0){
|
||||
compileId = idList.get(0);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.info("获取编译ID出错");
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
|
||||
}
|
||||
entity.setCompileId(compileId);
|
||||
entity.setCreateTime(new Date());
|
||||
entity.setCreatorId(entity.getCurrentUser().getId());
|
||||
@@ -113,11 +124,12 @@ public class InterceptCfgService extends CrudService<WebsiteCfgDao,CfgIndexInfo>
|
||||
websiteCfgDao.saveIpPortCfg(cfg);
|
||||
}
|
||||
}
|
||||
if(entity.getInterceptPktBinList()!=null){
|
||||
|
||||
if(entity.getInterceptPktBinList()!=null ){
|
||||
for(InterceptPktBin cfg:entity.getInterceptPktBinList()){
|
||||
if(StringUtils.isNotBlank(cfg.getCfgKeywords())){
|
||||
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
|
||||
interceptCfgDao.insertInterceptPktBin(cfg);
|
||||
interceptCfgDao.saveInterceptPktBin(cfg);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -129,11 +141,7 @@ public class InterceptCfgService extends CrudService<WebsiteCfgDao,CfgIndexInfo>
|
||||
areaIpCfgDao.saveAreaIpCfg(cfg);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.info("获取编译ID出错");
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
}else{
|
||||
|
||||
@@ -160,7 +168,7 @@ public class InterceptCfgService extends CrudService<WebsiteCfgDao,CfgIndexInfo>
|
||||
for(InterceptPktBin cfg:entity.getInterceptPktBinList()){
|
||||
if(StringUtils.isNotBlank(cfg.getCfgKeywords())){
|
||||
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
|
||||
interceptCfgDao.insertInterceptPktBin(cfg);
|
||||
interceptCfgDao.saveInterceptPktBin(cfg);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -174,13 +182,13 @@ public class InterceptCfgService extends CrudService<WebsiteCfgDao,CfgIndexInfo>
|
||||
}
|
||||
}
|
||||
}
|
||||
/**//**
|
||||
/**
|
||||
* dns配置删除
|
||||
* @param isValid
|
||||
* @param ids
|
||||
* @param functionId
|
||||
*//*
|
||||
public void updateDnsCfgValid(Integer isValid,String ids,Integer functionId){
|
||||
*/
|
||||
public void updatInterceptValid(Integer isValid,String ids,Integer functionId){
|
||||
CfgIndexInfo entity = new CfgIndexInfo();
|
||||
String[] idArray = ids.split(",");
|
||||
for(String id :idArray){
|
||||
@@ -192,18 +200,18 @@ public class InterceptCfgService extends CrudService<WebsiteCfgDao,CfgIndexInfo>
|
||||
entity.setFunctionId(functionId);
|
||||
websiteCfgDao.updateCfgValid(entity);
|
||||
//查询子配置
|
||||
entity = this.getDnsCfg(Long.parseLong(id));
|
||||
entity = this.getInterceptIpCfg(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.getDomainList()!=null && entity.getDomainList().size()>0)
|
||||
if(entity.getInterceptPktBinList()!=null && entity.getInterceptPktBinList().size()>0)
|
||||
{
|
||||
SslKeywordCfg cfg = new SslKeywordCfg();
|
||||
InterceptPktBin cfg = new InterceptPktBin();
|
||||
BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"});
|
||||
cfg.setTableName(DnsDomainCfg.getTablename());
|
||||
cfg.setTableName(InterceptPktBin.getTablename());
|
||||
websiteCfgDao.updateCfgValid(cfg);
|
||||
}
|
||||
//保存区域IP信息
|
||||
@@ -217,13 +225,13 @@ public class InterceptCfgService extends CrudService<WebsiteCfgDao,CfgIndexInfo>
|
||||
}
|
||||
|
||||
}
|
||||
*//**
|
||||
/**
|
||||
* dns配置审核
|
||||
* @param entity
|
||||
* @param isAudit
|
||||
* @throws MaatConvertException
|
||||
*//*
|
||||
public void auditDnsCfg(CfgIndexInfo entity,Integer isAudit) throws MaatConvertException{
|
||||
*/
|
||||
public void auditInterceptIpCfg(CfgIndexInfo entity,Integer isAudit) throws MaatConvertException{
|
||||
//修改数据库审核状态信息
|
||||
entity.setTableName(CfgIndexInfo.getTablename());
|
||||
websiteCfgDao.auditCfg(entity);
|
||||
@@ -239,7 +247,7 @@ public class InterceptCfgService extends CrudService<WebsiteCfgDao,CfgIndexInfo>
|
||||
List<IpCfg> areaIpRegionList = new ArrayList();
|
||||
|
||||
//查询子配置并修改审核状态
|
||||
entity = this.getDnsCfg(entity.getCfgId());
|
||||
entity = this.getInterceptIpCfg(entity.getCfgId());
|
||||
if(entity.getIpPortList()!=null && entity.getIpPortList().size()>0){
|
||||
IpPortCfg cfg = new IpPortCfg();
|
||||
BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"});
|
||||
@@ -254,13 +262,13 @@ public class InterceptCfgService extends CrudService<WebsiteCfgDao,CfgIndexInfo>
|
||||
}
|
||||
}
|
||||
}
|
||||
if(entity.getDomainList()!=null && entity.getDomainList().size()>0){
|
||||
DnsDomainCfg cfg = new DnsDomainCfg();
|
||||
if(entity.getInterceptPktBinList()!=null && entity.getInterceptPktBinList().size()>0){
|
||||
InterceptPktBin cfg = new InterceptPktBin();
|
||||
BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"});
|
||||
cfg.setTableName(DnsDomainCfg.getTablename());
|
||||
cfg.setTableName(InterceptPktBin.getTablename());
|
||||
websiteCfgDao.auditCfg(cfg);
|
||||
if(isAudit==1){
|
||||
Map<String,List> map = cfgConvert(strRegionList,entity.getDomainList(),2,entity,groupRelationList);
|
||||
Map<String,List> map = cfgConvert(strRegionList,entity.getInterceptPktBinList(),2,entity,groupRelationList);
|
||||
groupRelationList=map.get("groupList");
|
||||
strRegionList=map.get("dstList");
|
||||
}
|
||||
@@ -293,11 +301,41 @@ public class InterceptCfgService extends CrudService<WebsiteCfgDao,CfgIndexInfo>
|
||||
maatCfg.setGroupNum(groupRelationList.size());
|
||||
maatCfg.setAreaIpRegionList(areaIpRegionList);
|
||||
maatCfg.setIsValid(entity.getIsValid());
|
||||
// dns reject userRegion=;dnsStrategyId;
|
||||
if(!StringUtil.isEmpty(entity.getDnsStrategyId())){
|
||||
// maatCfg.setUserRegion(Constants.USER_REGION_SPLIT+entity.getDnsStrategyId()+Constants.USER_REGION_SPLIT);
|
||||
maatCfg.setUserRegion(Constants.DNS_STRATEGY_USER_REGION_KEY+"="+entity.getDnsStrategyId());
|
||||
|
||||
//监测需要发keyring_id
|
||||
if(entity.getAction().equals(Constants.MONIT_ACTION)){
|
||||
entity.setUserRegion1(StringUtil.isEmpty(entity.getUserRegion1()) ? "0":entity.getUserRegion1());
|
||||
maatCfg.setUserRegion(Constants.INTERCEPT_IP_MONIT_USER_REGION_KEY+"="+entity.getUserRegion1());
|
||||
}
|
||||
//限速需要发Droprate=0.001 ,暂不支持Bandwidth=200kbps
|
||||
if(entity.getAction().equals(Constants.RATELIMIT_ACTION)){
|
||||
entity.setUserRegion2(StringUtil.isEmpty(entity.getUserRegion2()) ? "":entity.getUserRegion2());
|
||||
|
||||
maatCfg.setUserRegion(Constants.INTERCEPT_IP_RATELIMIT_DROPRATE_USER_REGION_KEY+"="+entity.getUserRegion2());
|
||||
}
|
||||
String userRegion="";
|
||||
//替换需要发zone
|
||||
if(entity.getAction().equals(Constants.REPLACE_ACTION)){
|
||||
//HTTP replace: replace type is not null ;find is not null;replace with is not null(userRegion is not null)
|
||||
userRegion=Constants.REPLACE_ZONE_KEY+"="+entity.getUserRegion3();
|
||||
String substitute="";
|
||||
String userRegion4=StringUtil.isEmpty(entity.getUserRegion4()) ? "":entity.getUserRegion4();
|
||||
substitute="/";
|
||||
userRegion4 = BaseService.replaceContentEscape(userRegion4);
|
||||
substitute=substitute+userRegion4;
|
||||
|
||||
String userRegion5=StringUtil.isEmpty(entity.getUserRegion5()) ? "":entity.getUserRegion5();
|
||||
userRegion5 = BaseService.replaceContentEscape(userRegion5);
|
||||
substitute=substitute+"/"+userRegion5;
|
||||
|
||||
userRegion=userRegion+";"+Constants.REPLACE_SUBSTITUTE_KEY+"="+substitute;
|
||||
maatCfg.setUserRegion(userRegion);
|
||||
}
|
||||
|
||||
if(StringUtil.isEmpty(maatCfg.getUserRegion())){
|
||||
maatCfg.setUserRegion(Constants.USER_REGION_PLACEHOLDER);
|
||||
}
|
||||
|
||||
configCompileList.add(maatCfg);
|
||||
maatBean.setConfigCompileList(configCompileList);
|
||||
maatBean.setAuditTime(entity.getAuditTime());
|
||||
@@ -306,10 +344,10 @@ public class InterceptCfgService extends CrudService<WebsiteCfgDao,CfgIndexInfo>
|
||||
maatBean.setOpAction(Constants.INSERT_ACTION);
|
||||
//调用服务接口下发配置数据
|
||||
String json=gsonToJson(maatBean);
|
||||
logger.info("dns配置下发配置参数:"+json);
|
||||
logger.info("intercept IP 配置下发配置参数:"+json);
|
||||
//调用服务接口下发配置
|
||||
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
|
||||
logger.info("dns配置下发响应信息:"+result.getMsg());
|
||||
logger.info("intercept IP 配置下发响应信息:"+result.getMsg());
|
||||
|
||||
}else if(isAudit==3){
|
||||
maatCfg.setCompileId(entity.getCompileId());
|
||||
@@ -323,10 +361,10 @@ public class InterceptCfgService extends CrudService<WebsiteCfgDao,CfgIndexInfo>
|
||||
maatBean.setOpAction(Constants.UPDATE_ACTION);
|
||||
//调用服务接口取消配置
|
||||
String json=gsonToJson(maatBean);
|
||||
logger.info("dns配置下发配置参数:"+json);
|
||||
logger.info("intercept IP 配置下发配置参数:"+json);
|
||||
//调用服务接口下发配置
|
||||
ToMaatResult result = ConfigServiceUtil.put(json,1);
|
||||
logger.info("dns配置取消配置响应信息:"+result.getMsg());
|
||||
logger.info("intercept IP 配置取消配置响应信息:"+result.getMsg());
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user