OCT
REM: 1. 拆分配置文件,将工程配置文件拆分到独立的配置文件中 2. 新增log4j日志等级不同配置文件 3. 增加处置任务数据库相关内容 4. 增加处置任务相关单元测试用例
This commit is contained in:
parent
1ccdc5e194
commit
12ba2b9be3
|
@ -0,0 +1,21 @@
|
||||||
|
#调试配置
|
||||||
|
dispose.debug-model=true
|
||||||
|
dispose.check-protocol-timeout=false
|
||||||
|
dispose.check-request-token=true
|
||||||
|
dispose.split_char=,
|
||||||
|
dispose.request-timeout-second=5
|
||||||
|
|
||||||
|
dispose.used-privacy-protect=true
|
||||||
|
|
||||||
|
# 迪普设备配置
|
||||||
|
# 发送超时时间(s)
|
||||||
|
dptech.soap-conn-timeout-second=60
|
||||||
|
# 接收超时时间(s)
|
||||||
|
dptech.soap-recv-timeout-second=60
|
||||||
|
|
||||||
|
# 用户权限配置
|
||||||
|
permission.admin-check=true
|
||||||
|
permission.admin-users=admin
|
||||||
|
|
||||||
|
# 认证配置
|
||||||
|
auth.token-timeout-minute=30
|
|
@ -4,11 +4,11 @@ server.tomcat.basedir=./basedir
|
||||||
# 多个项目放在nginx下同个端口,通过该配置区分
|
# 多个项目放在nginx下同个端口,通过该配置区分
|
||||||
server.servlet.context-path=/dispose
|
server.servlet.context-path=/dispose
|
||||||
# 配置数据源
|
# 配置数据源
|
||||||
spring.datasource.url=jdbc:mysql://172.28.72.118:33061/dispose_hx?serverTimezone=Asia/Shanghai&zeroDateTimeBehavior\
|
spring.datasource.url=jdbc:mysql://10.88.77.65:33061/dispose_hx?serverTimezone=Asia/Shanghai&zeroDateTimeBehavior\
|
||||||
=convertToNull&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true
|
=convertToNull&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true
|
||||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||||
spring.datasource.username=phoenix
|
spring.datasource.username=root
|
||||||
spring.datasource.password=Hy@rfph32
|
spring.datasource.password=h0K0_8u
|
||||||
# 配置连接池
|
# 配置连接池
|
||||||
spring.datasource.type=org.apache.commons.dbcp2.BasicDataSource
|
spring.datasource.type=org.apache.commons.dbcp2.BasicDataSource
|
||||||
spring.datasource.dbcp2.max-total=128
|
spring.datasource.dbcp2.max-total=128
|
||||||
|
@ -26,7 +26,7 @@ mybatis.mapper-locations=classpath*:mappers/*.xml
|
||||||
mybatis.type-aliases-package=com.dispose.pojo.entity
|
mybatis.type-aliases-package=com.dispose.pojo.entity
|
||||||
mybatis.configuration.default-enum-type-handler=com.dispose.common.CommonEnumHandler
|
mybatis.configuration.default-enum-type-handler=com.dispose.common.CommonEnumHandler
|
||||||
#config log
|
#config log
|
||||||
logging.config=file:config/logback.xml
|
logging.config=file:config/logback_debug.xml
|
||||||
#config tomcat
|
#config tomcat
|
||||||
server.tomcat.max-threads=128
|
server.tomcat.max-threads=128
|
||||||
#Json sort
|
#Json sort
|
||||||
|
@ -53,25 +53,3 @@ phoenix.response-enc-switch=false
|
||||||
#config aes 128 key,用于上述body的加解密
|
#config aes 128 key,用于上述body的加解密
|
||||||
phoenix.aes-key=Wt4EJu6Rrq5udd/42bNpCQ==
|
phoenix.aes-key=Wt4EJu6Rrq5udd/42bNpCQ==
|
||||||
#====custom config,begin with phoenix====
|
#====custom config,begin with phoenix====
|
||||||
|
|
||||||
#调试配置
|
|
||||||
dispose.debug-model=true
|
|
||||||
dispose.check-protocol-timeout=false
|
|
||||||
dispose.check-request-token=true
|
|
||||||
dispose.split_char=,
|
|
||||||
dispose.request-timeout-second=5
|
|
||||||
|
|
||||||
dispose.used-privacy-protect=true
|
|
||||||
|
|
||||||
# 迪普设备配置
|
|
||||||
# 发送超时时间(ms)
|
|
||||||
dptech.soap-conn-timeout-second=60
|
|
||||||
# 接收超时时间(ms)
|
|
||||||
dptech.soap-recv-timeout-second=60
|
|
||||||
|
|
||||||
# 用户权限配置
|
|
||||||
permission.admin-check=true
|
|
||||||
permission.admin-users=admin
|
|
||||||
|
|
||||||
# 认证配置
|
|
||||||
auth.token-timeout-minute=30
|
|
|
@ -51,13 +51,3 @@ phoenix.response-enc-switch=false
|
||||||
#config aes 128 key,用于上述body的加解密
|
#config aes 128 key,用于上述body的加解密
|
||||||
phoenix.aes-key=Wt4EJu6Rrq5udd/42bNpCQ==
|
phoenix.aes-key=Wt4EJu6Rrq5udd/42bNpCQ==
|
||||||
#====custom config,begin with phoenix====
|
#====custom config,begin with phoenix====
|
||||||
#调试配置
|
|
||||||
dispose.check-protocol-timeout=false
|
|
||||||
dispose.check-request-token=true
|
|
||||||
dispose.check-admin-permission=true
|
|
||||||
# 迪普设备配置
|
|
||||||
# 发送超时时间(ms)
|
|
||||||
#dptech.soap-conn-timeout=5000
|
|
||||||
# 接收超时时间(ms)
|
|
||||||
dptech.soap-recv-timeout=50000
|
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
spring.profiles.active=local
|
spring.profiles.active=local,dispose
|
|
@ -2,7 +2,7 @@
|
||||||
<configuration scan="true">
|
<configuration scan="true">
|
||||||
|
|
||||||
<property name="LOG_PATH" value="./logs"/>
|
<property name="LOG_PATH" value="./logs"/>
|
||||||
<property name="LOG_LEVEL" value="debug"/>
|
<property name="LOG_LEVEL" value="info"/>
|
||||||
|
|
||||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
<encoder charset="UTF-8">
|
<encoder charset="UTF-8">
|
||||||
|
|
|
@ -0,0 +1,101 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<configuration scan="true">
|
||||||
|
|
||||||
|
<property name="LOG_PATH" value="./logs"/>
|
||||||
|
<property name="LOG_LEVEL" value="debug"/>
|
||||||
|
|
||||||
|
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<encoder charset="UTF-8">
|
||||||
|
<pattern>[%d{yy-MM-dd HH:mm:ss:SSS}][%-5p][%c{0}][%M\(%L\)][%t]: %m%n</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<appender name="BIZ"
|
||||||
|
class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<file>${LOG_PATH}/biz.log</file>
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<fileNamePattern>${LOG_PATH}/biz.log.%d{yyyyMMdd}
|
||||||
|
</fileNamePattern>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder charset="UTF-8">
|
||||||
|
<pattern>[%d{yy-MM-dd HH:mm:ss:SSS}][%-5p][%c{0}][%M\(%L\)][%t]: %m%n</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
<appender name="SYSTEM-LOG-FILE"
|
||||||
|
class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<file>${LOG_PATH}/system.log</file>
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<fileNamePattern>${LOG_PATH}/system.log.%d{yyyyMMdd}
|
||||||
|
</fileNamePattern>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder charset="UTF-8">
|
||||||
|
<pattern>[%d{yy-MM-dd HH:mm:ss:SSS}][%-5p][%c{0}][%M\(%L\)][%t]: %m%n</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<appender name="DATA"
|
||||||
|
class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<file>${LOG_PATH}/data.log</file>
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<fileNamePattern>${LOG_PATH}/data.log.%d{yyyyMMdd}
|
||||||
|
</fileNamePattern>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder charset="UTF-8">
|
||||||
|
<pattern>[%d{yy-MM-dd HH:mm:ss:SSS}][%-5p][%c{0}][%M\(%L\)][%t]: %m%n</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<logger name="com.cmcc.hy.phoenix" level="${LOG_LEVEL}" additivity="false">
|
||||||
|
<appender-ref ref="BIZ"/>
|
||||||
|
<appender-ref ref="CONSOLE"/>
|
||||||
|
|
||||||
|
</logger>
|
||||||
|
|
||||||
|
<logger name="com.cmcc.hy.phoenix.mapper" level="${LOG_LEVEL}"
|
||||||
|
additivity="false">
|
||||||
|
<appender-ref ref="DATA"/>
|
||||||
|
<appender-ref ref="CONSOLE"/>
|
||||||
|
</logger>
|
||||||
|
|
||||||
|
<logger name="org.mybatis" level="${LOG_LEVEL}" additivity="false">
|
||||||
|
<appender-ref ref="DATA"/>
|
||||||
|
<appender-ref ref="CONSOLE"/>
|
||||||
|
</logger>
|
||||||
|
|
||||||
|
<logger name="org.apache.ibatis" level="${LOG_LEVEL}"
|
||||||
|
additivity="false">
|
||||||
|
<appender-ref ref="DATA"/>
|
||||||
|
</logger>
|
||||||
|
|
||||||
|
<logger name="org.mybatis.spring" level="${LOG_LEVEL}"
|
||||||
|
additivity="false">
|
||||||
|
<appender-ref ref="DATA"/>
|
||||||
|
</logger>
|
||||||
|
|
||||||
|
<logger name="org.springframework.jdbc" level="${LOG_LEVEL}"
|
||||||
|
additivity="false">
|
||||||
|
<appender-ref ref="DATA"/>
|
||||||
|
<appender-ref ref="CONSOLE"/>
|
||||||
|
</logger>
|
||||||
|
<logger name="org.springframework.orm" level="${LOG_LEVEL}"
|
||||||
|
additivity="false">
|
||||||
|
<appender-ref ref="DATA"/>
|
||||||
|
</logger>
|
||||||
|
<logger name="com.mysql" level="${LOG_LEVEL}" additivity="false">
|
||||||
|
<appender-ref ref="DATA"/>
|
||||||
|
<appender-ref ref="CONSOLE"/>
|
||||||
|
</logger>
|
||||||
|
<logger name="java.sql" level="${LOG_LEVEL}" additivity="false">
|
||||||
|
<appender-ref ref="DATA"/>
|
||||||
|
<appender-ref ref="CONSOLE"/>
|
||||||
|
</logger>
|
||||||
|
<logger name="javax.sql" level="${LOG_LEVEL}" additivity="false">
|
||||||
|
<appender-ref ref="DATA"/>
|
||||||
|
</logger>
|
||||||
|
|
||||||
|
<root level="${LOG_LEVEL}">
|
||||||
|
<appender-ref ref="SYSTEM-LOG-FILE"/>
|
||||||
|
<appender-ref ref="CONSOLE"/>
|
||||||
|
</root>
|
||||||
|
|
||||||
|
</configuration>
|
|
@ -118,7 +118,7 @@ public class DpTechAbilityImpl implements DisposeAbility {
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
dirList.forEach(d -> typeList.forEach(t -> CompletableFuture.supplyAsync(() ->
|
dirList.forEach(d -> typeList.forEach(t -> CompletableFuture.supplyAsync(() ->
|
||||||
cleanTypePort.startAbnormalTaskForUMC(ip, t.getValue(), d.getCode()))
|
cleanTypePort.startAbnormalTaskForUMC(ip, t.getValue(), d.getValue()))
|
||||||
.whenComplete((v, ex) -> {
|
.whenComplete((v, ex) -> {
|
||||||
if (ex != null) {
|
if (ex != null) {
|
||||||
log.error("DPTech run dispose: {}, {}, error:{}", ip, t.getValue(),
|
log.error("DPTech run dispose: {}, {}, error:{}", ip, t.getValue(),
|
||||||
|
@ -173,7 +173,7 @@ public class DpTechAbilityImpl implements DisposeAbility {
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
dirList.forEach(d -> typeList.forEach(t -> CompletableFuture.supplyAsync(() ->
|
dirList.forEach(d -> typeList.forEach(t -> CompletableFuture.supplyAsync(() ->
|
||||||
cleanTypePort.stopAbnormalTaskForUMC(ipAddr, t.getValue(), d.getCode()))
|
cleanTypePort.stopAbnormalTaskForUMC(ipAddr, t.getValue(), d.getValue()))
|
||||||
.whenComplete((v, ex) -> {
|
.whenComplete((v, ex) -> {
|
||||||
if (ex != null) {
|
if (ex != null) {
|
||||||
log.error("DPTech stop dispose: {}, {}, error:{}", ipAddr, t.getValue(), ex.getMessage());
|
log.error("DPTech stop dispose: {}, {}, error:{}", ipAddr, t.getValue(), ex.getMessage());
|
||||||
|
|
|
@ -1,188 +1,194 @@
|
||||||
package com.dispose.common;
|
package com.dispose.common;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The enum D do s attack type.
|
* The enum D do s attack type.
|
||||||
*
|
*
|
||||||
* @author <huangxin@cmhi.chinamoblie.com>
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
*/
|
*/
|
||||||
public enum DDoSAttackType implements BaseEnum {
|
@Slf4j
|
||||||
|
public enum DDoSAttackType implements BaseEnum {
|
||||||
/**
|
/**
|
||||||
* The Host total traffic.
|
* The Host total traffic.
|
||||||
*/
|
*/
|
||||||
HOST_TOTAL_TRAFFIC ( 0, "HOST_TOTAL_TRAFFIC"),
|
HOST_TOTAL_TRAFFIC(0, "HOST_TOTAL_TRAFFIC"),
|
||||||
/**
|
/**
|
||||||
* The Rst flood.
|
* The Rst flood.
|
||||||
*/
|
*/
|
||||||
RST_FLOOD ( 1, "RST_FLOOD"),
|
RST_FLOOD(1, "RST_FLOOD"),
|
||||||
/**
|
/**
|
||||||
* The Syn flood.
|
* The Syn flood.
|
||||||
*/
|
*/
|
||||||
SYN_FLOOD ( 2, "SYN_FLOOD"),
|
SYN_FLOOD(2, "SYN_FLOOD"),
|
||||||
/**
|
/**
|
||||||
* The Ack flood.
|
* The Ack flood.
|
||||||
*/
|
*/
|
||||||
ACK_FLOOD ( 3, "ACK_FLOOD"),
|
ACK_FLOOD(3, "ACK_FLOOD"),
|
||||||
/**
|
/**
|
||||||
* The Tcp null.
|
* The Tcp null.
|
||||||
*/
|
*/
|
||||||
TCP_NULL ( 4, "TCP_NULL"),
|
TCP_NULL(4, "TCP_NULL"),
|
||||||
/**
|
/**
|
||||||
* The Syn ack amplification.
|
* The Syn ack amplification.
|
||||||
*/
|
*/
|
||||||
SYN_ACK_AMPLIFICATION ( 5, "SYN/ACK_AMPLIFICATION"),
|
SYN_ACK_AMPLIFICATION(5, "SYN/ACK_AMPLIFICATION"),
|
||||||
/**
|
/**
|
||||||
* The Tcp misuse.
|
* The Tcp misuse.
|
||||||
*/
|
*/
|
||||||
TCP_MISUSE ( 6, "TCP_MISUSE"),
|
TCP_MISUSE(6, "TCP_MISUSE"),
|
||||||
/**
|
/**
|
||||||
* The Fin flood.
|
* The Fin flood.
|
||||||
*/
|
*/
|
||||||
FIN_FLOOD ( 7, "FIN_FLOOD"),
|
FIN_FLOOD(7, "FIN_FLOOD"),
|
||||||
/**
|
/**
|
||||||
* The Tcp fragment.
|
* The Tcp fragment.
|
||||||
*/
|
*/
|
||||||
TCP_FRAGMENT ( 8, "TCP_FRAGMENT"),
|
TCP_FRAGMENT(8, "TCP_FRAGMENT"),
|
||||||
/**
|
/**
|
||||||
* The Http flood.
|
* The Http flood.
|
||||||
*/
|
*/
|
||||||
HTTP_FLOOD ( 9, "HTTP_FLOOD"),
|
HTTP_FLOOD(9, "HTTP_FLOOD"),
|
||||||
/**
|
/**
|
||||||
* The Https flood.
|
* The Https flood.
|
||||||
*/
|
*/
|
||||||
HTTPS_FLOOD ( 10, "HTTPS_FLOOD"),
|
HTTPS_FLOOD(10, "HTTPS_FLOOD"),
|
||||||
/**
|
/**
|
||||||
* The Win nuke.
|
* The Win nuke.
|
||||||
*/
|
*/
|
||||||
WIN_NUKE ( 11, "WIN_NUKE"),
|
WIN_NUKE(11, "WIN_NUKE"),
|
||||||
/**
|
/**
|
||||||
* The Sip flood.
|
* The Sip flood.
|
||||||
*/
|
*/
|
||||||
SIP_FLOOD ( 12, "SIP_FLOOD"),
|
SIP_FLOOD(12, "SIP_FLOOD"),
|
||||||
/**
|
/**
|
||||||
* The Dns flood.
|
* The Dns flood.
|
||||||
*/
|
*/
|
||||||
DNS_FLOOD ( 13, "DNS_FLOOD"),
|
DNS_FLOOD(13, "DNS_FLOOD"),
|
||||||
/**
|
/**
|
||||||
* The Udp fragment.
|
* The Udp fragment.
|
||||||
*/
|
*/
|
||||||
UDP_FRAGMENT ( 14, "UDP_FRAGMENT"),
|
UDP_FRAGMENT(14, "UDP_FRAGMENT"),
|
||||||
/**
|
/**
|
||||||
* The Charged amplification.
|
* The Charged amplification.
|
||||||
*/
|
*/
|
||||||
CHARGED_AMPLIFICATION ( 15, "CHARGED_AMPLIFICATION"),
|
CHARGED_AMPLIFICATION(15, "CHARGED_AMPLIFICATION"),
|
||||||
/**
|
/**
|
||||||
* The L 2 tp amplification.
|
* The L 2 tp amplification.
|
||||||
*/
|
*/
|
||||||
L2TP_AMPLIFICATION ( 16, "L2TP_AMPLIFICATION"),
|
L2TP_AMPLIFICATION(16, "L2TP_AMPLIFICATION"),
|
||||||
/**
|
/**
|
||||||
* The Mdns amplification.
|
* The Mdns amplification.
|
||||||
*/
|
*/
|
||||||
MDNS_AMPLIFICATION ( 17, "MDNS_AMPLIFICATION"),
|
MDNS_AMPLIFICATION(17, "MDNS_AMPLIFICATION"),
|
||||||
/**
|
/**
|
||||||
* The Ms sql rs amplification.
|
* The Ms sql rs amplification.
|
||||||
*/
|
*/
|
||||||
MS_SQL_RS_AMPLIFICATION ( 18, "MS_SQL_RS_AMPLIFICATION"),
|
MS_SQL_RS_AMPLIFICATION(18, "MS_SQL_RS_AMPLIFICATION"),
|
||||||
/**
|
/**
|
||||||
* The Net bios amplification.
|
* The Net bios amplification.
|
||||||
*/
|
*/
|
||||||
NET_BIOS_AMPLIFICATION ( 19, "NET_BIOS_AMPLIFICATION"),
|
NET_BIOS_AMPLIFICATION(19, "NET_BIOS_AMPLIFICATION"),
|
||||||
/**
|
/**
|
||||||
* The Ntp amplification.
|
* The Ntp amplification.
|
||||||
*/
|
*/
|
||||||
NTP_AMPLIFICATION ( 20, "NTP_AMPLIFICATION"),
|
NTP_AMPLIFICATION(20, "NTP_AMPLIFICATION"),
|
||||||
/**
|
/**
|
||||||
* The Ripv 1 amplification.
|
* The Ripv 1 amplification.
|
||||||
*/
|
*/
|
||||||
RIPV1_AMPLIFICATION ( 21, "RIPV1_AMPLIFICATION"),
|
RIPV1_AMPLIFICATION(21, "RIPV1_AMPLIFICATION"),
|
||||||
/**
|
/**
|
||||||
* The Rpcbind amplification.
|
* The Rpcbind amplification.
|
||||||
*/
|
*/
|
||||||
RPCBIND_AMPLIFICATION ( 22, "RPCBIND_AMPLIFICATION"),
|
RPCBIND_AMPLIFICATION(22, "RPCBIND_AMPLIFICATION"),
|
||||||
/**
|
/**
|
||||||
* The Snmp amplification.
|
* The Snmp amplification.
|
||||||
*/
|
*/
|
||||||
SNMP_AMPLIFICATION ( 23, "SNMP_AMPLIFICATION"),
|
SNMP_AMPLIFICATION(23, "SNMP_AMPLIFICATION"),
|
||||||
/**
|
/**
|
||||||
* The Ssdp amplification.
|
* The Ssdp amplification.
|
||||||
*/
|
*/
|
||||||
SSDP_AMPLIFICATION ( 24, "SSDP_AMPLIFICATION"),
|
SSDP_AMPLIFICATION(24, "SSDP_AMPLIFICATION"),
|
||||||
/**
|
/**
|
||||||
* The Dns amplification.
|
* The Dns amplification.
|
||||||
*/
|
*/
|
||||||
DNS_AMPLIFICATION ( 25, "DNS_AMPLIFICATION"),
|
DNS_AMPLIFICATION(25, "DNS_AMPLIFICATION"),
|
||||||
/**
|
/**
|
||||||
* The Qotd amplification.
|
* The Qotd amplification.
|
||||||
*/
|
*/
|
||||||
QOTD_AMPLIFICATION ( 26, "QOTD_AMPLIFICATION"),
|
QOTD_AMPLIFICATION(26, "QOTD_AMPLIFICATION"),
|
||||||
/**
|
/**
|
||||||
* The Quake 3 amplification.
|
* The Quake 3 amplification.
|
||||||
*/
|
*/
|
||||||
QUAKE3_AMPLIFICATION ( 27, "QUAKE3_AMPLIFICATION"),
|
QUAKE3_AMPLIFICATION(27, "QUAKE3_AMPLIFICATION"),
|
||||||
/**
|
/**
|
||||||
* The Steam amplification.
|
* The Steam amplification.
|
||||||
*/
|
*/
|
||||||
STEAM_AMPLIFICATION ( 28, "STEAM_AMPLIFICATION"),
|
STEAM_AMPLIFICATION(28, "STEAM_AMPLIFICATION"),
|
||||||
/**
|
/**
|
||||||
* The Cldap amplification.
|
* The Cldap amplification.
|
||||||
*/
|
*/
|
||||||
CLDAP_AMPLIFICATION ( 29, "CLDAP_AMPLIFICATION"),
|
CLDAP_AMPLIFICATION(29, "CLDAP_AMPLIFICATION"),
|
||||||
/**
|
/**
|
||||||
* The Memcache amplification.
|
* The Memcache amplification.
|
||||||
*/
|
*/
|
||||||
MEMCACHE_AMPLIFICATION ( 30, "MEMCACHE_AMPLIFICATION"),
|
MEMCACHE_AMPLIFICATION(30, "MEMCACHE_AMPLIFICATION"),
|
||||||
/**
|
/**
|
||||||
* The Tftp amplification.
|
* The Tftp amplification.
|
||||||
*/
|
*/
|
||||||
TFTP_AMPLIFICATION ( 31, "TFTP_AMPLIFICATION"),
|
TFTP_AMPLIFICATION(31, "TFTP_AMPLIFICATION"),
|
||||||
/**
|
/**
|
||||||
* The Portmapper amplification.
|
* The Portmapper amplification.
|
||||||
*/
|
*/
|
||||||
PORTMAPPER_AMPLIFICATION ( 32, "PORTMAPPER_AMPLIFICATION"),
|
PORTMAPPER_AMPLIFICATION(32, "PORTMAPPER_AMPLIFICATION"),
|
||||||
/**
|
/**
|
||||||
* The Sentinel amplification.
|
* The Sentinel amplification.
|
||||||
*/
|
*/
|
||||||
SENTINEL_AMPLIFICATION ( 33, "SENTINEL_AMPLIFICATION"),
|
SENTINEL_AMPLIFICATION(33, "SENTINEL_AMPLIFICATION"),
|
||||||
/**
|
/**
|
||||||
* The Fraggle flood.
|
* The Fraggle flood.
|
||||||
*/
|
*/
|
||||||
FRAGGLE_FLOOD ( 34, "FRAGGLE_FLOOD"),
|
FRAGGLE_FLOOD(34, "FRAGGLE_FLOOD"),
|
||||||
/**
|
/**
|
||||||
* The Udp flood.
|
* The Udp flood.
|
||||||
*/
|
*/
|
||||||
UDP_FLOOD ( 35, "UDP_FLOOD"),
|
UDP_FLOOD(35, "UDP_FLOOD"),
|
||||||
/**
|
/**
|
||||||
* The Smurf.
|
* The Smurf.
|
||||||
*/
|
*/
|
||||||
SMURF ( 36, "SMURF"),
|
SMURF(36, "SMURF"),
|
||||||
/**
|
/**
|
||||||
* The Icmp fragment.
|
* The Icmp fragment.
|
||||||
*/
|
*/
|
||||||
ICMP_FRAGMENT ( 37, "ICMP_FRAGMENT"),
|
ICMP_FRAGMENT(37, "ICMP_FRAGMENT"),
|
||||||
/**
|
/**
|
||||||
* The Icmp flood.
|
* The Icmp flood.
|
||||||
*/
|
*/
|
||||||
ICMP_FLOOD ( 38, "ICMP_FLOOD"),
|
ICMP_FLOOD(38, "ICMP_FLOOD"),
|
||||||
/**
|
/**
|
||||||
* The Ipv 4 protocol 0.
|
* The Ipv 4 protocol 0.
|
||||||
*/
|
*/
|
||||||
IPV4_PROTOCOL0 ( 39, "IPV4_PROTOCOL0"),
|
IPV4_PROTOCOL0(39, "IPV4_PROTOCOL0"),
|
||||||
/**
|
/**
|
||||||
* The Ip private.
|
* The Ip private.
|
||||||
*/
|
*/
|
||||||
IP_PRIVATE ( 40, "IP_PRIVATE"),
|
IP_PRIVATE(40, "IP_PRIVATE"),
|
||||||
/**
|
/**
|
||||||
* The Land flood.
|
* The Land flood.
|
||||||
*/
|
*/
|
||||||
LAND_FLOOD ( 41, "LAND_FLOOD"),
|
LAND_FLOOD(41, "LAND_FLOOD"),
|
||||||
/**
|
/**
|
||||||
* The Igmp flood.
|
* The Igmp flood.
|
||||||
*/
|
*/
|
||||||
IGMP_FLOOD ( 42, "IGMP_FLOOD"),
|
IGMP_FLOOD(42, "IGMP_FLOOD"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All attacks d do s attack type.
|
* The All attacks.
|
||||||
*/
|
*/
|
||||||
ALL_ATTACKS (-1, "ALL_ATTACKS"),
|
ALL_ATTACKS(-1, "ALL_ATTACKS"),
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
@ -206,6 +212,56 @@ public enum DDoSAttackType implements BaseEnum {
|
||||||
this.readme = readme;
|
this.readme = readme;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets type mask from attack type.
|
||||||
|
*
|
||||||
|
* @param types the types
|
||||||
|
* @return the type mask from attack type
|
||||||
|
*/
|
||||||
|
public static Long getTypeMaskFromAttackType(List<DDoSAttackType> types) {
|
||||||
|
long mask = 0L;
|
||||||
|
|
||||||
|
if (types.contains(ALL_ATTACKS)) {
|
||||||
|
for (DDoSAttackType type : DDoSAttackType.values()) {
|
||||||
|
if (type.equals(ALL_ATTACKS)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
mask |= type.getValue() << 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (DDoSAttackType type : types) {
|
||||||
|
mask |= type.getValue() << 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets type mask from attack type.
|
||||||
|
*
|
||||||
|
* @param types the types
|
||||||
|
* @return the type mask from attack type
|
||||||
|
*/
|
||||||
|
public static Long getTypeMaskFromAttackType(DDoSAttackType[] types) {
|
||||||
|
long mask = 0L;
|
||||||
|
|
||||||
|
if (Arrays.asList(types).contains(ALL_ATTACKS)) {
|
||||||
|
for (DDoSAttackType type : DDoSAttackType.values()) {
|
||||||
|
if (type.equals(ALL_ATTACKS)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
mask |= (long)1 << type.getValue();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (DDoSAttackType type : types) {
|
||||||
|
mask |= (long)1 << type.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return mask;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets value.
|
* Gets value.
|
||||||
*
|
*
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
package com.dispose.common;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The enum Task status.
|
||||||
|
*
|
||||||
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
|
*/
|
||||||
|
public enum DisposeTaskStatus implements BaseEnum {
|
||||||
|
/**
|
||||||
|
* The Task new.
|
||||||
|
*/
|
||||||
|
TASK_NEW(0, "新建"),
|
||||||
|
/**
|
||||||
|
* The Task starting.
|
||||||
|
*/
|
||||||
|
TASK_STARTING(1, "启动中"),
|
||||||
|
/**
|
||||||
|
* The Task started.
|
||||||
|
*/
|
||||||
|
TASK_STARTED(2, "启动完成"),
|
||||||
|
/**
|
||||||
|
* The Task finished.
|
||||||
|
*/
|
||||||
|
TASK_FINISHED(3, "结束"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Task canceled task status.
|
||||||
|
*/
|
||||||
|
TASK_CANCELED(4, "用户中止"),
|
||||||
|
;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Code.
|
||||||
|
*/
|
||||||
|
private final Integer code;
|
||||||
|
/**
|
||||||
|
* The Readme.
|
||||||
|
*/
|
||||||
|
private final String readme;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new Task status.
|
||||||
|
*
|
||||||
|
* @param code the code
|
||||||
|
* @param readme the readme
|
||||||
|
*/
|
||||||
|
DisposeTaskStatus(int code, String readme) {
|
||||||
|
this.code = code;
|
||||||
|
this.readme = readme;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets value.
|
||||||
|
*
|
||||||
|
* @return the value
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Integer getValue() {
|
||||||
|
return this.code;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets description.
|
||||||
|
*
|
||||||
|
* @return the description
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return this.readme;
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,19 +5,24 @@ package com.dispose.common;
|
||||||
*
|
*
|
||||||
* @author <huangxin@cmhi.chinamoblie.com>
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
*/
|
*/
|
||||||
public enum NetflowDirection {
|
public enum NetflowDirection implements BaseEnum {
|
||||||
/**
|
/**
|
||||||
* Direction in netflow direction.
|
* The Direction in.
|
||||||
*/
|
*/
|
||||||
DIRECTION_IN(0, "入方向"),
|
DIRECTION_IN(0, "入方向"),
|
||||||
/**
|
/**
|
||||||
* Direction out netflow direction.
|
* The Direction out.
|
||||||
*/
|
*/
|
||||||
DIRECTION_OUT(1, "出方向");
|
DIRECTION_OUT(1, "出方向"),
|
||||||
|
/**
|
||||||
|
* The Direction bi.
|
||||||
|
*/
|
||||||
|
DIRECTION_BI(2, "双向");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Code.
|
* The Code.
|
||||||
*/
|
*/
|
||||||
private final int code;
|
private final Integer code;
|
||||||
/**
|
/**
|
||||||
* The Readme.
|
* The Readme.
|
||||||
*/
|
*/
|
||||||
|
@ -35,20 +40,22 @@ public enum NetflowDirection {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets code.
|
* Gets value.
|
||||||
*
|
*
|
||||||
* @return the code
|
* @return the value
|
||||||
*/
|
*/
|
||||||
public int getCode() {
|
@Override
|
||||||
|
public Integer getValue() {
|
||||||
return this.code;
|
return this.code;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets readme.
|
* Gets description.
|
||||||
*
|
*
|
||||||
* @return the readme
|
* @return the description
|
||||||
*/
|
*/
|
||||||
public String getReadme() {
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
return this.readme;
|
return this.readme;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
package com.dispose.mapper;
|
||||||
|
|
||||||
|
import com.dispose.common.DisposeTaskStatus;
|
||||||
|
import com.dispose.pojo.entity.DisposeTask;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The interface Dispose task mapper.
|
||||||
|
*
|
||||||
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
|
*/
|
||||||
|
public interface DisposeTaskMapper {
|
||||||
|
/**
|
||||||
|
* Select all list.
|
||||||
|
*
|
||||||
|
* @return the list
|
||||||
|
*/
|
||||||
|
List<DisposeTask> selectAll();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add new task int.
|
||||||
|
*
|
||||||
|
* @param task the task
|
||||||
|
* @return the int
|
||||||
|
*/
|
||||||
|
int addNewTask(DisposeTask task);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets task status.
|
||||||
|
*
|
||||||
|
* @param taskId the task id
|
||||||
|
* @return the task status
|
||||||
|
*/
|
||||||
|
DisposeTaskStatus getTaskStatus(@Param("id") Long taskId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Chang task status int.
|
||||||
|
*
|
||||||
|
* @param taskId the task id
|
||||||
|
* @param status the status
|
||||||
|
* @return the int
|
||||||
|
*/
|
||||||
|
int changTaskStatus(@Param("id") Long taskId,
|
||||||
|
@Param("status") DisposeTaskStatus status);
|
||||||
|
}
|
|
@ -6,32 +6,29 @@ import com.dispose.common.IpAddrType;
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Getter;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
|
||||||
import lombok.ToString;
|
|
||||||
import tk.mybatis.mapper.annotation.KeySql;
|
import tk.mybatis.mapper.annotation.KeySql;
|
||||||
import tk.mybatis.mapper.annotation.NameStyle;
|
import tk.mybatis.mapper.annotation.NameStyle;
|
||||||
import tk.mybatis.mapper.code.Style;
|
import tk.mybatis.mapper.code.Style;
|
||||||
|
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type Dispose capacity.
|
* The type Dispose capacity.
|
||||||
*
|
*
|
||||||
* @author <huangxin@cmhi.chinamoblie.com>
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Data
|
||||||
@Setter
|
|
||||||
@ToString
|
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Builder
|
@Builder
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
@Table(name = "dispose_capacity")
|
@Table(name = "dispose_capacity")
|
||||||
@NameStyle(Style.normal)
|
@NameStyle(Style.normal)
|
||||||
public class DisposeCapacity {
|
public class DisposeCapacity implements Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The constant serialVersionUID.
|
* The constant serialVersionUID.
|
||||||
|
|
|
@ -7,10 +7,8 @@ import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Getter;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
|
||||||
import lombok.ToString;
|
|
||||||
import tk.mybatis.mapper.annotation.KeySql;
|
import tk.mybatis.mapper.annotation.KeySql;
|
||||||
import tk.mybatis.mapper.annotation.NameStyle;
|
import tk.mybatis.mapper.annotation.NameStyle;
|
||||||
import tk.mybatis.mapper.code.Style;
|
import tk.mybatis.mapper.code.Style;
|
||||||
|
@ -26,9 +24,7 @@ import java.util.List;
|
||||||
*
|
*
|
||||||
* @author <huangxin@cmhi.chinamoblie.com>
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Data
|
||||||
@Setter
|
|
||||||
@ToString
|
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Builder
|
@Builder
|
||||||
|
|
|
@ -0,0 +1,90 @@
|
||||||
|
package com.dispose.pojo.entity;
|
||||||
|
|
||||||
|
import com.dispose.common.DisposeCapacityType;
|
||||||
|
import com.dispose.common.DisposeTaskStatus;
|
||||||
|
import com.dispose.common.NetflowDirection;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import tk.mybatis.mapper.annotation.KeySql;
|
||||||
|
import tk.mybatis.mapper.annotation.NameStyle;
|
||||||
|
import tk.mybatis.mapper.code.Style;
|
||||||
|
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type Dispose task.
|
||||||
|
*
|
||||||
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Builder
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonPropertyOrder(alphabetic = true)
|
||||||
|
@Table(name = "dispose_task")
|
||||||
|
@NameStyle(Style.normal)
|
||||||
|
public class DisposeTask implements Serializable {
|
||||||
|
/**
|
||||||
|
* The constant serialVersionUID.
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Id.
|
||||||
|
*/
|
||||||
|
@Id
|
||||||
|
@KeySql(useGeneratedKeys = true)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Device id.
|
||||||
|
*/
|
||||||
|
private Long deviceId;
|
||||||
|
/**
|
||||||
|
* The Account id.
|
||||||
|
*/
|
||||||
|
private Long accountId;
|
||||||
|
/**
|
||||||
|
* The Capacity type.
|
||||||
|
*/
|
||||||
|
private DisposeCapacityType capacityType;
|
||||||
|
/**
|
||||||
|
* The Dispose ip.
|
||||||
|
*/
|
||||||
|
private String disposeIp;
|
||||||
|
/**
|
||||||
|
* The Create time.
|
||||||
|
*/
|
||||||
|
private String createTime;
|
||||||
|
/**
|
||||||
|
* The Plan end time.
|
||||||
|
*/
|
||||||
|
private String planEndTime;
|
||||||
|
/**
|
||||||
|
* The End time.
|
||||||
|
*/
|
||||||
|
private String endTime;
|
||||||
|
/**
|
||||||
|
* The Flow direction.
|
||||||
|
*/
|
||||||
|
private NetflowDirection flowDirection;
|
||||||
|
/**
|
||||||
|
* The Attack type.
|
||||||
|
*/
|
||||||
|
private Long attackType;
|
||||||
|
/**
|
||||||
|
* The Flow band width.
|
||||||
|
*/
|
||||||
|
private Integer flowBandWidth;
|
||||||
|
/**
|
||||||
|
* The Current status.
|
||||||
|
*/
|
||||||
|
private DisposeTaskStatus currentStatus;
|
||||||
|
}
|
|
@ -3,10 +3,8 @@ package com.dispose.pojo.entity;
|
||||||
import com.dispose.common.ObjectStatus;
|
import com.dispose.common.ObjectStatus;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Getter;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
|
||||||
import lombok.ToString;
|
|
||||||
import tk.mybatis.mapper.annotation.KeySql;
|
import tk.mybatis.mapper.annotation.KeySql;
|
||||||
import tk.mybatis.mapper.annotation.NameStyle;
|
import tk.mybatis.mapper.annotation.NameStyle;
|
||||||
import tk.mybatis.mapper.code.Style;
|
import tk.mybatis.mapper.code.Style;
|
||||||
|
@ -20,9 +18,7 @@ import java.io.Serializable;
|
||||||
*
|
*
|
||||||
* @author <huangxin@cmhi.chinamoblie.com>
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Data
|
||||||
@Setter
|
|
||||||
@ToString
|
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Builder
|
@Builder
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.dispose.mapper.DisposeTaskMapper">
|
||||||
|
<resultMap id="dispose_task" type="com.dispose.pojo.entity.DisposeTask">
|
||||||
|
<id column="id" property="id"/>
|
||||||
|
<id column = "deviceId" property="deviceId"/>
|
||||||
|
<id column = "accountId" property="accountId"/>
|
||||||
|
<result column="capacityType" property="capacityType" javaType="com.dispose.common.DisposeCapacityType"/>
|
||||||
|
<result column="disposeIp" property="disposeIp"/>
|
||||||
|
<result column="createTime" property="createTime"/>
|
||||||
|
<result column="planEndTime" property="planEndTime"/>
|
||||||
|
<result column="endTime" property="endTime"/>
|
||||||
|
<result column="flowDirection" property="flowDirection" javaType="com.dispose.common.NetflowDirection"/>
|
||||||
|
<result column="attackType" property="attackType"/>
|
||||||
|
<result column="flowBandWidth" property="flowBandWidth"/>
|
||||||
|
<result column="currentStatus" property="currentStatus" javaType="com.dispose.common.DisposeTaskStatus"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<select id="selectAll" resultMap="dispose_task">
|
||||||
|
SELECT *
|
||||||
|
FROM dispose_task
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="addNewTask" useGeneratedKeys="true" keyProperty="id"
|
||||||
|
parameterType="com.dispose.pojo.entity.DisposeTask">
|
||||||
|
INSERT IGNORE INTO dispose_task(deviceId, accountId, capacityType, disposeIp,
|
||||||
|
planEndTime, flowDirection, attackType, flowBandWidth,
|
||||||
|
currentStatus)
|
||||||
|
VALUES (#{deviceId}, #{accountId}, #{capacityType}, #{disposeIp},
|
||||||
|
date_add(now(), interval #{planEndTime} MINUTE), #{flowDirection}, #{attackType},
|
||||||
|
#{flowBandWidth}, ${@com.dispose.common.DisposeTaskStatus@TASK_FINISHED.getValue()})
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="changTaskStatus">
|
||||||
|
UPDATE
|
||||||
|
dispose_task
|
||||||
|
SET
|
||||||
|
currentStatus = #{status, javaType="com.dispose.common.DisposeTaskStatus"}
|
||||||
|
<if test="status == @com.dispose.common.DisposeTaskStatus@TASK_FINISHED
|
||||||
|
and status == @com.dispose.common.DisposeTaskStatus@TASK_CANCELED">
|
||||||
|
, endTime = CURRENT_TIMESTAMP
|
||||||
|
</if>
|
||||||
|
WHERE
|
||||||
|
id = #{id, jdbcType=INTEGER}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<select id="getTaskStatus" resultType="com.dispose.common.DisposeTaskStatus">
|
||||||
|
SELECT currentStatus
|
||||||
|
FROM dispose_task
|
||||||
|
WHERE id = #{id, jdbcType=INTEGER}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
|
@ -1,5 +1,6 @@
|
||||||
package com.dispose.test.debug;
|
package com.dispose.test.debug;
|
||||||
|
|
||||||
|
import com.dispose.common.DDoSAttackType;
|
||||||
import com.dispose.common.DisposeDeviceType;
|
import com.dispose.common.DisposeDeviceType;
|
||||||
import com.dispose.common.HttpType;
|
import com.dispose.common.HttpType;
|
||||||
import com.dispose.common.ObjectStatus;
|
import com.dispose.common.ObjectStatus;
|
||||||
|
@ -137,4 +138,10 @@ public class demo {
|
||||||
log.info(PrivacyHelper.ipAddressPrivacy("2001:0000:4136:e378:8000:63bf:3fff:fdd2"));
|
log.info(PrivacyHelper.ipAddressPrivacy("2001:0000:4136:e378:8000:63bf:3fff:fdd2"));
|
||||||
log.info(PrivacyHelper.ipAddressPrivacy("3fde::fde2"));
|
log.info(PrivacyHelper.ipAddressPrivacy("3fde::fde2"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getTypeMaskFromAttackType() {
|
||||||
|
Long ret = DDoSAttackType.getTypeMaskFromAttackType(new DDoSAttackType[] {DDoSAttackType.ALL_ATTACKS});
|
||||||
|
log.debug("Ret: 0x{}", Long.toHexString(ret).toUpperCase());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
package com.dispose.test.mapper;
|
||||||
|
|
||||||
|
import com.dispose.common.DDoSAttackType;
|
||||||
|
import com.dispose.common.DisposeCapacityType;
|
||||||
|
import com.dispose.common.NetflowDirection;
|
||||||
|
import com.dispose.mapper.DisposeDeviceMapper;
|
||||||
|
import com.dispose.mapper.DisposeTaskMapper;
|
||||||
|
import com.dispose.mapper.UserAccountMapper;
|
||||||
|
import com.dispose.pojo.entity.DisposeTask;
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.junit.FixMethodOrder;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.junit.runners.MethodSorters;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest
|
||||||
|
@Slf4j
|
||||||
|
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||||
|
public class DisposeTaskMapperTest {
|
||||||
|
@Resource
|
||||||
|
private DisposeTaskMapper disposeTaskMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private UserAccountMapper userAccountMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DisposeDeviceMapper disposeDeviceMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ObjectMapper objectMapper;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void a1_addNewDisposeTask() throws JsonProcessingException {
|
||||||
|
Long uId = userAccountMapper.selectAll().get(0).getId();
|
||||||
|
Long dId = disposeDeviceMapper.selectAll().get(0).getId();
|
||||||
|
DisposeTask task = DisposeTask.builder()
|
||||||
|
.deviceId(dId)
|
||||||
|
.accountId(uId)
|
||||||
|
.capacityType(DisposeCapacityType.CLEANUP)
|
||||||
|
.disposeIp("192.168.0.1")
|
||||||
|
.planEndTime("30")
|
||||||
|
.flowDirection(NetflowDirection.DIRECTION_BI)
|
||||||
|
.attackType(DDoSAttackType.getTypeMaskFromAttackType(new DDoSAttackType[] {DDoSAttackType.ALL_ATTACKS}))
|
||||||
|
.flowBandWidth(1024)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
int ret = disposeTaskMapper.addNewTask(task);
|
||||||
|
|
||||||
|
log.info("add ret {}: {}", ret,
|
||||||
|
objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(task));
|
||||||
|
|
||||||
|
List<DisposeTask> taskList = disposeTaskMapper.selectAll();
|
||||||
|
|
||||||
|
log.info("Database: {}", objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(taskList));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue