@@ -27,7 +27,6 @@ import com.nis.domain.maat.MaatCfg.DigestCfg;
import com.nis.domain.maat.MaatCfg.GroupCfg ;
import com.nis.domain.maat.MaatCfg.IpCfg ;
import com.nis.domain.maat.MaatCfg.StringCfg ;
import com.nis.domain.specific.ConfigGroupInfo ;
import com.nis.exceptions.MaatConvertException ;
import com.nis.util.ConfigServiceUtil ;
import com.nis.util.Constants ;
@@ -58,6 +57,9 @@ public class InterceptCfgService extends CrudService<WebsiteCfgDao,CfgIndexInfo>
public CfgIndexInfo getInterceptCfg ( Long cfgId , Integer compileId ) {
CfgIndexInfo entity = websiteCfgDao . getCfgIndexInfo ( cfgId , compileId ) ;
if ( entity . getServiceId ( ) . equals ( 512 ) ) {
entity . setUserRegion ( ( Map < String , Object > ) this . gsonFromJson ( entity . getUserRegion1 ( ) , Map . class ) ) ;
}
List < IpPortCfg > ipPortList = websiteCfgDao . getIpPortList ( entity ) ;
List < InterceptPktBin > pktBinList = interceptCfgDao . getInterceptPktBin ( entity ) ;
List < HttpUrlCfg > httpUrlList = websiteCfgDao . getHttpUrlList ( entity ) ;
@@ -108,7 +110,10 @@ public class InterceptCfgService extends CrudService<WebsiteCfgDao,CfgIndexInfo>
if ( ! StringUtil . isEmpty ( entity . getIsValid ( ) ) & & entity . getIsValid ( ) = = 1 ) {
isValid = 1 ;
}
//处理复杂用户自定义域
if ( ! StringUtil . isEmpty ( entity . getUserRegion ( ) ) ) {
entity . setUserRegion1 ( gsonToJson ( entity . getUserRegion ( ) ) ) ;
}
entity . setIsValid ( 0 ) ;
entity . setIsAudit ( 0 ) ;
@@ -459,7 +464,9 @@ public class InterceptCfgService extends CrudService<WebsiteCfgDao,CfgIndexInfo>
boolean doaminFlag = false ;
String domainUserRegion = " " ;
if ( entity . getHttpUrlList ( ) ! = null & & entity . getHttpUrlList ( ) . size ( ) > 0 ) {
doaminFlag = true ;
if ( ! entity . getServiceId ( ) . equals ( 512 ) ) {
doaminFlag = true ;
}
domainUserRegion = Constants . USERREGION_DOMAIN_ID + " = " + entity . getCompileId ( ) ;
String domainStr = " " ;
if ( entity ! = null & & entity . getHttpUrlList ( ) ! = null & & entity . getHttpUrlList ( ) . size ( ) > 0 ) {
@@ -511,59 +518,66 @@ public class InterceptCfgService extends CrudService<WebsiteCfgDao,CfgIndexInfo>
maatCfg . setGroupNum ( groupRelationList . size ( ) ) ;
maatCfg . setAreaIpRegionList ( areaIpRegionList ) ;
maatCfg . setIsValid ( entity . getIsValid ( ) ) ;
//监测 需要发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 ( ) ) ;
//监测的域名需下发拦截强度
if ( entity . getFunctionId ( ) . equals ( 200 ) ) {
if ( entity . getHttpUrlList ( ) ! = null & & entity . getHttpUrlList ( ) . size ( ) > 0 ) {
entity . setUserRegion5 ( StringUtil . isEmpty ( entity . getUserRegion5 ( ) ) ? " 1 " : entity . getUserRegion5 ( ) ) ;
if ( StringUtil . isEmpty ( maatCfg . getUserRegion ( ) ) ) {
maatCfg . setUserRegion ( Constants . INTERCEPT_DOMAN_INTENSITY_USER_REGION_KEY + " = " + entity . getUserRegion5 ( ) ) ;
} else {
maatCfg . setUserRegion ( maatCfg . getUserRegion ( ) + " ; " + Constants . INTERCEPT_DOMAN_INTENSITY_USER_REGION_KEY + " = " + entity . getUserRegion5 ( ) ) ;
if ( entity . getServiceId ( ) . equals ( 512 ) ) {
maatCfg . setUserRegion ( entity . getUserRegion1 ( ) ) ;
if ( StringUtil . isEmpty ( maatCfg . getUserRegion ( ) ) ) {
maatCfg . setUserRegion ( Constants . USER_REGION_PLACEHOLDER ) ;
}
} else {
//监测 需要发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 ( ) ) ;
//监测的域名需下发拦截强度
if ( entity . getFunctionId ( ) . equals ( 200 ) ) {
if ( entity . getHttpUrlList ( ) ! = null & & entity . getHttpUrlList ( ) . size ( ) > 0 ) {
entity . setUserRegion5 ( StringUtil . isEmpty ( entity . getUserRegion5 ( ) ) ? " 1 " : entity . getUserRegion5 ( ) ) ;
if ( StringUtil . isEmpty ( maatCfg . getUserRegion ( ) ) ) {
maatCfg . setUserRegion ( Constants . INTERCEPT_DOMAN_INTENSITY_USER_REGION_KEY + " = " + entity . getUserRegion5 ( ) ) ;
} else {
maatCfg . setUserRegion ( maatCfg . getUserRegion ( ) + " ; " + Constants . INTERCEPT_DOMAN_INTENSITY_USER_REGION_KEY + " = " + entity . getUserRegion5 ( ) ) ;
}
}
}
}
//限速 需要发Droprate=0.001 , 暂不支持Bandwidth=200kbps
if ( entity . getAction ( ) . equals ( Constants . RATELIMIT_ACTION ) ) {
if ( entity . getUserRegion1 ( ) . equals ( " 0 " ) ) { //丢包率
entity . setUserRegion2 ( StringUtil . isEmpty ( entity . getUserRegion2 ( ) ) ? " " : entity . getUserRegion2 ( ) ) ;
maatCfg . setUserRegion ( Constants . INTERCEPT_IP_RATELIMIT_DROPRATE_USER_REGION_KEY + " = " + entity . getUserRegion2 ( ) ) ;
} else if ( entity . getUserRegion1 ( ) . equals ( " 1 " ) ) { //带宽
entity . setUserRegion3 ( StringUtil . isEmpty ( entity . getUserRegion3 ( ) ) ? " " : entity . getUserRegion3 ( ) ) ;
maatCfg . setUserRegion ( Constants . INTERCEPT_IP_RATELIMIT_BANDWITH_USER_REGION_KEY + " = " + entity . getUserRegion3 ( ) ) ;
}
}
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 . getUserRegion1 ( ) ;
String substitute = " " ;
String userRegion2 = StringUtil . isEmpty ( entity . getUserRegion2 ( ) ) ? " " : entity . getUserRegion2 ( ) ;
substitute = " / " ;
userRegion2 = BaseService . replaceContentEscape ( userRegion2 ) ;
substitute = substitute + userRegion2 ;
String userRegion3 = StringUtil . isEmpty ( entity . getUserRegion3 ( ) ) ? " " : entity . getUserRegion3 ( ) ;
userRegion3 = BaseService . replaceContentEscape ( userRegion3 ) ;
substitute = substitute + " / " + userRegion3 ;
userRegion = userRegion + " ; " + Constants . REPLACE_SUBSTITUTE_KEY + " = " + substitute ;
maatCfg . setUserRegion ( userRegion ) ;
}
//ip仿冒自定义域信息
if ( entity . getAction ( ) . equals ( 48 ) ) {
//HTTP replace: replace type is not null ;find is not null;replace with is not null(userRegion is not null)
userRegion = " nat_type= " + entity . getUserRegion1 ( ) ;
userRegion + = " ;spoofing_ip_pool= " + entity . getUserRegion3 ( ) ;
maatCfg . setUserRegion ( userRegion ) ;
}
}
//限速 需要发Droprate=0.001 , 暂不支持Bandwidth=200kbps
if ( entity . getAction ( ) . equals ( Constants . RATELIMIT_ACTION ) ) {
if ( entity . getUserRegion1 ( ) . equals ( " 0 " ) ) { //丢包率
entity . setUserRegion2 ( StringUtil . isEmpty ( entity . getUserRegion2 ( ) ) ? " " : entity . getUserRegion2 ( ) ) ;
maatCfg . setUserRegion ( Constants . INTERCEPT_IP_RATELIMIT_DROPRATE_USER_REGION_KEY + " = " + entity . getUserRegion2 ( ) ) ;
} else if ( entity . getUserRegion1 ( ) . equals ( " 1 " ) ) { //带宽
entity . setUserRegion3 ( StringUtil . isEmpty ( entity . getUserRegion3 ( ) ) ? " " : entity . getUserRegion3 ( ) ) ;
maatCfg . setUserRegion ( Constants . INTERCEPT_IP_RATELIMIT_BANDWITH_USER_REGION_KEY + " = " + entity . getUserRegion3 ( ) ) ;
}
}
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 . getUserRegion1 ( ) ;
String substitute = " " ;
String userRegion2 = StringUtil . isEmpty ( entity . getUserRegion2 ( ) ) ? " " : entity . getUserRegion2 ( ) ;
substitute = " / " ;
userRegion2 = BaseService . replaceContentEscape ( userRegion2 ) ;
substitute = substitute + userRegion2 ;
String userRegion3 = StringUtil . isEmpty ( entity . getUserRegion3 ( ) ) ? " " : entity . getUserRegion3 ( ) ;
userRegion3 = BaseService . replaceContentEscape ( userRegion3 ) ;
substitute = substitute + " / " + userRegion3 ;
userRegion = userRegion + " ; " + Constants . REPLACE_SUBSTITUTE_KEY + " = " + substitute ;
maatCfg . setUserRegion ( userRegion ) ;
}
//ip仿冒自定义域信息
if ( entity . getAction ( ) . equals ( 48 ) ) {
//HTTP replace: replace type is not null ;find is not null;replace with is not null(userRegion is not null)
userRegion = " nat_type= " + entity . getUserRegion1 ( ) ;
userRegion + = " ;spoofing_ip_pool= " + entity . getUserRegion3 ( ) ;
maatCfg . setUserRegion ( userRegion ) ;
}
//域名拦截需要增加域名id和域名字符串自定义配置
if ( StringUtil . isEmpty ( maatCfg . getUserRegion ( ) )