From f92bc9a0976447eb64a0477b63b652320bfc0447 Mon Sep 17 00:00:00 2001 From: HuangXin Date: Wed, 20 Oct 2021 09:17:57 +0800 Subject: [PATCH] =?UTF-8?q?OCT=20REM:=201.=20=E9=9B=86=E5=9B=A2=E4=B8=80?= =?UTF-8?q?=E9=94=AE=E5=A4=84=E7=BD=AE=EF=BC=8C=E7=A7=BB=E9=99=A4=E5=AF=B9?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E8=83=BD=E5=8A=9B=E4=BF=A1=E6=81=AF=E7=9A=84?= =?UTF-8?q?=E5=88=A4=E6=96=AD=EF=BC=8C=E9=BB=98=E8=AE=A4=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=A4=84=E7=BD=AE=E8=83=BD=E5=8A=9B=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E5=A4=84=E7=BD=AE=E7=9A=84IP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ability/impl/PengXinAbilityImpl.java | 164 +++++++++--------- 1 file changed, 85 insertions(+), 79 deletions(-) diff --git a/src/main/java/com/dispose/ability/impl/PengXinAbilityImpl.java b/src/main/java/com/dispose/ability/impl/PengXinAbilityImpl.java index f017599b..a732fac8 100644 --- a/src/main/java/com/dispose/ability/impl/PengXinAbilityImpl.java +++ b/src/main/java/com/dispose/ability/impl/PengXinAbilityImpl.java @@ -163,10 +163,12 @@ public class PengXinAbilityImpl implements DisposeAbility { try { log.info("++++Begging PengXin Start Cleanup Task: {}", disposeObject); - if (capType != DisposeCapacityType.BLACKHOOL) { - log.error("----Error PengXin don't support dispose capacity type: {}", capType); - return new MulReturnType<>(ErrorCode.ERR_UNSUPPORT, null); - } + + // 集团一键处置线上环境,移除对处置能力检测操作 +// if (capType != DisposeCapacityType.BLACKHOOL) { +// log.error("----Error PengXin don't support dispose capacity type: {}", capType); +// return new MulReturnType<>(ErrorCode.ERR_UNSUPPORT, null); +// } // 适配处置时间参数, -1为不限制处置时间 if (duration == null || duration < 0) { @@ -359,54 +361,55 @@ public class PengXinAbilityImpl implements DisposeAbility { */ @Override public void getDisposeDeviceProtectObject() { + // 集团一键处置线上环境,移除从设备获取能力信息相关接口调用 - if (token == null || token.length() == 0) { - return; - } +// if (token == null || token.length() == 0) { +// return; +// } - try { - String url = urlRootPath + "dispose_device/information/capacity"; - - ProtocolRespDTO rspInfo = restfulInterface.getDeviceDisposeAbility(url, token); - - // 判断是否token过期 - if (rspInfo != null && reLogin(rspInfo, rspInfo.getMsgContent().getStatus())) { - 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())) { - String [] allIpAddr = {null, "0.0.0.0", "0.0.0.0,::"}; - - if(Arrays.asList(allIpAddr).contains(v.getDisposeIp())) { - 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) { - } +// try { +// String url = urlRootPath + "dispose_device/information/capacity"; +// +// ProtocolRespDTO rspInfo = restfulInterface.getDeviceDisposeAbility(url, token); +// +// // 判断是否token过期 +// if (rspInfo != null && reLogin(rspInfo, rspInfo.getMsgContent().getStatus())) { +// 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())) { +// String [] allIpAddr = {null, "0.0.0.0", "0.0.0.0,::"}; +// +// if(Arrays.asList(allIpAddr).contains(v.getDisposeIp())) { +// 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) { +// } } /** @@ -417,34 +420,36 @@ public class PengXinAbilityImpl implements DisposeAbility { */ @Override public boolean isCarryProtectIp(String ipAddr) { - boolean ret = false; - IPAddress addr = new IPAddressString(ipAddr).getAddress(); - synchronized (this) { - if (addr.isIPv4()) { - ret = protectIpV4.stream().anyMatch(v -> Helper.ipInRange(v, ipAddr)); - } - - if (addr.isIPv6()) { - ret = protectIpV6.stream().anyMatch(v -> Helper.ipInRange(v, ipAddr)); - } - } - - if (!ret) { - // 更新设备防护IP - getDisposeDeviceProtectObject(); - - synchronized (this) { - if (addr.isIPv4()) { - ret = protectIpV4.stream().anyMatch(v -> Helper.ipInRange(v, ipAddr)); - } - - if (addr.isIPv6()) { - ret = protectIpV6.stream().anyMatch(v -> Helper.ipInRange(v, ipAddr)); - } - } - } - - return ret; + // 集团一键处置线上环境,默认支持所有IP地址 + return true; +// boolean ret = false; +// IPAddress addr = new IPAddressString(ipAddr).getAddress(); +// synchronized (this) { +// if (addr.isIPv4()) { +// ret = protectIpV4.stream().anyMatch(v -> Helper.ipInRange(v, ipAddr)); +// } +// +// if (addr.isIPv6()) { +// ret = protectIpV6.stream().anyMatch(v -> Helper.ipInRange(v, ipAddr)); +// } +// } +// +// if (!ret) { +// // 更新设备防护IP +// getDisposeDeviceProtectObject(); +// +// synchronized (this) { +// if (addr.isIPv4()) { +// ret = protectIpV4.stream().anyMatch(v -> Helper.ipInRange(v, ipAddr)); +// } +// +// if (addr.isIPv6()) { +// ret = protectIpV6.stream().anyMatch(v -> Helper.ipInRange(v, ipAddr)); +// } +// } +// } +// +// return ret; } /** @@ -533,8 +538,9 @@ public class PengXinAbilityImpl implements DisposeAbility { public void periodTaskRuntime() { log.debug("++++PengXin Period Task Running"); + // 集团一键处置线上环境,不再定时获取设备能力信息 // 更新防护对象 - getDisposeDeviceProtectObject(); + //getDisposeDeviceProtectObject(); // 更新心跳状态 if (timerCnt++ % DisposeConfigValue.HEART_PERIOD_OF_SECOND == 0) {