parent
8b1a247b32
commit
96e99b6556
|
@ -1,15 +1,10 @@
|
|||
package com.dispose.service.impl;
|
||||
|
||||
import com.dispose.common.DisposeConfigValue;
|
||||
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.common.*;
|
||||
import com.dispose.manager.DeviceTaskManager;
|
||||
import com.dispose.manager.DisposeTaskManager;
|
||||
import com.dispose.pojo.entity.DeviceTask;
|
||||
import com.dispose.pojo.entity.DisposeCapacity;
|
||||
import com.dispose.pojo.entity.DisposeTask;
|
||||
import com.dispose.pojo.po.AbilityInfo;
|
||||
import com.dispose.pojo.po.MulReturnType;
|
||||
|
@ -22,6 +17,7 @@ import org.springframework.scheduling.annotation.Scheduled;
|
|||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
|
@ -56,6 +52,39 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
|||
@Resource
|
||||
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.
|
||||
*
|
||||
|
@ -482,6 +511,11 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
|||
// 判断设备是否就绪
|
||||
.filter(c -> c.getDb().deviceReady())
|
||||
.forEach(d -> {
|
||||
// // 检查当前设备protectIp是否支持清洗IP
|
||||
// if(!isCarryDisposeObject(v.getDisposeObject(), d.getDev().getDevCapacity())){
|
||||
// return;
|
||||
// }
|
||||
|
||||
// 检查当前设备是否已经创建了该任务
|
||||
if (deviceTaskManager.deviceTaskCreated(v.getId(),
|
||||
d.getDev().getId())) {
|
||||
|
|
|
@ -219,12 +219,6 @@ public class DisposeAbilityRouterServiceImpl implements DisposeAbilityRouterServ
|
|||
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()
|
||||
.noneMatch(c -> c.getDb().isCarryProtectIp(disposeIp))) {
|
||||
return ErrorCode.ERR_IPNODEVICE;
|
||||
|
|
Loading…
Reference in New Issue