REM:
1. 备份代码
This commit is contained in:
HuangXin 2020-09-27 14:36:03 +08:00
parent 6667ae9735
commit f7599efa4b
15 changed files with 126 additions and 114 deletions

View File

@ -18,7 +18,7 @@
</parent>
<groupId>com.dispose</groupId>
<artifactId>phoenix_ddos_handle</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>
<name>phoenix_ddos_handle</name>
<description>Dispose Platform</description>
<dependencies>

View File

@ -4,6 +4,7 @@ import com.dispose.common.CommonEnumHandler;
import com.dispose.common.DDoSAttackType;
import com.dispose.common.DisposeCapacityType;
import com.dispose.common.DisposeConfigValue;
import com.dispose.common.DisposeObjectType;
import com.dispose.common.ErrorCode;
import com.dispose.common.Helper;
import com.dispose.common.NetflowDirection;
@ -96,30 +97,31 @@ public class DisposeTaskController {
// 构造处置任务参数
DisposeTask task = DisposeTask.builder()
.deviceId(Long.parseLong(Optional.ofNullable(req.getId()).orElse("-1")))
.accountId(userAccountService.getUserIdByAuthHead(Objects.requireNonNull(headers.get("Authorization"))
.get(0)))
.disposeCapacity(CommonEnumHandler.codeOf(DisposeCapacityType.class,
req.getType()))
.disposeIp(Helper.ipAddressNormalize(req.getDisposeIp()))
.planEndTime(String.valueOf(req.getDisposeTime()))
.flowDirection(CommonEnumHandler.codeOf(NetflowDirection.class,
Optional.ofNullable(req.getFlowDirection())
.orElse(2)))
.attackType(DDoSAttackType.getTypeMaskFromAttackType(
Optional.ofNullable(req.getAttackType())
.orElse(new Integer[]{DDoSAttackType.ALL_ATTACKS.getValue()})))
.flowBandWidth(Optional.ofNullable(req.getFlowBandwidth())
.orElse(DisposeConfigValue.DEFAULT_DISPOSE_BANDWIDTH))
.build();
.deviceId(Long.parseLong(Optional.ofNullable(req.getId()).orElse("-1")))
.accountId(userAccountService.getUserIdByAuthHead(Objects.requireNonNull(headers.get("Authorization"))
.get(0)))
.disposeCapacity(CommonEnumHandler.codeOf(DisposeCapacityType.class,
req.getType()))
.disposeObject(Helper.ipAddressNormalize(req.getDisposeIp()))
.objectType(DisposeObjectType.IP)
.planEndTime(String.valueOf(req.getDisposeTime()))
.flowDirection(CommonEnumHandler.codeOf(NetflowDirection.class,
Optional.ofNullable(req.getFlowDirection())
.orElse(2)))
.attackType(DDoSAttackType.getTypeMaskFromAttackType(
Optional.ofNullable(req.getAttackType())
.orElse(new Integer[]{DDoSAttackType.ALL_ATTACKS.getValue()})))
.flowBandWidth(Optional.ofNullable(req.getFlowBandwidth())
.orElse(DisposeConfigValue.DEFAULT_DISPOSE_BANDWIDTH))
.build();
// 创建处置任务
MulReturnType<ErrorCode, DisposeTask> ret = disposeTaskService.createTask(task);
// 设置返回消息
TaskStartRsp rspInfo = TaskStartRsp.builder()
.disposeIp(task.getDisposeIp())
.build();
.disposeIp(task.getDisposeObject())
.build();
rspInfo.setStatus(ret.getFirstParam().getCode());
rspInfo.setMessage(new String[]{ret.getFirstParam().getMsg()});
@ -157,40 +159,41 @@ public class DisposeTaskController {
DisposeCapacityType capType = CommonEnumHandler.codeOf(DisposeCapacityType.class, req.getType());
String endTime = String.valueOf(req.getDisposeTime());
NetflowDirection netDir = CommonEnumHandler.codeOf(NetflowDirection.class,
Optional.ofNullable(req.getFlowDirection()).orElse(2));
Optional.ofNullable(req.getFlowDirection()).orElse(2));
Long attackType = DDoSAttackType.getTypeMaskFromAttackType(Optional.ofNullable(req.getAttackType())
.orElse(new Integer[]{DDoSAttackType.ALL_ATTACKS.getValue()}));
.orElse(new Integer[]{DDoSAttackType.ALL_ATTACKS.getValue()}));
Integer flowBand = Optional.ofNullable(req.getFlowBandwidth())
.orElse(DisposeConfigValue.DEFAULT_DISPOSE_BANDWIDTH);
.orElse(DisposeConfigValue.DEFAULT_DISPOSE_BANDWIDTH);
TaskStartMulRsp mulRsp = TaskStartMulRsp.builder()
.items(new ArrayList<>())
.build();
.items(new ArrayList<>())
.build();
for (String ip : req.getMulDisposeIp()) {
// 构造处置任务参数
DisposeTask task = DisposeTask.builder()
.deviceId(devId)
.accountId(aId)
.disposeCapacity(capType)
.disposeIp(Helper.ipAddressNormalize(ip))
.planEndTime(endTime)
.flowDirection(netDir)
.attackType(attackType)
.flowBandWidth(flowBand)
.build();
.deviceId(devId)
.accountId(aId)
.disposeCapacity(capType)
.disposeObject(Helper.ipAddressNormalize(ip))
.objectType(DisposeObjectType.IP)
.planEndTime(endTime)
.flowDirection(netDir)
.attackType(attackType)
.flowBandWidth(flowBand)
.build();
// 创建处置任务
MulReturnType<ErrorCode, DisposeTask> ret = disposeTaskService.createTask(task);
// 设置返回消息
TaskStartRsp rspInfo = TaskStartRsp.builder()
.disposeIp(ip)
.build();
.disposeIp(ip)
.build();
// 启动任务成功
if (ret.getFirstParam() == ErrorCode.ERR_OK ||
ret.getFirstParam() == ErrorCode.ERR_TASKRUNNING) {
ret.getFirstParam() == ErrorCode.ERR_TASKRUNNING) {
rspInfo.setTaskId(ret.getSecondParam().getId().toString());
rspInfo.setExpireTime(ret.getSecondParam().getPlanEndTime());
}
@ -231,13 +234,13 @@ public class DisposeTaskController {
// 停止成功
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
rspInfo.setDisposeDevice(ret.getSecondParam().getDeviceTask().stream()
.map(DeviceTask::getDeviceId)
.map(String::valueOf)
.toArray(String[]::new));
.map(DeviceTask::getDeviceId)
.map(String::valueOf)
.toArray(String[]::new));
rspInfo.setType(ret.getSecondParam().getDisposeCapacity().getValue());
rspInfo.setDisposeIp(ret.getSecondParam().getDisposeIp());
rspInfo.setDisposeIp(ret.getSecondParam().getDisposeObject());
rspInfo.setLeftTime(String.valueOf(Math.abs(
Helper.getTimestampDiffNow(ret.getSecondParam().getPlanEndTime())) / 60));
Helper.getTimestampDiffNow(ret.getSecondParam().getPlanEndTime())) / 60));
}
rspInfo.setTaskId(tId);
@ -260,26 +263,27 @@ public class DisposeTaskController {
@ResponseBody
@ApiOperation("获取处置任务")
public ProtocolRespDTO<GetTaskRsp> getAllDisposeTask(
@Validated(ValidGroups.ProtocolCommonValid.class)
@RequestBody ProtocolReqDTO<BasePagesGetReq> mr
@Validated(ValidGroups.ProtocolCommonValid.class)
@RequestBody ProtocolReqDTO<BasePagesGetReq> mr
) {
GetTaskRsp rspInfo = GetTaskRsp.builder().build();
List<GetTaskDetail> getTaskDetail = new ArrayList<>();
//获取TaskId列表
List<Long> reqTaskIds = Arrays.stream(Optional.ofNullable(mr.getMsgContent().getTaskId()).orElse(new String[]{})).
map(Long::parseLong).collect(Collectors.toList());
List<Long> reqTaskIds = Arrays.stream(Optional.ofNullable(mr.getMsgContent().getTaskId())
.orElse(new String[]{})).
map(Long::parseLong).collect(Collectors.toList());
//获取所有可用处置任务
List<DisposeTask> taskList = disposeTaskService.getAllDisposeTask();
List<Long> idArray = taskList.stream().filter(v -> reqTaskIds.size() == 0 || reqTaskIds.contains(v.getId()))
.map(DisposeTask::getId).collect(Collectors.toList());
.map(DisposeTask::getId).collect(Collectors.toList());
if (idArray.size() > 0) {
MulReturnType<PageInfo<DisposeTask>, List<DisposeTask>> ret =
disposeTaskService.getPageDisposeTask(idArray,
mr.getMsgContent().getStartPage(),
mr.getMsgContent().getPageSize());
disposeTaskService.getPageDisposeTask(idArray,
mr.getMsgContent().getStartPage(),
mr.getMsgContent().getPageSize());
// 分页信息
rspInfo.setCurPageNumber(ret.getFirstParam().getPageNum());
@ -289,29 +293,29 @@ public class DisposeTaskController {
ret.getSecondParam().forEach(v -> {
GetTaskDetail taskDetail = GetTaskDetail.builder()
.taskId(String.valueOf(v.getId()))
.accountId(String.valueOf(v.getAccountId()))
.disposeCapacity(v.getDisposeCapacity().getValue())
.disposeIp(v.getDisposeIp())
.createTime(v.getCreateTime())
.planEndTime(v.getPlanEndTime())
.endTime(v.getEndTime())
.flowDirection(v.getFlowDirection().getValue())
.attackType(v.getAttackType().toString())
.flowBandWidth(v.getFlowBandWidth())
.currentStatus(v.getCurrentStatus().getValue())
.deviceTask(new ArrayList<>())
.build();
.taskId(String.valueOf(v.getId()))
.accountId(String.valueOf(v.getAccountId()))
.disposeCapacity(v.getDisposeCapacity().getValue())
.disposeIp(v.getDisposeObject())
.createTime(v.getCreateTime())
.planEndTime(v.getPlanEndTime())
.endTime(v.getEndTime())
.flowDirection(v.getFlowDirection().getValue())
.attackType(v.getAttackType().toString())
.flowBandWidth(v.getFlowBandWidth())
.currentStatus(v.getCurrentStatus().getValue())
.deviceTask(new ArrayList<>())
.build();
taskDetail.setStatus(ErrorCode.ERR_OK.getCode());
taskDetail.setMessage(new String[]{ErrorCode.ERR_OK.getMsg()});
v.getDeviceTask().forEach(k -> {
GetDeviceTaskDetail deviceTaskDetail = GetDeviceTaskDetail.builder()
.devTaskId(String.valueOf(k.getId()))
.devId(String.valueOf(k.getDeviceId()))
.externId(String.valueOf(k.getExternId()))
.status(k.getStatus())
.build();
.devTaskId(String.valueOf(k.getId()))
.devId(String.valueOf(k.getDeviceId()))
.externId(String.valueOf(k.getExternId()))
.status(k.getStatus())
.build();
taskDetail.getDeviceTask().add(deviceTaskDetail);
});
@ -322,19 +326,19 @@ public class DisposeTaskController {
// 设置不存在taskId的错误码
if (reqTaskIds.stream().anyMatch(v -> taskList.stream().noneMatch(k -> k.getId().equals(v)))) {
reqTaskIds.stream()
.filter(v -> taskList.stream().noneMatch(k -> k.getId().equals(v)))
.forEach(v -> {
GetTaskDetail td = GetTaskDetail.builder().build();
td.setTaskId(String.valueOf(v));
td.setStatus(ErrorCode.ERR_NOSUCHTASK.getCode());
td.setMessage(new String[]{ErrorCode.ERR_NOSUCHTASK.getMsg()});
getTaskDetail.add(td);
});
.filter(v -> taskList.stream().noneMatch(k -> k.getId().equals(v)))
.forEach(v -> {
GetTaskDetail td = GetTaskDetail.builder().build();
td.setTaskId(String.valueOf(v));
td.setStatus(ErrorCode.ERR_NOSUCHTASK.getCode());
td.setMessage(new String[]{ErrorCode.ERR_NOSUCHTASK.getMsg()});
getTaskDetail.add(td);
});
}
// 对返回的信息按照TaskID排序
rspInfo.setItems(getTaskDetail.stream().sorted(Comparator.comparing(GetTaskDetail::getTaskId))
.collect(Collectors.toList()));
.collect(Collectors.toList()));
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);
}

View File

@ -1,6 +1,7 @@
package com.dispose.pojo.entity;
import com.dispose.common.DisposeCapacityType;
import com.dispose.common.DisposeObjectType;
import com.dispose.common.DisposeTaskStatus;
import com.dispose.common.NetflowDirection;
import com.fasterxml.jackson.annotation.JsonInclude;
@ -56,9 +57,13 @@ public class DisposeTask implements Serializable {
*/
private DisposeCapacityType disposeCapacity;
/**
* The Dispose ip.
* The Dispose object.
*/
private String disposeIp;
private String disposeObject;
/**
* The Object type.
*/
private DisposeObjectType objectType;
/**
* The Create time.
*/
@ -88,7 +93,7 @@ public class DisposeTask implements Serializable {
*/
private DisposeTaskStatus currentStatus;
/**
* The Task info.
* The Device task.
*/
private List<DeviceTask> deviceTask;
}

View File

@ -68,7 +68,7 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
deviceTask.getTaskAttackType());
// 调用设备执行处置任务
ret = ai.getDb().runDispose(disposeTask.getDisposeIp(), disposeTask.getDisposeCapacity(), null, null, null);
ret = ai.getDb().runDispose(disposeTask.getDisposeObject(), disposeTask.getDisposeCapacity(), null, null, null);
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
// 设置攻击类型任务启动结果
@ -97,7 +97,7 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
MulReturnType<ErrorCode, Long> ret;
// 调用设备执行处置任务
ret = ai.getDb().stopDispose(disposeTask.getDisposeIp(), disposeTask.getDisposeCapacity(), null, null, null);
ret = ai.getDb().stopDispose(disposeTask.getDisposeObject(), disposeTask.getDisposeCapacity(), null, null, null);
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
deviceTaskManager.setAttackTypeStatus(deviceTask.getId(),disposeTask.getFlowDirection(), 0L);
@ -132,7 +132,7 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
deviceTaskManager.setExecAttackType(deviceTask.getId(), NetflowDirection.DIRECTION_BI,
deviceTask.getTaskAttackType());
ret = ai.getDb().runDispose(disposeTask.getDisposeIp(), disposeTask.getDisposeCapacity(), null, null,
ret = ai.getDb().runDispose(disposeTask.getDisposeObject(), disposeTask.getDisposeCapacity(), null, null,
(long) -(Helper.getTimestampDiffNow(disposeTask.getPlanEndTime()) / 60));
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
@ -175,7 +175,7 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
MulReturnType<ErrorCode, Long> ret;
// 停止处置任务
ret = ai.getDb().stopDispose(disposeTask.getDisposeIp(), disposeTask.getDisposeCapacity(), null, null,
ret = ai.getDb().stopDispose(disposeTask.getDisposeObject(), disposeTask.getDisposeCapacity(), null, null,
deviceTask.getExternId());
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
@ -219,7 +219,7 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
deviceTaskManager.execAttackTypeSetBit(deviceTask.getId(), NetflowDirection.DIRECTION_OUT,
t.getValue());
// 调用迪普设备启动处置任务
ret = ai.getDb().runDispose(disposeTask.getDisposeIp(), disposeTask.getDisposeCapacity(),
ret = ai.getDb().runDispose(disposeTask.getDisposeObject(), disposeTask.getDisposeCapacity(),
NetflowDirection.DIRECTION_OUT, t.getValue(), null);
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
@ -256,7 +256,7 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
deviceTaskManager.execAttackTypeSetBit(deviceTask.getId(), NetflowDirection.DIRECTION_IN,
t.getValue());
// 调用迪普设备启动处置任务
ret = ai.getDb().runDispose(disposeTask.getDisposeIp(), disposeTask.getDisposeCapacity(),
ret = ai.getDb().runDispose(disposeTask.getDisposeObject(), disposeTask.getDisposeCapacity(),
NetflowDirection.DIRECTION_IN, t.getValue(), null);
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
@ -331,7 +331,7 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
// 出方向
if (disposeTask.getFlowDirection() != NetflowDirection.DIRECTION_IN) {
// 调用迪普设备停止处置任务
ret = ai.getDb().stopDispose(disposeTask.getDisposeIp(), disposeTask.getDisposeCapacity(),
ret = ai.getDb().stopDispose(disposeTask.getDisposeObject(), disposeTask.getDisposeCapacity(),
NetflowDirection.DIRECTION_OUT, t.getValue(), null);
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
@ -357,7 +357,7 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
// 入方向
if (disposeTask.getFlowDirection() != NetflowDirection.DIRECTION_OUT) {
// 调用迪普设备启动处置任务
ret = ai.getDb().stopDispose(disposeTask.getDisposeIp(), disposeTask.getDisposeCapacity(),
ret = ai.getDb().stopDispose(disposeTask.getDisposeObject(), disposeTask.getDisposeCapacity(),
NetflowDirection.DIRECTION_IN, t.getValue(), null);
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
@ -421,7 +421,7 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
// 清理过期任务
for (DisposeTask v : disposeTaskManager.getExpiredTasks()) {
log.info("Task {} {} {} is expired, expect finished at {}",
v.getId(), v.getDisposeCapacity(), v.getDisposeIp(), v.getPlanEndTime());
v.getId(), v.getDisposeCapacity(), v.getDisposeObject(), v.getPlanEndTime());
// 设置任务状态过期任务不再为设备创建处置任务
disposeTaskManager.changeDisposeTaskStatus(v.getId(), DisposeTaskStatus.TASK_EXPIRED);
}
@ -438,7 +438,7 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
// 当前设备是否支持该处置能力
.filter(c -> c.getDev().getDevCapacity().stream().anyMatch(m -> m.getCapacityType() == v
.getDisposeCapacity()))
.filter(c -> c.getDb().isCarryProtectIp(v.getDisposeIp()))
.filter(c -> c.getDb().isCarryProtectIp(v.getDisposeObject()))
.forEach(d -> {
log.info("Add dispose task for device: {}", d.getDev());
@ -467,7 +467,7 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
AbilityInfo ai = disposeAbilityRouterService.getAbilityDevice(v.getDeviceId());
// 对处置IP生成一个唯一的操作标识符
String taskStartKey = task.getDisposeIp() + "Start" + ai.getDev().getDeviceType().getDescription();
String taskStartKey = task.getDisposeObject() + "Start" + ai.getDev().getDeviceType().getDescription();
if (taskCache.containsKey(taskStartKey)) {
continue;
@ -526,7 +526,7 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
AbilityInfo ai = disposeAbilityRouterService.getAbilityDevice(v.getDeviceId());
// 对处置IP生成一个唯一的操作标识符
String taskStopKey = task.getDisposeIp() + "Stop" + ai.getDev().getDeviceType().getDescription();
String taskStopKey = task.getDisposeObject() + "Stop" + ai.getDev().getDeviceType().getDescription();
if (taskCache.containsKey(taskStopKey)) {
continue;

View File

@ -41,14 +41,14 @@ public class DisposeTaskServiceImpl implements DisposeTaskService {
@Override
public MulReturnType<ErrorCode, DisposeTask> createTask(DisposeTask task) {
DisposeTask exitTask = disposeTaskManager.getDisposeTask(task.getDeviceId(),
task.getDisposeIp(), task.getDisposeCapacity());
task.getDisposeObject(), task.getDisposeCapacity());
if (exitTask != null) {
return new MulReturnType<>(ErrorCode.ERR_TASKRUNNING, exitTask);
}
ErrorCode err = disposeAbilityRouterService.verifyDisposeCapacity(
task.getDeviceId(), task.getDisposeIp(), task.getDisposeCapacity()
task.getDeviceId(), task.getDisposeObject(), task.getDisposeCapacity()
);
if (err != ErrorCode.ERR_OK) {
@ -100,6 +100,7 @@ public class DisposeTaskServiceImpl implements DisposeTaskService {
*
* @return the dispose task list
*/
@Override
public List<DisposeTask> getAllDisposeTask() {
return disposeTaskManager.getDisposeTasks();
}

View File

@ -1,8 +1,8 @@
-- ----------------------------
-- Records of dispose_device
-- ----------------------------
INSERT INTO `dispose_device` VALUES (1, '10.88.77.88:18080', 1, 1, 0, '中移杭研实验室浩瀚清洗设备', 'HaoHan', 'Unknown', 'Unknown', '', '', 'http://%s/DDoSClean/clean', '实验室测试设备', 0);
INSERT INTO `dispose_device` VALUES (2, '10.88.77.15', 0, 1, 0, '中移杭研实验室迪普清洗设备', 'DPTech', 'UMC', 'B5.2.27.7', 'admin', 'UMCAdministrator', 'http://%s/UMC/service/AbnormalFlowCleaningService', '实验室测试设备', 0);
-- INSERT INTO `dispose_device` VALUES (1, '10.88.77.88:18080', 1, 1, 0, '中移杭研实验室浩瀚清洗设备', 'HaoHan', 'Unknown', 'Unknown', '', '', 'http://%s/DDoSClean/clean', '实验室测试设备', 0);
-- INSERT INTO `dispose_device` VALUES (2, '10.88.77.15', 0, 1, 0, '中移杭研实验室迪普清洗设备', 'DPTech', 'UMC', 'B5.2.27.7', 'admin', 'UMCAdministrator', 'http://%s/UMC/service/AbnormalFlowCleaningService', '实验室测试设备', 0);
-- ----------------------------

View File

@ -6,7 +6,8 @@
<id column="deviceId" property="deviceId"/>
<id column="accountId" property="accountId"/>
<result column="disposeCapacity" property="disposeCapacity" javaType="com.dispose.common.DisposeCapacityType"/>
<result column="disposeIp" property="disposeIp"/>
<result column="disposeObject" property="disposeObject"/>
<result column="objectType" property="objectType" javaType="com.dispose.common.DisposeObjectType"/>
<result column="createTime" property="createTime"/>
<result column="planEndTime" property="planEndTime"/>
<result column="endTime" property="endTime"/>
@ -103,7 +104,7 @@
FROM dispose_task dt LEFT JOIN device_task ti on dt.id = ti.taskId
WHERE
dt.disposeCapacity = #{capType} AND
dt.disposeIp = #{disposeIp} AND
dt.disposeObject = #{disposeObject} AND
dt.currentStatus != ${@com.dispose.common.DisposeTaskStatus@TASK_FINISHED.getValue()} AND
dt.currentStatus != ${@com.dispose.common.DisposeTaskStatus@TASK_CANCELED.getValue()} AND
dt.currentStatus != ${@com.dispose.common.DisposeTaskStatus@TASK_EXPIRED.getValue()} AND
@ -130,10 +131,10 @@
<insert id="addNewTask" useGeneratedKeys="true" keyProperty="id"
parameterType="com.dispose.pojo.entity.DisposeTask">
INSERT IGNORE INTO dispose_task(deviceId, accountId, disposeCapacity, disposeIp,
INSERT IGNORE INTO dispose_task(deviceId, accountId, disposeCapacity, disposeObject, objectType,
planEndTime, flowDirection, attackType, flowBandWidth,
currentStatus)
VALUES (#{deviceId}, #{accountId}, #{disposeCapacity}, #{disposeIp},
VALUES (#{deviceId}, #{accountId}, #{disposeCapacity}, #{disposeObject}, ${objectType},
date_add(now(), interval #{planEndTime} MINUTE), #{flowDirection}, #{attackType},
#{flowBandWidth}, ${@com.dispose.common.DisposeTaskStatus@TASK_NEW.getValue()})
</insert>

View File

@ -116,7 +116,8 @@ CREATE TABLE `dispose_task` (
`deviceId` int(10) NOT NULL COMMENT '处置设备唯一标识符',
`accountId` int(10) UNSIGNED NOT NULL COMMENT '用户唯一标识符',
`disposeCapacity` int(11) NOT NULL COMMENT '处置能力类型0清洗 1高防 2黑洞 3检测',
`disposeIp` varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '处置IP',
`disposeObject` varchar(4096) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '处置对象',
`objectType` int(8) NOT NULL COMMENT '处置对象类型:\r\n0IP\r\n1域名 \r\n2URL',
`createTime` timestamp(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '开始时间',
`planEndTime` timestamp(0) NOT NULL DEFAULT '1970-01-02 00:00:00' COMMENT '计划结束时间',
`endTime` timestamp(0) NULL DEFAULT '1970-01-02 00:00:00' COMMENT '实际结束时间',
@ -132,8 +133,8 @@ CREATE TABLE `dispose_task` (
-- ----------------------------
-- Records of dispose_task
-- ----------------------------
INSERT INTO `dispose_task` VALUES (1, -1, 1, 0, '192.168.10.1', CURRENT_TIMESTAMP, date_add(now(), interval 60 MINUTE), null, 2, 8796093022207, 1024, 0);
INSERT INTO `dispose_task` VALUES (2, -1, 1, 0, '192.168.10.2', CURRENT_TIMESTAMP, date_add(now(), interval 60 MINUTE), null, 2, 8796093022207, 1024, 0);
INSERT INTO `dispose_task` VALUES (1, -1, 1, 0, '192.168.10.1', 1, CURRENT_TIMESTAMP, date_add(now(), interval 60 MINUTE), null, 2, 8796093022207, 1024, 0);
INSERT INTO `dispose_task` VALUES (2, -1, 1, 0, '192.168.10.2', 1, CURRENT_TIMESTAMP, date_add(now(), interval 60 MINUTE), null, 2, 8796093022207, 1024, 0);
-- ----------------------------
-- Table structure for user_account

View File

@ -144,7 +144,7 @@ public class DisposeTaskControllerTest extends InitTestEnvironment {
disposeTaskMapper.selectAll().forEach(v -> {
if (v.getDeviceId().equals(Long.valueOf(req.getId())) &&
v.getDisposeIp().equals(req.getDisposeIp()) &&
v.getDisposeObject().equals(req.getDisposeIp()) &&
v.getAttackType().equals((long) DDoSAttackType.ACK_FLOOD.getValue())) {
Assert.assertEquals(Long.valueOf(rspInfo.getMsgContent().getTaskId()), v.getId());
}
@ -164,7 +164,7 @@ public class DisposeTaskControllerTest extends InitTestEnvironment {
TaskStartReq req = TaskStartReq.builder()
.id(String.valueOf(disposeTask.getDeviceId()))
.type(disposeTask.getDisposeCapacity().getValue())
.disposeIp(disposeTask.getDisposeIp())
.disposeIp(disposeTask.getDisposeObject())
.disposeTime(60)
.flowDirection(NetflowDirection.DIRECTION_IN.getValue())
.attackType(new Integer[]{DDoSAttackType.ACK_FLOOD.getValue()})

View File

@ -75,7 +75,7 @@ public class DisposeTaskManagerTest extends InitTestEnvironment {
@Test
public void a1_disposeIpRunning() {
disposeTaskMapper.selectAll().forEach(v -> {
DisposeTask runningResult = disposeTaskManager.getDisposeTask(v.getDeviceId(), v.getDisposeIp(),
DisposeTask runningResult = disposeTaskManager.getDisposeTask(v.getDeviceId(), v.getDisposeObject(),
v.getDisposeCapacity());
log.info("runningResult-->{}", runningResult);
@ -178,7 +178,7 @@ public class DisposeTaskManagerTest extends InitTestEnvironment {
.deviceId(dId)
.accountId(uId)
.disposeCapacity(DisposeCapacityType.CLEANUP)
.disposeIp("192.168.0.1")
.disposeObject("192.168.0.1")
.planEndTime("30")
.flowDirection(NetflowDirection.DIRECTION_BI)
.attackType(DDoSAttackType.getTypeMaskFromAttackType(new DDoSAttackType[]{DDoSAttackType.ALL_ATTACKS}))

View File

@ -76,7 +76,7 @@ public class DisposeTaskMapperTest extends InitTestEnvironment {
.deviceId(dId)
.accountId(uId)
.disposeCapacity(DisposeCapacityType.CLEANUP)
.disposeIp("192.168.0.1")
.disposeObject("192.168.0.1")
.planEndTime("30")
.flowDirection(NetflowDirection.DIRECTION_BI)
.attackType(DDoSAttackType.getTypeMaskFromAttackType(new DDoSAttackType[]{DDoSAttackType.ALL_ATTACKS}))

View File

@ -98,7 +98,7 @@ public class DeviceTaskManagerServiceTest extends InitTestEnvironment {
.deviceId(dId)
.accountId(uId)
.disposeCapacity(DisposeCapacityType.CLEANUP)
.disposeIp("192.168.0.1")
.disposeObject("192.168.0.1")
.planEndTime("30")
.flowDirection(NetflowDirection.DIRECTION_BI)
.attackType(DDoSAttackType.getTypeMaskFromAttackType(new DDoSAttackType[]{DDoSAttackType.ALL_ATTACKS}))

View File

@ -99,7 +99,7 @@ public class DisposeTaskServiceTest extends InitTestEnvironment {
.deviceId(disposeDeviceManager.getAllNormalDisposeDevices().get(0).getId())
.accountId(1L)
.disposeCapacity(DisposeCapacityType.CLEANUP)
.disposeIp("192.168.5.2")
.disposeObject("192.168.5.2")
.planEndTime("30")
.flowDirection(NetflowDirection.DIRECTION_IN)
.attackType(DDoSAttackType.getTypeMaskFromAttackType(new Integer[]{DDoSAttackType.ALL_ATTACKS.getValue()}))
@ -124,7 +124,7 @@ public class DisposeTaskServiceTest extends InitTestEnvironment {
Assert.assertEquals(result.getFirstParam().getCode(), ErrorCode.ERR_TASKRUNNING.getCode());
Assert.assertEquals(result.getSecondParam().getId(), disposeTaskManager.getDisposeTask(newTask.getDeviceId(),
newTask.getDisposeIp(), newTask.getDisposeCapacity()).getId());
newTask.getDisposeObject(), newTask.getDisposeCapacity()).getId());
});
}
@ -137,7 +137,7 @@ public class DisposeTaskServiceTest extends InitTestEnvironment {
.deviceId(disposeDeviceManager.getAllNormalDisposeDevices().get(0).getId())
.accountId(1L)
.disposeCapacity(DisposeCapacityType.CLEANUP)
.disposeIp("192.168.5.2")
.disposeObject("192.168.5.2")
.planEndTime("30")
.flowDirection(NetflowDirection.DIRECTION_IN)
.attackType(DDoSAttackType.getTypeMaskFromAttackType(new Integer[]{DDoSAttackType.ALL_ATTACKS.getValue()}))
@ -175,7 +175,7 @@ public class DisposeTaskServiceTest extends InitTestEnvironment {
.deviceId(disposeDeviceManager.getAllNormalDisposeDevices().get(0).getId())
.accountId(1L)
.disposeCapacity(DisposeCapacityType.CLEANUP)
.disposeIp("192.168.10.2")
.disposeObject("192.168.10.2")
.planEndTime("60")
.flowDirection(NetflowDirection.DIRECTION_IN)
.attackType(DDoSAttackType.getTypeMaskFromAttackType(new Integer[]{DDoSAttackType.ALL_ATTACKS.getValue()}))

View File

@ -54,7 +54,7 @@ public class JsonTestCaseRun extends CommonRestfulJson implements TestCaseRun {
/**
* The constant jsonIdFilter.
*/
private static final Integer[] jsonIdFilter = new Integer[]{};
private static final Integer[] jsonIdFilter = new Integer[]{5};
/**
* The Spring method rule.
*/

View File

@ -100,7 +100,7 @@ public class P2TaskList {
.deviceId(1L)
.accountId(1L)
.disposeCapacity(DisposeCapacityType.CLEANUP)
.disposeIp("192.168.0." + i)
.disposeObject("192.168.0." + i)
.planEndTime("60")
.flowDirection(NetflowDirection.DIRECTION_BI)
.attackType(DDoSAttackType.getTypeMaskFromAttackType(new DDoSAttackType[]{DDoSAttackType.ALL_ATTACKS}))