From 1d7da3354d2f2f721bd165330895a7fe421ce714 Mon Sep 17 00:00:00 2001 From: HuangXin Date: Thu, 24 Sep 2020 10:58:14 +0800 Subject: [PATCH] =?UTF-8?q?OCT=20REM:=201.=20=E8=BF=AA=E6=99=AE=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E9=98=B2=E6=8A=A4IP=E4=B8=8D=E5=9C=A8=E8=8C=83?= =?UTF-8?q?=E5=9B=B4=E5=86=85=E6=97=B6=EF=BC=8C=E8=87=AA=E5=8A=A8=E4=BB=8E?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E4=B8=8A=E6=9B=B4=E6=96=B0=E4=B8=80=E6=AC=A1?= =?UTF-8?q?=E9=98=B2=E6=8A=A4IP=EF=BC=8C=E5=86=8D=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ability/impl/DpTechAbilityImpl.java | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/dispose/ability/impl/DpTechAbilityImpl.java b/src/main/java/com/dispose/ability/impl/DpTechAbilityImpl.java index b29f8310..4b1e168f 100644 --- a/src/main/java/com/dispose/ability/impl/DpTechAbilityImpl.java +++ b/src/main/java/com/dispose/ability/impl/DpTechAbilityImpl.java @@ -92,9 +92,6 @@ public class DpTechAbilityImpl implements DisposeAbility { //读取超时 policy.setReceiveTimeout(DpTechConfigValue.SOAP_RECEIVE_TIMEOUT_SECOND); conduit.setClient(policy); - - // 获取迪普设备防护IP - getDisposeDeviceProtectObject(); } /** @@ -266,16 +263,33 @@ public class DpTechAbilityImpl implements DisposeAbility { */ @Override public boolean isCarryProtectIp(String ipAddr) { + boolean ret = false; IPAddress addr = new IPAddressString(ipAddr).getAddress(); synchronized (this) { if (addr.isIPv4()) { - return protectIpV4.stream().anyMatch(v -> Helper.ipInRange(v, ipAddr)); + ret = protectIpV4.stream().anyMatch(v -> Helper.ipInRange(v, ipAddr)); } if (addr.isIPv6()) { - return protectIpV6.stream().anyMatch(v -> Helper.ipInRange(v, ipAddr)); + ret = protectIpV6.stream().anyMatch(v -> Helper.ipInRange(v, ipAddr)); } } - return false; + + 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; } }