From fea3f7d971107b0373916945f335b04603ae64dd Mon Sep 17 00:00:00 2001 From: chenlinghy Date: Tue, 8 Dec 2020 14:51:19 +0800 Subject: [PATCH] =?UTF-8?q?OCT=20REM:=201.=E5=8D=8E=E4=B8=BA=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E5=90=AF=E5=8A=A8=E5=92=8C=E5=81=9C=E6=AD=A2=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E6=97=B6=E5=A2=9E=E5=8A=A0Ipv6=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ability/impl/HuaWeiAbilityImpl.java | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/dispose/ability/impl/HuaWeiAbilityImpl.java b/src/main/java/com/dispose/ability/impl/HuaWeiAbilityImpl.java index 0a58604f..8f422494 100644 --- a/src/main/java/com/dispose/ability/impl/HuaWeiAbilityImpl.java +++ b/src/main/java/com/dispose/ability/impl/HuaWeiAbilityImpl.java @@ -12,6 +12,8 @@ import com.dispose.pojo.vo.DeviceFirewareInfo; import com.fasterxml.jackson.databind.ObjectMapper; import com.huawei.dispose.common.HuaWeiLoginResp; import com.huawei.dispose.protocol.HuaWeiInterface; +import inet.ipaddr.IPAddress; +import inet.ipaddr.IPAddressString; import lombok.Getter; import lombok.Setter; import lombok.extern.slf4j.Slf4j; @@ -93,7 +95,15 @@ public class HuaWeiAbilityImpl implements DisposeAbility { @Nullable Integer attackType, @Nullable Long duration) { String url = urlRootPath + "/divert"; - String disposeObj = disposeObject + "/32"; + String disposeObj = null; + + IPAddress addr = new IPAddressString(disposeObject).getAddress(); + + if (addr.isIPv4()) { + disposeObj = disposeObject + "/32"; + }else if(addr.isIPv6()) { + disposeObj = disposeObject + "/128"; + } if (token == null || token.length() == 0) { return new MulReturnType<>(ErrorCode.ERR_LOGOUT, ""); @@ -151,7 +161,15 @@ public class HuaWeiAbilityImpl implements DisposeAbility { @Nullable Integer attackType, @Nullable String taskId) { - String disposeObj = disposeObject + "-32"; + IPAddress addr = new IPAddressString(disposeObject).getAddress(); + String disposeObj = null; + + if (addr.isIPv4()) { + disposeObj = disposeObject + "-32"; + }else if(addr.isIPv6()) { + disposeObj = disposeObject + "-128"; + } + String url = urlRootPath + "/divert/" + disposeObj; if (token == null || token.length() == 0) {