From 96e99b65563c4a17ec70b2b28ec02e70408fec57 Mon Sep 17 00:00:00 2001 From: chenlinghy Date: Fri, 29 Jan 2021 17:25:42 +0800 Subject: [PATCH] =?UTF-8?q?OCT=20REM:=201.=E5=88=A0=E9=99=A4=E5=A4=9A?= =?UTF-8?q?=E4=BD=99=E4=BB=A3=E7=A0=81=202.=E5=A2=9E=E5=8A=A0=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E8=AE=BE=E5=A4=87=E6=98=AF=E5=90=A6=E6=94=AF=E6=8C=81?= =?UTF-8?q?IP=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/DeviceTaskManagerServiceImpl.java | 48 ++++++++++++++++--- .../impl/DisposeAbilityRouterServiceImpl.java | 6 --- 2 files changed, 41 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/dispose/service/impl/DeviceTaskManagerServiceImpl.java b/src/main/java/com/dispose/service/impl/DeviceTaskManagerServiceImpl.java index d62fc05e..fb9aff18 100644 --- a/src/main/java/com/dispose/service/impl/DeviceTaskManagerServiceImpl.java +++ b/src/main/java/com/dispose/service/impl/DeviceTaskManagerServiceImpl.java @@ -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 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())) { diff --git a/src/main/java/com/dispose/service/impl/DisposeAbilityRouterServiceImpl.java b/src/main/java/com/dispose/service/impl/DisposeAbilityRouterServiceImpl.java index 5a1336b7..fdf888e0 100644 --- a/src/main/java/com/dispose/service/impl/DisposeAbilityRouterServiceImpl.java +++ b/src/main/java/com/dispose/service/impl/DisposeAbilityRouterServiceImpl.java @@ -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;