parent
383e093c82
commit
693536fd0e
|
@ -76,6 +76,9 @@ public class taskController {
|
|||
// Token 正确则处理业务
|
||||
switch (mr.getCmdId()) {
|
||||
case ConstValue.ProtocolCmdId.START_DISPOSE_CMD:
|
||||
EnumMap<ErrorCode, String> startMap = StartTaskByTaskId(mr);
|
||||
err = startMap.keySet().iterator().next();
|
||||
msgCtx = startMap.get(err);
|
||||
break;
|
||||
//停止清洗任务
|
||||
case ConstValue.ProtocolCmdId.STOP_DISPOSE_CMD_BY_TASKID:
|
||||
|
@ -113,6 +116,7 @@ public class taskController {
|
|||
|
||||
private EnumMap<ErrorCode, String> StopTaskByTaskId(ProtocolDTO mr) throws JsonProcessingException {
|
||||
String ipAddr = "10.88.77.15";
|
||||
DisposeProcess dp = new DptechUMC(ipAddr);
|
||||
EnumMap<ErrorCode, String> retMap = new EnumMap<>(ErrorCode.class);
|
||||
ErrorCode err = ErrorCode.ERR_OK;
|
||||
|
||||
|
@ -136,7 +140,6 @@ public class taskController {
|
|||
int attackType = 1;
|
||||
int direction = 0;
|
||||
|
||||
DisposeProcess dp = new DptechUMC(ipAddr);
|
||||
NtcRequestResultInfo ntc_result = dp.stopAbnormalTask(disposeIp, attackType, direction);
|
||||
|
||||
StopTaskResult sig_results = new StopTaskResult();
|
||||
|
@ -158,6 +161,7 @@ public class taskController {
|
|||
|
||||
private EnumMap<ErrorCode, String> StopTaskByIp(ProtocolDTO mr) throws JsonProcessingException {
|
||||
String ipAddr = "10.88.77.15";
|
||||
DisposeProcess dp = new DptechUMC(ipAddr);
|
||||
EnumMap<ErrorCode, String> retMap = new EnumMap<>(ErrorCode.class);
|
||||
ErrorCode err = ErrorCode.ERR_OK;
|
||||
|
||||
|
@ -198,7 +202,6 @@ public class taskController {
|
|||
int attackType = 1;
|
||||
int direction = 0;
|
||||
|
||||
DisposeProcess dp = new DptechUMC(ipAddr);
|
||||
NtcRequestResultInfo ntc_result = dp.stopAbnormalTask(v.getDisposeIP(), attackType, direction);
|
||||
|
||||
StopTaskResult result = new StopTaskResult();
|
||||
|
@ -224,6 +227,7 @@ public class taskController {
|
|||
|
||||
private EnumMap<ErrorCode, String> StopTaskByPoint(ProtocolDTO mr) throws JsonProcessingException {
|
||||
String ipAddr = "10.88.77.15";
|
||||
DisposeProcess dp = new DptechUMC(ipAddr);
|
||||
EnumMap<ErrorCode, String> retMap = new EnumMap<>(ErrorCode.class);
|
||||
ErrorCode err = ErrorCode.ERR_OK;
|
||||
|
||||
|
@ -268,7 +272,6 @@ public class taskController {
|
|||
int direction = 0;
|
||||
int taskid = 0;
|
||||
|
||||
DisposeProcess dp = new DptechUMC(ipAddr);
|
||||
for (String getDisposeIp : getDisposeIps
|
||||
) {
|
||||
NtcRequestResultInfo ntc_result = dp.stopAbnormalTask(getDisposeIp, attackType, direction);
|
||||
|
@ -298,6 +301,7 @@ public class taskController {
|
|||
|
||||
private EnumMap<ErrorCode, String> StopTaskAll(ProtocolDTO mr) throws JsonProcessingException {
|
||||
String ipAddr = "10.88.77.15";
|
||||
DisposeProcess dp = new DptechUMC(ipAddr);
|
||||
EnumMap<ErrorCode, String> retMap = new EnumMap<>(ErrorCode.class);
|
||||
ErrorCode err = ErrorCode.ERR_OK;
|
||||
|
||||
|
@ -331,6 +335,7 @@ public class taskController {
|
|||
taskIds.add("4");
|
||||
|
||||
String disposeIp = "";
|
||||
|
||||
for (String v : taskIds
|
||||
) {
|
||||
//每个taskId对应disposeIp,通过taskId获取disposeIp
|
||||
|
@ -348,7 +353,6 @@ public class taskController {
|
|||
int attackType = 1;
|
||||
int direction = 0;
|
||||
|
||||
DisposeProcess dp = new DptechUMC(ipAddr);
|
||||
NtcRequestResultInfo ntc_result = dp.stopAbnormalTask(disposeIp, attackType, direction);
|
||||
|
||||
StopTaskResult result = new StopTaskResult();
|
||||
|
@ -371,4 +375,53 @@ public class taskController {
|
|||
retMap.put(err, objectMapper.writeValueAsString(repInfo));
|
||||
return retMap;
|
||||
}
|
||||
|
||||
|
||||
private EnumMap<ErrorCode, String> StartTaskByTaskId(ProtocolDTO mr) throws JsonProcessingException {
|
||||
String ipAddr = "10.88.77.15";
|
||||
DisposeProcess dp = new DptechUMC(ipAddr);
|
||||
EnumMap<ErrorCode, String> retMap = new EnumMap<>(ErrorCode.class);
|
||||
ErrorCode err = ErrorCode.ERR_OK;
|
||||
int status_result = 0;
|
||||
|
||||
StartTaskRep repInfo = StartTaskRep.builder()
|
||||
.id("")
|
||||
.taskId("")
|
||||
.expireTime(0L)
|
||||
.status(err.getCode()).build();
|
||||
|
||||
StartTaskReq reqInfo = objectMapper.readValue(mr.getMsgContent(), StartTaskReq.class);
|
||||
|
||||
List<Integer> attackTypes = reqInfo.getAttackType();
|
||||
int direction = reqInfo.getFlowDirection();
|
||||
String disposeIp = reqInfo.getDisposeIp();
|
||||
|
||||
for (Integer attackType : attackTypes
|
||||
) {
|
||||
NtcRequestResultInfo ntc_result = dp.startAbnormalTask(disposeIp, attackType, direction);
|
||||
int ret_err = -1;
|
||||
if (ntc_result.getResultRetVal().equals(ret_err)) {
|
||||
System.out.println("启动清洗任务失败");
|
||||
err = ErrorCode.ERR_UNKNOWNCMD;
|
||||
repInfo = null;
|
||||
retMap.put(err, objectMapper.writeValueAsString(repInfo));
|
||||
return retMap;
|
||||
}
|
||||
|
||||
status_result = ntc_result.getResultRetVal();
|
||||
}
|
||||
|
||||
repInfo.setId(reqInfo.getId());
|
||||
//MySql 根据设备Id查找对应的taskId
|
||||
//test 假设设备id与taskId相同
|
||||
repInfo.setTaskId(reqInfo.getId());
|
||||
repInfo.setExpireTime(System.currentTimeMillis()+reqInfo.getDisposeTime());
|
||||
repInfo.setStatus(status_result);
|
||||
|
||||
//启动清洗任务成功,task数据到MySql
|
||||
|
||||
retMap.put(err, objectMapper.writeValueAsString(repInfo));
|
||||
return retMap;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,4 +15,6 @@ public interface DisposeProcess {
|
|||
|
||||
public NtcRequestResultInfo stopAbnormalTask(String abnormalIp, int attackType, int direction);
|
||||
|
||||
public NtcRequestResultInfo startAbnormalTask(String abnormalIp, int attackType, int direction);
|
||||
|
||||
}
|
||||
|
|
|
@ -12,6 +12,11 @@ import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor;
|
|||
import org.apache.wss4j.dom.WSConstants;
|
||||
import org.apache.wss4j.dom.handler.WSHandlerConstants;
|
||||
|
||||
import javax.jws.WebMethod;
|
||||
import javax.jws.WebParam;
|
||||
import javax.jws.WebResult;
|
||||
import javax.xml.ws.RequestWrapper;
|
||||
import javax.xml.ws.ResponseWrapper;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -73,4 +78,10 @@ public class DptechUMC implements DisposeProcess {
|
|||
public NtcRequestResultInfo stopAbnormalTask(String abnormalIp, int attackType, int direction){
|
||||
return cleanTypePort.stopAbnormalTaskForUMC(abnormalIp, attackType, direction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NtcRequestResultInfo startAbnormalTask(String abnormalIp, int attackType, int direction){
|
||||
return cleanTypePort.startAbnormalTaskForUMC(abnormalIp, attackType, direction);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package com.cmcc.hy.phoenix.pojo.vo;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@Builder
|
||||
public class StartTaskRep {
|
||||
private String id;
|
||||
private String taskId;
|
||||
private long expireTime;
|
||||
private int status;
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.cmcc.hy.phoenix.pojo.vo;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class StartTaskReq {
|
||||
private String id;
|
||||
private int type;
|
||||
private String disposeIp;
|
||||
private long disposeTime;
|
||||
private int flowDirection;
|
||||
private List<Integer> attackType;
|
||||
private int flowBandwidth;
|
||||
}
|
||||
|
Loading…
Reference in New Issue