diff --git a/src/main/java/com/dispose/ability/impl/DpTechBypassAbilityImpl.java b/src/main/java/com/dispose/ability/impl/DpTechBypassAbilityImpl.java index 55c36239..47fa5643 100644 --- a/src/main/java/com/dispose/ability/impl/DpTechBypassAbilityImpl.java +++ b/src/main/java/com/dispose/ability/impl/DpTechBypassAbilityImpl.java @@ -133,7 +133,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { dpBypassManager.getTractionStrategyName().remove(v.getPolicyName()); } else { log.info("!!!!Remove Traction Strategy {} Error: {}", v.getPolicyName(), - ret.getResultInfo().getValue()); + ret.getResultInfo().getValue()); return ErrorCode.ERR_CALLDEVICE; } } @@ -239,17 +239,14 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { /** * Gets traction strategy format. * - * @param disposeObject the dispose object + * @param ipSegment the dispose object * @return the traction strategy format */ - private String getTractionStrategyFormat(String disposeObject) { - // 根据 - / 字符进行分割字符串 - String[] ret = disposeObject.replaceAll("/", "-").split("-"); - - if(ret.length == 0) { - return disposeObject; + private String getIpSegmentFormat(String ipSegment) { + if (!ipSegment.contains("/") && !ipSegment.contains("-")) { + return ipSegment + "-" + ipSegment; } else { - return ret[0] + "-" + ret[0]; + return ipSegment; } } @@ -279,7 +276,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { // 创建旁路手动牵引策略 ret = getCleanTypePort().addBypassManualTractionStrategyForUMC(tractionName, objName, - getTractionStrategyFormat(disposeObject)); + getIpSegmentFormat(disposeObject)); if (ret.getResultRetVal() == 0) { log.debug("----Finish Create Traction Strategy {} Succeed", tractionName); return ErrorCode.ERR_OK; @@ -466,9 +463,9 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { // 将业务Ip根据IP地址类型进行拆分 for (String k : StringUtils.deleteWhitespace(v.getServiceIp()).split(DisposeConfigValue.SPLIT_CHAR)) { if (!k.contains(":")) { - ipV4.add(ipV4Idx++ + "_" + k); + ipV4.add(ipV4Idx++ + "_" + getIpSegmentFormat(k)); } else { - ipV6.add(ipV6Idx++ + "_" + k); + ipV6.add(ipV6Idx++ + "_" + getIpSegmentFormat(k)); } } @@ -1064,6 +1061,6 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { */ @Override public Long toDeviceAttackType(Long ddosAttackTypeMask) { - return DpTechAttackType.getTypeMaskFromAttackType(new DpTechAttackType[] {DpTechAttackType.AUTO_ATTACK_TYPE}); + return DpTechAttackType.getTypeMaskFromAttackType(new DpTechAttackType[]{DpTechAttackType.AUTO_ATTACK_TYPE}); } }