REM:
1. 迪普设备兼容第三方联动与旁路手动牵引两种清洗模式
This commit is contained in:
HuangXin 2021-01-19 10:20:05 +08:00
parent 20c56c79ba
commit 0e91b3a064
3 changed files with 77 additions and 63 deletions

View File

@ -275,7 +275,7 @@ public class DpTechAbilityImpl implements DisposeAbility {
*/
@Override
public Long toDeviceAttackType(Long ddosAttackTypeMask) {
return DpTechAttackType.formDdosAttackTypeMaks(ddosAttackTypeMask);
return DpTechAttackType.getTypeMaskFromAttackType(new DpTechAttackType[] {DpTechAttackType.UDP_FLOOD});
}
/**

View File

@ -53,7 +53,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
private final Hashtable<String, ServiceInfo> disposeServiceGroup = new Hashtable<>();
/**
* The Obj prefix.
* The Object prefix.
*/
private final String objectPrefix = "CMHI";
/**
@ -1026,4 +1026,15 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
return super.deviceReady();
}
/**
* To device attack type long.
*
* @param ddosAttackTypeMask the ddos attack type mask
* @return the long
*/
@Override
public Long toDeviceAttackType(Long ddosAttackTypeMask) {
return DpTechAttackType.getTypeMaskFromAttackType(new DpTechAttackType[] {DpTechAttackType.AUTO_ATTACK_TYPE});
}
}

View File

