REM:
1. 修正迪普设备对比IP格式转换问题
2. 增加业务管理接口参数验证功能
This commit is contained in:
HuangXin 2021-01-18 18:23:02 +08:00
parent ad0929e168
commit a670d67fc8
4 changed files with 46 additions and 9 deletions

View File

@ -32,6 +32,7 @@ import java.util.HashMap;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.List; import java.util.List;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors;
/** /**
* The type Dp tech bypass ability. * The type Dp tech bypass ability.
@ -141,6 +142,12 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
for (DpProtectionStrategyInfo v : dpBypassManager.getProtectStrategy().values()) { for (DpProtectionStrategyInfo v : dpBypassManager.getProtectStrategy().values()) {
// 如果防护对象关联了防护策略模板那么解除该防护策略模板 // 如果防护对象关联了防护策略模板那么解除该防护策略模板
if (v.getProtectTargetName().equals(objName)) { if (v.getProtectTargetName().equals(objName)) {
// 没有关联模板的防护对象
if (v.getProtectStrategyName().length() == 0) {
break;
}
ret = getCleanTypePort().disableProtectionStrategyTemplateForUMC(objName, v.getProtectStrategyName()); ret = getCleanTypePort().disableProtectionStrategyTemplateForUMC(objName, v.getProtectStrategyName());
if (ret.getResultRetVal() == 0) { if (ret.getResultRetVal() == 0) {
@ -471,15 +478,21 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
// 判断防护IP段是否有变化 // 判断防护IP段是否有变化
if (IpAddrType.IPV4.equals(t)) { if (IpAddrType.IPV4.equals(t)) {
if (ipV4.size() != dp.getIpSegment().values().size() if (ipV4.size() != dp.getIpSegment().values().size()) {
|| !ipV4.containsAll(dp.getIpSegment().values()) List<String> ipList =
|| dp.getIpSegment().values().containsAll(ipV4)) { ipV4.stream().map(k -> k.replaceAll("\\d+_", "")).collect(Collectors.toList());
if (!ipList.containsAll(dp.getIpSegment().values())
|| !dp.getIpSegment().values().containsAll(ipList)) {
upgradeIpSegment = true; upgradeIpSegment = true;
} }
}
} else if (IpAddrType.IPV6.equals(t)) { } else if (IpAddrType.IPV6.equals(t)) {
if (ipV6.size() != dp.getIpSegment().values().size() List<String> ipList =
|| !ipV6.containsAll(dp.getIpSegment().values()) ipV6.stream().map(k -> k.replaceAll("\\d+_", "")).collect(Collectors.toList());
|| dp.getIpSegment().values().containsAll(ipV6)) {
if (!ipList.containsAll(dp.getIpSegment().values())
|| !dp.getIpSegment().values().containsAll(ipList)) {
upgradeIpSegment = true; upgradeIpSegment = true;
} }
} }
@ -689,6 +702,9 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
// 获取所有检测设备 // 获取所有检测设备
initCleanupDevices(); initCleanupDevices();
// 更新设备信息
upgradeDeviceBypassInfo();
} }
/** /**

View File

@ -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]$)|" + 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]$)"; "(^[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. * The type Protocol.
* *

View File

@ -17,6 +17,7 @@ import com.dispose.validation.group.ValidGroups;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -71,7 +72,7 @@ public class UserBusinessController {
.serviceId(v.getBusinessId()) .serviceId(v.getBusinessId())
.serviceType(v.getBusinessType()) .serviceType(v.getBusinessType())
.serviceBandwidth((long) Math.ceil(Double.parseDouble(v.getBusinessBandwidth()))) .serviceBandwidth((long) Math.ceil(Double.parseDouble(v.getBusinessBandwidth())))
.serviceIp(v.getBusinessIp()) .serviceIp(StringUtils.deleteWhitespace(v.getBusinessIp()))
.build()); .build());
} }

View File

@ -1,6 +1,8 @@
package com.dispose.pojo.dto.protocol.device.business; package com.dispose.pojo.dto.protocol.device.business;
import com.dispose.common.ConstValue;
import com.dispose.validation.group.ValidGroups; import com.dispose.validation.group.ValidGroups;
import com.dispose.validation.valids.ValidIpSegment;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
@ -8,6 +10,7 @@ import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
/** /**
* The type User svr info. * The type User svr info.
@ -28,16 +31,23 @@ public class UserSvrInfo {
* The Business type. * The Business type.
*/ */
@NotBlank(message = "businessType 客户业务类型不能为空", groups = ValidGroups.AddUserInfoValid.class) @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; private String businessType;
/** /**
* The Business ip. * The Business ip.
*/ */
@JsonProperty("businessIP") @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; private String businessIp;
/** /**
* The Business bandwidth. * The Business bandwidth.
*/ */
@NotBlank(message = "businessBandwidth 客户业务带宽不能为空", groups = ValidGroups.AddUserInfoValid.class) @NotBlank(message = "businessBandwidth 客户业务带宽不能为空", groups = ValidGroups.AddUserInfoValid.class)
@Pattern(regexp = ConstValue.NUMBER_TYPE,
message = "businessBandwidth 只能为数字",
groups = ValidGroups.AddUserInfoValid.class)
private String businessBandwidth; private String businessBandwidth;
} }