OCT
REM: 1. 增加迪普设备启动处置任务功能 2. 重构配置文件,全局变量初始化方式 3. 移除重复的处置类型
This commit is contained in:
parent
cb1ccfca88
commit
4868b1abf8
|
@ -1,6 +1,5 @@
|
||||||
package com.dispose.ability;
|
package com.dispose.ability;
|
||||||
|
|
||||||
import com.dispose.common.DDoSAttackType;
|
|
||||||
import com.dispose.common.DisposeCapacityType;
|
import com.dispose.common.DisposeCapacityType;
|
||||||
import com.dispose.common.ErrorCode;
|
import com.dispose.common.ErrorCode;
|
||||||
import com.dispose.common.NetflowDirection;
|
import com.dispose.common.NetflowDirection;
|
||||||
|
@ -14,7 +13,7 @@ import javax.annotation.Nullable;
|
||||||
*
|
*
|
||||||
* @author <huangxin@cmhi.chinamoblie.com>
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
*/
|
*/
|
||||||
public interface DisposeAbility<T> {
|
public interface DisposeAbility {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init device env.
|
* Init device env.
|
||||||
|
@ -35,9 +34,9 @@ public interface DisposeAbility<T> {
|
||||||
* @param duration the duration
|
* @param duration the duration
|
||||||
* @return the mul return type
|
* @return the mul return type
|
||||||
*/
|
*/
|
||||||
T runDispose(String ip, DisposeCapacityType capType,
|
MulReturnType<ErrorCode, Long> runDispose(String ip, DisposeCapacityType capType,
|
||||||
@Nullable NetflowDirection nfDirection,
|
@Nullable NetflowDirection nfDirection,
|
||||||
@Nullable DDoSAttackType attackType,
|
@Nullable Integer attackType,
|
||||||
@Nullable Long duration);
|
@Nullable Long duration);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,9 +49,9 @@ public interface DisposeAbility<T> {
|
||||||
* @param taskId the task id
|
* @param taskId the task id
|
||||||
* @return the mul return type
|
* @return the mul return type
|
||||||
*/
|
*/
|
||||||
T stopDispose(String ip, DisposeCapacityType capType,
|
MulReturnType<ErrorCode, Long> stopDispose(String ip, DisposeCapacityType capType,
|
||||||
@Nullable NetflowDirection nfDirection,
|
@Nullable NetflowDirection nfDirection,
|
||||||
@Nullable DDoSAttackType attackType,
|
@Nullable Integer attackType,
|
||||||
@Nullable Long taskId);
|
@Nullable Long taskId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
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.CommonEnumHandler;
|
||||||
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;
|
||||||
import com.dispose.common.DpTechConfigValue;
|
import com.dispose.common.DpTechConfigValue;
|
||||||
|
@ -22,21 +20,18 @@ import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
|
||||||
import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor;
|
import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor;
|
||||||
import org.apache.wss4j.dom.WSConstants;
|
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 javax.xml.ws.BindingProvider;
|
import javax.xml.ws.BindingProvider;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type Dp tech ability.
|
* The type Dp tech ability.
|
||||||
*
|
*
|
||||||
* @author <huangxin@cmhi.chinamoblie.com>
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
*/
|
*/
|
||||||
@Component
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class DpTechAbilityImpl implements DisposeAbility<ErrorCode>, DeviceDisposeAbility<ErrorCode> {
|
public class DpTechAbilityImpl implements DisposeAbility {
|
||||||
/**
|
/**
|
||||||
* The Clean type port.
|
* The Clean type port.
|
||||||
*/
|
*/
|
||||||
|
@ -94,29 +89,35 @@ public class DpTechAbilityImpl implements DisposeAbility<ErrorCode>, DeviceDispo
|
||||||
* @return the mul return type
|
* @return the mul return type
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ErrorCode runDispose(String ip, DisposeCapacityType capType,
|
public MulReturnType<ErrorCode, Long> runDispose(String ip, DisposeCapacityType capType,
|
||||||
NetflowDirection nfDirection,
|
NetflowDirection nfDirection,
|
||||||
DDoSAttackType attackType,
|
Integer attackType,
|
||||||
Long duration) {
|
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,
|
||||||
nfDirection.getValue());
|
nfDirection.getValue());
|
||||||
|
|
||||||
if (ret.getResultRetVal() != 0) {
|
if (ret.getResultRetVal() != 0) {
|
||||||
err = ErrorCode.ERR_CALLDEVICE;
|
err = ErrorCode.ERR_CALLDEVICE;
|
||||||
|
log.error("----Error DPTech Start Cleanup Task: {}, {}, {}, {}", ip, nfDirection,
|
||||||
|
CommonEnumHandler.codeOf(DpTechAttackType.class, attackType),
|
||||||
|
ret.getResultInfo().getValue());
|
||||||
} else {
|
} else {
|
||||||
log.error("----Finish DPTech Start Cleanup Task: {} status {}", ip, err);
|
log.info("----Finish DPTech Start Cleanup Task: {}, {}, {}, {}", ip, nfDirection,
|
||||||
|
CommonEnumHandler.codeOf(DpTechAttackType.class, attackType),
|
||||||
|
ret.getResultInfo().getValue());
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
err = ErrorCode.ERR_SYSTEMEXCEPTION;
|
err = ErrorCode.ERR_SYSTEMEXCEPTION;
|
||||||
log.error("----Exception Error DPTech Start Cleanup Task: {}", ip);
|
log.error("----Exception DPTech Start Cleanup Task: {}, {}, {}", ip, nfDirection,
|
||||||
|
CommonEnumHandler.codeOf(DpTechAttackType.class, attackType));
|
||||||
}
|
}
|
||||||
|
|
||||||
return err;
|
return new MulReturnType<>(err, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -131,31 +132,36 @@ public class DpTechAbilityImpl implements DisposeAbility<ErrorCode>, DeviceDispo
|
||||||
* @return the mul return type
|
* @return the mul return type
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ErrorCode stopDispose(String ip,
|
public MulReturnType<ErrorCode, Long> stopDispose(String ip,
|
||||||
DisposeCapacityType capType,
|
DisposeCapacityType capType,
|
||||||
NetflowDirection nfDirection,
|
NetflowDirection nfDirection,
|
||||||
DDoSAttackType attackType,
|
Integer 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,
|
||||||
nfDirection.getValue());
|
nfDirection.getValue());
|
||||||
|
|
||||||
if (ret.getResultRetVal() != 0) {
|
if (ret.getResultRetVal() != 0) {
|
||||||
err = ErrorCode.ERR_CALLDEVICE;
|
err = ErrorCode.ERR_CALLDEVICE;
|
||||||
log.error("----Finish DPTech Stop Cleanup Task: {} status {}", ip, err);
|
log.error("----Error DPTech Stop Cleanup Task: {}, {}, {}, {}", ip, nfDirection,
|
||||||
|
CommonEnumHandler.codeOf(DpTechAttackType.class, attackType),
|
||||||
|
ret.getResultInfo().getValue());
|
||||||
} else {
|
} else {
|
||||||
log.info("----Finish DPTech Stop Cleanup Task: {} status {}", ip, err);
|
log.info("----Finish DPTech Stop Cleanup Task: {}, {}, {}, {}", ip, nfDirection,
|
||||||
|
CommonEnumHandler.codeOf(DpTechAttackType.class, attackType),
|
||||||
|
ret.getResultInfo().getValue());
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
err = ErrorCode.ERR_SYSTEMEXCEPTION;
|
err = ErrorCode.ERR_SYSTEMEXCEPTION;
|
||||||
log.error("----Exception Error DPTech Stop Cleanup Task: {}", ip);
|
log.error("----Exception DPTech Stop Cleanup Task: {}, {}, {}", ip, nfDirection,
|
||||||
|
CommonEnumHandler.codeOf(DpTechAttackType.class, attackType));
|
||||||
}
|
}
|
||||||
|
|
||||||
return err;
|
return new MulReturnType<>(err, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -208,52 +214,4 @@ public class DpTechAbilityImpl implements DisposeAbility<ErrorCode>, DeviceDispo
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
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.DisposeCapacityType;
|
import com.dispose.common.DisposeCapacityType;
|
||||||
import com.dispose.common.ErrorCode;
|
import com.dispose.common.ErrorCode;
|
||||||
import com.dispose.common.NetflowDirection;
|
import com.dispose.common.NetflowDirection;
|
||||||
|
@ -24,8 +21,7 @@ import javax.annotation.Nullable;
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class HaoHanAbilityImpl implements DisposeAbility<MulReturnType<ErrorCode, Long>>,
|
public class HaoHanAbilityImpl implements DisposeAbility {
|
||||||
DeviceDisposeAbility<MulReturnType<ErrorCode, Long>> {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The constant DISPOSE_PLATFORM_NAME.
|
* The constant DISPOSE_PLATFORM_NAME.
|
||||||
|
@ -65,7 +61,7 @@ public class HaoHanAbilityImpl implements DisposeAbility<MulReturnType<ErrorCode
|
||||||
@Override
|
@Override
|
||||||
public MulReturnType<ErrorCode, Long> runDispose(String ip, DisposeCapacityType capType,
|
public MulReturnType<ErrorCode, Long> runDispose(String ip, DisposeCapacityType capType,
|
||||||
@Nullable NetflowDirection nfDirection,
|
@Nullable NetflowDirection nfDirection,
|
||||||
@Nullable DDoSAttackType attackType,
|
@Nullable Integer attackType,
|
||||||
@Nullable Long duration) {
|
@Nullable Long duration) {
|
||||||
log.info("++++Begging Haohan Start Cleanup Task: {}", ip);
|
log.info("++++Begging Haohan Start Cleanup Task: {}", ip);
|
||||||
|
|
||||||
|
@ -104,7 +100,7 @@ public class HaoHanAbilityImpl implements DisposeAbility<MulReturnType<ErrorCode
|
||||||
@Override
|
@Override
|
||||||
public MulReturnType<ErrorCode, Long> stopDispose(String ip, DisposeCapacityType capType,
|
public MulReturnType<ErrorCode, Long> stopDispose(String ip, DisposeCapacityType capType,
|
||||||
@Nullable NetflowDirection nfDirection,
|
@Nullable NetflowDirection nfDirection,
|
||||||
@Nullable DDoSAttackType attackType,
|
@Nullable Integer attackType,
|
||||||
@Nullable Long taskId) {
|
@Nullable Long taskId) {
|
||||||
log.info("++++Begging Haohan Stop Cleanup Task: {}", taskId);
|
log.info("++++Begging Haohan Stop Cleanup Task: {}", taskId);
|
||||||
|
|
||||||
|
@ -167,50 +163,4 @@ public class HaoHanAbilityImpl implements DisposeAbility<MulReturnType<ErrorCode
|
||||||
public Long toDeviceAttackType(Long ddosAttackTypeMask) {
|
public Long toDeviceAttackType(Long ddosAttackTypeMask) {
|
||||||
return ddosAttackTypeMask;
|
return ddosAttackTypeMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Device dispose exec mul return type.
|
|
||||||
*
|
|
||||||
* @param capType the cap type
|
|
||||||
* @param ipAddr the ip addr
|
|
||||||
* @param duration the duration
|
|
||||||
* @return the mul return type
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public MulReturnType<ErrorCode, Long> deviceDisposeExec(DisposeTaskCallback callback,
|
|
||||||
DisposeCapacityType capType,
|
|
||||||
String ipAddr,
|
|
||||||
Object... duration) {
|
|
||||||
MulReturnType<ErrorCode, Long> ret = runDispose(ipAddr,
|
|
||||||
capType,
|
|
||||||
null,
|
|
||||||
DDoSAttackType.ALL_ATTACKS,
|
|
||||||
(long) duration[0]);
|
|
||||||
|
|
||||||
callback.upgradeStatusCallback(ret.getFirstParam());
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Device dispose stop mul return type.
|
|
||||||
*
|
|
||||||
* @param capType the cap type
|
|
||||||
* @param taskId the task id
|
|
||||||
* @return the mul return type
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public MulReturnType<ErrorCode, Long> deviceDisposeStop(DisposeTaskCallback callback,
|
|
||||||
DisposeCapacityType capType,
|
|
||||||
Object... taskId) {
|
|
||||||
MulReturnType<ErrorCode, Long> ret = stopDispose(null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
DDoSAttackType.ALL_ATTACKS,
|
|
||||||
(long) taskId[0]);
|
|
||||||
|
|
||||||
callback.upgradeStatusCallback(ret.getFirstParam());
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
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.DisposeCapacityType;
|
import com.dispose.common.DisposeCapacityType;
|
||||||
import com.dispose.common.ErrorCode;
|
import com.dispose.common.ErrorCode;
|
||||||
import com.dispose.common.NetflowDirection;
|
import com.dispose.common.NetflowDirection;
|
||||||
|
@ -17,7 +14,7 @@ import javax.annotation.Nullable;
|
||||||
*
|
*
|
||||||
* @author <huangxin@cmhi.chinamoblie.com>
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
*/
|
*/
|
||||||
public class VirtualAbilityImpl implements DisposeAbility<ErrorCode>, DeviceDisposeAbility<ErrorCode> {
|
public class VirtualAbilityImpl implements DisposeAbility {
|
||||||
/**
|
/**
|
||||||
* Init device env.
|
* Init device env.
|
||||||
*
|
*
|
||||||
|
@ -41,10 +38,10 @@ public class VirtualAbilityImpl implements DisposeAbility<ErrorCode>, DeviceDisp
|
||||||
* @return the mul return type
|
* @return the mul return type
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ErrorCode runDispose(String ip, DisposeCapacityType capType,
|
public MulReturnType<ErrorCode, Long> runDispose(String ip, DisposeCapacityType capType,
|
||||||
@Nullable NetflowDirection nfDirection,
|
@Nullable NetflowDirection nfDirection,
|
||||||
@Nullable DDoSAttackType attackType, @Nullable Long duration) {
|
@Nullable Integer attackType, @Nullable Long duration) {
|
||||||
return ErrorCode.ERR_OK;
|
return new MulReturnType<>(ErrorCode.ERR_OK, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -58,10 +55,10 @@ public class VirtualAbilityImpl implements DisposeAbility<ErrorCode>, DeviceDisp
|
||||||
* @return the mul return type
|
* @return the mul return type
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ErrorCode stopDispose(String ip, DisposeCapacityType capType,
|
public MulReturnType<ErrorCode, Long> stopDispose(String ip, DisposeCapacityType capType,
|
||||||
@Nullable NetflowDirection nfDirection,
|
@Nullable NetflowDirection nfDirection,
|
||||||
@Nullable DDoSAttackType attackType, @Nullable Long taskId) {
|
@Nullable Integer attackType, @Nullable Long taskId) {
|
||||||
return ErrorCode.ERR_OK;
|
return new MulReturnType<>(ErrorCode.ERR_OK, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -106,46 +103,4 @@ public class VirtualAbilityImpl implements DisposeAbility<ErrorCode>, DeviceDisp
|
||||||
public Long toDeviceAttackType(Long ddosAttackTypeMask) {
|
public Long toDeviceAttackType(Long ddosAttackTypeMask) {
|
||||||
return ddosAttackTypeMask;
|
return ddosAttackTypeMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Device dispose exec error code.
|
|
||||||
*
|
|
||||||
* @param capType the cap type
|
|
||||||
* @param ipAddr the ip addr
|
|
||||||
* @param duration the duration
|
|
||||||
* @return the error code
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ErrorCode deviceDisposeExec(DisposeTaskCallback callback, DisposeCapacityType capType, String ipAddr,
|
|
||||||
Object... duration) {
|
|
||||||
ErrorCode ret = runDispose(ipAddr,
|
|
||||||
capType,
|
|
||||||
null,
|
|
||||||
DDoSAttackType.ALL_ATTACKS,
|
|
||||||
null);
|
|
||||||
|
|
||||||
callback.upgradeStatusCallback(ret);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Device dispose stop error code.
|
|
||||||
*
|
|
||||||
* @param capType the cap type
|
|
||||||
* @param taskId the task id
|
|
||||||
* @return the error code
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ErrorCode deviceDisposeStop(DisposeTaskCallback callback, DisposeCapacityType capType, Object... taskId) {
|
|
||||||
ErrorCode ret = stopDispose(null,
|
|
||||||
capType,
|
|
||||||
null,
|
|
||||||
DDoSAttackType.ALL_ATTACKS,
|
|
||||||
null);
|
|
||||||
|
|
||||||
callback.upgradeStatusCallback(ret);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,27 +6,24 @@ package com.dispose.common;
|
||||||
* @author <huangxin@cmhi.chinamoblie.com>
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
*/
|
*/
|
||||||
public enum DisposeCapacityType implements BaseEnum {
|
public enum DisposeCapacityType implements BaseEnum {
|
||||||
|
//1.清洗,2.压制,3.高防
|
||||||
/**
|
/**
|
||||||
* The Cleanup.
|
* The Cleanup.
|
||||||
*/
|
*/
|
||||||
CLEANUP(0, "清洗能力"),
|
CLEANUP(0, "清洗能力"),
|
||||||
|
/**
|
||||||
|
* Blackhool dispose capacity type.
|
||||||
|
*/
|
||||||
|
BLACKHOOL(1, "压制能力"),
|
||||||
/**
|
/**
|
||||||
* The Hidepend.
|
* The Hidepend.
|
||||||
*/
|
*/
|
||||||
HIDEPEND(1, "高防能力"),
|
HIDEPEND(2, "高防能力"),
|
||||||
/**
|
|
||||||
* The Blackhool.
|
|
||||||
*/
|
|
||||||
BLACKHOOL(2, "黑洞能力"),
|
|
||||||
/**
|
/**
|
||||||
* The Detecive.
|
* The Detecive.
|
||||||
*/
|
*/
|
||||||
DETECIVE(3, "检测能力"),
|
DETECIVE(3, "检测能力"),
|
||||||
|
;
|
||||||
/**
|
|
||||||
* Blocking dispose capacity type.
|
|
||||||
*/
|
|
||||||
BLOCKING(4, "封堵");
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Code.
|
* The Code.
|
||||||
|
@ -49,9 +46,9 @@ public enum DisposeCapacityType implements BaseEnum {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets code.
|
* Gets value.
|
||||||
*
|
*
|
||||||
* @return the code
|
* @return the value
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Integer getValue() {
|
public Integer getValue() {
|
||||||
|
@ -59,12 +56,13 @@ public enum DisposeCapacityType implements BaseEnum {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets readme.
|
* Gets description.
|
||||||
*
|
*
|
||||||
* @return the readme
|
* @return the description
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return this.readme;
|
return this.readme;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -109,6 +109,24 @@ public enum DpTechAttackType implements BaseEnum {
|
||||||
.distinct().toArray(DpTechAttackType[]::new));
|
.distinct().toArray(DpTechAttackType[]::new));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mask to ddos attack type list.
|
||||||
|
*
|
||||||
|
* @param attackTypeMask the attack type mask
|
||||||
|
* @return the list
|
||||||
|
*/
|
||||||
|
public static List<DpTechAttackType> maskToDdosAttackType(Long attackTypeMask) {
|
||||||
|
List<DpTechAttackType> attackTypes = new ArrayList<>();
|
||||||
|
|
||||||
|
for(DpTechAttackType t : DpTechAttackType.values()) {
|
||||||
|
if((((long)1 << t.getValue()) & attackTypeMask) != 0) {
|
||||||
|
attackTypes.add(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return attackTypes;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* From ddos attack type value stream.
|
* From ddos attack type value stream.
|
||||||
*
|
*
|
||||||
|
@ -223,4 +241,13 @@ public enum DpTechAttackType implements BaseEnum {
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return this.readme;
|
return this.readme;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets attack type mask.
|
||||||
|
*
|
||||||
|
* @return the attack type mask
|
||||||
|
*/
|
||||||
|
public Long getAttackTypeMask() {
|
||||||
|
return (long)1 << this.code;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,9 +9,9 @@ public class DpTechConfigValue {
|
||||||
/**
|
/**
|
||||||
* The constant SOAP_CONNECT_TIMEOUT.
|
* The constant SOAP_CONNECT_TIMEOUT.
|
||||||
*/
|
*/
|
||||||
public static volatile int SOAP_CONNECT_TIMEOUT_SECOND = 60;
|
public static volatile long SOAP_CONNECT_TIMEOUT_SECOND = 60;
|
||||||
/**
|
/**
|
||||||
* The constant SOAP_RECEIVE_TIMEOUT.
|
* The constant SOAP_RECEIVE_TIMEOUT.
|
||||||
*/
|
*/
|
||||||
public static volatile int SOAP_RECEIVE_TIMEOUT_SECOND = 60;
|
public static volatile long SOAP_RECEIVE_TIMEOUT_SECOND = 60;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
package com.dispose.config;
|
package com.dispose.config;
|
||||||
|
|
||||||
|
import com.dispose.common.AuthConfigValue;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type Auth configure.
|
* The type Auth configure.
|
||||||
*
|
*
|
||||||
|
@ -14,14 +19,24 @@ import org.springframework.stereotype.Component;
|
||||||
@Setter
|
@Setter
|
||||||
@Component
|
@Component
|
||||||
@ConfigurationProperties(prefix = "auth")
|
@ConfigurationProperties(prefix = "auth")
|
||||||
|
@Configuration
|
||||||
public class AuthConfigure {
|
public class AuthConfigure {
|
||||||
/**
|
/**
|
||||||
* The Token timeout minute.
|
* The Token timeout minute.
|
||||||
*/
|
*/
|
||||||
private String tokenTimeoutMinute;
|
private Long tokenTimeoutMinute;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Verify request token.
|
* The Verify request token.
|
||||||
*/
|
*/
|
||||||
private String verifyRequestToken;
|
private Boolean verifyRequestToken;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init global value.
|
||||||
|
*/
|
||||||
|
@PostConstruct
|
||||||
|
private void initGlobalValue() {
|
||||||
|
AuthConfigValue.TOKEN_EXPIRED_TIME_MS = Optional.ofNullable(tokenTimeoutMinute).orElse((long) 30 * 60 * 1000);
|
||||||
|
AuthConfigValue.VERIFY_REQUEST_TOKEN = Optional.ofNullable(verifyRequestToken).orElse(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
package com.dispose.config;
|
package com.dispose.config;
|
||||||
|
|
||||||
|
import com.dispose.common.DisposeConfigValue;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type Dispose configure.
|
* The type Dispose configure.
|
||||||
*
|
*
|
||||||
|
@ -14,29 +19,38 @@ import org.springframework.stereotype.Component;
|
||||||
@Setter
|
@Setter
|
||||||
@Component
|
@Component
|
||||||
@ConfigurationProperties(prefix = "dispose")
|
@ConfigurationProperties(prefix = "dispose")
|
||||||
|
@Configuration
|
||||||
public class DisposeConfigure {
|
public class DisposeConfigure {
|
||||||
|
/**
|
||||||
|
* The Call error retry times.
|
||||||
|
*/
|
||||||
|
public Integer callErrorRetryTimes;
|
||||||
/**
|
/**
|
||||||
* The Check protocol timeout.
|
* The Check protocol timeout.
|
||||||
*/
|
*/
|
||||||
private String checkProtocolTimeout;
|
private Boolean checkProtocolTimeout;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Split char.
|
* The Split char.
|
||||||
*/
|
*/
|
||||||
private String splitChar;
|
private String splitChar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Request timeout second.
|
* The Request timeout second.
|
||||||
*/
|
*/
|
||||||
private String requestTimeoutSecond;
|
private Long requestTimeoutSecond;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Used privacy protect.
|
* The Used privacy protect.
|
||||||
*/
|
*/
|
||||||
private String usedPrivacyProtect;
|
private Boolean usedPrivacyProtect;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Call error retry times.
|
* Init global value.
|
||||||
*/
|
*/
|
||||||
public String callErrorRetryTimes;
|
@PostConstruct
|
||||||
|
private void initGlobalValue() {
|
||||||
|
DisposeConfigValue.REQUEST_TIMEOUT_MS = Optional.ofNullable(requestTimeoutSecond).orElse((long) 5 * 1000);
|
||||||
|
DisposeConfigValue.CHECK_PROTO_REQUEST_TIMEOUT = Optional.ofNullable(checkProtocolTimeout).orElse(true);
|
||||||
|
DisposeConfigValue.USED_PRIVACY_PROTECT = Optional.ofNullable(usedPrivacyProtect).orElse(true);
|
||||||
|
DisposeConfigValue.CALL_ERROR_RETRY_TIMES = Optional.ofNullable(callErrorRetryTimes).orElse(5);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
package com.dispose.config;
|
package com.dispose.config;
|
||||||
|
|
||||||
|
import com.dispose.common.DpTechConfigValue;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type Dp tech configure.
|
* The type Dp tech configure.
|
||||||
*
|
*
|
||||||
|
@ -14,14 +19,26 @@ import org.springframework.stereotype.Component;
|
||||||
@Setter
|
@Setter
|
||||||
@Component
|
@Component
|
||||||
@ConfigurationProperties(prefix = "dptech")
|
@ConfigurationProperties(prefix = "dptech")
|
||||||
|
@Configuration
|
||||||
public class DpTechConfigure {
|
public class DpTechConfigure {
|
||||||
/**
|
/**
|
||||||
* The Soap conn timeout.
|
* The Soap conn timeout second.
|
||||||
*/
|
*/
|
||||||
private String soapConnTimeoutSecond;
|
private Integer soapConnTimeoutSecond;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Soap recv timeout.
|
* The Soap recv timeout second.
|
||||||
*/
|
*/
|
||||||
private String soapRecvTimeoutSecond;
|
private Integer soapRecvTimeoutSecond;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init global value.
|
||||||
|
*/
|
||||||
|
@PostConstruct
|
||||||
|
private void initGlobalValue() {
|
||||||
|
DpTechConfigValue.SOAP_CONNECT_TIMEOUT_SECOND = Optional.ofNullable(soapConnTimeoutSecond).orElse(50) * 1000;
|
||||||
|
DpTechConfigValue.SOAP_RECEIVE_TIMEOUT_SECOND = Optional.ofNullable(soapRecvTimeoutSecond).orElse(50) * 1000;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,24 @@ public interface DeviceTaskManager {
|
||||||
*/
|
*/
|
||||||
boolean setExecAttackType(Long id, NetflowDirection nf, Long attackTypeMask);
|
boolean setExecAttackType(Long id, NetflowDirection nf, Long attackTypeMask);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exec attack type clean bit.
|
||||||
|
*
|
||||||
|
* @param id the id
|
||||||
|
* @param nf the nf
|
||||||
|
* @param bit the bit
|
||||||
|
*/
|
||||||
|
void execAttackTypeCleanBit(Long id, NetflowDirection nf, Integer bit);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exec attack type set bit.
|
||||||
|
*
|
||||||
|
* @param id the id
|
||||||
|
* @param nf the nf
|
||||||
|
* @param bit the bit
|
||||||
|
*/
|
||||||
|
void execAttackTypeSetBit(Long id, NetflowDirection nf, Integer bit);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets attack type status.
|
* Sets attack type status.
|
||||||
*
|
*
|
||||||
|
@ -58,6 +76,24 @@ public interface DeviceTaskManager {
|
||||||
*/
|
*/
|
||||||
boolean setAttackTypeStatus(Long id, NetflowDirection nf, Long attackTypeMask);
|
boolean setAttackTypeStatus(Long id, NetflowDirection nf, Long attackTypeMask);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attack type status clean bit.
|
||||||
|
*
|
||||||
|
* @param id the id
|
||||||
|
* @param nf the nf
|
||||||
|
* @param bit the bit
|
||||||
|
*/
|
||||||
|
void attackTypeStatusCleanBit(Long id, NetflowDirection nf, Integer bit);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attack type status set bit.
|
||||||
|
*
|
||||||
|
* @param id the id
|
||||||
|
* @param nf the nf
|
||||||
|
* @param bit the bit
|
||||||
|
*/
|
||||||
|
void attackTypeStatusSetBit(Long id, NetflowDirection nf, Integer bit);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets task err retry times.
|
* Sets task err retry times.
|
||||||
*
|
*
|
||||||
|
@ -75,4 +111,12 @@ public interface DeviceTaskManager {
|
||||||
* @return the task extern id
|
* @return the task extern id
|
||||||
*/
|
*/
|
||||||
boolean setTaskExternId(Long id, Long externId);
|
boolean setTaskExternId(Long id, Long externId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets task by id.
|
||||||
|
*
|
||||||
|
* @param id the id
|
||||||
|
* @return the task by id
|
||||||
|
*/
|
||||||
|
DeviceTask getTaskById(Long id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,10 +41,10 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
return deviceTaskMapper.addNewTaskInfo(DeviceTask.builder()
|
return deviceTaskMapper.addNewTaskInfo(DeviceTask.builder()
|
||||||
.taskId(taskId)
|
.taskId(taskId)
|
||||||
.deviceId(deviceId)
|
.deviceId(deviceId)
|
||||||
.taskAttackType(attackTypeMask)
|
.taskAttackType(attackTypeMask)
|
||||||
.build()) == 1;
|
.build()) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -81,17 +81,79 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
|
||||||
public boolean setExecAttackType(Long id, NetflowDirection nf, Long attackTypeMask) {
|
public boolean setExecAttackType(Long id, NetflowDirection nf, Long attackTypeMask) {
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if(nf != NetflowDirection.DIRECTION_IN) {
|
if (nf != NetflowDirection.DIRECTION_IN) {
|
||||||
ret = deviceTaskMapper.changeExecAttackTypeOutValue(id, attackTypeMask);
|
ret = deviceTaskMapper.changeExecAttackTypeOutValue(id, attackTypeMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(nf != NetflowDirection.DIRECTION_OUT) {
|
if (nf != NetflowDirection.DIRECTION_OUT) {
|
||||||
ret = deviceTaskMapper.changeAttackTypeStatusInValue(id, attackTypeMask);
|
ret = deviceTaskMapper.changeExecAttackTypeInValue(id, attackTypeMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret == 1;
|
return ret == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exec attack type clean bit.
|
||||||
|
*
|
||||||
|
* @param id the id
|
||||||
|
* @param nf the nf
|
||||||
|
* @param bit the bit
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void execAttackTypeCleanBit(Long id, NetflowDirection nf, Integer bit) {
|
||||||
|
Long execAttackTypeMask;
|
||||||
|
long bitMask = (long)1 << bit;
|
||||||
|
|
||||||
|
DeviceTask devTask = deviceTaskMapper.getTaskInfoById(id);
|
||||||
|
|
||||||
|
if (devTask == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nf != NetflowDirection.DIRECTION_IN) {
|
||||||
|
execAttackTypeMask = devTask.getExecAttackTypeOut();
|
||||||
|
execAttackTypeMask &= ~bitMask;
|
||||||
|
setExecAttackType(id, NetflowDirection.DIRECTION_OUT, execAttackTypeMask);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nf != NetflowDirection.DIRECTION_OUT) {
|
||||||
|
execAttackTypeMask = devTask.getExecAttackTypeIn();
|
||||||
|
execAttackTypeMask &= ~bitMask;
|
||||||
|
setExecAttackType(id, NetflowDirection.DIRECTION_IN, execAttackTypeMask);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exec attack type set bit.
|
||||||
|
*
|
||||||
|
* @param id the id
|
||||||
|
* @param nf the nf
|
||||||
|
* @param bit the bit
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void execAttackTypeSetBit(Long id, NetflowDirection nf, Integer bit) {
|
||||||
|
Long execAttackTypeMask;
|
||||||
|
long bitMask = (long)1 << bit;
|
||||||
|
|
||||||
|
DeviceTask devTask = deviceTaskMapper.getTaskInfoById(id);
|
||||||
|
|
||||||
|
if (devTask == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nf != NetflowDirection.DIRECTION_IN) {
|
||||||
|
execAttackTypeMask = devTask.getExecAttackTypeOut();
|
||||||
|
execAttackTypeMask |= bitMask;
|
||||||
|
setExecAttackType(id, NetflowDirection.DIRECTION_OUT, execAttackTypeMask);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nf != NetflowDirection.DIRECTION_OUT) {
|
||||||
|
execAttackTypeMask = devTask.getExecAttackTypeIn();
|
||||||
|
execAttackTypeMask |= bitMask;
|
||||||
|
setExecAttackType(id, NetflowDirection.DIRECTION_IN, execAttackTypeMask);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets attack type status.
|
* Sets attack type status.
|
||||||
*
|
*
|
||||||
|
@ -104,17 +166,79 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
|
||||||
public boolean setAttackTypeStatus(Long id, NetflowDirection nf, Long attackTypeMask) {
|
public boolean setAttackTypeStatus(Long id, NetflowDirection nf, Long attackTypeMask) {
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if(nf != NetflowDirection.DIRECTION_IN) {
|
if (nf != NetflowDirection.DIRECTION_IN) {
|
||||||
ret = deviceTaskMapper.changeAttackTypeStatusOutValue(id, attackTypeMask);
|
ret = deviceTaskMapper.changeAttackTypeStatusOutValue(id, attackTypeMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(nf != NetflowDirection.DIRECTION_OUT) {
|
if (nf != NetflowDirection.DIRECTION_OUT) {
|
||||||
ret = deviceTaskMapper.changeAttackTypeStatusInValue(id, attackTypeMask);
|
ret = deviceTaskMapper.changeAttackTypeStatusInValue(id, attackTypeMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret == 1;
|
return ret == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attack type status clean bit.
|
||||||
|
*
|
||||||
|
* @param id the id
|
||||||
|
* @param nf the nf
|
||||||
|
* @param bit the bit
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void attackTypeStatusCleanBit(Long id, NetflowDirection nf, Integer bit) {
|
||||||
|
Long attackTypeStatusMask;
|
||||||
|
long bitMask = (long)1 << bit;
|
||||||
|
|
||||||
|
DeviceTask devTask = deviceTaskMapper.getTaskInfoById(id);
|
||||||
|
|
||||||
|
if (devTask == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nf != NetflowDirection.DIRECTION_IN) {
|
||||||
|
attackTypeStatusMask = devTask.getAttackTypeStatusOut();
|
||||||
|
attackTypeStatusMask &= ~bitMask;
|
||||||
|
setAttackTypeStatus(id, NetflowDirection.DIRECTION_OUT, attackTypeStatusMask);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nf != NetflowDirection.DIRECTION_OUT) {
|
||||||
|
attackTypeStatusMask = devTask.getAttackTypeStatusIn();
|
||||||
|
attackTypeStatusMask &= ~bitMask;
|
||||||
|
setAttackTypeStatus(id, NetflowDirection.DIRECTION_IN, attackTypeStatusMask);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attack type status set bit.
|
||||||
|
*
|
||||||
|
* @param id the id
|
||||||
|
* @param nf the nf
|
||||||
|
* @param bit the bit
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void attackTypeStatusSetBit(Long id, NetflowDirection nf, Integer bit) {
|
||||||
|
Long attackTypeStatusMask;
|
||||||
|
long bitMask = (long)1 << bit;
|
||||||
|
|
||||||
|
DeviceTask devTask = deviceTaskMapper.getTaskInfoById(id);
|
||||||
|
|
||||||
|
if (devTask == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nf != NetflowDirection.DIRECTION_IN) {
|
||||||
|
attackTypeStatusMask = devTask.getAttackTypeStatusOut();
|
||||||
|
attackTypeStatusMask |= bitMask;
|
||||||
|
setAttackTypeStatus(id, NetflowDirection.DIRECTION_OUT, attackTypeStatusMask);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nf != NetflowDirection.DIRECTION_OUT) {
|
||||||
|
attackTypeStatusMask = devTask.getAttackTypeStatusIn();
|
||||||
|
attackTypeStatusMask |= bitMask;
|
||||||
|
setAttackTypeStatus(id, NetflowDirection.DIRECTION_IN, attackTypeStatusMask);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets task err retry times.
|
* Sets task err retry times.
|
||||||
*
|
*
|
||||||
|
@ -138,4 +262,15 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
|
||||||
public boolean setTaskExternId(Long id, Long externId) {
|
public boolean setTaskExternId(Long id, Long externId) {
|
||||||
return deviceTaskMapper.changeExternId(id, externId) == 1;
|
return deviceTaskMapper.changeExternId(id, externId) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets task by id.
|
||||||
|
*
|
||||||
|
* @param id the id
|
||||||
|
* @return the task by id
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public DeviceTask getTaskById(Long id) {
|
||||||
|
return deviceTaskMapper.getTaskInfoById(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,14 @@ public interface DeviceTaskMapper {
|
||||||
*/
|
*/
|
||||||
List<DeviceTask> getTaskInfoByTaskId(@Param("taskId") Long taskId);
|
List<DeviceTask> getTaskInfoByTaskId(@Param("taskId") Long taskId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets task info by id.
|
||||||
|
*
|
||||||
|
* @param id the id
|
||||||
|
* @return the task info by id
|
||||||
|
*/
|
||||||
|
DeviceTask getTaskInfoById(@Param("id") Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add new task info list int.
|
* Add new task info list int.
|
||||||
*
|
*
|
||||||
|
@ -90,7 +98,7 @@ public interface DeviceTaskMapper {
|
||||||
* @return the int
|
* @return the int
|
||||||
*/
|
*/
|
||||||
int changeExecAttackTypeOutValue(@Param("id") Long id,
|
int changeExecAttackTypeOutValue(@Param("id") Long id,
|
||||||
@Param("attackTypeValue") Long attackTypeValue);
|
@Param("attackTypeValue") Long attackTypeValue);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change attack type status in value int.
|
* Change attack type status in value int.
|
||||||
|
@ -100,7 +108,7 @@ public interface DeviceTaskMapper {
|
||||||
* @return the int
|
* @return the int
|
||||||
*/
|
*/
|
||||||
int changeAttackTypeStatusInValue(@Param("id") Long id,
|
int changeAttackTypeStatusInValue(@Param("id") Long id,
|
||||||
@Param("attackStatsValue") Long attackStatsValue);
|
@Param("attackStatsValue") Long attackStatsValue);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change attack type status out value int.
|
* Change attack type status out value int.
|
||||||
|
@ -110,7 +118,7 @@ public interface DeviceTaskMapper {
|
||||||
* @return the int
|
* @return the int
|
||||||
*/
|
*/
|
||||||
int changeAttackTypeStatusOutValue(@Param("id") Long id,
|
int changeAttackTypeStatusOutValue(@Param("id") Long id,
|
||||||
@Param("attackTypeValue") Long attackStatsValue);
|
@Param("attackStatsValue") Long attackStatsValue);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change err retry int.
|
* Change err retry int.
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
package com.dispose.service.impl;
|
package com.dispose.service.impl;
|
||||||
|
|
||||||
import com.dispose.ability.impl.HaoHanAbilityImpl;
|
|
||||||
import com.dispose.ability.impl.VirtualAbilityImpl;
|
|
||||||
import com.dispose.common.DisposeConfigValue;
|
import com.dispose.common.DisposeConfigValue;
|
||||||
import com.dispose.common.DisposeTaskStatus;
|
import com.dispose.common.DisposeTaskStatus;
|
||||||
|
import com.dispose.common.DpTechAttackType;
|
||||||
import com.dispose.common.ErrorCode;
|
import com.dispose.common.ErrorCode;
|
||||||
import com.dispose.common.Helper;
|
import com.dispose.common.Helper;
|
||||||
import com.dispose.common.NetflowDirection;
|
import com.dispose.common.NetflowDirection;
|
||||||
import com.dispose.manager.DeviceTaskManager;
|
import com.dispose.manager.DeviceTaskManager;
|
||||||
import com.dispose.manager.DisposeTaskManager;
|
import com.dispose.manager.DisposeTaskManager;
|
||||||
|
import com.dispose.pojo.entity.DeviceTask;
|
||||||
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.pojo.po.MulReturnType;
|
||||||
|
@ -95,12 +95,118 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
||||||
deviceTaskManager.getNewDisposeDeviceTaskInfo().forEach(v -> {
|
deviceTaskManager.getNewDisposeDeviceTaskInfo().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, v);
|
||||||
|
|
||||||
|
MulReturnType<ErrorCode, Long> ret;
|
||||||
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:
|
||||||
|
// 设置任务状态为启动中
|
||||||
|
deviceTaskManager.changeDisposeDeviceTaskInfoStatus(v.getId(), DisposeTaskStatus.TASK_STARTING);
|
||||||
|
|
||||||
|
// 遍历设备攻击类型
|
||||||
|
for (DpTechAttackType t : DpTechAttackType.maskToDdosAttackType(v.getTaskAttackType())) {
|
||||||
|
// 入方向
|
||||||
|
if (task.getFlowDirection() != NetflowDirection.DIRECTION_IN) {
|
||||||
|
// 已经启动过的任务不再重复启动
|
||||||
|
if ((v.getExecAttackTypeOut() & t.getAttackTypeMask()) != 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 设置启动任务攻击类型状态
|
||||||
|
deviceTaskManager.execAttackTypeSetBit(v.getId(), NetflowDirection.DIRECTION_OUT,
|
||||||
|
t.getValue());
|
||||||
|
// 调用迪普设备启动处置任务
|
||||||
|
ret = ai.getDb().runDispose(task.getDisposeIp(), task.getDisposeCapacity(),
|
||||||
|
NetflowDirection.DIRECTION_OUT, t.getValue(), null);
|
||||||
|
|
||||||
|
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
|
||||||
|
// 标志启动成功
|
||||||
|
deviceTaskManager.attackTypeStatusSetBit(v.getId(), NetflowDirection.DIRECTION_OUT,
|
||||||
|
t.getValue());
|
||||||
|
|
||||||
|
log.info("DPTECH_UMC setup task {}, {} succeed: {}", t,
|
||||||
|
NetflowDirection.DIRECTION_OUT, v);
|
||||||
|
|
||||||
|
deviceTaskManager.setTaskErrRetryTimes(v.getId(), 0);
|
||||||
|
} else if (v.getErrRetry() < DisposeConfigValue.CALL_ERROR_RETRY_TIMES * 10) {
|
||||||
|
// 设置该任务为新任务,待下次重试启动
|
||||||
|
// 记录任务出错重试次数
|
||||||
|
v.setErrRetry(v.getErrRetry() + 1);
|
||||||
|
deviceTaskManager.setTaskErrRetryTimes(v.getId(), v.getErrRetry());
|
||||||
|
//清除任务攻击类型启动标志
|
||||||
|
deviceTaskManager.execAttackTypeCleanBit(v.getId(), NetflowDirection.DIRECTION_OUT,
|
||||||
|
t.getValue());
|
||||||
|
log.error("DPTECH_UMC setup task {}, {} times {} error: {}", t,
|
||||||
|
NetflowDirection.DIRECTION_OUT, v.getErrRetry(), v);
|
||||||
|
} else {
|
||||||
|
log.info("DPTECH_UMC setup task {}, {} error {}: {}", t,
|
||||||
|
NetflowDirection.DIRECTION_OUT, ret.getFirstParam(), v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 出方向
|
||||||
|
if (task.getFlowDirection() != NetflowDirection.DIRECTION_OUT) {
|
||||||
|
// 已经启动过的任务不再重复启动
|
||||||
|
if ((v.getExecAttackTypeIn() & t.getAttackTypeMask()) != 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 设置启动任务攻击类型状态
|
||||||
|
deviceTaskManager.execAttackTypeSetBit(v.getId(), NetflowDirection.DIRECTION_IN,
|
||||||
|
t.getValue());
|
||||||
|
// 调用迪普设备启动处置任务
|
||||||
|
ret = ai.getDb().runDispose(task.getDisposeIp(), task.getDisposeCapacity(),
|
||||||
|
NetflowDirection.DIRECTION_IN, t.getValue(), null);
|
||||||
|
|
||||||
|
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
|
||||||
|
// 标志启动成功
|
||||||
|
deviceTaskManager.attackTypeStatusSetBit(v.getId(), NetflowDirection.DIRECTION_IN,
|
||||||
|
t.getValue());
|
||||||
|
|
||||||
|
log.info("DPTECH_UMC setup task {}, {} succeed: {}", t,
|
||||||
|
NetflowDirection.DIRECTION_IN, v);
|
||||||
|
|
||||||
|
deviceTaskManager.setTaskErrRetryTimes(v.getId(), 0);
|
||||||
|
} else if (v.getErrRetry() < DisposeConfigValue.CALL_ERROR_RETRY_TIMES * 10) {
|
||||||
|
// 设置该任务为新任务,待下次重试启动
|
||||||
|
// 记录任务出错重试次数
|
||||||
|
v.setErrRetry(v.getErrRetry() + 1);
|
||||||
|
deviceTaskManager.setTaskErrRetryTimes(v.getId(), v.getErrRetry());
|
||||||
|
//清除任务攻击类型启动标志
|
||||||
|
deviceTaskManager.execAttackTypeCleanBit(v.getId(), NetflowDirection.DIRECTION_IN,
|
||||||
|
t.getValue());
|
||||||
|
log.error("DPTECH_UMC setup task {}, {} times {} error: {}", t,
|
||||||
|
NetflowDirection.DIRECTION_IN, v.getErrRetry(), v);
|
||||||
|
} else {
|
||||||
|
log.info("DPTECH_UMC setup task {}, {} error {}: {}", t,
|
||||||
|
NetflowDirection.DIRECTION_IN, ret.getFirstParam(), v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean taskSetupSuccessed = true;
|
||||||
|
DeviceTask devTask = deviceTaskManager.getTaskById(v.getId());
|
||||||
|
|
||||||
|
if (task.getFlowDirection() != NetflowDirection.DIRECTION_IN) {
|
||||||
|
if (!devTask.getExecAttackTypeOut().equals(devTask.getTaskAttackType())
|
||||||
|
|| !devTask.getExecAttackTypeOut().equals(devTask.getAttackTypeStatusOut())) {
|
||||||
|
taskSetupSuccessed = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (task.getFlowDirection() != NetflowDirection.DIRECTION_OUT) {
|
||||||
|
if (!devTask.getExecAttackTypeIn().equals(devTask.getTaskAttackType())
|
||||||
|
|| !devTask.getExecAttackTypeIn().equals(devTask.getAttackTypeStatusIn())) {
|
||||||
|
taskSetupSuccessed = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (taskSetupSuccessed) {
|
||||||
|
// 更改处置任务状态为处置中
|
||||||
|
deviceTaskManager.changeDisposeDeviceTaskInfoStatus(v.getId(),
|
||||||
|
DisposeTaskStatus.TASK_STARTED);
|
||||||
|
log.info("DPTECH_UMC setup task succeed: {}", v);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HAOHAN_PLATFORM:
|
case HAOHAN_PLATFORM:
|
||||||
|
@ -109,40 +215,35 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
||||||
// 设置启动任务攻击类型状态
|
// 设置启动任务攻击类型状态
|
||||||
deviceTaskManager.setExecAttackType(v.getId(), NetflowDirection.DIRECTION_BI,
|
deviceTaskManager.setExecAttackType(v.getId(), NetflowDirection.DIRECTION_BI,
|
||||||
v.getTaskAttackType());
|
v.getTaskAttackType());
|
||||||
// 调用设备处置能力
|
|
||||||
MulReturnType<ErrorCode, Long> ret = ((HaoHanAbilityImpl) ai.getDb()).deviceDisposeExec(
|
ret = ai.getDb().runDispose(task.getDisposeIp(), task.getDisposeCapacity(), null, null,
|
||||||
errorCode -> {
|
|
||||||
// 启动处置任务成功
|
|
||||||
if (errorCode == ErrorCode.ERR_OK) {
|
|
||||||
// 设置攻击类型任务启动结果
|
|
||||||
deviceTaskManager.setAttackTypeStatus(v.getId(),
|
|
||||||
task.getFlowDirection(), v.getTaskAttackType());
|
|
||||||
// 更改处置任务状态为处置中
|
|
||||||
deviceTaskManager.changeDisposeDeviceTaskInfoStatus(v.getId(),
|
|
||||||
DisposeTaskStatus.TASK_STARTED);
|
|
||||||
log.info("HAOHAN_PLATFORM setup task succeed: {}", v);
|
|
||||||
} else if (v.getErrRetry() < DisposeConfigValue.CALL_ERROR_RETRY_TIMES) {
|
|
||||||
// 设置该任务为新任务,待下次重试启动
|
|
||||||
deviceTaskManager.changeDisposeDeviceTaskInfoStatus(v.getId(),
|
|
||||||
DisposeTaskStatus.TASK_NEW);
|
|
||||||
// 记录任务出错重试次数
|
|
||||||
deviceTaskManager.setTaskErrRetryTimes(v.getId(), v.getErrRetry() + 1);
|
|
||||||
log.error("HAOHAN_PLATFORM setup task times {} error {}: {}",
|
|
||||||
v.getErrRetry(), errorCode, v);
|
|
||||||
} else {
|
|
||||||
// 任务出错,不在重试,当做失败任务处理
|
|
||||||
deviceTaskManager.setAttackTypeStatus(v.getId(),
|
|
||||||
task.getFlowDirection(), ~v.getTaskAttackType());
|
|
||||||
log.error("HAOHAN_PLATFORM setup task error {}: {}", errorCode, v);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
task.getDisposeCapacity(),
|
|
||||||
task.getDisposeIp(),
|
|
||||||
(long) Helper.getTimestampDiffNow(task.getPlanEndTime()));
|
(long) Helper.getTimestampDiffNow(task.getPlanEndTime()));
|
||||||
|
|
||||||
// 启动任务成功,保存浩瀚任务ID到数据库
|
|
||||||
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
|
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
|
||||||
|
// 设置攻击类型任务启动结果
|
||||||
|
deviceTaskManager.setAttackTypeStatus(v.getId(),
|
||||||
|
task.getFlowDirection(), v.getTaskAttackType());
|
||||||
|
// 更改处置任务状态为处置中
|
||||||
|
deviceTaskManager.changeDisposeDeviceTaskInfoStatus(v.getId(),
|
||||||
|
DisposeTaskStatus.TASK_STARTED);
|
||||||
|
|
||||||
|
// 记录浩瀚设备返回的任务ID
|
||||||
deviceTaskManager.setTaskExternId(v.getId(), ret.getSecondParam());
|
deviceTaskManager.setTaskExternId(v.getId(), ret.getSecondParam());
|
||||||
|
|
||||||
|
log.info("HAOHAN_PLATFORM setup task succeed: {}, device taskId {}", v, ret.getSecondParam());
|
||||||
|
} else if (v.getErrRetry() < DisposeConfigValue.CALL_ERROR_RETRY_TIMES) {
|
||||||
|
// 设置该任务为新任务,待下次重试启动
|
||||||
|
deviceTaskManager.changeDisposeDeviceTaskInfoStatus(v.getId(),
|
||||||
|
DisposeTaskStatus.TASK_NEW);
|
||||||
|
// 记录任务出错重试次数
|
||||||
|
deviceTaskManager.setTaskErrRetryTimes(v.getId(), v.getErrRetry() + 1);
|
||||||
|
log.error("HAOHAN_PLATFORM setup task times {} error {}: {}", v.getErrRetry(),
|
||||||
|
ret.getSecondParam(), v);
|
||||||
|
} else {
|
||||||
|
// 任务出错,不在重试,当做失败任务处理
|
||||||
|
deviceTaskManager.setAttackTypeStatus(v.getId(),
|
||||||
|
task.getFlowDirection(), ~v.getTaskAttackType());
|
||||||
|
log.error("HAOHAN_PLATFORM setup task error {}: {}", ret.getFirstParam(), v);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -153,26 +254,23 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
||||||
deviceTaskManager.setExecAttackType(v.getId(), NetflowDirection.DIRECTION_BI,
|
deviceTaskManager.setExecAttackType(v.getId(), NetflowDirection.DIRECTION_BI,
|
||||||
v.getTaskAttackType());
|
v.getTaskAttackType());
|
||||||
|
|
||||||
((VirtualAbilityImpl) ai.getDb()).deviceDisposeExec(
|
// 调用设备执行处置任务
|
||||||
errorCode -> {
|
ret = ai.getDb().runDispose(task.getDisposeIp(), task.getDisposeCapacity(), null, null, null);
|
||||||
// 启动处置任务成功
|
|
||||||
if (errorCode == ErrorCode.ERR_OK) {
|
if (ret.getFirstParam() == 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("VIRTUAL_DISPOSE setup task succeed: {}", v);
|
log.info("VIRTUAL_DISPOSE setup task succeed: {}", v);
|
||||||
} else {
|
} else {
|
||||||
// 任务出错,不在重试,当做失败任务处理
|
// 任务出错,不在重试,当做失败任务处理
|
||||||
deviceTaskManager.setAttackTypeStatus(v.getId(),
|
deviceTaskManager.setAttackTypeStatus(v.getId(),
|
||||||
task.getFlowDirection(), ~v.getTaskAttackType());
|
task.getFlowDirection(), ~v.getTaskAttackType());
|
||||||
log.error("VIRTUAL_DISPOSE setup task error {}: {}", errorCode, v);
|
log.error("VIRTUAL_DISPOSE setup task error {}: {}", ret.getFirstParam(), v);
|
||||||
}
|
}
|
||||||
},
|
|
||||||
task.getDisposeCapacity(),
|
|
||||||
task.getDisposeIp());
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -1,12 +1,6 @@
|
||||||
package com.dispose.setup;
|
package com.dispose.setup;
|
||||||
|
|
||||||
import com.dispose.common.AuthConfigValue;
|
|
||||||
import com.dispose.common.DisposeConfigValue;
|
|
||||||
import com.dispose.common.DpTechConfigValue;
|
|
||||||
import com.dispose.common.ErrorCode;
|
import com.dispose.common.ErrorCode;
|
||||||
import com.dispose.config.AuthConfigure;
|
|
||||||
import com.dispose.config.DisposeConfigure;
|
|
||||||
import com.dispose.config.DpTechConfigure;
|
|
||||||
import com.dispose.pojo.po.MulReturnType;
|
import com.dispose.pojo.po.MulReturnType;
|
||||||
import com.dispose.pojo.vo.DeviceFirewareInfo;
|
import com.dispose.pojo.vo.DeviceFirewareInfo;
|
||||||
import com.dispose.service.DisposeAbilityRouterService;
|
import com.dispose.service.DisposeAbilityRouterService;
|
||||||
|
@ -25,24 +19,6 @@ import javax.annotation.Resource;
|
||||||
@Component
|
@Component
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class SystemInitial implements CommandLineRunner {
|
public class SystemInitial implements CommandLineRunner {
|
||||||
/**
|
|
||||||
* The Dispose configure.
|
|
||||||
*/
|
|
||||||
@Resource
|
|
||||||
DisposeConfigure disposeConfigure;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The Auth configure.
|
|
||||||
*/
|
|
||||||
@Resource
|
|
||||||
AuthConfigure authConfigure;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The Dp tech configure.
|
|
||||||
*/
|
|
||||||
@Resource
|
|
||||||
DpTechConfigure dpTechConfigure;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Dispose ability router service.
|
* The Dispose ability router service.
|
||||||
*/
|
*/
|
||||||
|
@ -50,62 +26,8 @@ public class SystemInitial implements CommandLineRunner {
|
||||||
private DisposeAbilityRouterService disposeAbilityRouterService;
|
private DisposeAbilityRouterService disposeAbilityRouterService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load configure.
|
* Sets ability device.
|
||||||
*/
|
*/
|
||||||
private void loadConfigure() {
|
|
||||||
|
|
||||||
try {
|
|
||||||
AuthConfigValue.TOKEN_EXPIRED_TIME_MS = Long.parseLong(authConfigure.getTokenTimeoutMinute()) * 60 * 1000;
|
|
||||||
} catch (Exception ex) {
|
|
||||||
log.error("load TOKEN_EXPIRED_TIME_MS configure error: {}", ex.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
AuthConfigValue.VERIFY_REQUEST_TOKEN = Boolean.parseBoolean(authConfigure.getVerifyRequestToken());
|
|
||||||
} catch (Exception ex) {
|
|
||||||
log.error("load VERIFY_REQUEST_TOKEN configure error: {}", ex.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
DpTechConfigValue.SOAP_CONNECT_TIMEOUT_SECOND =
|
|
||||||
Integer.parseInt(dpTechConfigure.getSoapConnTimeoutSecond());
|
|
||||||
} catch (Exception ex) {
|
|
||||||
log.error("load SOAP_CONNECT_TIMEOUT_SECOND configure error: {}", ex.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
DpTechConfigValue.SOAP_RECEIVE_TIMEOUT_SECOND =
|
|
||||||
Integer.parseInt(dpTechConfigure.getSoapRecvTimeoutSecond());
|
|
||||||
} catch (Exception ex) {
|
|
||||||
log.error("load SOAP_RECEIVE_TIMEOUT_SECOND configure error: {}", ex.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
DisposeConfigValue.REQUEST_TIMEOUT_MS = Integer.parseInt(disposeConfigure.getRequestTimeoutSecond()) * 1000;
|
|
||||||
} catch (Exception ex) {
|
|
||||||
log.error("load REQUEST_TIMEOUT_MS configure error: {}", ex.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
DisposeConfigValue.CHECK_PROTO_REQUEST_TIMEOUT =
|
|
||||||
Boolean.parseBoolean(disposeConfigure.getCheckProtocolTimeout());
|
|
||||||
} catch (Exception ex) {
|
|
||||||
log.error("load CHECK_PROTO_REQUEST_TIMEOUT configure error: {}", ex.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
DisposeConfigValue.USED_PRIVACY_PROTECT = Boolean.parseBoolean(disposeConfigure.getUsedPrivacyProtect());
|
|
||||||
} catch (Exception ex) {
|
|
||||||
log.error("load USED_PRIVACY_PROTECT configure error: {}", ex.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
DisposeConfigValue.CALL_ERROR_RETRY_TIMES = Integer.parseInt(disposeConfigure.getCallErrorRetryTimes());
|
|
||||||
} catch (Exception ex) {
|
|
||||||
log.error("load CALL_ERROR_RETRY_TIMES configure error: {}", ex.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Async("bizExecutor")
|
@Async("bizExecutor")
|
||||||
public void setupAbilityDevice() {
|
public void setupAbilityDevice() {
|
||||||
disposeAbilityRouterService.getAllAbilityDevices().forEach(v -> {
|
disposeAbilityRouterService.getAllAbilityDevices().forEach(v -> {
|
||||||
|
@ -118,7 +40,6 @@ public class SystemInitial implements CommandLineRunner {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run.
|
* Run.
|
||||||
*
|
*
|
||||||
|
@ -126,9 +47,6 @@ public class SystemInitial implements CommandLineRunner {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void run(String... args) {
|
public void run(String... args) {
|
||||||
// 系统初始化入口
|
|
||||||
loadConfigure();
|
|
||||||
|
|
||||||
// 初始化处置能力设备
|
// 初始化处置能力设备
|
||||||
setupAbilityDevice();
|
setupAbilityDevice();
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,12 @@
|
||||||
${@com.dispose.common.DisposeTaskStatus@TASK_NEW.getValue()})
|
${@com.dispose.common.DisposeTaskStatus@TASK_NEW.getValue()})
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
<select id="getTaskInfoById" resultMap="device_task">
|
||||||
|
SELECT *
|
||||||
|
FROM device_task
|
||||||
|
WHERE id = #{id, jdbcType=INTEGER}
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="getTaskInfoByTaskId" resultMap="device_task">
|
<select id="getTaskInfoByTaskId" resultMap="device_task">
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM device_task
|
FROM device_task
|
||||||
|
@ -48,7 +54,8 @@
|
||||||
<select id="getNewTaskInfos" resultMap="device_task">
|
<select id="getNewTaskInfos" resultMap="device_task">
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM device_task
|
FROM device_task
|
||||||
WHERE status = ${@com.dispose.common.DisposeTaskStatus@TASK_NEW.getValue()}
|
WHERE status = ${@com.dispose.common.DisposeTaskStatus@TASK_NEW.getValue()} OR
|
||||||
|
status = ${@com.dispose.common.DisposeTaskStatus@TASK_STARTING.getValue()}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getTaskByDetails" resultMap="device_task">
|
<select id="getTaskByDetails" resultMap="device_task">
|
||||||
|
|
|
@ -1,11 +1,26 @@
|
||||||
package com.dispose.test.controller;
|
package com.dispose.test.controller;
|
||||||
|
|
||||||
import com.dispose.common.*;
|
import com.dispose.common.ConstValue;
|
||||||
|
import com.dispose.common.DisposeCapacityType;
|
||||||
|
import com.dispose.common.DisposeDeviceType;
|
||||||
|
import com.dispose.common.DisposeObjectType;
|
||||||
|
import com.dispose.common.ErrorCode;
|
||||||
|
import com.dispose.common.HttpType;
|
||||||
|
import com.dispose.common.IpAddrType;
|
||||||
|
import com.dispose.common.ObjectStatus;
|
||||||
|
import com.dispose.common.ProtoCryptoType;
|
||||||
import com.dispose.mapper.DisposeDeviceMapper;
|
import com.dispose.mapper.DisposeDeviceMapper;
|
||||||
import com.dispose.pojo.dto.protocol.base.IdArraysReq;
|
import com.dispose.pojo.dto.protocol.base.IdArraysReq;
|
||||||
import com.dispose.pojo.dto.protocol.base.ProtocolReqDTO;
|
import com.dispose.pojo.dto.protocol.base.ProtocolReqDTO;
|
||||||
import com.dispose.pojo.dto.protocol.base.ProtocolRespDTO;
|
import com.dispose.pojo.dto.protocol.base.ProtocolRespDTO;
|
||||||
import com.dispose.pojo.dto.protocol.device.manager.*;
|
import com.dispose.pojo.dto.protocol.device.manager.AddCapacityInfo;
|
||||||
|
import com.dispose.pojo.dto.protocol.device.manager.AddDeviceInfo;
|
||||||
|
import com.dispose.pojo.dto.protocol.device.manager.AddDeviceReq;
|
||||||
|
import com.dispose.pojo.dto.protocol.device.manager.AddDeviceRet;
|
||||||
|
import com.dispose.pojo.dto.protocol.device.manager.AddDeviceRsp;
|
||||||
|
import com.dispose.pojo.dto.protocol.device.manager.DeviceInfoRsp;
|
||||||
|
import com.dispose.pojo.dto.protocol.device.manager.GetDeviceReq;
|
||||||
|
import com.dispose.pojo.dto.protocol.device.manager.GetDeviceRsp;
|
||||||
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.test.Global.InitTestEnvironment;
|
import com.dispose.test.Global.InitTestEnvironment;
|
||||||
|
@ -27,7 +42,6 @@ import org.springframework.test.web.servlet.MockMvc;
|
||||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
@ -85,7 +99,7 @@ public class DisposeDeviceManagerControllerTest extends InitTestEnvironment {
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
newCapList.add(AddCapacityInfo.builder()
|
newCapList.add(AddCapacityInfo.builder()
|
||||||
.capacityType(DisposeCapacityType.BLOCKING.getValue())
|
.capacityType(DisposeCapacityType.BLACKHOOL.getValue())
|
||||||
.objectType(DisposeObjectType.URL.getValue())
|
.objectType(DisposeObjectType.URL.getValue())
|
||||||
.ipType(IpAddrType.IPV4_IPV6.getValue())
|
.ipType(IpAddrType.IPV4_IPV6.getValue())
|
||||||
.protectIp("")
|
.protectIp("")
|
||||||
|
|
|
@ -166,4 +166,15 @@ public class demo {
|
||||||
Long ret = DDoSAttackType.getTypeMaskFromAttackType(new DDoSAttackType[] {DDoSAttackType.ALL_ATTACKS});
|
Long ret = DDoSAttackType.getTypeMaskFromAttackType(new DDoSAttackType[] {DDoSAttackType.ALL_ATTACKS});
|
||||||
log.debug("Ret: 0x{}", Long.toHexString(ret).toUpperCase());
|
log.debug("Ret: 0x{}", Long.toHexString(ret).toUpperCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void ipBelong() {
|
||||||
|
// for(int i = 1; i <= 255; i++) {
|
||||||
|
// log.info("112.13.117.{} : {}", i,
|
||||||
|
// HttpRequest.get("http://172.28.72.32:8888/ip/112.13.117." + i).execute().body());
|
||||||
|
// log.info("112.13.119.{} : {}", i,
|
||||||
|
// HttpRequest.get("http://172.28.72.32:8888/ip/112.13.119." + i).execute().body());
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class DPTechInterfaceTestCase extends InitTestEnvironment {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void t1_runDisposeTest() {
|
public void t1_runDisposeTest() {
|
||||||
DisposeAbility<ErrorCode> db;
|
DisposeAbility db;
|
||||||
|
|
||||||
DisposeDevice dev = DisposeDevice.builder()
|
DisposeDevice dev = DisposeDevice.builder()
|
||||||
.ipAddr("10.88.77.15")
|
.ipAddr("10.88.77.15")
|
||||||
|
@ -84,10 +84,10 @@ public class DPTechInterfaceTestCase extends InitTestEnvironment {
|
||||||
// 初始化设备
|
// 初始化设备
|
||||||
db.initDeviceEnv(url, dev.getUserName(), dev.getPassword());
|
db.initDeviceEnv(url, dev.getUserName(), dev.getPassword());
|
||||||
|
|
||||||
ErrorCode ret = db.runDispose("192.168.3.5", DisposeCapacityType.CLEANUP,
|
MulReturnType<ErrorCode, Long> ret = db.runDispose("192.168.3.5", DisposeCapacityType.CLEANUP,
|
||||||
NetflowDirection.DIRECTION_BI, DDoSAttackType.ALL_ATTACKS, -1L);
|
NetflowDirection.DIRECTION_BI, DDoSAttackType.ALL_ATTACKS.getValue(), -1L);
|
||||||
|
|
||||||
Assert.assertEquals(ret, ErrorCode.ERR_OK);
|
Assert.assertEquals(ret.getFirstParam(), ErrorCode.ERR_OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ public class DPTechInterfaceTestCase extends InitTestEnvironment {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void t2_stopDisposeTest() {
|
public void t2_stopDisposeTest() {
|
||||||
DisposeAbility<ErrorCode> db;
|
DisposeAbility db;
|
||||||
|
|
||||||
DisposeDevice dev = DisposeDevice.builder()
|
DisposeDevice dev = DisposeDevice.builder()
|
||||||
.ipAddr("10.88.77.15")
|
.ipAddr("10.88.77.15")
|
||||||
|
@ -126,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());
|
||||||
ErrorCode ret = db.stopDispose("192.168.3.5", DisposeCapacityType.CLEANUP,
|
MulReturnType<ErrorCode, Long> ret = db.stopDispose("192.168.3.5", DisposeCapacityType.CLEANUP,
|
||||||
NetflowDirection.DIRECTION_BI, DDoSAttackType.ALL_ATTACKS, -1L);
|
NetflowDirection.DIRECTION_BI, DDoSAttackType.ALL_ATTACKS.getValue(), -1L);
|
||||||
|
|
||||||
Assert.assertEquals(ret, ErrorCode.ERR_OK);
|
Assert.assertEquals(ret.getFirstParam(), ErrorCode.ERR_OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ public class DPTechInterfaceTestCase extends InitTestEnvironment {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void t3_getAbilityDeviceFirewareTest() {
|
public void t3_getAbilityDeviceFirewareTest() {
|
||||||
DisposeAbility<ErrorCode> db;
|
DisposeAbility db;
|
||||||
|
|
||||||
DisposeDevice dev = DisposeDevice.builder()
|
DisposeDevice dev = DisposeDevice.builder()
|
||||||
.ipAddr("10.88.77.15")
|
.ipAddr("10.88.77.15")
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class HAOHanInterfaceTestCast extends InitTestEnvironment {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void t1_runDisposeTest() {
|
public void t1_runDisposeTest() {
|
||||||
DisposeAbility<MulReturnType<ErrorCode, Long>> db;
|
DisposeAbility db;
|
||||||
|
|
||||||
DisposeDevice dev = DisposeDevice.builder()
|
DisposeDevice dev = DisposeDevice.builder()
|
||||||
.ipAddr("10.88.77.88")
|
.ipAddr("10.88.77.88")
|
||||||
|
@ -95,7 +95,7 @@ public class HAOHanInterfaceTestCast extends InitTestEnvironment {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void t2_stopDisposeTest() {
|
public void t2_stopDisposeTest() {
|
||||||
DisposeAbility<MulReturnType<ErrorCode, Long>> db;
|
DisposeAbility db;
|
||||||
|
|
||||||
DisposeDevice dev = DisposeDevice.builder()
|
DisposeDevice dev = DisposeDevice.builder()
|
||||||
.ipAddr("10.88.77.88")
|
.ipAddr("10.88.77.88")
|
||||||
|
@ -138,7 +138,7 @@ public class HAOHanInterfaceTestCast extends InitTestEnvironment {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void t3_getAbilityDeviceFirewareTest() {
|
public void t3_getAbilityDeviceFirewareTest() {
|
||||||
DisposeAbility<? extends MulReturnType<ErrorCode, Long>> db;
|
DisposeAbility db;
|
||||||
|
|
||||||
DisposeDevice dev = DisposeDevice.builder()
|
DisposeDevice dev = DisposeDevice.builder()
|
||||||
.ipAddr("10.88.77.88")
|
.ipAddr("10.88.77.88")
|
||||||
|
|
|
@ -105,7 +105,7 @@ public class DisposeCapacityMapperTest {
|
||||||
newCapList.add(DisposeCapacity.builder()
|
newCapList.add(DisposeCapacity.builder()
|
||||||
.deviceId(deviceId)
|
.deviceId(deviceId)
|
||||||
.ipType(IpAddrType.IPV4_IPV6)
|
.ipType(IpAddrType.IPV4_IPV6)
|
||||||
.capacityType(DisposeCapacityType.BLOCKING)
|
.capacityType(DisposeCapacityType.BLACKHOOL)
|
||||||
.objectType(DisposeObjectType.IP)
|
.objectType(DisposeObjectType.IP)
|
||||||
.protectIp("")
|
.protectIp("")
|
||||||
.build());
|
.build());
|
||||||
|
@ -150,7 +150,7 @@ public class DisposeCapacityMapperTest {
|
||||||
newCapList.add(DisposeCapacity.builder()
|
newCapList.add(DisposeCapacity.builder()
|
||||||
.deviceId(deviceId)
|
.deviceId(deviceId)
|
||||||
.ipType(IpAddrType.IPV4_IPV6)
|
.ipType(IpAddrType.IPV4_IPV6)
|
||||||
.capacityType(DisposeCapacityType.BLOCKING)
|
.capacityType(DisposeCapacityType.BLACKHOOL)
|
||||||
.objectType(DisposeObjectType.IP)
|
.objectType(DisposeObjectType.IP)
|
||||||
.protectIp("")
|
.protectIp("")
|
||||||
.build());
|
.build());
|
||||||
|
@ -184,7 +184,7 @@ public class DisposeCapacityMapperTest {
|
||||||
newCapList.add(DisposeCapacity.builder()
|
newCapList.add(DisposeCapacity.builder()
|
||||||
.deviceId(deviceId)
|
.deviceId(deviceId)
|
||||||
.ipType(IpAddrType.IPV4_IPV6)
|
.ipType(IpAddrType.IPV4_IPV6)
|
||||||
.capacityType(DisposeCapacityType.BLOCKING)
|
.capacityType(DisposeCapacityType.BLACKHOOL)
|
||||||
.objectType(DisposeObjectType.IP)
|
.objectType(DisposeObjectType.IP)
|
||||||
.protectIp("")
|
.protectIp("")
|
||||||
.build());
|
.build());
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
package com.dispose.test.service;
|
package com.dispose.test.service;
|
||||||
|
|
||||||
import com.dispose.common.*;
|
import com.dispose.common.DisposeDeviceType;
|
||||||
|
import com.dispose.common.ErrorCode;
|
||||||
|
import com.dispose.common.HttpType;
|
||||||
|
import com.dispose.common.ObjectStatus;
|
||||||
import com.dispose.mapper.DisposeDeviceMapper;
|
import com.dispose.mapper.DisposeDeviceMapper;
|
||||||
import com.dispose.pojo.entity.DisposeDevice;
|
import com.dispose.pojo.entity.DisposeDevice;
|
||||||
import com.dispose.pojo.po.MulReturnType;
|
import com.dispose.pojo.po.MulReturnType;
|
||||||
|
|
Loading…
Reference in New Issue