@ -135,73 +135,75 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
// 启动迪普设备采用一种攻击类型
DpTechAttackType attackType = DpTechAttackType.maskToDdosAttackType(deviceTask.getTaskAttackType()).get(0);
// 出方向
if (disposeTask.getFlowDirection() != NetflowDirection.DIRECTION_IN) {
// 设置启动任务攻击类型状态
deviceTaskManager.execAttackTypeSetBit(deviceTask.getId(), NetflowDirection.DIRECTION_OUT,
attackType.getValue());
// 调用迪普设备启动处置任务
ret = ai.getDb().runDispose(disposeTask.getDisposeObject(), disposeTask.getObjectType(),
disposeTask.getDisposeCapacity(), NetflowDirection.DIRECTION_OUT,
attackType.getValue(), null);
// 出方向
if (disposeTask.getFlowDirection() != NetflowDirection.DIRECTION_IN) {
// 设置启动任务攻击类型状态
deviceTaskManager.execAttackTypeSetBit(deviceTask.getId(), NetflowDirection.DIRECTION_OUT,
attackType.getValue());
// 调用迪普设备启动处置任务
ret = ai.getDb().runDispose(disposeTask.getDisposeObject(), disposeTask.getObjectType(),
disposeTask.getDisposeCapacity(), NetflowDirection.DIRECTION_OUT,
attackType.getValue(), null);
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
// 标志启动成功
deviceTaskManager.attackTypeStatusSetBit(deviceTask.getId(), NetflowDirection.DIRECTION_OUT,
attackType.getValue());
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
// 标志启动成功
deviceTaskManager.attackTypeStatusSetBit(deviceTask.getId(), NetflowDirection.DIRECTION_OUT,
attackType.getValue());
log.info("DPTECH_UMC setup task {}, {} succeed: {}", attackType, NetflowDirection.DIRECTION_OUT, deviceTask);
log.info("DPTECH_UMC setup task {}, {} succeed: {}", attackType, NetflowDirection.DIRECTION_OUT,
deviceTask);
deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), 0);
} else if (deviceTask.getErrRetry() < DisposeConfigValue.CALL_ERROR_RETRY_TIMES * 10) {
// 设置该任务为新任务待下次重试启动
// 记录任务出错重试次数
deviceTask.setErrRetry(deviceTask.getErrRetry() + 1);
deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), deviceTask.getErrRetry());
//清除任务攻击类型启动标志
deviceTaskManager.execAttackTypeCleanBit(deviceTask.getId(), NetflowDirection.DIRECTION_OUT,
attackType.getValue());
log.error("DPTECH_UMC setup task {}, {} times {} error: {}", attackType,
NetflowDirection.DIRECTION_OUT, deviceTask.getErrRetry(), deviceTask);
} else {
log.error("DPTECH_UMC setup task {}, {} error {}: {}", attackType,
NetflowDirection.DIRECTION_OUT, ret.getFirstParam(), deviceTask);
}
deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), 0);
} else if (deviceTask.getErrRetry() < DisposeConfigValue.CALL_ERROR_RETRY_TIMES * 10) {
// 设置该任务为新任务待下次重试启动
// 记录任务出错重试次数
deviceTask.setErrRetry(deviceTask.getErrRetry() + 1);
deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), deviceTask.getErrRetry());
//清除任务攻击类型启动标志
deviceTaskManager.execAttackTypeCleanBit(deviceTask.getId(), NetflowDirection.DIRECTION_OUT,
attackType.getValue());
log.error("DPTECH_UMC setup task {}, {} times {} error: {}", attackType,
NetflowDirection.DIRECTION_OUT, deviceTask.getErrRetry(), deviceTask);
} else {
log.error("DPTECH_UMC setup task {}, {} error {}: {}", attackType,
NetflowDirection.DIRECTION_OUT, ret.getFirstParam(), deviceTask);
}
}
// 入方向
if (disposeTask.getFlowDirection() != NetflowDirection.DIRECTION_OUT) {
// 设置启动任务攻击类型状态
deviceTaskManager.execAttackTypeSetBit(deviceTask.getId(), NetflowDirection.DIRECTION_IN,
attackType.getValue());
// 调用迪普设备启动处置任务
ret = ai.getDb().runDispose(disposeTask.getDisposeObject(), disposeTask.getObjectType(),
disposeTask.getDisposeCapacity(), NetflowDirection.DIRECTION_IN,
attackType.getValue(), null);
// 入方向
if (disposeTask.getFlowDirection() != NetflowDirection.DIRECTION_OUT) {
// 设置启动任务攻击类型状态
deviceTaskManager.execAttackTypeSetBit(deviceTask.getId(), NetflowDirection.DIRECTION_IN,
attackType.getValue());
// 调用迪普设备启动处置任务
ret = ai.getDb().runDispose(disposeTask.getDisposeObject(), disposeTask.getObjectType(),
disposeTask.getDisposeCapacity(), NetflowDirection.DIRECTION_IN,
attackType.getValue(), null);
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
// 标志启动成功
deviceTaskManager.attackTypeStatusSetBit(deviceTask.getId(), NetflowDirection.DIRECTION_IN,
attackType.getValue());
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
// 标志启动成功
deviceTaskManager.attackTypeStatusSetBit(deviceTask.getId(), NetflowDirection.DIRECTION_IN,
attackType.getValue());
log.info("DPTECH_UMC setup task {}, {} succeed: {}", attackType, NetflowDirection.DIRECTION_IN, deviceTask);
log.info("DPTECH_UMC setup task {}, {} succeed: {}", attackType, NetflowDirection.DIRECTION_IN,
deviceTask);
deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), 0);
} else if (deviceTask.getErrRetry() < DisposeConfigValue.CALL_ERROR_RETRY_TIMES * 10) {
// 设置该任务为新任务待下次重试启动
// 记录任务出错重试次数
deviceTask.setErrRetry(deviceTask.getErrRetry() + 1);
deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), deviceTask.getErrRetry());
//清除任务攻击类型启动标志
deviceTaskManager.execAttackTypeCleanBit(deviceTask.getId(), NetflowDirection.DIRECTION_IN,
attackType.getValue());
log.error("DPTECH_UMC setup task {}, {} times {} error: {}", attackType,
NetflowDirection.DIRECTION_IN, deviceTask.getErrRetry(), deviceTask);
} else {
log.error("DPTECH_UMC setup task {}, {} error {}: {}", attackType,
NetflowDirection.DIRECTION_IN, ret.getFirstParam(), deviceTask);
}
deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), 0);
} else if (deviceTask.getErrRetry() < DisposeConfigValue.CALL_ERROR_RETRY_TIMES * 10) {
// 设置该任务为新任务待下次重试启动
// 记录任务出错重试次数
deviceTask.setErrRetry(deviceTask.getErrRetry() + 1);
deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), deviceTask.getErrRetry());
//清除任务攻击类型启动标志
deviceTaskManager.execAttackTypeCleanBit(deviceTask.getId(), NetflowDirection.DIRECTION_IN,
attackType.getValue());
log.error("DPTECH_UMC setup task {}, {} times {} error: {}", attackType,
NetflowDirection.DIRECTION_IN, deviceTask.getErrRetry(), deviceTask);
} else {
log.error("DPTECH_UMC setup task {}, {} error {}: {}", attackType,
NetflowDirection.DIRECTION_IN, ret.getFirstParam(), deviceTask);
}
}
// 检查需要处置的各种攻击类型任务启动状态与处置任务执行状态判断该处置任务是否调用成功
@ -482,9 +484,10 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
.forEach(d -> {
log.info("Add dispose task for device: {}", d.getDev());
if (!deviceTaskManager.addDisposeDeviceTaskInfo(v.getId(), d.getDev().getId(),
d.getDb()
.toDeviceAttackType(v.getAttackType()))) {
if (!deviceTaskManager
.addDisposeDeviceTaskInfo(v.getId(),
d.getDev().getId(),
d.getDb().toDeviceAttackType(v.getAttackType()))) {
log.error("Add task {} to device {} error", v, d);
}
});