REM:
1.删除多余代码
2.增加判断设备是否支持IP判断
This commit is contained in:
chenlinghy 2021-01-29 17:25:42 +08:00
parent 8b1a247b32
commit 96e99b6556
2 changed files with 41 additions and 13 deletions

View File

@ -1,15 +1,10 @@
package com.dispose.service.impl; package com.dispose.service.impl;
import com.dispose.common.DisposeConfigValue; import com.dispose.common.*;
import com.dispose.common.DisposeDeviceType;
import com.dispose.common.DisposeTaskStatus;
import com.dispose.common.DpTechAttackType;
import com.dispose.common.ErrorCode;
import com.dispose.common.Helper;
import com.dispose.common.NetflowDirection;
import com.dispose.manager.DeviceTaskManager; import com.dispose.manager.DeviceTaskManager;
import com.dispose.manager.DisposeTaskManager; import com.dispose.manager.DisposeTaskManager;
import com.dispose.pojo.entity.DeviceTask; import com.dispose.pojo.entity.DeviceTask;
import com.dispose.pojo.entity.DisposeCapacity;
import com.dispose.pojo.entity.DisposeTask; import com.dispose.pojo.entity.DisposeTask;
import com.dispose.pojo.po.AbilityInfo; import com.dispose.pojo.po.AbilityInfo;
import com.dispose.pojo.po.MulReturnType; import com.dispose.pojo.po.MulReturnType;
@ -22,6 +17,7 @@ import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
/** /**
@ -56,6 +52,39 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
@Resource @Resource
private DisposeAbilityRouterService disposeAbilityRouterService; private DisposeAbilityRouterService disposeAbilityRouterService;
/**
* Is carry ip boolean.
*
* @param disposeIp the dispose ip
* @param ipSegment the ip segment
* @return the boolean
*/
private boolean isCarryIp(String disposeIp, String ipSegment) {
for (String v : ipSegment.split(DisposeConfigValue.SPLIT_CHAR)) {
if (Helper.ipInRange(v, disposeIp)) {
return true;
}
}
return false;
}
/**
* Is carry dispose object boolean.
*
* @param disposeIp the dispose ip
* @param cfgProtect the cfg protect
* @return the boolean
*/
private boolean isCarryDisposeObject(String disposeIp, List<DisposeCapacity> cfgProtect) {
if (cfgProtect.stream().noneMatch(k -> (k.getObjectType().getValue() & DisposeObjectType.IP.getValue()) != 0)) {
return false;
}
return cfgProtect.stream().anyMatch(k -> isCarryIp(disposeIp, k.getProtectIp()));
}
/** /**
* Virtual device task run. * Virtual device task run.
* *
@ -482,6 +511,11 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
// 判断设备是否就绪 // 判断设备是否就绪
.filter(c -> c.getDb().deviceReady()) .filter(c -> c.getDb().deviceReady())
.forEach(d -> { .forEach(d -> {
// // 检查当前设备protectIp是否支持清洗IP
// if(!isCarryDisposeObject(v.getDisposeObject(), d.getDev().getDevCapacity())){
// return;
// }
// 检查当前设备是否已经创建了该任务 // 检查当前设备是否已经创建了该任务
if (deviceTaskManager.deviceTaskCreated(v.getId(), if (deviceTaskManager.deviceTaskCreated(v.getId(),
d.getDev().getId())) { d.getDev().getId())) {

View File

@ -219,12 +219,6 @@ public class DisposeAbilityRouterServiceImpl implements DisposeAbilityRouterServ
return ErrorCode.ERR_NOSUCHTYPE; return ErrorCode.ERR_NOSUCHTYPE;
} }
// if (getAllAbilityDevices().stream()
// .filter(f -> deviceId == -1 || f.getDev().getId().equals(deviceId))
// .noneMatch(f -> isCarryDisposeObject(disposeIp, f.getDev().getDevCapacity()))) {
// return ErrorCode.ERR_NOSUCHDEVICE;
// }
if (getAllAbilityDevices().stream() if (getAllAbilityDevices().stream()
.noneMatch(c -> c.getDb().isCarryProtectIp(disposeIp))) { .noneMatch(c -> c.getDb().isCarryProtectIp(disposeIp))) {
return ErrorCode.ERR_IPNODEVICE; return ErrorCode.ERR_IPNODEVICE;