REM:
1. 删除无用的单元测试文件
2. 设备任务externId字段修改为字符串类型
3. 更新数据库初始化脚本
4. 更新Restful公共接口
5. 增加亿阳处置设备
This commit is contained in:
HuangXin 2020-09-29 11:31:15 +08:00
parent 240e2fb721
commit f55c06a626
25 changed files with 890 additions and 340 deletions

View File

@ -17,7 +17,6 @@ public interface DisposeAbility {
/**
* Init device env.
*
* @param urlPath the url path
* @param username the username
* @param password the password
@ -34,7 +33,7 @@ public interface DisposeAbility {
* @param duration the duration
* @return the mul return type
*/
MulReturnType<ErrorCode, Long> runDispose(String ip, DisposeCapacityType capType,
MulReturnType<ErrorCode, String> runDispose(String ip, DisposeCapacityType capType,
@Nullable NetflowDirection nfDirection,
@Nullable Integer attackType,
@Nullable Long duration);
@ -52,7 +51,7 @@ public interface DisposeAbility {
MulReturnType<ErrorCode, Long> stopDispose(String ip, DisposeCapacityType capType,
@Nullable NetflowDirection nfDirection,
@Nullable Integer attackType,
@Nullable Long taskId);
@Nullable String taskId);
/**
* Gets ability device fireware.

View File

@ -55,7 +55,6 @@ public class DpTechAbilityImpl implements DisposeAbility {
/**
* Init device env.
*
* @param urlPath the url path
* @param username the username
* @param password the password
@ -105,7 +104,7 @@ public class DpTechAbilityImpl implements DisposeAbility {
* @return the mul return type
*/
@Override
public MulReturnType<ErrorCode, Long> runDispose(String ip, DisposeCapacityType capType,
public MulReturnType<ErrorCode, String> runDispose(String ip, DisposeCapacityType capType,
NetflowDirection nfDirection,
Integer attackType,
Long duration) {
@ -156,7 +155,7 @@ public class DpTechAbilityImpl implements DisposeAbility {
DisposeCapacityType capType,
NetflowDirection nfDirection,
Integer attackType,
Long taskId) {
String taskId) {
ErrorCode err = ErrorCode.ERR_OK;
try {

View File

@ -8,7 +8,7 @@ import com.dispose.pojo.po.MulReturnType;
import com.dispose.pojo.vo.DeviceFirewareInfo;
import com.haohan.dispose.common.HaoHanStartCleanResp;
import com.haohan.dispose.common.HaoHanStopCleanResp;
import com.haohan.dispose.protocol.RestfulInterface;
import com.haohan.dispose.protocol.HaoHanInterface;
import inet.ipaddr.IPAddress;
import inet.ipaddr.IPAddressString;
import lombok.extern.slf4j.Slf4j;
@ -32,7 +32,7 @@ public class HaoHanAbilityImpl implements DisposeAbility {
/**
* The Restful interface.
*/
private final RestfulInterface restfulInterface = new RestfulInterface();
private final HaoHanInterface restfulInterface = new HaoHanInterface();
/**
* The Url root path.
*/
@ -61,7 +61,7 @@ public class HaoHanAbilityImpl implements DisposeAbility {
* @return the mul return type
*/
@Override
public MulReturnType<ErrorCode, Long> runDispose(String ip, DisposeCapacityType capType,
public MulReturnType<ErrorCode, String> runDispose(String ip, DisposeCapacityType capType,
@Nullable NetflowDirection nfDirection,
@Nullable Integer attackType,
@Nullable Long duration) {
@ -93,7 +93,7 @@ public class HaoHanAbilityImpl implements DisposeAbility {
}
log.debug("----Finish Haohan Start Cleanup Task: {}", ip);
return new MulReturnType<>(ErrorCode.ERR_OK, (long) resp.getCleanTaskId());
return new MulReturnType<>(ErrorCode.ERR_OK, String.valueOf(resp.getCleanTaskId()));
} catch (Exception ex) {
log.error("----Exception Haohan Start Cleanup Task: {}, {}, {}", ip, nfDirection, duration);
return new MulReturnType<>(ErrorCode.ERR_SYSTEMEXCEPTION, null);
@ -114,7 +114,7 @@ public class HaoHanAbilityImpl implements DisposeAbility {
public MulReturnType<ErrorCode, Long> stopDispose(String ip, DisposeCapacityType capType,
@Nullable NetflowDirection nfDirection,
@Nullable Integer attackType,
@Nullable Long taskId) {
@Nullable String taskId) {
try {
log.debug("++++Begging Haohan Stop Cleanup Task: {}", taskId);
@ -127,7 +127,8 @@ public class HaoHanAbilityImpl implements DisposeAbility {
return new MulReturnType<>(ErrorCode.ERR_PARAMS, null);
}
HaoHanStopCleanResp resp = restfulInterface.stopClean(this.urlRootPath, taskId.intValue(),
HaoHanStopCleanResp resp = restfulInterface.stopClean(this.urlRootPath,
Integer.parseInt(taskId),
DISPOSE_PLATFORM_NAME);
if (resp == null) {

View File

@ -22,7 +22,6 @@ public class VirtualAbilityImpl implements DisposeAbility {
/**
* Init device env.
*
* @param urlPath the url path
* @param username the username
* @param password the password
@ -47,7 +46,7 @@ public class VirtualAbilityImpl implements DisposeAbility {
* @return the mul return type
*/
@Override
public MulReturnType<ErrorCode, Long> runDispose(String ip, DisposeCapacityType capType,
public MulReturnType<ErrorCode, String> runDispose(String ip, DisposeCapacityType capType,
@Nullable NetflowDirection nfDirection,
@Nullable Integer attackType, @Nullable Long duration) {
return new MulReturnType<>(ErrorCode.ERR_OK, null);
@ -66,7 +65,7 @@ public class VirtualAbilityImpl implements DisposeAbility {
@Override
public MulReturnType<ErrorCode, Long> stopDispose(String ip, DisposeCapacityType capType,
@Nullable NetflowDirection nfDirection,
@Nullable Integer attackType, @Nullable Long taskId) {
@Nullable Integer attackType, @Nullable String taskId) {
return new MulReturnType<>(ErrorCode.ERR_OK, null);
}

View File

@ -0,0 +1,199 @@
package com.dispose.ability.impl;
import com.dispose.ability.DisposeAbility;
import com.dispose.common.DisposeCapacityType;
import com.dispose.common.ErrorCode;
import com.dispose.common.NetflowDirection;
import com.dispose.pojo.dto.protocol.base.ProtocolRespDTO;
import com.dispose.pojo.po.MulReturnType;
import com.dispose.pojo.vo.DeviceFirewareInfo;
import com.dispose.yiyang.dispose.common.YiYangLoginRsp;
import com.dispose.yiyang.dispose.protocol.YiYangInterface;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import javax.annotation.Nullable;
/**
* The type Yi yang ability.
*
* @author <huangxin@cmhi.chinamoblie.com>
*/
@Slf4j
public class YiYangAbilityImpl implements DisposeAbility {
/**
* The Restful interface.
*/
private final YiYangInterface restfulInterface = new YiYangInterface();
/**
* The Url root path.
*/
@Getter
@Setter
private String urlRootPath;
/**
* The Username.
*/
@Getter
@Setter
private String username;
/**
* The Password.
*/
@Getter
@Setter
private String password;
/**
* The Token.
*/
private String token;
/**
* Init device env.
*
* @param urlPath the url path
* @param username the username
* @param password the password
*/
@Override
public void initDeviceEnv(String urlPath, String username, String password) {
this.urlRootPath = urlPath;
this.username = username;
this.password = password;
restfulInterface.setParams(1, 0);
upgradeToken();
}
/**
* 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, String> runDispose(String ip, DisposeCapacityType capType,
@Nullable NetflowDirection nfDirection,
@Nullable Integer attackType, @Nullable Long duration) {
return 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 Integer attackType, @Nullable String taskId) {
return null;
}
/**
* Gets ability device fireware.
*
* @return the ability device fireware
*/
@Override
public MulReturnType<ErrorCode, DeviceFirewareInfo> getAbilityDeviceFireware() {
return new MulReturnType<>(ErrorCode.ERR_OK,
DeviceFirewareInfo.builder()
.vendor("YiYang")
.model("Unknown")
.firmware("Unknown")
.os("Linux Server")
.kernel("Linux")
.arch("x86_64")
.version("Unknown")
.memory(-1)
.freeMemory(-1)
.cpuUsed(-1)
.build());
}
/**
* To device attack type long.
*
* @param ddosAttackTypeMask the ddos attack type mask
* @return the long
*/
@Override
public Long toDeviceAttackType(Long ddosAttackTypeMask) {
return ddosAttackTypeMask;
}
/**
* Gets device link status.
*
* @return the device link status
*/
@Override
public boolean getDeviceLinkStatus() {
try {
if (token == null || token.length() == 0) {
return false;
}
ErrorCode err = restfulInterface.getLinkStatus(urlRootPath, token);
if (err == ErrorCode.ERR_LOGOUT) {
err = restfulInterface.getLinkStatus(urlRootPath, token);
}
return err == ErrorCode.ERR_OK;
} catch (Exception ex) {
log.error(ex.getMessage());
}
return false;
}
/**
* Gets dispose device protect object.
*/
@Override
public void getDisposeDeviceProtectObject() {
}
/**
* Is carry protect ip boolean.
*
* @param ipAddr the ip addr
* @return the boolean
*/
@Override
public boolean isCarryProtectIp(String ipAddr) {
return true;
}
/**
* Upgrade token.
*/
private void upgradeToken() {
try {
ProtocolRespDTO<YiYangLoginRsp> logInfo = restfulInterface.login(urlRootPath, username, password);
if (logInfo != null && logInfo.getMsgContent().getStatus() == ErrorCode.ERR_OK.getCode()) {
this.token = logInfo.getMsgContent().getToken();
}
} catch (Exception ignored) {
}
}
}

View File

@ -7,31 +7,48 @@ package com.dispose.common;
*/
public enum DisposeDeviceType implements BaseEnum {
/**
* Dptech umc dispose device type.
* The Dptech umc.
*/
DPTECH_UMC(0, "迪普UMC管理平台"),
/**
* Haohan platform dispose device type.
* The Haohan platform.
*/
HAOHAN_PLATFORM(1, "浩瀚处置设备"),
/**
* Virtual dispose dispose device type.
* Yiyang platform dispose device type.
*/
YIYANG_PLATFORM(2, "亿阳处置设备"),
/**
* The Virtual dispose.
*/
VIRTUAL_DISPOSE(999, "虚拟处置设备");
/**
* The Code.
*/
private final int code;
/**
* The Readme.
*/
private final String readme;
/**
* Instantiates a new Dispose device type.
*
* @param code the code
* @param readme the readme
*/
DisposeDeviceType(int code, String readme) {
this.code = code;
this.readme = readme;
}
/**
* Gets code.
* Gets value.
*
* @return the code
* @return the value
*/
@Override
public Integer getValue() {
@ -39,9 +56,9 @@ public enum DisposeDeviceType implements BaseEnum {
}
/**
* Gets readme.
* Gets description.
*
* @return the readme
* @return the description
*/
@Override
public String getDescription() {

View File

@ -272,8 +272,9 @@ public enum ErrorCode {
case ERR_INPUTMISS:
return HttpServletResponse.SC_BAD_REQUEST;
case ERR_UNSUPPORT:
case ERR_UNKNOWNINTERFACE:
return HttpServletResponse.SC_METHOD_NOT_ALLOWED;
case ERR_UNKNOWNINTERFACE:
return HttpServletResponse.SC_NOT_FOUND;
default:
return HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
}

View File

@ -117,7 +117,7 @@ public interface DeviceTaskManager {
* @param externId the extern id
* @return the task extern id
*/
boolean setTaskExternId(Long id, Long externId);
boolean setTaskExternId(Long id, String externId);
/**
* Gets task by id.

View File

@ -269,7 +269,7 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
* @return the task extern id
*/
@Override
public boolean setTaskExternId(Long id, Long externId) {
public boolean setTaskExternId(Long id, String externId) {
return deviceTaskMapper.changeExternId(id, externId) == 1;
}

View File

@ -143,5 +143,5 @@ public interface DeviceTaskMapper {
* @return the int
*/
int changeExternId(@Param("id") Long id,
@Param("externId") Long externId);
@Param("externId") String externId);
}

View File

@ -78,7 +78,7 @@ public class DeviceTask implements Serializable {
/**
* The Extern id.
*/
private Long externId;
private String externId;
/**
* The Err retry.
*/

View File

@ -0,0 +1,153 @@
package com.dispose.restful;
import cn.hutool.http.Header;
import cn.hutool.http.HttpRequest;
import com.dispose.common.ConstValue;
import com.dispose.pojo.dto.protocol.base.ProtocolRespDTO;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMethod;
import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;
/**
* The type Restful interface.
*
* @author <huangxin@cmhi.chinamoblie.com>
*/
@Slf4j
public class RestfulInterface {
/**
* The constant OBJECT_MAPPER.
*/
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
/**
* Post json string.
*
* @param url the url
* @param header the header
* @param body the body
* @return the string
*/
private static String postJson(String url, Map<String, String> header, String body) {
return HttpRequest.post(url).header(Header.CONTENT_TYPE, "application/json").addHeaders(header).body(body)
.execute().body();
}
/**
* Gets json.
*
* @param url the url
* @param header the header
* @return the json
*/
private static String getJson(String url, Map<String, String> header) {
return HttpRequest.get(url).header(Header.CONTENT_TYPE, "application/json").addHeaders(header)
.execute().body();
}
/**
* Protocol run t.
*
* @param <T> the type parameter
* @param <E> the type parameter
* @param url the url
* @param obj the obj
* @param outType the out type
* @return the t
*/
public static <T, E> T protocolRun(String url, E obj, Class<T> outType) {
try {
Map<String, String> httpHeadMap = new HashMap<>(2);
httpHeadMap.put(String.valueOf(Header.CONNECTION), "keep-alive");
httpHeadMap.put(String.valueOf(Header.ACCEPT), "*/*");
String svrResp = postJson(url, httpHeadMap, OBJECT_MAPPER.writeValueAsString(obj));
if (svrResp == null) {
log.debug("Server return null: {}", url);
return null;
}
return OBJECT_MAPPER.readValue(svrResp, outType);
} catch (JsonProcessingException e) {
log.debug("System exception: ", e);
return null;
}
}
/**
* Base pro run protocol resp dto.
*
* @param <T> the type parameter
* @param <E> the type parameter
* @param url the url
* @param token the token
* @param obj the obj
* @param subClass the sub class
* @param reqType the req type
* @return the protocol resp dto
*/
public static <T, E> ProtocolRespDTO<T> baseProRun(String url, String token, E obj, Class<T> subClass,
RequestMethod reqType) {
try {
String svrResp = null;
Map<String, String> httpHeadMap = new HashMap<>(2);
httpHeadMap.put(String.valueOf(Header.CONNECTION), "keep-alive");
httpHeadMap.put(String.valueOf(Header.ACCEPT), "*/*");
if (token != null && token.length() > 0) {
httpHeadMap.put(String.valueOf(Header.AUTHORIZATION), ConstValue.STRING_HTTP_AUTH_HEAD + token);
}
switch (reqType) {
case GET:
svrResp = getJson(url, httpHeadMap);
break;
case POST:
svrResp = postJson(url, httpHeadMap, OBJECT_MAPPER.writeValueAsString(obj));
break;
default:
log.error("Unknown method: {}", reqType);
break;
}
if (svrResp == null) {
log.debug("Server return null: {}", url);
return null;
}
return OBJECT_MAPPER.readValue(svrResp,
new TypeReference<ProtocolRespDTO<T>>() {
@Override
public Type getType() {
return createRespType(subClass);
}
});
} catch (JsonProcessingException e) {
log.debug("System exception: ", e);
return null;
}
}
/**
* Create resp type type.
*
* @param <T> the type parameter
* @param c the c
* @return the type
*/
private static <T> Type createRespType(Class<T> c) {
Type[] types = new Type[1];
types[0] = c;
return ParameterizedTypeImpl.make(ProtocolRespDTO.class, types,
ProtocolRespDTO.class.getDeclaringClass());
}
}

View File

@ -59,7 +59,7 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
* @param disposeTask the dispose task
*/
private void virtualDeviceTaskRun(AbilityInfo ai, DeviceTask deviceTask, DisposeTask disposeTask) {
MulReturnType<ErrorCode, Long> ret;
MulReturnType<ErrorCode, String> ret;
// 设置任务状态为启动中
deviceTaskManager.changeDisposeDeviceTaskInfoStatus(deviceTask.getId(), DisposeTaskStatus.TASK_STARTING);
@ -119,7 +119,7 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
* @param disposeTask the dispose task
*/
private void haoHanDeviceTaskRun(AbilityInfo ai, DeviceTask deviceTask, DisposeTask disposeTask) {
MulReturnType<ErrorCode, Long> ret;
MulReturnType<ErrorCode, String> ret;
// 重试错误次数过多
if (deviceTask.getErrRetry() >= DisposeConfigValue.CALL_ERROR_RETRY_TIMES) {
@ -202,7 +202,7 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
* @param disposeTask the dispose task
*/
private void dpTechDeviceTaskRun(AbilityInfo ai, DeviceTask deviceTask, DisposeTask disposeTask) {
MulReturnType<ErrorCode, Long> ret;
MulReturnType<ErrorCode, String> ret;
// 设置任务状态为启动中
deviceTaskManager.changeDisposeDeviceTaskInfoStatus(deviceTask.getId(), DisposeTaskStatus.TASK_STARTING);
@ -568,12 +568,12 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
@Scheduled(fixedDelay = 1000)
public void scheduleRunnerThread() {
// 处理处置任务数据
//disposeTaskManagerSchedule();
disposeTaskManagerSchedule();
// 处置设备启动任务
//deviceTaskRunnerSchedule();
deviceTaskRunnerSchedule();
// 处置设备停止任务
//deviceTaskStopSchedule();
deviceTaskStopSchedule();
}
}

View File

@ -4,6 +4,7 @@ import com.dispose.ability.DisposeAbility;
import com.dispose.ability.impl.DpTechAbilityImpl;
import com.dispose.ability.impl.HaoHanAbilityImpl;
import com.dispose.ability.impl.VirtualAbilityImpl;
import com.dispose.ability.impl.YiYangAbilityImpl;
import com.dispose.common.DisposeCapacityType;
import com.dispose.common.ErrorCode;
import com.dispose.common.HttpType;
@ -111,6 +112,9 @@ public class DisposeAbilityRouterServiceImpl implements DisposeAbilityRouterServ
case HAOHAN_PLATFORM:
db = new HaoHanAbilityImpl();
break;
case YIYANG_PLATFORM:
db = new YiYangAbilityImpl();
break;
case VIRTUAL_DISPOSE:
db = new VirtualAbilityImpl();
break;

View File

@ -0,0 +1,24 @@
package com.dispose.yiyang.dispose.common;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* The type Yi yang base resp status.
*
* @author <huangxin@cmhi.chinamoblie.com>
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class YiYangBaseResp {
/**
* The Status.
*/
private Integer status;
/**
* The Message.
*/
private String message;
}

View File

@ -0,0 +1,26 @@
package com.dispose.yiyang.dispose.common;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* The type Yi yang login req.
*
* @author <huangxin@cmhi.chinamoblie.com>
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class YiYangLoginReq {
/**
* The User name.
*/
private String userName;
/**
* The Password.
*/
private String password;
}

View File

@ -0,0 +1,42 @@
package com.dispose.yiyang.dispose.common;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
* The type Yi yang login rsp.
*
* @author <huangxin@cmhi.chinamoblie.com>
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({"userName", "token", "logTime", "expireTime", "status", "message"})
public class YiYangLoginRsp extends YiYangBaseResp {
/**
* The User name.
*/
private String userName;
/**
* The Token.
*/
private String token;
/**
* The Log time.
*/
private Long logTime;
/**
* The Expire time.
*/
private Long expireTime;
}

View File

@ -0,0 +1,91 @@
package com.dispose.yiyang.dispose.protocol;
import com.dispose.common.ErrorCode;
import com.dispose.pojo.dto.protocol.base.BaseProtocolDTO;
import com.dispose.pojo.dto.protocol.base.ProtocolRespDTO;
import com.dispose.restful.RestfulInterface;
import com.dispose.yiyang.dispose.common.YiYangBaseResp;
import com.dispose.yiyang.dispose.common.YiYangLoginReq;
import com.dispose.yiyang.dispose.common.YiYangLoginRsp;
import org.springframework.web.bind.annotation.RequestMethod;
import javax.servlet.http.HttpServletResponse;
/**
* The type Yi yang interface.
*
* @author <huangxin@cmhi.chinamoblie.com>
*/
public class YiYangInterface {
/**
* The Ver.
*/
private int ver;
/**
* The Crypto type.
*/
private int cryptoType;
/**
* Sets params.
*
* @param ver the ver
* @param cryptoType the crypto type
*/
public void setParams(int ver, int cryptoType) {
this.ver = ver;
this.cryptoType = cryptoType;
}
/**
* Login protocol resp dto.
*
* @param baseUrlPath the base url path
* @param username the username
* @param password the password
* @return the protocol resp dto
*/
public ProtocolRespDTO<YiYangLoginRsp> login(String baseUrlPath, String username, String password) {
BaseProtocolDTO<YiYangLoginReq> reqInfo = new BaseProtocolDTO<>();
reqInfo.setMsgContent(YiYangLoginReq.builder()
.userName(username)
.password(password)
.build());
reqInfo.setCryptoType(this.cryptoType);
reqInfo.setVer(this.ver);
reqInfo.setTimeStamp(System.currentTimeMillis());
return RestfulInterface.baseProRun(baseUrlPath + "dispose_device/auth/login",
null,
reqInfo,
YiYangLoginRsp.class,
RequestMethod.POST);
}
/**
* Gets link status.
*
* @param baseUrlPath the base url path
* @param token the token
* @return the link status
*/
public ErrorCode getLinkStatus(String baseUrlPath, String token) {
ProtocolRespDTO<YiYangBaseResp> rspInfo = RestfulInterface.baseProRun(baseUrlPath + "dispose_device/information/linkstatus",
token,
null,
YiYangBaseResp.class,
RequestMethod.GET);
if(rspInfo != null && rspInfo.getMsgContent() != null) {
if(rspInfo.getCode() == HttpServletResponse.SC_UNAUTHORIZED) {
return ErrorCode.ERR_LOGOUT;
} else if(rspInfo.getMsgContent().getStatus() == ErrorCode.ERR_OK.getCode()) {
return ErrorCode.ERR_OK;
}
}
return ErrorCode.ERR_UNKNOWNCMD;
}
}

View File

@ -1,10 +1,7 @@
package com.haohan.dispose.protocol;
import cn.hutool.http.Header;
import cn.hutool.http.HttpRequest;
import com.dispose.common.ErrorCode;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.dispose.restful.RestfulInterface;
import com.haohan.dispose.common.HaoHanGetCleanTaskNetflowInfoReq;
import com.haohan.dispose.common.HaoHanGetCleanTaskNetflowInfoResp;
import com.haohan.dispose.common.HaoHanGetCleanTaskStatusReq;
@ -18,67 +15,17 @@ import com.haohan.dispose.common.HaoHanStopCleanResp;
import lombok.extern.slf4j.Slf4j;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* The type Restful interface.
* The type Hao han interface.
*
* @author <huangxin@cmhi.chinamoblie.com>
*/
@Slf4j
public class RestfulInterface {
/**
* The constant OBJECT_MAPPER.
*/
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
/**
* Post json string.
*
* @param url the url
* @param header the header
* @param body the body
* @return the string
*/
private static String postJson(String url, Map<String, String> header, String body) {
return HttpRequest.post(url).header(Header.CONTENT_TYPE, "application/json").addHeaders(header).body(body)
.execute().body();
}
/**
* Protocol run t.
*
* @param <T> the type parameter
* @param <E> the type parameter
* @param url the url
* @param obj the obj
* @param outType the out type
* @return the t
*/
private <T, E> T protocolRun(String url, E obj, Class<T> outType) {
try {
Map<String, String> httpHeadMap = new HashMap<>(2);
httpHeadMap.put(String.valueOf(Header.CONNECTION), "keep-alive");
httpHeadMap.put(String.valueOf(Header.ACCEPT), "*/*");
String svrResp = postJson(url, httpHeadMap, OBJECT_MAPPER.writeValueAsString(obj));
if (svrResp == null) {
log.debug("Server return null: {}", url);
return null;
}
return OBJECT_MAPPER.readValue(svrResp, outType);
} catch (JsonProcessingException e) {
log.debug("System exception: ", e);
return null;
}
}
public class HaoHanInterface {
/**
* Gets clean task status.
*
@ -87,7 +34,7 @@ public class RestfulInterface {
* @return the clean task status
*/
public HaoHanGetCleanTaskStatusResp getCleanTaskStatus(String baseUrlPath, Integer taskId) {
return protocolRun(baseUrlPath + "/getCleanTaskState",
return RestfulInterface.protocolRun(baseUrlPath + "/getCleanTaskState",
HaoHanGetCleanTaskStatusReq.builder().cleanTaskId(taskId).build(),
HaoHanGetCleanTaskStatusResp.class);
}
@ -102,7 +49,7 @@ public class RestfulInterface {
* @return the hao han start clean resp
*/
public HaoHanStartCleanResp startClean(String baseUrlPath, String ipAddr, int times, String readme) {
HaoHanStartCleanResp svrResp = protocolRun(baseUrlPath + "/sendTow",
HaoHanStartCleanResp svrResp = RestfulInterface.protocolRun(baseUrlPath + "/sendTow",
new HaoHanStartCleanReq(ipAddr, times, readme),
HaoHanStartCleanResp.class);
@ -158,7 +105,7 @@ public class RestfulInterface {
* @return the hao han stop clean resp
*/
public HaoHanStopCleanResp stopClean(String baseUrlPath, Integer taskId, String readme) {
return protocolRun(baseUrlPath + "/delTow",
return RestfulInterface.protocolRun(baseUrlPath + "/delTow",
new HaoHanStopCleanReq(taskId, readme),
HaoHanStopCleanResp.class);
}
@ -171,7 +118,7 @@ public class RestfulInterface {
* @return the cleaning netflow
*/
public HaoHanGetCleaningNetflowInfoResp getCleaningNetflow(String baseUrlPath, String readme) {
return protocolRun(baseUrlPath + "/allIpFlow",
return RestfulInterface.protocolRun(baseUrlPath + "/allIpFlow",
new HaoHanGetCleaningNetflowInfoReq(readme),
HaoHanGetCleaningNetflowInfoResp.class);
}
@ -184,7 +131,7 @@ public class RestfulInterface {
* @return the clean task netflow
*/
public HaoHanGetCleanTaskNetflowInfoResp getCleanTaskNetflow(String baseUrlPath, Integer taskId) {
return protocolRun(baseUrlPath + "/cleanTaskFlow",
return RestfulInterface.protocolRun(baseUrlPath + "/cleanTaskFlow",
new HaoHanGetCleanTaskNetflowInfoReq(taskId),
HaoHanGetCleanTaskNetflowInfoResp.class
);

View File

@ -21,7 +21,8 @@ SET FOREIGN_KEY_CHECKS = 0;
-- Table structure for device_task
-- ----------------------------
DROP TABLE IF EXISTS `device_task`;
CREATE TABLE `device_task` (
CREATE TABLE `device_task`
(
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '任务信息唯一标识符',
`taskId` int(11) UNSIGNED NOT NULL COMMENT '处置任务唯一标识符',
`deviceId` int(10) UNSIGNED NOT NULL COMMENT '处置设备唯一标识符',
@ -32,21 +33,26 @@ CREATE TABLE `device_task` (
`attackTypeStatusIn` bigint(255) UNSIGNED NOT NULL DEFAULT 0 COMMENT '执行的攻击类型状态(Input)',
`execAttackTypeOut` bigint(255) UNSIGNED NOT NULL DEFAULT 0 COMMENT '已经执行处置的攻击类型(Output)',
`attackTypeStatusOut` bigint(255) UNSIGNED NOT NULL DEFAULT 0 COMMENT '执行的攻击类型状态(Input)',
`externId` int(11) NULL DEFAULT NULL COMMENT '扩展任务ID',
`externId` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '扩展任务ID',
`errRetry` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '调用失败重试次数',
`status` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '任务状态',
`status` int(10) NOT NULL DEFAULT 0 COMMENT '任务状态',
PRIMARY KEY (`id`) USING BTREE,
INDEX `task_info_ibfk_1`(`taskId`) USING BTREE,
INDEX `task_info_ibfk_2`(`deviceId`) USING BTREE,
INDEX `task_info_ibfk_1` (`taskId`) USING BTREE,
INDEX `task_info_ibfk_2` (`deviceId`) USING BTREE,
CONSTRAINT `device_task_ibfk_1` FOREIGN KEY (`taskId`) REFERENCES `dispose_task` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `device_task_ibfk_2` FOREIGN KEY (`deviceId`) REFERENCES `dispose_device` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
) ENGINE = InnoDB
AUTO_INCREMENT = 1
CHARACTER SET = utf8
COLLATE = utf8_general_ci
ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for dispose_capacity
-- ----------------------------
DROP TABLE IF EXISTS `dispose_capacity`;
CREATE TABLE `dispose_capacity` (
CREATE TABLE `dispose_capacity`
(
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '设备处置能力唯一标识符',
`deviceId` int(11) UNSIGNED NOT NULL COMMENT '设备ID',
`capacityType` int(8) NOT NULL COMMENT '处置能力:\r\n0清洗\r\n1高防 \r\n2路由黑洞 \r\n3检测\r\n4WAF封堵\r\n',
@ -55,15 +61,20 @@ CREATE TABLE `dispose_capacity` (
`protectIp` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '该处置能力能够处置的IP',
`reserveNetflow` int(11) NULL DEFAULT NULL COMMENT '清洗能力储备流量值,单位(G)',
PRIMARY KEY (`id`) USING BTREE,
INDEX `id`(`deviceId`) USING BTREE,
INDEX `id` (`deviceId`) USING BTREE,
CONSTRAINT `dispose_capacity_ibfk_1` FOREIGN KEY (`deviceId`) REFERENCES `dispose_device` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
) ENGINE = InnoDB
AUTO_INCREMENT = 1
CHARACTER SET = utf8
COLLATE = utf8_general_ci
ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for dispose_device
-- ----------------------------
DROP TABLE IF EXISTS `dispose_device`;
CREATE TABLE `dispose_device` (
CREATE TABLE `dispose_device`
(
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '设备唯一标识符',
`ipAddr` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '设备IP地址, IPv4/IPv6',
`ipPort` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '端口',
@ -80,14 +91,19 @@ CREATE TABLE `dispose_device` (
`readme` varchar(1024) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '备注',
`status` int(11) NOT NULL DEFAULT 0 COMMENT '状态0正常1锁定2禁用 3删除',
PRIMARY KEY (`id`) USING BTREE,
INDEX `ipAddr`(`ipAddr`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
INDEX `ipAddr` (`ipAddr`) USING BTREE
) ENGINE = InnoDB
AUTO_INCREMENT = 1
CHARACTER SET = utf8
COLLATE = utf8_general_ci
ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for dispose_task
-- ----------------------------
DROP TABLE IF EXISTS `dispose_task`;
CREATE TABLE `dispose_task` (
CREATE TABLE `dispose_task`
(
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '处置任务唯一标识符',
`deviceId` int(10) NOT NULL COMMENT '处置设备唯一标识符',
`accountId` int(10) UNSIGNED NOT NULL COMMENT '用户唯一标识符',
@ -102,15 +118,20 @@ CREATE TABLE `dispose_task` (
`flowBandWidth` int(10) UNSIGNED NULL DEFAULT 1024 COMMENT '攻击流量占用带宽(MB)',
`currentStatus` int(11) NOT NULL DEFAULT 0 COMMENT '状态0停止。1启动',
PRIMARY KEY (`id`) USING BTREE,
INDEX `dispose_task_device_capacity_id_fk`(`disposeCapacity`) USING BTREE,
INDEX `dispose_task_user_account_id_fk`(`accountId`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = DYNAMIC;
INDEX `dispose_task_device_capacity_id_fk` (`disposeCapacity`) USING BTREE,
INDEX `dispose_task_user_account_id_fk` (`accountId`) USING BTREE
) ENGINE = InnoDB
AUTO_INCREMENT = 1
CHARACTER SET = utf8
COLLATE = utf8_general_ci
ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Table structure for user_account
-- ----------------------------
DROP TABLE IF EXISTS `user_account`;
CREATE TABLE `user_account` (
CREATE TABLE `user_account`
(
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '账户唯一编号',
`username` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '用户名',
`password` varchar(512) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '密码',
@ -123,7 +144,11 @@ CREATE TABLE `user_account` (
`pwdErrTimes` int(10) NOT NULL DEFAULT 0 COMMENT '密码错误次数',
`status` int(11) NULL DEFAULT 0 COMMENT '账户状态',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `USERNAME`(`username`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
UNIQUE INDEX `USERNAME` (`username`) USING BTREE
) ENGINE = InnoDB
AUTO_INCREMENT = 1
CHARACTER SET = utf8
COLLATE = utf8_general_ci
ROW_FORMAT = Dynamic;
SET FOREIGN_KEY_CHECKS = 1;

View File

@ -21,7 +21,8 @@ SET FOREIGN_KEY_CHECKS = 0;
-- Table structure for device_task
-- ----------------------------
DROP TABLE IF EXISTS `device_task`;
CREATE TABLE `device_task` (
CREATE TABLE `device_task`
(
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '任务信息唯一标识符',
`taskId` int(11) UNSIGNED NOT NULL COMMENT '处置任务唯一标识符',
`deviceId` int(10) UNSIGNED NOT NULL COMMENT '处置设备唯一标识符',
@ -32,15 +33,19 @@ CREATE TABLE `device_task` (
`attackTypeStatusIn` bigint(255) UNSIGNED NOT NULL DEFAULT 0 COMMENT '执行的攻击类型状态(Input)',
`execAttackTypeOut` bigint(255) UNSIGNED NOT NULL DEFAULT 0 COMMENT '已经执行处置的攻击类型(Output)',
`attackTypeStatusOut` bigint(255) UNSIGNED NOT NULL DEFAULT 0 COMMENT '执行的攻击类型状态(Input)',
`externId` int(11) NULL DEFAULT NULL COMMENT '扩展任务ID',
`externId` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '扩展任务ID',
`errRetry` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '调用失败重试次数',
`status` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '任务状态',
`status` int(10) NOT NULL DEFAULT 0 COMMENT '任务状态',
PRIMARY KEY (`id`) USING BTREE,
INDEX `task_info_ibfk_1`(`taskId`) USING BTREE,
INDEX `task_info_ibfk_2`(`deviceId`) USING BTREE,
INDEX `task_info_ibfk_1` (`taskId`) USING BTREE,
INDEX `task_info_ibfk_2` (`deviceId`) USING BTREE,
CONSTRAINT `device_task_ibfk_1` FOREIGN KEY (`taskId`) REFERENCES `dispose_task` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `device_task_ibfk_2` FOREIGN KEY (`deviceId`) REFERENCES `dispose_device` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
) ENGINE = InnoDB
AUTO_INCREMENT = 1
CHARACTER SET = utf8
COLLATE = utf8_general_ci
ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of device_task
@ -50,7 +55,8 @@ CREATE TABLE `device_task` (
-- Table structure for dispose_capacity
-- ----------------------------
DROP TABLE IF EXISTS `dispose_capacity`;
CREATE TABLE `dispose_capacity` (
CREATE TABLE `dispose_capacity`
(
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '设备处置能力唯一标识符',
`deviceId` int(11) UNSIGNED NOT NULL COMMENT '设备ID',
`capacityType` int(8) NOT NULL COMMENT '处置能力:\r\n0清洗\r\n1高防 \r\n2路由黑洞 \r\n3检测\r\n4WAF封堵\r\n',
@ -59,27 +65,39 @@ CREATE TABLE `dispose_capacity` (
`protectIp` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '该处置能力能够处置的IP',
`reserveNetflow` int(11) NULL DEFAULT NULL COMMENT '清洗能力储备流量值,单位(G)',
PRIMARY KEY (`id`) USING BTREE,
INDEX `id`(`deviceId`) USING BTREE,
INDEX `id` (`deviceId`) USING BTREE,
CONSTRAINT `dispose_capacity_ibfk_1` FOREIGN KEY (`deviceId`) REFERENCES `dispose_device` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
) ENGINE = InnoDB
AUTO_INCREMENT = 1
CHARACTER SET = utf8
COLLATE = utf8_general_ci
ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of dispose_capacity
-- ----------------------------
INSERT INTO `dispose_capacity` VALUES (1, 1, 0, 1, 3, '0.0.0.0', 10);
INSERT INTO `dispose_capacity` VALUES (2, 1, 1, 7, 3, '', NULL);
INSERT INTO `dispose_capacity` VALUES (3, 1, 2, 7, 3, '0.0.0.0', NULL);
INSERT INTO `dispose_capacity` VALUES (4, 1, 3, 1, 3, '0.0.0.0', NULL);
INSERT INTO `dispose_capacity`
VALUES (1, 1, 0, 1, 3, '0.0.0.0', 10);
INSERT INTO `dispose_capacity`
VALUES (2, 1, 1, 7, 3, '', NULL);
INSERT INTO `dispose_capacity`
VALUES (3, 1, 2, 7, 3, '0.0.0.0', NULL);
INSERT INTO `dispose_capacity`
VALUES (4, 1, 3, 1, 3, '0.0.0.0', NULL);
INSERT INTO `dispose_capacity` VALUES (5, 2, 0, 1, 3, '0.0.0.0', 10);
INSERT INTO `dispose_capacity` VALUES (6, 3, 0, 1, 3, '0.0.0.0', 10);
INSERT INTO `dispose_capacity` VALUES (7, 4, 0, 1, 3, '0.0.0.0', 10);
INSERT INTO `dispose_capacity`
VALUES (5, 2, 0, 1, 3, '0.0.0.0', 10);
INSERT INTO `dispose_capacity`
VALUES (6, 3, 0, 1, 3, '0.0.0.0', 10);
INSERT INTO `dispose_capacity`
VALUES (7, 4, 0, 1, 3, '0.0.0.0', 10);
-- ----------------------------
-- Table structure for dispose_device
-- ----------------------------
DROP TABLE IF EXISTS `dispose_device`;
CREATE TABLE `dispose_device` (
CREATE TABLE `dispose_device`
(
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '设备唯一标识符',
`ipAddr` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '设备IP地址, IPv4/IPv6',
`ipPort` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '端口',
@ -96,22 +114,35 @@ CREATE TABLE `dispose_device` (
`readme` varchar(1024) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '备注',
`status` int(11) NOT NULL DEFAULT 0 COMMENT '状态0正常1锁定2禁用 3删除',
PRIMARY KEY (`id`) USING BTREE,
INDEX `ipAddr`(`ipAddr`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
INDEX `ipAddr` (`ipAddr`) USING BTREE
) ENGINE = InnoDB
AUTO_INCREMENT = 1
CHARACTER SET = utf8
COLLATE = utf8_general_ci
ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of dispose_device
-- ----------------------------
INSERT INTO `dispose_device` VALUES (1, '127.0.0.1', '', 999, 0, '虚拟处置设备', 'Virtual Dispose Device', 'CMCC', 'V0.0.1', '1', '', '', 0, '持续集成单元测试用虚拟设备', 0);
INSERT INTO `dispose_device` VALUES (2, '127.0.0.1', '1000', 999, 0, '虚拟处置设备', 'Virtual Dispose Device', 'CMCC', 'V0.0.1', '1', '', '', 0, '持续集成单元测试用虚拟设备', 0);
INSERT INTO `dispose_device` VALUES (3, '127.0.0.1', '1001', 999, 0, '虚拟处置设备', 'Virtual Dispose Device', 'CMCC', 'V0.0.1', '0', '', '', 0, '持续集成单元测试用虚拟设备', 0);
INSERT INTO `dispose_device` VALUES (4, '127.0.0.1', '1002', 999, 0, '虚拟处置设备', 'Virtual Dispose Device', 'CMCC', 'V0.0.1', '0', '', '', 0, '持续集成单元测试用虚拟设备', 0);
INSERT INTO `dispose_device`
VALUES (1, '127.0.0.1', '', 999, 0, '虚拟处置设备', 'Virtual Dispose Device', 'CMCC', 'V0.0.1', '1', '', '', 0,
'持续集成单元测试用虚拟设备', 0);
INSERT INTO `dispose_device`
VALUES (2, '127.0.0.1', '1000', 999, 0, '虚拟处置设备', 'Virtual Dispose Device', 'CMCC', 'V0.0.1', '1', '', '', 0,
'持续集成单元测试用虚拟设备', 0);
INSERT INTO `dispose_device`
VALUES (3, '127.0.0.1', '1001', 999, 0, '虚拟处置设备', 'Virtual Dispose Device', 'CMCC', 'V0.0.1', '0', '', '', 0,
'持续集成单元测试用虚拟设备', 0);
INSERT INTO `dispose_device`
VALUES (4, '127.0.0.1', '1002', 999, 0, '虚拟处置设备', 'Virtual Dispose Device', 'CMCC', 'V0.0.1', '0', '', '', 0,
'持续集成单元测试用虚拟设备', 0);
-- ----------------------------
-- Table structure for dispose_task
-- ----------------------------
DROP TABLE IF EXISTS `dispose_task`;
CREATE TABLE `dispose_task` (
CREATE TABLE `dispose_task`
(
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '处置任务唯一标识符',
`deviceId` int(10) NOT NULL COMMENT '处置设备唯一标识符',
`accountId` int(10) UNSIGNED NOT NULL COMMENT '用户唯一标识符',
@ -126,21 +157,30 @@ CREATE TABLE `dispose_task` (
`flowBandWidth` int(10) UNSIGNED NULL DEFAULT 1024 COMMENT '攻击流量占用带宽(MB)',
`currentStatus` int(11) NOT NULL DEFAULT 0 COMMENT '状态0停止。1启动',
PRIMARY KEY (`id`) USING BTREE,
INDEX `dispose_task_device_capacity_id_fk`(`disposeCapacity`) USING BTREE,
INDEX `dispose_task_user_account_id_fk`(`accountId`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = DYNAMIC;
INDEX `dispose_task_device_capacity_id_fk` (`disposeCapacity`) USING BTREE,
INDEX `dispose_task_user_account_id_fk` (`accountId`) USING BTREE
) ENGINE = InnoDB
AUTO_INCREMENT = 1
CHARACTER SET = utf8
COLLATE = utf8_general_ci
ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of dispose_task
-- ----------------------------
INSERT INTO `dispose_task` VALUES (1, -1, 1, 0, '192.168.10.1', 1, CURRENT_TIMESTAMP, date_add(now(), interval 60 MINUTE), null, 2, 8796093022207, 1024, 0);
INSERT INTO `dispose_task` VALUES (2, -1, 1, 0, '192.168.10.2', 1, CURRENT_TIMESTAMP, date_add(now(), interval 60 MINUTE), null, 2, 8796093022207, 1024, 0);
INSERT INTO `dispose_task`
VALUES (1, -1, 1, 0, '192.168.10.1', 1, CURRENT_TIMESTAMP, date_add(now(), interval 60 MINUTE), null, 2, 8796093022207,
1024, 0);
INSERT INTO `dispose_task`
VALUES (2, -1, 1, 0, '192.168.10.2', 1, CURRENT_TIMESTAMP, date_add(now(), interval 60 MINUTE), null, 2, 8796093022207,
1024, 0);
-- ----------------------------
-- Table structure for user_account
-- ----------------------------
DROP TABLE IF EXISTS `user_account`;
CREATE TABLE `user_account` (
CREATE TABLE `user_account`
(
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '账户唯一编号',
`username` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '用户名',
`password` varchar(512) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '密码',
@ -153,12 +193,19 @@ CREATE TABLE `user_account` (
`pwdErrTimes` int(10) NOT NULL DEFAULT 0 COMMENT '密码错误次数',
`status` int(11) NULL DEFAULT 0 COMMENT '账户状态',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `USERNAME`(`username`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
UNIQUE INDEX `USERNAME` (`username`) USING BTREE
) ENGINE = InnoDB
AUTO_INCREMENT = 1
CHARACTER SET = utf8
COLLATE = utf8_general_ci
ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of user_account
-- ----------------------------
INSERT INTO `user_account` VALUES (1, 'admin', 'c3855e6b6bb120450f160ba91134522868f89d36062f2061ebeefd80817e1d58', '1970-01-02 00:00:00', '', '2020-09-11 00:34:16', 'c02094875da6d6b60a5ac7f056d40066a85005569bf7ce8ff03a50963651f931', '2020-09-11 00:34:16', '1970-01-02 00:00:00', 0, 0);
INSERT INTO `user_account`
VALUES (1, 'admin', 'c3855e6b6bb120450f160ba91134522868f89d36062f2061ebeefd80817e1d58', '1970-01-02 00:00:00', '',
'2020-09-11 00:34:16', 'c02094875da6d6b60a5ac7f056d40066a85005569bf7ce8ff03a50963651f931',
'2020-09-11 00:34:16', '1970-01-02 00:00:00', 0, 0);
SET FOREIGN_KEY_CHECKS = 1;

View File

@ -562,4 +562,8 @@ public class demo {
log.info("Src: {}", plainText);
log.info("AES256: {}", new String(encode));
}
@Test
public void codeDebug() {
}
}

View File

@ -262,7 +262,7 @@ public class DeviceTaskMapperTest extends InitTestEnvironment {
// change extern id.
for (long i = 223L; i <= 230L; i++) {
int result = deviceTaskMapper.changeExternId(deviceTask.getId(), i);
int result = deviceTaskMapper.changeExternId(deviceTask.getId(), String.valueOf(i));
Assert.assertEquals(result, 1);
Assert.assertEquals(String.valueOf(i), String.valueOf(deviceTaskMapper.getTaskInfoById(deviceTask.getId()).getExternId()));
}

View File

@ -1,14 +0,0 @@
package com.dispose.test.qa;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.wildfly.common.Assert;
@Slf4j
public class DemoTest2 {
@Test
public void t1_demo() {
log.error("++++++++++++++++++++++com.dispose.test.qa.DemoTest2.t1_demo");
Assert.assertFalse(false);
}
}

View File

@ -1,14 +0,0 @@
package com.dispose.test.qa.impl;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.wildfly.common.Assert;
@Slf4j
public class DemoTest {
@Test
public void t1_demo() {
log.error("++++++++++++++++++++++com.dispose.test.qa.DemoTest.t1_demo");
Assert.assertTrue(true);
}
}