From 495a73c005d4a2c2286d67cfc7a642f0c9ffd603 Mon Sep 17 00:00:00 2001 From: chenlinghy Date: Tue, 30 Mar 2021 18:32:17 +0800 Subject: [PATCH 1/3] =?UTF-8?q?OCT=20REM:=201.=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E8=BF=AA=E6=99=AE=E8=AE=BE=E5=A4=87=E6=B7=BB=E5=8A=A0=E9=98=B2?= =?UTF-8?q?=E6=8A=A4=E5=AF=B9=E8=B1=A1=E4=BB=A3=E7=A0=81=EF=BC=8CipV6?= =?UTF-8?q?=E7=9B=AE=E5=89=8D=E4=BB=85=E6=94=AF=E6=8C=81=E6=8E=A9=E7=A0=81?= =?UTF-8?q?=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ability/impl/DpTechBypassAbilityImpl.java | 26 ++++++++++++++++++- .../java/com/dispose/common/ConstValue.java | 10 +++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/dispose/ability/impl/DpTechBypassAbilityImpl.java b/src/main/java/com/dispose/ability/impl/DpTechBypassAbilityImpl.java index 7598546c..439dbd2e 100644 --- a/src/main/java/com/dispose/ability/impl/DpTechBypassAbilityImpl.java +++ b/src/main/java/com/dispose/ability/impl/DpTechBypassAbilityImpl.java @@ -263,6 +263,25 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { return ipSegment + "-" + ipSegment; } + /** + * Gets ipv6 segment format. + * + * @param ipSegment the ipv6 segment + * @return the ip segment format + */ + private String getIpV6SegmentFormat(String ipSegment) { + if(ipSegment.contains(ConstValue.IPV6_SEGMENT_SPILT)){ + return ipSegment; + } + + //如果输入格式为IP-IP,则返回值为null + if(ipSegment.contains(ConstValue.IPV6_ERR_SEGMENT_SPILT)){ + return null; + } + + return ipSegment + "/" + 128; + } + /** * Create traction strategy error code. * @@ -482,7 +501,12 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { if (!k.contains(":")) { ipV4.add(ipV4Idx++ + "_" + getIpSegmentFormat(k)); } else { - ipV6.add(ipV6Idx++ + "_" + getIpSegmentFormat(k)); + if(getIpV6SegmentFormat(k) == null){ + log.error("!!!!ipV6:{} format error", k); + return; + }else{ + ipV6.add(ipV6Idx++ + "_" + getIpV6SegmentFormat(k)); + } } } diff --git a/src/main/java/com/dispose/common/ConstValue.java b/src/main/java/com/dispose/common/ConstValue.java index fe3daa9c..6457e992 100644 --- a/src/main/java/com/dispose/common/ConstValue.java +++ b/src/main/java/com/dispose/common/ConstValue.java @@ -94,6 +94,16 @@ public class ConstValue { */ public static final String[] IP_SEGMENT_SPILT = new String[] {"-", "/"}; + /** + * The constant IPV6_ERR_SEGMENT_SPILT. + */ + public static final String IPV6_ERR_SEGMENT_SPILT = "-"; + + /** + * The constant IPV6_SEGMENT_SPILT. + */ + public static final String IPV6_SEGMENT_SPILT = "/"; + /** * The type Protocol. * From 73ff0820655fac46f718f9c72556c3fdb294edc5 Mon Sep 17 00:00:00 2001 From: chenlinghy Date: Tue, 20 Apr 2021 16:28:41 +0800 Subject: [PATCH 2/3] =?UTF-8?q?OCT=20REM:=201.=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=97=81=E8=B7=AF=E6=89=8B=E5=8A=A8=E7=89=B5=E5=BC=95=E6=96=B9?= =?UTF-8?q?=E5=BC=8F=E5=88=A0=E9=99=A4=E7=AC=AC=E4=B8=89=E6=96=B9=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E7=9A=84=E9=85=8D=E7=BD=AE=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ability/impl/DpTechBypassAbilityImpl.java | 68 +++++++------------ 1 file changed, 24 insertions(+), 44 deletions(-) diff --git a/src/main/java/com/dispose/ability/impl/DpTechBypassAbilityImpl.java b/src/main/java/com/dispose/ability/impl/DpTechBypassAbilityImpl.java index 439dbd2e..b22c1ab3 100644 --- a/src/main/java/com/dispose/ability/impl/DpTechBypassAbilityImpl.java +++ b/src/main/java/com/dispose/ability/impl/DpTechBypassAbilityImpl.java @@ -61,7 +61,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { /** * The Object prefix. */ - private final String objectPrefix = "C"; + private final String objectPrefix = "H"; /** * The Dp bypass manager. */ @@ -270,12 +270,12 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { * @return the ip segment format */ private String getIpV6SegmentFormat(String ipSegment) { - if(ipSegment.contains(ConstValue.IPV6_SEGMENT_SPILT)){ + if (ipSegment.contains(ConstValue.IPV6_SEGMENT_SPILT)) { return ipSegment; } //如果输入格式为IP-IP,则返回值为null - if(ipSegment.contains(ConstValue.IPV6_ERR_SEGMENT_SPILT)){ + if (ipSegment.contains(ConstValue.IPV6_ERR_SEGMENT_SPILT)) { return null; } @@ -501,10 +501,10 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { if (!k.contains(":")) { ipV4.add(ipV4Idx++ + "_" + getIpSegmentFormat(k)); } else { - if(getIpV6SegmentFormat(k) == null){ + if (getIpV6SegmentFormat(k) == null) { log.error("!!!!ipV6:{} format error", k); return; - }else{ + } else { ipV6.add(ipV6Idx++ + "_" + getIpV6SegmentFormat(k)); } } @@ -524,19 +524,22 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { for (Map.Entry entry : ipSegment.entrySet()) { String protectName = getProtectObjectName(v.getServiceId(), entry.getKey()); - // 防护对象存在 - if (dpBypassManager.getProtectObject().containsKey(protectName)) { - //进一步判断关联模板是都正确,防护IP段是否发生变化 - protectionObjExist(entry, protectName, template, ipV4, ipV6, ipSegment); - } else { - err = createProtectObject(protectName, - ipSegment.get(entry.getKey()), - IpAddrType.IPV4.equals(entry.getKey()) ? 0 : 1, - template); - if (err == ErrorCode.ERR_OK) { - log.debug("Add Protection Object {} Succeed", protectName); + //只处理CMHY前缀的防护对象 + if (protectName.startsWith(objectPrefix)) { + // 防护对象存在 + if (dpBypassManager.getProtectObject().containsKey(protectName)) { + //进一步判断关联模板是都正确,防护IP段是否发生变化 + protectionObjExist(entry, protectName, template, ipV4, ipV6, ipSegment); } else { - log.error("!!!!Add Protection Object {} Error: {}", protectName, err.getMsg()); + err = createProtectObject(protectName, + ipSegment.get(entry.getKey()), + IpAddrType.IPV4.equals(entry.getKey()) ? 0 : 1, + template); + if (err == ErrorCode.ERR_OK) { + log.debug("Add Protection Object {} Succeed", protectName); + } else { + log.error("!!!!Add Protection Object {} Error: {}", protectName, err.getMsg()); + } } } } @@ -604,7 +607,6 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { } } - // 更新防护对象 if (upgradeIpSegment) { err = upgradeProtectObject(protectName, @@ -734,18 +736,8 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { if (ret != null && ret.getBypassManualTractionStrategyForService().size() > 0) { ret.getBypassManualTractionStrategyForService().forEach(k -> { String policyName = k.getPolicyName().getValue(); - // 非法名称的旁路牵引策略 - if (!policyName.startsWith(objectPrefix)) { - NtcRequestResultInfo rsp = - getCleanTypePort().delBypassManualTractionStrategyForUMC(policyName); - - if (rsp.getResultRetVal() == 0) { - log.debug("Remove Traction Strategy {} Succeed", policyName); - } else { - log.error("!!!!Remove Traction Strategy {} Error: {}", policyName, rsp.getResultInfo() - .getValue()); - } - } else { + // 非法名称的旁路牵引策略-因UMC平台共享,不能删除第三方的方璐手动牵引策略 + if (policyName.startsWith(objectPrefix)) { DpTractionStrategy obj; if (dpBypassManager.getTractionStrategyName().containsKey(policyName)) { @@ -863,20 +855,9 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { ret.getProtectionObjectDataForService().forEach(k -> { String objName = k.getProtectionName().getValue(); - // 删除非法的防护对象 - if (!objName.startsWith(objectPrefix)) { - log.error("!!!!Found Unexpect Protection Object [{}, {}], Deleted it.", - objName, - k.getIpSegment().getValue()); - NtcRequestResultInfo rsp = getCleanTypePort().deleteProtectionObjectForUMC(objName); - - if (rsp.getResultRetVal() == 0) { - log.warn("!!!!Remove Protection Object {} Succeed", objName); - } else { - log.error("!!!!Remove Protection Object {} Error: {}", objName, rsp.getResultInfo().getValue()); - } - } else { + // 只处理CMHY相关对象,不可对UMC上的非杭研防护对象进行删除 + if (objName.startsWith(objectPrefix)) { DpProtectObject obj; if (dpBypassManager.getProtectObject().containsKey(objName)) { @@ -918,7 +899,6 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { rsp.getResultInfo().getValue()); } } - }); // 判断是否需要更新IP段信息 From 2b8984725c86519899b820c023da317a958f82e0 Mon Sep 17 00:00:00 2001 From: chenlinghy Date: Thu, 22 Apr 2021 15:39:57 +0800 Subject: [PATCH 3/3] =?UTF-8?q?OCT=20REM:=201.=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E9=98=B2=E6=8A=A4=E5=AF=B9=E8=B1=A1=E5=92=8C=E6=97=81=E8=B7=AF?= =?UTF-8?q?=E6=89=8B=E5=8A=A8=E7=89=B5=E5=BC=95=E7=AD=96=E7=95=A5=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E7=9A=84=E5=89=8D=E7=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dispose/ability/impl/DpTechBypassAbilityImpl.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/dispose/ability/impl/DpTechBypassAbilityImpl.java b/src/main/java/com/dispose/ability/impl/DpTechBypassAbilityImpl.java index b22c1ab3..43c16095 100644 --- a/src/main/java/com/dispose/ability/impl/DpTechBypassAbilityImpl.java +++ b/src/main/java/com/dispose/ability/impl/DpTechBypassAbilityImpl.java @@ -61,7 +61,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { /** * The Object prefix. */ - private final String objectPrefix = "H"; + private final String objectPrefix = "C"; /** * The Dp bypass manager. */ @@ -524,7 +524,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { for (Map.Entry entry : ipSegment.entrySet()) { String protectName = getProtectObjectName(v.getServiceId(), entry.getKey()); - //只处理CMHY前缀的防护对象 + //只处理C前缀的防护对象 if (protectName.startsWith(objectPrefix)) { // 防护对象存在 if (dpBypassManager.getProtectObject().containsKey(protectName)) { @@ -736,7 +736,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { if (ret != null && ret.getBypassManualTractionStrategyForService().size() > 0) { ret.getBypassManualTractionStrategyForService().forEach(k -> { String policyName = k.getPolicyName().getValue(); - // 非法名称的旁路牵引策略-因UMC平台共享,不能删除第三方的方璐手动牵引策略 + // 只处理C旁路手动牵引策略,不可删除第三方添加的旁路手动牵引策略 if (policyName.startsWith(objectPrefix)) { DpTractionStrategy obj; @@ -787,7 +787,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { ret.getProtectionTargetWithStrategyForService().forEach(k -> { String objName = k.getProtectionTargetName().getValue(); - // 只处理CMHI相关对象和模板 + // 只处理C相关对象和模板 if (objName.startsWith(objectPrefix)) { DpProtectionStrategyInfo obj; @@ -856,7 +856,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { ret.getProtectionObjectDataForService().forEach(k -> { String objName = k.getProtectionName().getValue(); - // 只处理CMHY相关对象,不可对UMC上的非杭研防护对象进行删除 + // 只处理C相关对象,不可对UMC上的非杭研防护对象进行删除 if (objName.startsWith(objectPrefix)) { DpProtectObject obj;