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) {