From 9a5c08b4b4b8976ddee59b77b73476683a8f6dab Mon Sep 17 00:00:00 2001 From: chenlinghy Date: Thu, 29 Jul 2021 11:00:12 +0800 Subject: [PATCH] =?UTF-8?q?OCT=20REM:=201.=20=E6=9B=B4=E6=96=B0upf?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E9=98=B2=E6=8A=A4=E5=AF=B9=E8=B1=A1=E5=92=8C?= =?UTF-8?q?=E5=BF=83=E8=B7=B3=E8=8E=B7=E5=8F=96=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dispose/ability/impl/UpfAbilityImpl.java | 139 +----------------- 1 file changed, 8 insertions(+), 131 deletions(-) diff --git a/src/main/java/com/dispose/ability/impl/UpfAbilityImpl.java b/src/main/java/com/dispose/ability/impl/UpfAbilityImpl.java index b3410082..69298c65 100644 --- a/src/main/java/com/dispose/ability/impl/UpfAbilityImpl.java +++ b/src/main/java/com/dispose/ability/impl/UpfAbilityImpl.java @@ -1,24 +1,18 @@ package com.dispose.ability.impl; 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.IpAddrType; import com.dispose.common.NetflowDirection; import com.dispose.pojo.dto.protocol.base.ProtocolRespDTO; import com.dispose.pojo.entity.ServiceInfo; import com.dispose.pojo.po.MulReturnType; import com.dispose.pojo.vo.DeviceFirewareInfo; -import com.pengxin.dispose.common.PengXinDisposeAbilityRsp; import com.pengxin.dispose.common.PengXinStartTaskItem; import com.pengxin.dispose.common.PengXinStartTaskRsp; import com.pengxin.dispose.common.PengXinStopTaskRsp; import com.pengxin.dispose.common.PengXinTaskStatusRsp; import com.pengxin.dispose.protocol.PengXinInterface; -import inet.ipaddr.IPAddress; -import inet.ipaddr.IPAddressString; import lombok.Getter; import lombok.Setter; import lombok.extern.slf4j.Slf4j; @@ -30,18 +24,11 @@ import java.util.List; /** * The type upf ability. + * * @author Nicole */ @Slf4j public class UpfAbilityImpl extends PengXinAbilityImpl { - /** - * The Protect ip v 4. - */ - private final List protectIpV4 = new ArrayList<>(); - /** - * The Protect ip v 6. - */ - private final List protectIpV6 = new ArrayList<>(); /** * The Restful interface. */ @@ -54,15 +41,6 @@ public class UpfAbilityImpl extends PengXinAbilityImpl { * The Task req id. */ private Long taskReqId = System.currentTimeMillis(); - /** - * The Timer cnt. - */ - private long timerCnt = 0; - /** - * The Device link status. - */ - private boolean deviceLinkStatus = false; - /** * The Url root path. */ @@ -300,39 +278,8 @@ public class UpfAbilityImpl extends PengXinAbilityImpl { */ @Override public boolean getDeviceLinkStatus() { - return deviceLinkStatus; - } - - /** - * Dev get link status. - */ - private void devGetLinkStatus() { - try { - String url = urlRootPath + "dispose_device/information/linkstatus"; - - if (token == null || token.length() == 0) { - deviceLinkStatus = false; - return; - } - - ErrorCode err = restfulInterface.getLinkStatus(url, token); - - if (err == ErrorCode.ERR_LOGOUT) { - // 重新登录获取 token - upgradeToken(); - err = restfulInterface.getLinkStatus(url, token); - } - - if (err == ErrorCode.ERR_OK) { - deviceLinkStatus = true; - } - - return; - } catch (Exception ex) { - log.error(ex.getMessage()); - } - - deviceLinkStatus = false; + //upf设备不提供链接状态接口,默认该设备在线 + return true; } /** @@ -340,45 +287,7 @@ public class UpfAbilityImpl extends PengXinAbilityImpl { */ @Override public void getDisposeDeviceProtectObject() { - if (token == null || token.length() == 0) { - return; - } - - try { - String url = urlRootPath + "dispose_device/information/capacity"; - ProtocolRespDTO rspInfo = restfulInterface.getDeviceDisposeAbility(url, token); - - if (rspInfo != null && rspInfo.getCode() == ErrorCode.ERR_OK.getHttpCode() - && rspInfo.getMsgContent().getStatus() == ErrorCode.ERR_OK.getCode()) { - - rspInfo.getMsgContent().getCapacity().forEach(v -> { - if (v.getObjectType().equals(DisposeObjectType.DOMAIN.getValue())) { - log.error("Unsupported: {}", v.getObjectType()); - } else if (v.getObjectType().equals(DisposeObjectType.URL.getValue())) { - log.error("Unsupported: {}", v.getObjectType()); - } else { - synchronized (this) { - - protectIpV4.clear(); - protectIpV6.clear(); - - if (v.getIpType() == null || v.getIpType().equals(IpAddrType.IPV4_IPV6.getValue())) { - if (v.getDisposeIp() == null) { - protectIpV4.add(""); - protectIpV6.add(""); - } - } else if (v.getIpType().equals(IpAddrType.IPV4.getValue())) { - protectIpV4.add(""); - } else if (v.getIpType().equals(IpAddrType.IPV6.getValue())) { - protectIpV6.add(""); - } - } - } - }); - - } - } catch (Exception ignored) { - } + //upf设备不提供处置能力接口 } /** @@ -389,34 +298,9 @@ public class UpfAbilityImpl extends PengXinAbilityImpl { */ @Override public boolean isCarryProtectIp(String ipAddress) { - boolean ret = false; - IPAddress address = new IPAddressString(ipAddress).getAddress(); - synchronized (this) { - if (address.isIPv4()) { - ret = protectIpV4.stream().anyMatch(v -> Helper.ipInRange(v, ipAddress)); - } - - if (address.isIPv6()) { - ret = protectIpV6.stream().anyMatch(v -> Helper.ipInRange(v, ipAddress)); - } - } - - if (!ret) { - // 更新设备防护IP - getDisposeDeviceProtectObject(); - - synchronized (this) { - if (address.isIPv4()) { - ret = protectIpV4.stream().anyMatch(v -> Helper.ipInRange(v, ipAddress)); - } - - if (address.isIPv6()) { - ret = protectIpV6.stream().anyMatch(v -> Helper.ipInRange(v, ipAddress)); - } - } - } - - return ret; + //根据设备提供的处置能力,涉及处置能力、处置对象类型、IP类型和该能力能够处置的IP,因现在未提供处置能力接口,默认所有的处置IP都支持 + //如果提供处置能力接口,入参ipAddress会根据能够处置的IP范围进行判断 + return true; } /** @@ -476,15 +360,8 @@ public class UpfAbilityImpl extends PengXinAbilityImpl { */ @Override public void periodTaskRuntime() { + //防护对象和设备状态都是默认值,不根据设备实时状态获取,不做处理 log.debug("++++UPF Period Task Running"); - // 更新防护对象 - getDisposeDeviceProtectObject(); - // 更新心跳状态 - if (timerCnt++ % DisposeConfigValue.HEART_PERIOD_OF_SECOND == 0) { - devGetLinkStatus(); - } - - log.debug("----UPF Period Task Running"); } /**