parent
9234d1a1c5
commit
118ebc1528
|
@ -14,7 +14,7 @@ import javax.annotation.Nullable;
|
||||||
*
|
*
|
||||||
* @author <huangxin@cmhi.chinamoblie.com>
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
*/
|
*/
|
||||||
public interface DisposeAbility {
|
public interface DisposeAbility<T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init device env.
|
* Init device env.
|
||||||
|
@ -35,22 +35,7 @@ public interface DisposeAbility {
|
||||||
* @param duration the duration
|
* @param duration the duration
|
||||||
* @return the mul return type
|
* @return the mul return type
|
||||||
*/
|
*/
|
||||||
MulReturnType<ErrorCode, Long> runDispose(String ip, DisposeCapacityType capType,
|
T runDispose(String ip, DisposeCapacityType capType,
|
||||||
@Nullable NetflowDirection[] nfDirection,
|
|
||||||
@Nullable DDoSAttackType[] attackType,
|
|
||||||
@Nullable Long duration);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Run dispose mul return type.
|
|
||||||
*
|
|
||||||
* @param ip the ip
|
|
||||||
* @param capType the cap type
|
|
||||||
* @param nfDirection the nf direction
|
|
||||||
* @param attackType the attack type
|
|
||||||
* @param duration the duration
|
|
||||||
* @return the mul return type
|
|
||||||
*/
|
|
||||||
MulReturnType<ErrorCode, Long> runDispose(String ip, DisposeCapacityType capType,
|
|
||||||
@Nullable NetflowDirection nfDirection,
|
@Nullable NetflowDirection nfDirection,
|
||||||
@Nullable DDoSAttackType attackType,
|
@Nullable DDoSAttackType attackType,
|
||||||
@Nullable Long duration);
|
@Nullable Long duration);
|
||||||
|
@ -65,23 +50,7 @@ public interface DisposeAbility {
|
||||||
* @param taskId the task id
|
* @param taskId the task id
|
||||||
* @return the mul return type
|
* @return the mul return type
|
||||||
*/
|
*/
|
||||||
MulReturnType<ErrorCode, Long> stopDispose(String ip, DisposeCapacityType capType,
|
T stopDispose(String ip, DisposeCapacityType capType,
|
||||||
@Nullable NetflowDirection[] nfDirection,
|
|
||||||
@Nullable DDoSAttackType[] attackType,
|
|
||||||
@Nullable Long taskId);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Stop dispose mul return type.
|
|
||||||
*
|
|
||||||
* @param ip the ip
|
|
||||||
* @param capType the cap type
|
|
||||||
* @param nfDirection the nf direction
|
|
||||||
* @param attackType the attack type
|
|
||||||
* @param taskId the task id
|
|
||||||
* @return the mul return type
|
|
||||||
*/
|
|
||||||
MulReturnType<ErrorCode, Long> stopDispose(String ip, DisposeCapacityType capType,
|
|
||||||
@Nullable NetflowDirection nfDirection,
|
@Nullable NetflowDirection nfDirection,
|
||||||
@Nullable DDoSAttackType attackType,
|
@Nullable DDoSAttackType attackType,
|
||||||
@Nullable Long taskId);
|
@Nullable Long taskId);
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package com.dispose.ability.impl;
|
package com.dispose.ability.impl;
|
||||||
|
|
||||||
|
import com.dispose.ability.DeviceDisposeAbility;
|
||||||
import com.dispose.ability.DisposeAbility;
|
import com.dispose.ability.DisposeAbility;
|
||||||
|
import com.dispose.ability.DisposeTaskCallback;
|
||||||
import com.dispose.common.DDoSAttackType;
|
import com.dispose.common.DDoSAttackType;
|
||||||
import com.dispose.common.DisposeCapacityType;
|
import com.dispose.common.DisposeCapacityType;
|
||||||
import com.dispose.common.DpTechAttackType;
|
import com.dispose.common.DpTechAttackType;
|
||||||
|
@ -22,14 +24,10 @@ import org.apache.wss4j.dom.WSConstants;
|
||||||
import org.apache.wss4j.dom.handler.WSHandlerConstants;
|
import org.apache.wss4j.dom.handler.WSHandlerConstants;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import javax.xml.ws.BindingProvider;
|
import javax.xml.ws.BindingProvider;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type Dp tech ability.
|
* The type Dp tech ability.
|
||||||
|
@ -38,7 +36,7 @@ import java.util.stream.Collectors;
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class DpTechAbilityImpl implements DisposeAbility {
|
public class DpTechAbilityImpl implements DisposeAbility<ErrorCode>, DeviceDisposeAbility<ErrorCode> {
|
||||||
/**
|
/**
|
||||||
* The Clean type port.
|
* The Clean type port.
|
||||||
*/
|
*/
|
||||||
|
@ -96,72 +94,17 @@ public class DpTechAbilityImpl implements DisposeAbility {
|
||||||
* @return the mul return type
|
* @return the mul return type
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public MulReturnType<ErrorCode, Long> runDispose(String ip, DisposeCapacityType capType,
|
public ErrorCode runDispose(String ip, DisposeCapacityType capType,
|
||||||
@Nullable NetflowDirection[] nfDirection,
|
NetflowDirection nfDirection,
|
||||||
@Nullable DDoSAttackType[] attackType,
|
DDoSAttackType attackType,
|
||||||
@Nullable Long duration) {
|
Long duration) {
|
||||||
ErrorCode err = ErrorCode.ERR_OK;
|
|
||||||
|
|
||||||
try {
|
|
||||||
log.info("++++Begging DPTech Start Cleanup Task: {}", ip);
|
|
||||||
|
|
||||||
// 查找需要处置的流量方向集合
|
|
||||||
List<NetflowDirection> dirList = Arrays.stream(NetflowDirection.values())
|
|
||||||
.filter(d -> nfDirection == null || nfDirection.length == 0 || Arrays.asList(nfDirection).contains(d))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
// 查找需要处理的攻击类型集合
|
|
||||||
List<DpTechAttackType> typeList = Arrays.stream(DDoSAttackType.values())
|
|
||||||
.filter(t -> attackType == null || attackType.length == 0 || Arrays.asList(attackType).contains(t))
|
|
||||||
.flatMap(DpTechAttackType::fromDdosAttackTypeValue)
|
|
||||||
.distinct()
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
dirList.forEach(d -> typeList.forEach(t -> CompletableFuture.supplyAsync(() ->
|
|
||||||
cleanTypePort.startAbnormalTaskForUMC(ip, t.getValue(), d.getValue()))
|
|
||||||
.whenComplete((v, ex) -> {
|
|
||||||
if (ex != null) {
|
|
||||||
log.error("DPTech run dispose: {}, {}, error:{}", ip, t.getValue(),
|
|
||||||
ex.getMessage());
|
|
||||||
} else {
|
|
||||||
log.debug("Cleanup: {} --> {}:{}", d, t.getDescription(), t.getValue());
|
|
||||||
if (v.getResultRetVal() != ErrorCode.ERR_OK.getCode()) {
|
|
||||||
log.error("DPTech run dispose {} error: {}", ip, v.getResultInfo());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})));
|
|
||||||
log.info("----Finish DPTech Start Cleanup Task: {}", ip);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
log.error(ex.getMessage());
|
|
||||||
log.error("----Error DPTech Start Cleanup Task: {}", ip);
|
|
||||||
err = ErrorCode.ERR_SYSTEMEXCEPTION;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new MulReturnType<>(err, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Run dispose mul return type.
|
|
||||||
*
|
|
||||||
* @param ip the ip
|
|
||||||
* @param capType the cap type
|
|
||||||
* @param nfDirection the nf direction
|
|
||||||
* @param attackType the attack type
|
|
||||||
* @param duration the duration
|
|
||||||
* @return the mul return type
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public MulReturnType<ErrorCode, Long> runDispose(String ip, DisposeCapacityType capType,
|
|
||||||
NetflowDirection nfDirection,
|
|
||||||
DDoSAttackType attackType,
|
|
||||||
Long duration) {
|
|
||||||
ErrorCode err = ErrorCode.ERR_OK;
|
ErrorCode err = ErrorCode.ERR_OK;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
log.info("++++Begging DPTech Start Cleanup Task: {}, {}, {} ", ip, attackType, nfDirection);
|
log.info("++++Begging DPTech Start Cleanup Task: {}, {}, {} ", ip, attackType, nfDirection);
|
||||||
|
|
||||||
NtcRequestResultInfo ret = cleanTypePort.startAbnormalTaskForUMC(ip, attackType.getValue(),
|
NtcRequestResultInfo ret = cleanTypePort.startAbnormalTaskForUMC(ip, attackType.getValue(),
|
||||||
nfDirection.getValue());
|
nfDirection.getValue());
|
||||||
|
|
||||||
if (ret.getResultRetVal() != 0) {
|
if (ret.getResultRetVal() != 0) {
|
||||||
err = ErrorCode.ERR_CALLDEVICE;
|
err = ErrorCode.ERR_CALLDEVICE;
|
||||||
|
@ -173,62 +116,9 @@ public class DpTechAbilityImpl implements DisposeAbility {
|
||||||
log.error("----Exception Error DPTech Start Cleanup Task: {}", ip);
|
log.error("----Exception Error DPTech Start Cleanup Task: {}", ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new MulReturnType<>(err, null);
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Stop dispose mul return type.
|
|
||||||
*
|
|
||||||
* @param ipAddr the ip addr
|
|
||||||
* @param capType the cap type
|
|
||||||
* @param nfDirection the nf direction
|
|
||||||
* @param attackType the attack type
|
|
||||||
* @param taskId the task id
|
|
||||||
* @return the mul return type
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public MulReturnType<ErrorCode, Long> stopDispose(String ipAddr, DisposeCapacityType capType,
|
|
||||||
@Nullable NetflowDirection[] nfDirection,
|
|
||||||
@Nullable DDoSAttackType[] attackType,
|
|
||||||
@Nullable Long taskId) {
|
|
||||||
ErrorCode err = ErrorCode.ERR_OK;
|
|
||||||
|
|
||||||
try {
|
|
||||||
log.info("++++Begging DPTech Stop Cleanup Task: {}", ipAddr);
|
|
||||||
|
|
||||||
// 查找需要处置的流量方向集合
|
|
||||||
List<NetflowDirection> dirList = Arrays.stream(NetflowDirection.values())
|
|
||||||
.filter(d -> nfDirection == null || nfDirection.length == 0 || Arrays.asList(nfDirection).contains(d))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
// 查找需要处理的攻击类型集合
|
|
||||||
List<DpTechAttackType> typeList = Arrays.stream(DDoSAttackType.values())
|
|
||||||
.filter(t -> attackType == null || attackType.length == 0 || Arrays.asList(attackType).contains(t))
|
|
||||||
.flatMap(DpTechAttackType::fromDdosAttackTypeValue)
|
|
||||||
.distinct()
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
dirList.forEach(d -> typeList.forEach(t -> CompletableFuture.supplyAsync(() ->
|
|
||||||
cleanTypePort.stopAbnormalTaskForUMC(ipAddr, t.getValue(), d.getValue()))
|
|
||||||
.whenComplete((v, ex) -> {
|
|
||||||
if (ex != null) {
|
|
||||||
log.error("DPTech stop dispose: {}, {}, error:{}", ipAddr, t.getValue(), ex.getMessage());
|
|
||||||
} else {
|
|
||||||
log.debug("Stop Cleanup: {} --> {}:{}", d, t.getDescription(), t.getValue());
|
|
||||||
if (v.getResultRetVal() != ErrorCode.ERR_OK.getCode()) {
|
|
||||||
log.error("DPTech stop dispose {} error: {}", ipAddr, v.getResultInfo());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})));
|
|
||||||
log.info("----Finish DPTech Stop Cleanup Task: {}", ipAddr);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
log.error(ex.getMessage());
|
|
||||||
log.error("----Error DPTech Stop Cleanup Task: {}", ipAddr);
|
|
||||||
err = ErrorCode.ERR_SYSTEMEXCEPTION;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new MulReturnType<>(err, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop dispose mul return type.
|
* Stop dispose mul return type.
|
||||||
|
@ -241,18 +131,18 @@ public class DpTechAbilityImpl implements DisposeAbility {
|
||||||
* @return the mul return type
|
* @return the mul return type
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public MulReturnType<ErrorCode, Long> stopDispose(String ip,
|
public ErrorCode stopDispose(String ip,
|
||||||
DisposeCapacityType capType,
|
DisposeCapacityType capType,
|
||||||
NetflowDirection nfDirection,
|
NetflowDirection nfDirection,
|
||||||
DDoSAttackType attackType,
|
DDoSAttackType attackType,
|
||||||
Long taskId) {
|
Long taskId) {
|
||||||
ErrorCode err = ErrorCode.ERR_OK;
|
ErrorCode err = ErrorCode.ERR_OK;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
log.info("++++Begging DPTech Stop Cleanup Task: {}, {}, {} ", ip, attackType, nfDirection);
|
log.info("++++Begging DPTech Stop Cleanup Task: {}, {}, {} ", ip, attackType, nfDirection);
|
||||||
|
|
||||||
NtcRequestResultInfo ret = cleanTypePort.stopAbnormalTaskForUMC(ip, attackType.getValue(),
|
NtcRequestResultInfo ret = cleanTypePort.stopAbnormalTaskForUMC(ip, attackType.getValue(),
|
||||||
nfDirection.getValue());
|
nfDirection.getValue());
|
||||||
|
|
||||||
if (ret.getResultRetVal() != 0) {
|
if (ret.getResultRetVal() != 0) {
|
||||||
err = ErrorCode.ERR_CALLDEVICE;
|
err = ErrorCode.ERR_CALLDEVICE;
|
||||||
|
@ -265,7 +155,7 @@ public class DpTechAbilityImpl implements DisposeAbility {
|
||||||
log.error("----Exception Error DPTech Stop Cleanup Task: {}", ip);
|
log.error("----Exception Error DPTech Stop Cleanup Task: {}", ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new MulReturnType<>(err, null);
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -294,18 +184,18 @@ public class DpTechAbilityImpl implements DisposeAbility {
|
||||||
@Override
|
@Override
|
||||||
public MulReturnType<ErrorCode, DeviceFirewareInfo> getAbilityDeviceFireware() {
|
public MulReturnType<ErrorCode, DeviceFirewareInfo> getAbilityDeviceFireware() {
|
||||||
return new MulReturnType<>(ErrorCode.ERR_OK,
|
return new MulReturnType<>(ErrorCode.ERR_OK,
|
||||||
DeviceFirewareInfo.builder()
|
DeviceFirewareInfo.builder()
|
||||||
.vendor("DpTech")
|
.vendor("DpTech")
|
||||||
.model("UMC")
|
.model("UMC")
|
||||||
.firmware("Unknown")
|
.firmware("Unknown")
|
||||||
.os("Windows Server")
|
.os("Windows Server")
|
||||||
.kernel("Windows")
|
.kernel("Windows")
|
||||||
.arch("x86_64")
|
.arch("x86_64")
|
||||||
.version("5.7.31")
|
.version("5.7.31")
|
||||||
.memory(-1)
|
.memory(-1)
|
||||||
.freeMemory(-1)
|
.freeMemory(-1)
|
||||||
.cpuUsed(-1)
|
.cpuUsed(-1)
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -318,4 +208,52 @@ public class DpTechAbilityImpl implements DisposeAbility {
|
||||||
public Long toDeviceAttackType(Long ddosAttackTypeMask) {
|
public Long toDeviceAttackType(Long ddosAttackTypeMask) {
|
||||||
return DpTechAttackType.formDdosAttackTypeMaks(ddosAttackTypeMask);
|
return DpTechAttackType.formDdosAttackTypeMaks(ddosAttackTypeMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Device dispose exec error code.
|
||||||
|
*
|
||||||
|
* @param callback the callback
|
||||||
|
* @param capType the cap type
|
||||||
|
* @param ipAddr the ip addr
|
||||||
|
* @param args the args
|
||||||
|
* @return the error code
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ErrorCode deviceDisposeExec(DisposeTaskCallback callback, DisposeCapacityType capType, String ipAddr,
|
||||||
|
Object... args) {
|
||||||
|
CompletableFuture.supplyAsync(() -> runDispose(ipAddr, capType, (NetflowDirection) args[0],
|
||||||
|
(DDoSAttackType) args[1], null))
|
||||||
|
.whenComplete((v, ex) -> {
|
||||||
|
if (ex != null) {
|
||||||
|
callback.upgradeStatusCallback(ErrorCode.ERR_SYSTEMEXCEPTION);
|
||||||
|
} else {
|
||||||
|
callback.upgradeStatusCallback(v);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return ErrorCode.ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Device dispose stop error code.
|
||||||
|
*
|
||||||
|
* @param callback the callback
|
||||||
|
* @param capType the cap type
|
||||||
|
* @param args the args
|
||||||
|
* @return the error code
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ErrorCode deviceDisposeStop(DisposeTaskCallback callback, DisposeCapacityType capType, Object... args) {
|
||||||
|
CompletableFuture.supplyAsync(() -> stopDispose((String) args[0], capType, (NetflowDirection) args[1],
|
||||||
|
(DDoSAttackType) args[2], null))
|
||||||
|
.whenComplete((v, ex) -> {
|
||||||
|
if (ex != null) {
|
||||||
|
callback.upgradeStatusCallback(ErrorCode.ERR_SYSTEMEXCEPTION);
|
||||||
|
} else {
|
||||||
|
callback.upgradeStatusCallback(v);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return ErrorCode.ERR_OK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,8 @@ import javax.annotation.Nullable;
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class HaoHanAbilityImpl implements DisposeAbility, DeviceDisposeAbility<MulReturnType<ErrorCode, Long>> {
|
public class HaoHanAbilityImpl implements DisposeAbility<MulReturnType<ErrorCode, Long>>,
|
||||||
|
DeviceDisposeAbility<MulReturnType<ErrorCode, Long>> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The constant DISPOSE_PLATFORM_NAME.
|
* The constant DISPOSE_PLATFORM_NAME.
|
||||||
|
@ -51,27 +52,6 @@ public class HaoHanAbilityImpl implements DisposeAbility, DeviceDisposeAbility<M
|
||||||
this.urlRootPath = urlPath;
|
this.urlRootPath = urlPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Run dispose mul return type.
|
|
||||||
*
|
|
||||||
* @param ip the ip
|
|
||||||
* @param capType the cap type
|
|
||||||
* @param nfDirection the nf direction
|
|
||||||
* @param attackType the attack type
|
|
||||||
* @param duration the duration
|
|
||||||
* @return the mul return type
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public MulReturnType<ErrorCode, Long> runDispose(String ip, DisposeCapacityType capType,
|
|
||||||
@Nullable NetflowDirection[] nfDirection,
|
|
||||||
@Nullable DDoSAttackType[] attackType,
|
|
||||||
@Nullable Long duration) {
|
|
||||||
return runDispose(ip, capType,
|
|
||||||
NetflowDirection.DIRECTION_BI,
|
|
||||||
DDoSAttackType.ALL_ATTACKS,
|
|
||||||
duration);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run dispose mul return type.
|
* Run dispose mul return type.
|
||||||
*
|
*
|
||||||
|
@ -111,27 +91,6 @@ public class HaoHanAbilityImpl implements DisposeAbility, DeviceDisposeAbility<M
|
||||||
return new MulReturnType<>(ErrorCode.ERR_OK, (long) resp.getCleanTaskId());
|
return new MulReturnType<>(ErrorCode.ERR_OK, (long) resp.getCleanTaskId());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Stop dispose mul return type.
|
|
||||||
*
|
|
||||||
* @param ip the ip
|
|
||||||
* @param capType the cap type
|
|
||||||
* @param nfDirection the nf direction
|
|
||||||
* @param attackType the attack type
|
|
||||||
* @param taskId the task id
|
|
||||||
* @return the mul return type
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public MulReturnType<ErrorCode, Long> stopDispose(String ip, DisposeCapacityType capType,
|
|
||||||
@Nullable NetflowDirection[] nfDirection,
|
|
||||||
@Nullable DDoSAttackType[] attackType,
|
|
||||||
@Nullable Long taskId) {
|
|
||||||
return stopDispose(ip, capType,
|
|
||||||
NetflowDirection.DIRECTION_BI,
|
|
||||||
DDoSAttackType.ALL_ATTACKS,
|
|
||||||
taskId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop dispose mul return type.
|
* Stop dispose mul return type.
|
||||||
*
|
*
|
||||||
|
@ -244,7 +203,7 @@ public class HaoHanAbilityImpl implements DisposeAbility, DeviceDisposeAbility<M
|
||||||
public MulReturnType<ErrorCode, Long> deviceDisposeStop(DisposeTaskCallback callback,
|
public MulReturnType<ErrorCode, Long> deviceDisposeStop(DisposeTaskCallback callback,
|
||||||
DisposeCapacityType capType,
|
DisposeCapacityType capType,
|
||||||
Object... taskId) {
|
Object... taskId) {
|
||||||
MulReturnType<ErrorCode, Long> ret = stopDispose(null,
|
MulReturnType<ErrorCode, Long> ret = stopDispose(null,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
DDoSAttackType.ALL_ATTACKS,
|
DDoSAttackType.ALL_ATTACKS,
|
||||||
|
|
|
@ -17,7 +17,7 @@ import javax.annotation.Nullable;
|
||||||
*
|
*
|
||||||
* @author <huangxin@cmhi.chinamoblie.com>
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
*/
|
*/
|
||||||
public class VirtualAbilityImpl implements DisposeAbility, DeviceDisposeAbility<ErrorCode> {
|
public class VirtualAbilityImpl implements DisposeAbility<ErrorCode>, DeviceDisposeAbility<ErrorCode> {
|
||||||
/**
|
/**
|
||||||
* Init device env.
|
* Init device env.
|
||||||
*
|
*
|
||||||
|
@ -41,28 +41,10 @@ public class VirtualAbilityImpl implements DisposeAbility, DeviceDisposeAbility<
|
||||||
* @return the mul return type
|
* @return the mul return type
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public MulReturnType<ErrorCode, Long> runDispose(String ip, DisposeCapacityType capType,
|
public ErrorCode runDispose(String ip, DisposeCapacityType capType,
|
||||||
@Nullable NetflowDirection[] nfDirection,
|
|
||||||
@Nullable DDoSAttackType[] attackType,
|
|
||||||
@Nullable Long duration) {
|
|
||||||
return new MulReturnType<>(ErrorCode.ERR_OK, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Run dispose mul return type.
|
|
||||||
*
|
|
||||||
* @param ip the ip
|
|
||||||
* @param capType the cap type
|
|
||||||
* @param nfDirection the nf direction
|
|
||||||
* @param attackType the attack type
|
|
||||||
* @param duration the duration
|
|
||||||
* @return the mul return type
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public MulReturnType<ErrorCode, Long> runDispose(String ip, DisposeCapacityType capType,
|
|
||||||
@Nullable NetflowDirection nfDirection,
|
@Nullable NetflowDirection nfDirection,
|
||||||
@Nullable DDoSAttackType attackType, @Nullable Long duration) {
|
@Nullable DDoSAttackType attackType, @Nullable Long duration) {
|
||||||
return new MulReturnType<>(ErrorCode.ERR_OK, null);
|
return ErrorCode.ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -76,28 +58,10 @@ public class VirtualAbilityImpl implements DisposeAbility, DeviceDisposeAbility<
|
||||||
* @return the mul return type
|
* @return the mul return type
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public MulReturnType<ErrorCode, Long> stopDispose(String ip, DisposeCapacityType capType,
|
public ErrorCode stopDispose(String ip, DisposeCapacityType capType,
|
||||||
@Nullable NetflowDirection[] nfDirection,
|
|
||||||
@Nullable DDoSAttackType[] attackType,
|
|
||||||
@Nullable Long taskId) {
|
|
||||||
return new MulReturnType<>(ErrorCode.ERR_OK, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Stop dispose mul return type.
|
|
||||||
*
|
|
||||||
* @param ip the ip
|
|
||||||
* @param capType the cap type
|
|
||||||
* @param nfDirection the nf direction
|
|
||||||
* @param attackType the attack type
|
|
||||||
* @param taskId the task id
|
|
||||||
* @return the mul return type
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public MulReturnType<ErrorCode, Long> stopDispose(String ip, DisposeCapacityType capType,
|
|
||||||
@Nullable NetflowDirection nfDirection,
|
@Nullable NetflowDirection nfDirection,
|
||||||
@Nullable DDoSAttackType attackType, @Nullable Long taskId) {
|
@Nullable DDoSAttackType attackType, @Nullable Long taskId) {
|
||||||
return new MulReturnType<>(ErrorCode.ERR_OK, null);
|
return ErrorCode.ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -158,7 +122,7 @@ public class VirtualAbilityImpl implements DisposeAbility, DeviceDisposeAbility<
|
||||||
capType,
|
capType,
|
||||||
null,
|
null,
|
||||||
DDoSAttackType.ALL_ATTACKS,
|
DDoSAttackType.ALL_ATTACKS,
|
||||||
null).getFirstParam();
|
null);
|
||||||
|
|
||||||
callback.upgradeStatusCallback(ret);
|
callback.upgradeStatusCallback(ret);
|
||||||
|
|
||||||
|
@ -178,7 +142,7 @@ public class VirtualAbilityImpl implements DisposeAbility, DeviceDisposeAbility<
|
||||||
capType,
|
capType,
|
||||||
null,
|
null,
|
||||||
DDoSAttackType.ALL_ATTACKS,
|
DDoSAttackType.ALL_ATTACKS,
|
||||||
null).getFirstParam();
|
null);
|
||||||
|
|
||||||
callback.upgradeStatusCallback(ret);
|
callback.upgradeStatusCallback(ret);
|
||||||
|
|
||||||
|
|
|
@ -66,4 +66,13 @@ public interface DeviceTaskManager {
|
||||||
* @return the task err retry times
|
* @return the task err retry times
|
||||||
*/
|
*/
|
||||||
boolean setTaskErrRetryTimes(Long id, Integer rTimes);
|
boolean setTaskErrRetryTimes(Long id, Integer rTimes);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets task extern id.
|
||||||
|
*
|
||||||
|
* @param id the id
|
||||||
|
* @param externId the extern id
|
||||||
|
* @return the task extern id
|
||||||
|
*/
|
||||||
|
boolean setTaskExternId(Long id, Long externId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,8 +115,27 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
|
||||||
return ret == 1;
|
return ret == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets task err retry times.
|
||||||
|
*
|
||||||
|
* @param id the id
|
||||||
|
* @param rTimes the r times
|
||||||
|
* @return the task err retry times
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean setTaskErrRetryTimes(Long id, Integer rTimes) {
|
public boolean setTaskErrRetryTimes(Long id, Integer rTimes) {
|
||||||
return deviceTaskMapper.changeErrRetry(id, rTimes) == 1;
|
return deviceTaskMapper.changeErrRetry(id, rTimes) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets task extern id.
|
||||||
|
*
|
||||||
|
* @param id the id
|
||||||
|
* @param externId the extern id
|
||||||
|
* @return the task extern id
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean setTaskExternId(Long id, Long externId) {
|
||||||
|
return deviceTaskMapper.changeExternId(id, externId) == 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,4 +121,14 @@ public interface DeviceTaskMapper {
|
||||||
*/
|
*/
|
||||||
int changeErrRetry(@Param("id") Long id,
|
int changeErrRetry(@Param("id") Long id,
|
||||||
@Param("errRetry") Integer errRetry);
|
@Param("errRetry") Integer errRetry);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change extern id int.
|
||||||
|
*
|
||||||
|
* @param id the id
|
||||||
|
* @param externId the extern id
|
||||||
|
* @return the int
|
||||||
|
*/
|
||||||
|
int changeExternId(@Param("id") Long id,
|
||||||
|
@Param("externId") Long externId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import com.dispose.manager.DeviceTaskManager;
|
||||||
import com.dispose.manager.DisposeTaskManager;
|
import com.dispose.manager.DisposeTaskManager;
|
||||||
import com.dispose.pojo.entity.DisposeTask;
|
import com.dispose.pojo.entity.DisposeTask;
|
||||||
import com.dispose.pojo.po.AbilityInfo;
|
import com.dispose.pojo.po.AbilityInfo;
|
||||||
|
import com.dispose.pojo.po.MulReturnType;
|
||||||
import com.dispose.service.DeviceTaskManagerService;
|
import com.dispose.service.DeviceTaskManagerService;
|
||||||
import com.dispose.service.DisposeAbilityRouterService;
|
import com.dispose.service.DisposeAbilityRouterService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
@ -91,107 +92,93 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
||||||
@Async("deviceTaskExecutor")
|
@Async("deviceTaskExecutor")
|
||||||
@Scheduled(fixedDelay = 1000)
|
@Scheduled(fixedDelay = 1000)
|
||||||
public void deviceTaskRunnerSchedule() {
|
public void deviceTaskRunnerSchedule() {
|
||||||
deviceTaskManager.getNewDisposeDeviceTaskInfo()
|
deviceTaskManager.getNewDisposeDeviceTaskInfo().forEach(v -> {
|
||||||
.forEach(v -> {
|
DisposeTask task = disposeTaskManager.getDisposeTaskById(v.getTaskId());
|
||||||
DisposeTask task = disposeTaskManager.getDisposeTaskById(v.getTaskId());
|
assert task != null;
|
||||||
assert task != null;
|
log.info("Run task {}", task);
|
||||||
log.info("Run task {}", task);
|
|
||||||
|
|
||||||
AbilityInfo ai = disposeAbilityRouterService.getAbilityDevice(task.getDeviceId());
|
AbilityInfo ai = disposeAbilityRouterService.getAbilityDevice(task.getDeviceId());
|
||||||
|
|
||||||
switch (ai.getDev().getDeviceType()) {
|
switch (ai.getDev().getDeviceType()) {
|
||||||
case DPTECH_UMC:
|
case DPTECH_UMC:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HAOHAN_PLATFORM:
|
case HAOHAN_PLATFORM:
|
||||||
// 设置任务状态为启动中
|
// 设置任务状态为启动中
|
||||||
deviceTaskManager.changeDisposeDeviceTaskInfoStatus(v.getId(), DisposeTaskStatus.TASK_STARTING);
|
deviceTaskManager.changeDisposeDeviceTaskInfoStatus(v.getId(), DisposeTaskStatus.TASK_STARTING);
|
||||||
// 设置启动任务攻击类型状态
|
// 设置启动任务攻击类型状态
|
||||||
deviceTaskManager.setExecAttackType(v.getId(), NetflowDirection.DIRECTION_BI,
|
deviceTaskManager.setExecAttackType(v.getId(), NetflowDirection.DIRECTION_BI,
|
||||||
v.getTaskAttackType());
|
v.getTaskAttackType());
|
||||||
// 调用设备处置能力
|
// 调用设备处置能力
|
||||||
((HaoHanAbilityImpl) ai.getDb()).deviceDisposeExec(
|
MulReturnType<ErrorCode, Long> ret = ((HaoHanAbilityImpl) ai.getDb()).deviceDisposeExec(
|
||||||
errorCode -> {
|
errorCode -> {
|
||||||
// 启动处置任务成功
|
// 启动处置任务成功
|
||||||
if (errorCode == ErrorCode.ERR_OK) {
|
if (errorCode == ErrorCode.ERR_OK) {
|
||||||
// 设置攻击类型任务启动结果
|
// 设置攻击类型任务启动结果
|
||||||
deviceTaskManager.setAttackTypeStatus(v.getId(),
|
deviceTaskManager.setAttackTypeStatus(v.getId(),
|
||||||
task.getFlowDirection(), v.getTaskAttackType());
|
task.getFlowDirection(), v.getTaskAttackType());
|
||||||
// 更改处置任务状态为处置中
|
// 更改处置任务状态为处置中
|
||||||
deviceTaskManager.changeDisposeDeviceTaskInfoStatus(v.getId(),
|
deviceTaskManager.changeDisposeDeviceTaskInfoStatus(v.getId(),
|
||||||
DisposeTaskStatus.TASK_STARTED);
|
DisposeTaskStatus.TASK_STARTED);
|
||||||
log.info("HAOHAN_PLATFORM setup task succeed: {}", v);
|
log.info("HAOHAN_PLATFORM setup task succeed: {}", v);
|
||||||
} else if (v.getErrRetry() < DisposeConfigValue.CALL_ERROR_RETRY_TIMES) {
|
} else if (v.getErrRetry() < DisposeConfigValue.CALL_ERROR_RETRY_TIMES) {
|
||||||
// 设置该任务为新任务,待下次重试启动
|
// 设置该任务为新任务,待下次重试启动
|
||||||
deviceTaskManager.changeDisposeDeviceTaskInfoStatus(v.getId(),
|
deviceTaskManager.changeDisposeDeviceTaskInfoStatus(v.getId(),
|
||||||
DisposeTaskStatus.TASK_NEW);
|
DisposeTaskStatus.TASK_NEW);
|
||||||
// 记录任务出错重试次数
|
// 记录任务出错重试次数
|
||||||
deviceTaskManager.setTaskErrRetryTimes(v.getId(), v.getErrRetry() + 1);
|
deviceTaskManager.setTaskErrRetryTimes(v.getId(), v.getErrRetry() + 1);
|
||||||
log.error("HAOHAN_PLATFORM setup task times {} error {}: {}",
|
log.error("HAOHAN_PLATFORM setup task times {} error {}: {}",
|
||||||
v.getErrRetry(), errorCode, v);
|
v.getErrRetry(), errorCode, v);
|
||||||
} else {
|
} else {
|
||||||
// 任务出错,不在重试,当做失败任务处理
|
// 任务出错,不在重试,当做失败任务处理
|
||||||
deviceTaskManager.setAttackTypeStatus(v.getId(),
|
deviceTaskManager.setAttackTypeStatus(v.getId(),
|
||||||
task.getFlowDirection(), ~v.getTaskAttackType());
|
task.getFlowDirection(), ~v.getTaskAttackType());
|
||||||
log.error("HAOHAN_PLATFORM setup task error {}: {}", errorCode, v);
|
log.error("HAOHAN_PLATFORM setup task error {}: {}", errorCode, v);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
task.getDisposeCapacity(),
|
task.getDisposeCapacity(),
|
||||||
task.getDisposeIp(),
|
task.getDisposeIp(),
|
||||||
(long) Helper.getTimestampDiffNow(task.getPlanEndTime()));
|
(long) Helper.getTimestampDiffNow(task.getPlanEndTime()));
|
||||||
break;
|
|
||||||
|
|
||||||
case VIRTUAL_DISPOSE:
|
// 启动任务成功,保存浩瀚任务ID到数据库
|
||||||
// 设置任务状态为启动中
|
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
|
||||||
deviceTaskManager.changeDisposeDeviceTaskInfoStatus(v.getId(), DisposeTaskStatus.TASK_STARTING);
|
deviceTaskManager.setTaskExternId(v.getId(), ret.getSecondParam());
|
||||||
// 设置启动任务攻击类型状态
|
}
|
||||||
deviceTaskManager.setExecAttackType(v.getId(), NetflowDirection.DIRECTION_BI,
|
break;
|
||||||
v.getTaskAttackType());
|
|
||||||
|
|
||||||
((VirtualAbilityImpl) ai.getDb()).deviceDisposeExec(
|
case VIRTUAL_DISPOSE:
|
||||||
errorCode -> {
|
// 设置任务状态为启动中
|
||||||
// 启动处置任务成功
|
deviceTaskManager.changeDisposeDeviceTaskInfoStatus(v.getId(), DisposeTaskStatus.TASK_STARTING);
|
||||||
if (errorCode == ErrorCode.ERR_OK) {
|
// 设置启动任务攻击类型状态
|
||||||
// 设置攻击类型任务启动结果
|
deviceTaskManager.setExecAttackType(v.getId(), NetflowDirection.DIRECTION_BI,
|
||||||
deviceTaskManager.setAttackTypeStatus(v.getId(),
|
v.getTaskAttackType());
|
||||||
task.getFlowDirection(), v.getTaskAttackType());
|
|
||||||
// 更改处置任务状态为处置中
|
|
||||||
deviceTaskManager.changeDisposeDeviceTaskInfoStatus(v.getId(),
|
|
||||||
DisposeTaskStatus.TASK_STARTED);
|
|
||||||
log.info("VIRTUAL_DISPOSE setup task succeed: {}", v);
|
|
||||||
} else {
|
|
||||||
// 任务出错,不在重试,当做失败任务处理
|
|
||||||
deviceTaskManager.setAttackTypeStatus(v.getId(),
|
|
||||||
task.getFlowDirection(), ~v.getTaskAttackType());
|
|
||||||
log.error("VIRTUAL_DISPOSE setup task error {}: {}", errorCode, v);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
task.getDisposeCapacity(),
|
|
||||||
task.getDisposeIp());
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
((VirtualAbilityImpl) ai.getDb()).deviceDisposeExec(
|
||||||
log.error("Unknown dispose device type: {}", ai.getDev());
|
errorCode -> {
|
||||||
break;
|
// 启动处置任务成功
|
||||||
}
|
if (errorCode == ErrorCode.ERR_OK) {
|
||||||
|
// 设置攻击类型任务启动结果
|
||||||
|
deviceTaskManager.setAttackTypeStatus(v.getId(),
|
||||||
|
task.getFlowDirection(), v.getTaskAttackType());
|
||||||
|
// 更改处置任务状态为处置中
|
||||||
|
deviceTaskManager.changeDisposeDeviceTaskInfoStatus(v.getId(),
|
||||||
|
DisposeTaskStatus.TASK_STARTED);
|
||||||
|
log.info("VIRTUAL_DISPOSE setup task succeed: {}", v);
|
||||||
|
} else {
|
||||||
|
// 任务出错,不在重试,当做失败任务处理
|
||||||
|
deviceTaskManager.setAttackTypeStatus(v.getId(),
|
||||||
|
task.getFlowDirection(), ~v.getTaskAttackType());
|
||||||
|
log.error("VIRTUAL_DISPOSE setup task error {}: {}", errorCode, v);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
task.getDisposeCapacity(),
|
||||||
|
task.getDisposeIp());
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
// if (task != null) {
|
log.error("Unknown dispose device type: {}", ai.getDev());
|
||||||
//
|
break;
|
||||||
// CompletableFuture.supplyAsync(() ->
|
}
|
||||||
// disposeAbilityRouterService
|
});
|
||||||
// .getAbilityDevice(task.getDeviceId())
|
|
||||||
// .getDb()
|
|
||||||
// .runDispose(task.getDisposeIp(),
|
|
||||||
// task.getDisposeCapacity(),
|
|
||||||
// task.getFlowDirection(),
|
|
||||||
// null,
|
|
||||||
// (long)Helper.getTimestampDiffNow(task.getPlanEndTime())))
|
|
||||||
// .whenComplete((k, ex) -> {
|
|
||||||
//
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,4 +106,10 @@
|
||||||
WHERE id = #{id}
|
WHERE id = #{id}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<update id="changeExternId">
|
||||||
|
UPDATE device_task
|
||||||
|
SET externId = #{externId}
|
||||||
|
WHERE id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
|
@ -2,7 +2,13 @@ package com.dispose.test.dptech;
|
||||||
|
|
||||||
import com.dispose.ability.DisposeAbility;
|
import com.dispose.ability.DisposeAbility;
|
||||||
import com.dispose.ability.impl.DpTechAbilityImpl;
|
import com.dispose.ability.impl.DpTechAbilityImpl;
|
||||||
import com.dispose.common.*;
|
import com.dispose.common.DDoSAttackType;
|
||||||
|
import com.dispose.common.DisposeCapacityType;
|
||||||
|
import com.dispose.common.DisposeDeviceType;
|
||||||
|
import com.dispose.common.ErrorCode;
|
||||||
|
import com.dispose.common.HttpType;
|
||||||
|
import com.dispose.common.NetflowDirection;
|
||||||
|
import com.dispose.common.ObjectStatus;
|
||||||
import com.dispose.pojo.entity.DisposeDevice;
|
import com.dispose.pojo.entity.DisposeDevice;
|
||||||
import com.dispose.pojo.po.MulReturnType;
|
import com.dispose.pojo.po.MulReturnType;
|
||||||
import com.dispose.pojo.vo.DeviceFirewareInfo;
|
import com.dispose.pojo.vo.DeviceFirewareInfo;
|
||||||
|
@ -49,11 +55,7 @@ public class DPTechInterfaceTestCase extends InitTestEnvironment {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void t1_runDisposeTest() {
|
public void t1_runDisposeTest() {
|
||||||
DisposeAbility db;
|
DisposeAbility<ErrorCode> db;
|
||||||
|
|
||||||
NetflowDirection[] nfDirection = {NetflowDirection.DIRECTION_IN};
|
|
||||||
|
|
||||||
DDoSAttackType[] ddoSAttackType = {DDoSAttackType.ACK_FLOOD, DDoSAttackType.CHARGED_AMPLIFICATION};
|
|
||||||
|
|
||||||
DisposeDevice dev = DisposeDevice.builder()
|
DisposeDevice dev = DisposeDevice.builder()
|
||||||
.ipAddr("10.88.77.15")
|
.ipAddr("10.88.77.15")
|
||||||
|
@ -82,10 +84,10 @@ public class DPTechInterfaceTestCase extends InitTestEnvironment {
|
||||||
// 初始化设备
|
// 初始化设备
|
||||||
db.initDeviceEnv(url, dev.getUserName(), dev.getPassword());
|
db.initDeviceEnv(url, dev.getUserName(), dev.getPassword());
|
||||||
|
|
||||||
MulReturnType<ErrorCode, Long> ret = db.runDispose("192.168.3.5", DisposeCapacityType.CLEANUP,
|
ErrorCode ret = db.runDispose("192.168.3.5", DisposeCapacityType.CLEANUP,
|
||||||
nfDirection, ddoSAttackType, -1L);
|
NetflowDirection.DIRECTION_BI, DDoSAttackType.ALL_ATTACKS, -1L);
|
||||||
|
|
||||||
Assert.assertEquals(ret.getFirstParam(), ErrorCode.ERR_OK);
|
Assert.assertEquals(ret, ErrorCode.ERR_OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,11 +96,7 @@ public class DPTechInterfaceTestCase extends InitTestEnvironment {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void t2_stopDisposeTest() {
|
public void t2_stopDisposeTest() {
|
||||||
DisposeAbility db;
|
DisposeAbility<ErrorCode> db;
|
||||||
|
|
||||||
NetflowDirection[] nfDirection = {NetflowDirection.DIRECTION_IN};
|
|
||||||
|
|
||||||
DDoSAttackType[] ddoSAttackType = {DDoSAttackType.ACK_FLOOD, DDoSAttackType.CHARGED_AMPLIFICATION};
|
|
||||||
|
|
||||||
DisposeDevice dev = DisposeDevice.builder()
|
DisposeDevice dev = DisposeDevice.builder()
|
||||||
.ipAddr("10.88.77.15")
|
.ipAddr("10.88.77.15")
|
||||||
|
@ -128,10 +126,10 @@ public class DPTechInterfaceTestCase extends InitTestEnvironment {
|
||||||
db.initDeviceEnv(url, dev.getUserName(), dev.getPassword());
|
db.initDeviceEnv(url, dev.getUserName(), dev.getPassword());
|
||||||
|
|
||||||
Assert.assertTrue(db.getDeviceLinkStatus());
|
Assert.assertTrue(db.getDeviceLinkStatus());
|
||||||
MulReturnType<ErrorCode, Long> ret = db.stopDispose("192.168.3.5", DisposeCapacityType.CLEANUP,
|
ErrorCode ret = db.stopDispose("192.168.3.5", DisposeCapacityType.CLEANUP,
|
||||||
nfDirection, ddoSAttackType, -1L);
|
NetflowDirection.DIRECTION_BI, DDoSAttackType.ALL_ATTACKS, -1L);
|
||||||
|
|
||||||
Assert.assertEquals(ret.getFirstParam(), ErrorCode.ERR_OK);
|
Assert.assertEquals(ret, ErrorCode.ERR_OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +138,7 @@ public class DPTechInterfaceTestCase extends InitTestEnvironment {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void t3_getAbilityDeviceFirewareTest() {
|
public void t3_getAbilityDeviceFirewareTest() {
|
||||||
DisposeAbility db;
|
DisposeAbility<ErrorCode> db;
|
||||||
|
|
||||||
DisposeDevice dev = DisposeDevice.builder()
|
DisposeDevice dev = DisposeDevice.builder()
|
||||||
.ipAddr("10.88.77.15")
|
.ipAddr("10.88.77.15")
|
||||||
|
|
|
@ -2,7 +2,11 @@ package com.dispose.test.haohan;
|
||||||
|
|
||||||
import com.dispose.ability.DisposeAbility;
|
import com.dispose.ability.DisposeAbility;
|
||||||
import com.dispose.ability.impl.HaoHanAbilityImpl;
|
import com.dispose.ability.impl.HaoHanAbilityImpl;
|
||||||
import com.dispose.common.*;
|
import com.dispose.common.DisposeCapacityType;
|
||||||
|
import com.dispose.common.DisposeDeviceType;
|
||||||
|
import com.dispose.common.ErrorCode;
|
||||||
|
import com.dispose.common.HttpType;
|
||||||
|
import com.dispose.common.ObjectStatus;
|
||||||
import com.dispose.pojo.entity.DisposeDevice;
|
import com.dispose.pojo.entity.DisposeDevice;
|
||||||
import com.dispose.pojo.po.MulReturnType;
|
import com.dispose.pojo.po.MulReturnType;
|
||||||
import com.dispose.pojo.vo.DeviceFirewareInfo;
|
import com.dispose.pojo.vo.DeviceFirewareInfo;
|
||||||
|
@ -49,28 +53,24 @@ public class HAOHanInterfaceTestCast extends InitTestEnvironment {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void t1_runDisposeTest() {
|
public void t1_runDisposeTest() {
|
||||||
DisposeAbility db;
|
DisposeAbility<MulReturnType<ErrorCode, Long>> db;
|
||||||
|
|
||||||
NetflowDirection[] nfDirection = {NetflowDirection.DIRECTION_IN};
|
|
||||||
|
|
||||||
DDoSAttackType[] ddoSAttackType = {DDoSAttackType.ACK_FLOOD, DDoSAttackType.CHARGED_AMPLIFICATION};
|
|
||||||
|
|
||||||
DisposeDevice dev = DisposeDevice.builder()
|
DisposeDevice dev = DisposeDevice.builder()
|
||||||
.ipAddr("10.88.77.88")
|
.ipAddr("10.88.77.88")
|
||||||
.ipPort("18080")
|
.ipPort("18080")
|
||||||
.deviceType(DisposeDeviceType.HAOHAN_PLATFORM)
|
.deviceType(DisposeDeviceType.HAOHAN_PLATFORM)
|
||||||
.areaCode(0)
|
.areaCode(0)
|
||||||
.deviceName("中移杭研实验室浩瀚清洗设备")
|
.deviceName("中移杭研实验室浩瀚清洗设备")
|
||||||
.manufacturer("Haohan")
|
.manufacturer("Haohan")
|
||||||
.model("Unknown")
|
.model("Unknown")
|
||||||
.version("Unknown")
|
.version("Unknown")
|
||||||
.userName("")
|
.userName("")
|
||||||
.password("")
|
.password("")
|
||||||
.urlPath("DDoSClean/clean")
|
.urlPath("DDoSClean/clean")
|
||||||
.urlType(HttpType.HTTP)
|
.urlType(HttpType.HTTP)
|
||||||
.readme("实验室测试设备")
|
.readme("实验室测试设备")
|
||||||
.status(ObjectStatus.NORMAL)
|
.status(ObjectStatus.NORMAL)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
String httpType = dev.getUrlType() == HttpType.HTTP ? "http://" : "https://";
|
String httpType = dev.getUrlType() == HttpType.HTTP ? "http://" : "https://";
|
||||||
String addr = getAbilityMapKey(dev.getIpAddr(), dev.getIpPort());
|
String addr = getAbilityMapKey(dev.getIpAddr(), dev.getIpPort());
|
||||||
|
@ -82,8 +82,9 @@ public class HAOHanInterfaceTestCast extends InitTestEnvironment {
|
||||||
// 初始化设备
|
// 初始化设备
|
||||||
db.initDeviceEnv(url, dev.getUserName(), dev.getPassword());
|
db.initDeviceEnv(url, dev.getUserName(), dev.getPassword());
|
||||||
|
|
||||||
MulReturnType<ErrorCode, Long> ret = db.runDispose("192.168.3.5", DisposeCapacityType.CLEANUP,
|
MulReturnType<ErrorCode, Long> ret = db.runDispose("192.168.3.5",
|
||||||
nfDirection, ddoSAttackType, -1L);
|
DisposeCapacityType.CLEANUP,
|
||||||
|
null, null, -1L);
|
||||||
|
|
||||||
Assert.assertEquals(ret.getFirstParam(), ErrorCode.ERR_OK);
|
Assert.assertEquals(ret.getFirstParam(), ErrorCode.ERR_OK);
|
||||||
}
|
}
|
||||||
|
@ -94,28 +95,24 @@ public class HAOHanInterfaceTestCast extends InitTestEnvironment {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void t2_stopDisposeTest() {
|
public void t2_stopDisposeTest() {
|
||||||
DisposeAbility db;
|
DisposeAbility<MulReturnType<ErrorCode, Long>> db;
|
||||||
|
|
||||||
NetflowDirection[] nfDirection = {NetflowDirection.DIRECTION_IN};
|
|
||||||
|
|
||||||
DDoSAttackType[] ddoSAttackType = {DDoSAttackType.ACK_FLOOD, DDoSAttackType.CHARGED_AMPLIFICATION};
|
|
||||||
|
|
||||||
DisposeDevice dev = DisposeDevice.builder()
|
DisposeDevice dev = DisposeDevice.builder()
|
||||||
.ipAddr("10.88.77.88")
|
.ipAddr("10.88.77.88")
|
||||||
.ipPort("18080")
|
.ipPort("18080")
|
||||||
.deviceType(DisposeDeviceType.HAOHAN_PLATFORM)
|
.deviceType(DisposeDeviceType.HAOHAN_PLATFORM)
|
||||||
.areaCode(0)
|
.areaCode(0)
|
||||||
.deviceName("中移杭研实验室浩瀚清洗设备")
|
.deviceName("中移杭研实验室浩瀚清洗设备")
|
||||||
.manufacturer("Haohan")
|
.manufacturer("Haohan")
|
||||||
.model("Unknown")
|
.model("Unknown")
|
||||||
.version("Unknown")
|
.version("Unknown")
|
||||||
.userName("")
|
.userName("")
|
||||||
.password("")
|
.password("")
|
||||||
.urlPath("DDoSClean/clean")
|
.urlPath("DDoSClean/clean")
|
||||||
.urlType(HttpType.HTTP)
|
.urlType(HttpType.HTTP)
|
||||||
.readme("实验室测试设备")
|
.readme("实验室测试设备")
|
||||||
.status(ObjectStatus.NORMAL)
|
.status(ObjectStatus.NORMAL)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
String httpType = dev.getUrlType() == HttpType.HTTP ? "http://" : "https://";
|
String httpType = dev.getUrlType() == HttpType.HTTP ? "http://" : "https://";
|
||||||
String addr = getAbilityMapKey(dev.getIpAddr(), dev.getIpPort());
|
String addr = getAbilityMapKey(dev.getIpAddr(), dev.getIpPort());
|
||||||
|
@ -128,8 +125,9 @@ public class HAOHanInterfaceTestCast extends InitTestEnvironment {
|
||||||
db.initDeviceEnv(url, dev.getUserName(), dev.getPassword());
|
db.initDeviceEnv(url, dev.getUserName(), dev.getPassword());
|
||||||
|
|
||||||
Assert.assertTrue(db.getDeviceLinkStatus());
|
Assert.assertTrue(db.getDeviceLinkStatus());
|
||||||
MulReturnType<ErrorCode, Long> ret = db.stopDispose("192.168.3.5", DisposeCapacityType.CLEANUP,
|
MulReturnType<ErrorCode, Long> ret = db.stopDispose("192.168.3.5",
|
||||||
nfDirection, ddoSAttackType, -1L);
|
DisposeCapacityType.CLEANUP,
|
||||||
|
null, null, -1L);
|
||||||
|
|
||||||
Assert.assertEquals(ret.getFirstParam(), ErrorCode.ERR_OK);
|
Assert.assertEquals(ret.getFirstParam(), ErrorCode.ERR_OK);
|
||||||
}
|
}
|
||||||
|
@ -140,24 +138,24 @@ public class HAOHanInterfaceTestCast extends InitTestEnvironment {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void t3_getAbilityDeviceFirewareTest() {
|
public void t3_getAbilityDeviceFirewareTest() {
|
||||||
DisposeAbility db;
|
DisposeAbility<? extends MulReturnType<ErrorCode, Long>> db;
|
||||||
|
|
||||||
DisposeDevice dev = DisposeDevice.builder()
|
DisposeDevice dev = DisposeDevice.builder()
|
||||||
.ipAddr("10.88.77.88")
|
.ipAddr("10.88.77.88")
|
||||||
.ipPort("18080")
|
.ipPort("18080")
|
||||||
.deviceType(DisposeDeviceType.HAOHAN_PLATFORM)
|
.deviceType(DisposeDeviceType.HAOHAN_PLATFORM)
|
||||||
.areaCode(0)
|
.areaCode(0)
|
||||||
.deviceName("中移杭研实验室浩瀚清洗设备")
|
.deviceName("中移杭研实验室浩瀚清洗设备")
|
||||||
.manufacturer("Haohan")
|
.manufacturer("Haohan")
|
||||||
.model("Unknown")
|
.model("Unknown")
|
||||||
.version("Unknown")
|
.version("Unknown")
|
||||||
.userName("")
|
.userName("")
|
||||||
.password("")
|
.password("")
|
||||||
.urlPath("DDoSClean/clean")
|
.urlPath("DDoSClean/clean")
|
||||||
.urlType(HttpType.HTTP)
|
.urlType(HttpType.HTTP)
|
||||||
.readme("实验室测试设备")
|
.readme("实验室测试设备")
|
||||||
.status(ObjectStatus.NORMAL)
|
.status(ObjectStatus.NORMAL)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
String httpType = dev.getUrlType() == HttpType.HTTP ? "http://" : "https://";
|
String httpType = dev.getUrlType() == HttpType.HTTP ? "http://" : "https://";
|
||||||
String addr = getAbilityMapKey(dev.getIpAddr(), dev.getIpPort());
|
String addr = getAbilityMapKey(dev.getIpAddr(), dev.getIpPort());
|
||||||
|
|
Loading…
Reference in New Issue