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; }