From a670d67fc8fadcebe395b0313a4d66cd0e2e27be Mon Sep 17 00:00:00 2001 From: HuangXin Date: Mon, 18 Jan 2021 18:23:02 +0800 Subject: [PATCH] =?UTF-8?q?OCT=20REM:=201.=20=E4=BF=AE=E6=AD=A3=E8=BF=AA?= =?UTF-8?q?=E6=99=AE=E8=AE=BE=E5=A4=87=E5=AF=B9=E6=AF=94IP=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E8=BD=AC=E6=8D=A2=E9=97=AE=E9=A2=98=202.=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E4=B8=9A=E5=8A=A1=E7=AE=A1=E7=90=86=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E9=AA=8C=E8=AF=81=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ability/impl/DpTechBypassAbilityImpl.java | 30 ++++++++++++++----- .../java/com/dispose/common/ConstValue.java | 10 +++++++ .../controller/UserBusinessController.java | 3 +- .../protocol/device/business/UserSvrInfo.java | 12 +++++++- 4 files changed, 46 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/dispose/ability/impl/DpTechBypassAbilityImpl.java b/src/main/java/com/dispose/ability/impl/DpTechBypassAbilityImpl.java index 654d9c8a..a7081cf2 100644 --- a/src/main/java/com/dispose/ability/impl/DpTechBypassAbilityImpl.java +++ b/src/main/java/com/dispose/ability/impl/DpTechBypassAbilityImpl.java @@ -32,6 +32,7 @@ import java.util.HashMap; import java.util.Hashtable; import java.util.List; import java.util.regex.Pattern; +import java.util.stream.Collectors; /** * The type Dp tech bypass ability. @@ -141,6 +142,12 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { for (DpProtectionStrategyInfo v : dpBypassManager.getProtectStrategy().values()) { // 如果防护对象关联了防护策略模板,那么解除该防护策略模板 if (v.getProtectTargetName().equals(objName)) { + + // 没有关联模板的防护对象 + if (v.getProtectStrategyName().length() == 0) { + break; + } + ret = getCleanTypePort().disableProtectionStrategyTemplateForUMC(objName, v.getProtectStrategyName()); if (ret.getResultRetVal() == 0) { @@ -471,15 +478,21 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { // 判断防护IP段是否有变化 if (IpAddrType.IPV4.equals(t)) { - if (ipV4.size() != dp.getIpSegment().values().size() - || !ipV4.containsAll(dp.getIpSegment().values()) - || dp.getIpSegment().values().containsAll(ipV4)) { - upgradeIpSegment = true; + if (ipV4.size() != dp.getIpSegment().values().size()) { + List ipList = + ipV4.stream().map(k -> k.replaceAll("\\d+_", "")).collect(Collectors.toList()); + + if (!ipList.containsAll(dp.getIpSegment().values()) + || !dp.getIpSegment().values().containsAll(ipList)) { + upgradeIpSegment = true; + } } } else if (IpAddrType.IPV6.equals(t)) { - if (ipV6.size() != dp.getIpSegment().values().size() - || !ipV6.containsAll(dp.getIpSegment().values()) - || dp.getIpSegment().values().containsAll(ipV6)) { + List ipList = + ipV6.stream().map(k -> k.replaceAll("\\d+_", "")).collect(Collectors.toList()); + + if (!ipList.containsAll(dp.getIpSegment().values()) + || !dp.getIpSegment().values().containsAll(ipList)) { upgradeIpSegment = true; } } @@ -689,6 +702,9 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { // 获取所有检测设备 initCleanupDevices(); + + // 更新设备信息 + upgradeDeviceBypassInfo(); } /** diff --git a/src/main/java/com/dispose/common/ConstValue.java b/src/main/java/com/dispose/common/ConstValue.java index 2ea8f1e9..38c3ae18 100644 --- a/src/main/java/com/dispose/common/ConstValue.java +++ b/src/main/java/com/dispose/common/ConstValue.java @@ -79,6 +79,16 @@ public class ConstValue { public static final String IP_PORT_REG = "^[1-9]$|(^[1-9][0-9]$)|(^[1-9][0-9][0-9]$)|(^[1-9][0-9][0-9][0-9]$)|" + "(^[1-6][0-5][0-5][0-3][0-5]$)"; + /** + * The constant BUSINESS_TYPE. + */ + public static final String BUSINESS_TYPE = "^(GENERAL)|(WEB)|(DNS)|(GAME)$"; + + /** + * The constant NUM_TYPE. + */ + public static final String NUMBER_TYPE = "^[0-9]+([.]{1}[0-9]+){0,1}$"; + /** * The type Protocol. * diff --git a/src/main/java/com/dispose/controller/UserBusinessController.java b/src/main/java/com/dispose/controller/UserBusinessController.java index e24653a7..becf552d 100644 --- a/src/main/java/com/dispose/controller/UserBusinessController.java +++ b/src/main/java/com/dispose/controller/UserBusinessController.java @@ -17,6 +17,7 @@ import com.dispose.validation.group.ValidGroups; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang.StringUtils; import org.springframework.stereotype.Component; import org.springframework.stereotype.Controller; import org.springframework.validation.annotation.Validated; @@ -71,7 +72,7 @@ public class UserBusinessController { .serviceId(v.getBusinessId()) .serviceType(v.getBusinessType()) .serviceBandwidth((long) Math.ceil(Double.parseDouble(v.getBusinessBandwidth()))) - .serviceIp(v.getBusinessIp()) + .serviceIp(StringUtils.deleteWhitespace(v.getBusinessIp())) .build()); } diff --git a/src/main/java/com/dispose/pojo/dto/protocol/device/business/UserSvrInfo.java b/src/main/java/com/dispose/pojo/dto/protocol/device/business/UserSvrInfo.java index f05ab975..d74b8f62 100644 --- a/src/main/java/com/dispose/pojo/dto/protocol/device/business/UserSvrInfo.java +++ b/src/main/java/com/dispose/pojo/dto/protocol/device/business/UserSvrInfo.java @@ -1,6 +1,8 @@ package com.dispose.pojo.dto.protocol.device.business; +import com.dispose.common.ConstValue; import com.dispose.validation.group.ValidGroups; +import com.dispose.validation.valids.ValidIpSegment; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.Builder; @@ -8,6 +10,7 @@ import lombok.Data; import lombok.NoArgsConstructor; import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Pattern; /** * The type User svr info. @@ -28,16 +31,23 @@ public class UserSvrInfo { * The Business type. */ @NotBlank(message = "businessType 客户业务类型不能为空", groups = ValidGroups.AddUserInfoValid.class) + @Pattern(regexp = ConstValue.BUSINESS_TYPE, + message = "businessType 未知业务类型, [GENERAL, WEB, DNS, GAME]", + groups = ValidGroups.AddUserInfoValid.class) private String businessType; /** * The Business ip. */ @JsonProperty("businessIP") - @NotBlank(message = "businessIp 业务IP地址段不能为空", groups = ValidGroups.UpgradeDeviceValid.class) + @ValidIpSegment(message = "businessIp Ip地址格式错误", groups = ValidGroups.AddUserInfoValid.class) + @NotBlank(message = "businessIp 业务IP地址段不能为空", groups = ValidGroups.AddUserInfoValid.class) private String businessIp; /** * The Business bandwidth. */ @NotBlank(message = "businessBandwidth 客户业务带宽不能为空", groups = ValidGroups.AddUserInfoValid.class) + @Pattern(regexp = ConstValue.NUMBER_TYPE, + message = "businessBandwidth 只能为数字", + groups = ValidGroups.AddUserInfoValid.class) private String businessBandwidth; }