Merge remote-tracking branch 'origin/v2.0.9_dev'

# Conflicts:
#	config/application-dispose.properties
#	config/application-local.properties
#	pom.xml
#	src/main/java/com/cmhi/dispose/protocol/CmhiDisposeInterface.java
#	src/main/java/com/dispose/ability/impl/CmhiAbilityImpl.java
#	src/main/java/com/dispose/service/impl/DeviceTaskManagerServiceImpl.java
#	src/test/java/com/dispose/test/dev/debug/demo.java
This commit is contained in:
HuangXin 2021-11-01 14:41:05 +08:00
commit 7456a9947e
61 changed files with 2334 additions and 1107 deletions

View File

@ -15,25 +15,21 @@ dispose.call-error-retry-times=3
dispose.max-split-page-size=100 dispose.max-split-page-size=100
# 最小每页数据条数 # 最小每页数据条数
dispose.min-split-page-size=10 dispose.min-split-page-size=10
# 迪普设备配置 # 迪普设备配置
# 发送超时时间(s) # 发送超时时间(s)
dptech.soap-conn-timeout-second=60 dptech.soap-conn-timeout-second=60
# 接收超时时间(s) # 接收超时时间(s)
dptech.soap-recv-timeout-second=60 dptech.soap-recv-timeout-second=60
# 用户权限配置 # 用户权限配置
# 是否对设备管理进行用户验证 # 是否对设备管理进行用户验证
permission.admin-check=true permission.admin-check=true
# 运行管理设备的操作员用户名 # 运行管理设备的操作员用户名
permission.admin-users=admin permission.admin-users=admin
# 认证配置 # 认证配置
# 是否对接口访问进行认证 # 是否对接口访问进行认证
auth.verify-request-token=true auth.verify-request-token=true
# token访问超时时间 # token访问超时时间
auth.token-timeout-minute=30 auth.token-timeout-minute=30
# 安全配置 # 安全配置
#加密类型: 0 不加密 #加密类型: 0 不加密
# 1 Base64编码 # 1 Base64编码
@ -43,7 +39,20 @@ crypto.security-protocol-type=0
crypto.aes-key=hkoUV5ZWh0q1jSxMnpjovVn19Qg99HY6DD40 crypto.aes-key=hkoUV5ZWh0q1jSxMnpjovVn19Qg99HY6DD40
# 3DES秘钥 # 3DES秘钥
crypto.des-key=P3mq9iSIvQcvfyfdWR8sAnfAadO crypto.des-key=P3mq9iSIvQcvfyfdWR8sAnfAadO
# Kafka 服务器配置
#重试次数
kafka.producer.retries=3
#批量大小
kafka.producer.batch.size=16384
#延时
kafka.producer.linger=1
#生产端缓冲区大小
kafka.producer.buffer.memory=33554432
kafka.producer.servers=172.21.44.189:9092,172.21.44.9:9092,172.21.44.244:9092,172.21.44.236:9092,172.21.44.80:9092
kafka.dispose.topic=ddos-vip-customer-ck
#sonar配置信息
sonar.host.url=http://172.21.48.126:9000
sonar.login=8a66da73ef5943a8bc6e7daf9afbc25ce495febc
#信任主机配置 #信任主机配置
# 白名单开关 # 白名单开关
trust.auth-white-list-check=true trust.auth-white-list-check=true

View File

@ -18,7 +18,6 @@ spring.datasource.url=jdbc:mysql://172.21.48.75:3306/ci_dispose_v1?serverTimezon
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.username=root spring.datasource.username=root
spring.datasource.password=BCcf6Dd7&8 spring.datasource.password=BCcf6Dd7&8
# 配置连接池 # 配置连接池
spring.datasource.schema=classpath:test_db/unit_test.sql spring.datasource.schema=classpath:test_db/unit_test.sql
spring.datasource.initialization-mode=always spring.datasource.initialization-mode=always

15
pom.xml
View File

@ -12,12 +12,12 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.9.RELEASE</version> <version>2.3.12.RELEASE</version>
<relativePath/> <relativePath/>
</parent> </parent>
<groupId>com.dispose</groupId> <groupId>com.dispose</groupId>
<artifactId>dispose_platform</artifactId> <artifactId>dispose_platform</artifactId>
<version>2.0.8.11</version> <version>2.0.9</version>
<name>dispose_platform</name> <name>dispose_platform</name>
<description>Dispose Platform</description> <description>Dispose Platform</description>
@ -102,7 +102,11 @@
<version>2.4</version> <version>2.4</version>
<classifier>jdk15</classifier> <classifier>jdk15</classifier>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
<version>2.7.2</version>
</dependency>
<!--mysql --> <!--mysql -->
<dependency> <dependency>
<groupId>mysql</groupId> <groupId>mysql</groupId>
@ -349,6 +353,11 @@
</generateGitPropertiesFilename> </generateGitPropertiesFilename>
</configuration> </configuration>
</plugin> </plugin>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.9.0.2155</version>
</plugin>
</plugins> </plugins>
</build> </build>

View File

@ -1,4 +1,4 @@
package com.pengxin.dispose.common; package com.cmhi.dispose.common;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
@ -15,7 +15,7 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
public class PengXinDisposeAbilityInfo { public class CmhiDisposeAbilityInfo {
/** /**
* The Type. * The Type.
*/ */

View File

@ -1,4 +1,4 @@
package com.pengxin.dispose.common; package com.cmhi.dispose.common;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@ -18,7 +18,7 @@ import java.util.List;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
public class PengXinDisposeAbilityRsp extends PengXinBaseResp { public class CmhiDisposeAbilityRsp extends CmhiDisposeBaseResp {
/** /**
* The Device name. * The Device name.
*/ */
@ -27,5 +27,5 @@ public class PengXinDisposeAbilityRsp extends PengXinBaseResp {
/** /**
* The Capacity. * The Capacity.
*/ */
List<PengXinDisposeAbilityInfo> capacity; List<CmhiDisposeAbilityInfo> capacity;
} }

View File

@ -1,4 +1,4 @@
package com.pengxin.dispose.common; package com.cmhi.dispose.common;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
@ -12,7 +12,7 @@ import lombok.NoArgsConstructor;
@Data @Data
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
public class PengXinBaseResp { public class CmhiDisposeBaseResp {
/** /**
* The Status. * The Status.
*/ */

View File

@ -1,4 +1,4 @@
package com.pengxin.dispose.common; package com.cmhi.dispose.common;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
@ -14,7 +14,7 @@ import lombok.NoArgsConstructor;
@Builder @Builder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class PengXinLoginReq { public class CmhiDisposeLoginReq {
/** /**
* The User name. * The User name.
*/ */

View File

@ -1,4 +1,4 @@
package com.pengxin.dispose.common; package com.cmhi.dispose.common;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@ -16,7 +16,7 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
public class PengXinLoginRsp extends PengXinBaseResp { public class CmhiDisposeLoginRsp extends CmhiDisposeBaseResp {
/** /**
* The User name. * The User name.
*/ */

View File

@ -1,4 +1,4 @@
package com.pengxin.dispose.common; package com.cmhi.dispose.common;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
@ -14,7 +14,7 @@ import lombok.NoArgsConstructor;
@Builder @Builder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class PengXinStartTaskItem { public class CmhiDisposeStartTaskItem {
/** /**
* The Task req id. * The Task req id.
*/ */

View File

@ -1,4 +1,4 @@
package com.pengxin.dispose.common; package com.cmhi.dispose.common;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
@ -16,9 +16,9 @@ import java.util.List;
@Builder @Builder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class PengXinStartTaskReq { public class CmhiDisposeStartTaskReq {
/** /**
* The Items. * The Items.
*/ */
List<PengXinStartTaskItem> items; List<CmhiDisposeStartTaskItem> items;
} }

View File

@ -1,4 +1,4 @@
package com.pengxin.dispose.common; package com.cmhi.dispose.common;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@ -16,7 +16,7 @@ import java.util.List;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
public class PengXinStartTaskRsp { public class CmhiDisposeStartTaskRsp {
/** /**
* The Device name. * The Device name.
*/ */
@ -25,5 +25,5 @@ public class PengXinStartTaskRsp {
/** /**
* The Items. * The Items.
*/ */
List<PengXinStartedItem> items; List<CmhiDisposeStartedItem> items;
} }

View File

@ -1,4 +1,4 @@
package com.pengxin.dispose.common; package com.cmhi.dispose.common;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@ -16,7 +16,7 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
public class PengXinStartedItem extends PengXinBaseResp { public class CmhiDisposeStartedItem extends CmhiDisposeBaseResp {
/** /**
* The Task req id. * The Task req id.
*/ */

View File

@ -1,4 +1,4 @@
package com.pengxin.dispose.common; package com.cmhi.dispose.common;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
@ -14,7 +14,7 @@ import lombok.NoArgsConstructor;
@Builder @Builder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class PengXinStopTaskReq { public class CmhiDisposeStopTaskReq {
/** /**
* The Task id. * The Task id.
*/ */

View File

@ -1,4 +1,4 @@
package com.pengxin.dispose.common; package com.cmhi.dispose.common;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@ -16,7 +16,7 @@ import java.util.List;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
public class PengXinStopTaskRsp { public class CmhiDisposeStopTaskRsp {
/** /**
* The Device name. * The Device name.
*/ */
@ -24,5 +24,5 @@ public class PengXinStopTaskRsp {
/** /**
* The Items. * The Items.
*/ */
private List<PengXinStoppedItem> items; private List<CmhiDisposeStoppedItem> items;
} }

View File

@ -1,4 +1,4 @@
package com.pengxin.dispose.common; package com.cmhi.dispose.common;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@ -16,7 +16,7 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
public class PengXinStoppedItem extends PengXinBaseResp { public class CmhiDisposeStoppedItem extends CmhiDisposeBaseResp {
/** /**
* The Task id. * The Task id.
*/ */

View File

@ -1,4 +1,4 @@
package com.pengxin.dispose.common; package com.cmhi.dispose.common;
import com.dispose.common.BaseEnum; import com.dispose.common.BaseEnum;
@ -7,7 +7,7 @@ import com.dispose.common.BaseEnum;
* *
* @author <huangxin@cmhi.chinamoblie.com> * @author <huangxin@cmhi.chinamoblie.com>
*/ */
public enum PengXinTaskStatus implements BaseEnum { public enum CmhiDisposeTaskStatus implements BaseEnum {
/** /**
* The Task starting. * The Task starting.
*/ */
@ -69,7 +69,7 @@ public enum PengXinTaskStatus implements BaseEnum {
* @param code the code * @param code the code
* @param readme the readme * @param readme the readme
*/ */
PengXinTaskStatus(int code, String readme) { CmhiDisposeTaskStatus(int code, String readme) {
this.code = code; this.code = code;
this.readme = readme; this.readme = readme;
} }

View File

@ -1,4 +1,4 @@
package com.pengxin.dispose.common; package com.cmhi.dispose.common;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@ -16,7 +16,7 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
public class PengXinTaskStatusItem extends PengXinBaseResp { public class CmhiDisposeTaskStatusItem extends CmhiDisposeBaseResp {
/** /**
* The Task id. * The Task id.
*/ */

View File

@ -1,4 +1,4 @@
package com.pengxin.dispose.common; package com.cmhi.dispose.common;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@ -16,7 +16,7 @@ import java.util.List;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
public class PengXinTaskStatusRsp { public class CmhiDisposeTaskStatusRsp {
/** /**
* The Device name. * The Device name.
@ -26,5 +26,5 @@ public class PengXinTaskStatusRsp {
/** /**
* The Items. * The Items.
*/ */
private List<PengXinTaskStatusItem> items; private List<CmhiDisposeTaskStatusItem> items;
} }

View File

@ -1,20 +1,19 @@
package com.pengxin.dispose.protocol; package com.cmhi.dispose.protocol;
import com.dispose.common.CommonEnumHandler; import com.cmhi.dispose.common.CmhiDisposeAbilityRsp;
import com.cmhi.dispose.common.CmhiDisposeBaseResp;
import com.cmhi.dispose.common.CmhiDisposeLoginReq;
import com.cmhi.dispose.common.CmhiDisposeLoginRsp;
import com.cmhi.dispose.common.CmhiDisposeStartTaskItem;
import com.cmhi.dispose.common.CmhiDisposeStartTaskReq;
import com.cmhi.dispose.common.CmhiDisposeStartTaskRsp;
import com.cmhi.dispose.common.CmhiDisposeStopTaskReq;
import com.cmhi.dispose.common.CmhiDisposeStopTaskRsp;
import com.cmhi.dispose.common.CmhiDisposeTaskStatusRsp;
import com.dispose.common.ErrorCode; import com.dispose.common.ErrorCode;
import com.dispose.pojo.dto.protocol.base.BaseProtocolDTO; import com.dispose.pojo.dto.protocol.base.BaseProtocolDTO;
import com.dispose.pojo.dto.protocol.base.ProtocolRespDTO; import com.dispose.pojo.dto.protocol.base.ProtocolRespDTO;
import com.dispose.restful.RestfulInterface; import com.dispose.restful.RestfulInterface;
import com.pengxin.dispose.common.PengXinBaseResp;
import com.pengxin.dispose.common.PengXinDisposeAbilityRsp;
import com.pengxin.dispose.common.PengXinLoginReq;
import com.pengxin.dispose.common.PengXinLoginRsp;
import com.pengxin.dispose.common.PengXinStartTaskItem;
import com.pengxin.dispose.common.PengXinStartTaskReq;
import com.pengxin.dispose.common.PengXinStartTaskRsp;
import com.pengxin.dispose.common.PengXinStopTaskReq;
import com.pengxin.dispose.common.PengXinStopTaskRsp;
import com.pengxin.dispose.common.PengXinTaskStatusRsp;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -25,7 +24,7 @@ import java.util.List;
* *
* @author <huangxin@cmhi.chinamoblie.com> * @author <huangxin@cmhi.chinamoblie.com>
*/ */
public class PengXinInterface { public class CmhiDisposeInterface {
/** /**
* The Ver. * The Ver.
*/ */
@ -54,11 +53,11 @@ public class PengXinInterface {
* @param password the password * @param password the password
* @return the protocol resp dto * @return the protocol resp dto
*/ */
public ProtocolRespDTO<PengXinLoginRsp> login(String baseUrlPath, String username, String password) { public ProtocolRespDTO<CmhiDisposeLoginRsp> login(String baseUrlPath, String username, String password) {
BaseProtocolDTO<PengXinLoginReq> reqInfo = new BaseProtocolDTO<>(); BaseProtocolDTO<CmhiDisposeLoginReq> reqInfo = new BaseProtocolDTO<>();
reqInfo.setMsgContent(PengXinLoginReq.builder() reqInfo.setMsgContent(CmhiDisposeLoginReq.builder()
.userName(username) .userName(username)
.password(password) .password(password)
.build()); .build());
@ -70,7 +69,7 @@ public class PengXinInterface {
return RestfulInterface.baseProRun(baseUrlPath, return RestfulInterface.baseProRun(baseUrlPath,
null, null,
reqInfo, reqInfo,
PengXinLoginRsp.class, CmhiDisposeLoginRsp.class,
RequestMethod.POST); RequestMethod.POST);
} }
@ -82,12 +81,12 @@ public class PengXinInterface {
* @return the link status * @return the link status
*/ */
public ErrorCode getLinkStatus(String baseUrlPath, String token) { public ErrorCode getLinkStatus(String baseUrlPath, String token) {
ProtocolRespDTO<PengXinBaseResp> rspInfo = RestfulInterface.baseProRun(baseUrlPath, ProtocolRespDTO<CmhiDisposeBaseResp> rspInfo = RestfulInterface.baseProRun(baseUrlPath,
token, token,
null, null,
PengXinBaseResp.class, CmhiDisposeBaseResp.class,
RequestMethod.GET); RequestMethod.GET);
if (rspInfo != null) { if (rspInfo != null && rspInfo.getMsgContent() != null) {
if (rspInfo.getCode() == HttpServletResponse.SC_UNAUTHORIZED) { if (rspInfo.getCode() == HttpServletResponse.SC_UNAUTHORIZED) {
return ErrorCode.ERR_LOGOUT; return ErrorCode.ERR_LOGOUT;
} }
@ -124,10 +123,10 @@ public class PengXinInterface {
* @param items the items * @param items the items
* @return the protocol resp dto * @return the protocol resp dto
*/ */
public ProtocolRespDTO<PengXinStartTaskRsp> startDisposeTask(String baseUrlPath, String token, public ProtocolRespDTO<CmhiDisposeStartTaskRsp> startDisposeTask(String baseUrlPath, String token,
List<PengXinStartTaskItem> items) { List<CmhiDisposeStartTaskItem> items) {
BaseProtocolDTO<PengXinStartTaskReq> reqInfo = new BaseProtocolDTO<>(); BaseProtocolDTO<CmhiDisposeStartTaskReq> reqInfo = new BaseProtocolDTO<>();
reqInfo.setMsgContent(new PengXinStartTaskReq()); reqInfo.setMsgContent(new CmhiDisposeStartTaskReq());
reqInfo.getMsgContent().setItems(items); reqInfo.getMsgContent().setItems(items);
reqInfo.setCryptoType(this.cryptoType); reqInfo.setCryptoType(this.cryptoType);
@ -137,7 +136,7 @@ public class PengXinInterface {
return RestfulInterface.baseProRun(baseUrlPath, return RestfulInterface.baseProRun(baseUrlPath,
token, token,
reqInfo, reqInfo,
PengXinStartTaskRsp.class, CmhiDisposeStartTaskRsp.class,
RequestMethod.POST); RequestMethod.POST);
} }
@ -149,10 +148,10 @@ public class PengXinInterface {
* @param taskId the task id * @param taskId the task id
* @return the protocol resp dto * @return the protocol resp dto
*/ */
public ProtocolRespDTO<PengXinStopTaskRsp> stopDisposeTask(String baseUrlPath, String token, String[] taskId) { public ProtocolRespDTO<CmhiDisposeStopTaskRsp> stopDisposeTask(String baseUrlPath, String token, String[] taskId) {
BaseProtocolDTO<PengXinStopTaskReq> reqInfo = new BaseProtocolDTO<>(); BaseProtocolDTO<CmhiDisposeStopTaskReq> reqInfo = new BaseProtocolDTO<>();
reqInfo.setMsgContent(new PengXinStopTaskReq()); reqInfo.setMsgContent(new CmhiDisposeStopTaskReq());
reqInfo.getMsgContent().setTaskId(taskId); reqInfo.getMsgContent().setTaskId(taskId);
reqInfo.setCryptoType(this.cryptoType); reqInfo.setCryptoType(this.cryptoType);
@ -162,7 +161,7 @@ public class PengXinInterface {
return RestfulInterface.baseProRun(baseUrlPath, return RestfulInterface.baseProRun(baseUrlPath,
token, token,
reqInfo, reqInfo,
PengXinStopTaskRsp.class, CmhiDisposeStopTaskRsp.class,
RequestMethod.POST); RequestMethod.POST);
} }
@ -173,11 +172,11 @@ public class PengXinInterface {
* @param token the token * @param token the token
* @return the device dispose ability * @return the device dispose ability
*/ */
public ProtocolRespDTO<PengXinDisposeAbilityRsp> getDeviceDisposeAbility(String baseUrlPath, String token) { public ProtocolRespDTO<CmhiDisposeAbilityRsp> getDeviceDisposeAbility(String baseUrlPath, String token) {
return RestfulInterface.baseProRun(baseUrlPath, return RestfulInterface.baseProRun(baseUrlPath,
token, token,
null, null,
PengXinDisposeAbilityRsp.class, CmhiDisposeAbilityRsp.class,
RequestMethod.GET); RequestMethod.GET);
} }
@ -189,10 +188,10 @@ public class PengXinInterface {
* @param taskId the task id * @param taskId the task id
* @return the device task status * @return the device task status
*/ */
public ProtocolRespDTO<PengXinTaskStatusRsp> getDeviceTaskStatus(String baseUrlPath, String token, String[] taskId) { public ProtocolRespDTO<CmhiDisposeTaskStatusRsp> getDeviceTaskStatus(String baseUrlPath, String token, String[] taskId) {
BaseProtocolDTO<PengXinStopTaskReq> reqInfo = new BaseProtocolDTO<>(); BaseProtocolDTO<CmhiDisposeStopTaskReq> reqInfo = new BaseProtocolDTO<>();
reqInfo.setMsgContent(new PengXinStopTaskReq()); reqInfo.setMsgContent(new CmhiDisposeStopTaskReq());
reqInfo.getMsgContent().setTaskId(taskId); reqInfo.getMsgContent().setTaskId(taskId);
reqInfo.setCryptoType(this.cryptoType); reqInfo.setCryptoType(this.cryptoType);
@ -202,7 +201,7 @@ public class PengXinInterface {
return RestfulInterface.baseProRun(baseUrlPath, return RestfulInterface.baseProRun(baseUrlPath,
token, token,
reqInfo, reqInfo,
PengXinTaskStatusRsp.class, CmhiDisposeTaskStatusRsp.class,
RequestMethod.POST); RequestMethod.POST);
} }
} }

View File

@ -5,6 +5,7 @@ import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan; import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration;
import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableAsync;
@ -16,7 +17,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
* *
* @author <huangxin@cmhi.chinamoblie.com> * @author <huangxin@cmhi.chinamoblie.com>
*/ */
@SpringBootApplication @SpringBootApplication(exclude = {KafkaAutoConfiguration.class})
@EnableAsync @EnableAsync
@EnableScheduling @EnableScheduling
@EnableAspectJAutoProxy @EnableAspectJAutoProxy

View File

@ -1,23 +1,26 @@
package com.dispose.ability.impl; package com.dispose.ability.impl;
import com.cmhi.dispose.common.CmhiDisposeAbilityRsp;
import com.cmhi.dispose.common.CmhiDisposeLoginRsp;
import com.cmhi.dispose.common.CmhiDisposeStartTaskItem;
import com.cmhi.dispose.common.CmhiDisposeStartTaskRsp;
import com.cmhi.dispose.common.CmhiDisposeStopTaskRsp;
import com.cmhi.dispose.common.CmhiDisposeTaskStatusRsp;
import com.cmhi.dispose.protocol.CmhiDisposeInterface;
import com.dispose.ability.DisposeAbility; import com.dispose.ability.DisposeAbility;
import com.dispose.common.CommonEnumHandler;
import com.dispose.common.DisposeCapacityType; import com.dispose.common.DisposeCapacityType;
import com.dispose.common.DisposeConfigValue; import com.dispose.common.DisposeConfigValue;
import com.dispose.common.DisposeObjectType; import com.dispose.common.DisposeObjectType;
import com.dispose.common.ErrorCode; import com.dispose.common.ErrorCode;
import com.dispose.common.Helper;
import com.dispose.common.IpAddrType;
import com.dispose.common.NetflowDirection; import com.dispose.common.NetflowDirection;
import com.dispose.pojo.dto.protocol.base.ProtocolRespDTO; import com.dispose.pojo.dto.protocol.base.ProtocolRespDTO;
import com.dispose.pojo.entity.ServiceInfo; import com.dispose.pojo.entity.ServiceInfo;
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.security.arithmetic.CryptoHelper; import inet.ipaddr.IPAddress;
import com.pengxin.dispose.common.PengXinLoginRsp; import inet.ipaddr.IPAddressString;
import com.pengxin.dispose.common.PengXinStartTaskItem;
import com.pengxin.dispose.common.PengXinStartTaskRsp;
import com.pengxin.dispose.common.PengXinStopTaskRsp;
import com.pengxin.dispose.common.PengXinTaskStatusRsp;
import com.pengxin.dispose.protocol.PengXinInterface;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -25,27 +28,28 @@ import lombok.extern.slf4j.Slf4j;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
/** /**
* The type Peng xin ability. * The type Peng xin ability.
* @author xajhu *
* @author <huangxin@cmhi.chinamoblie.com>
*/ */
@Slf4j @Slf4j
public class PengXinAbilityImpl implements DisposeAbility { public class CmhiAbilityImpl implements DisposeAbility {
/* /**
The Protect ip v 4. * The Protect ip v 4.
*/ */
//private final List<String> protectIpV4 = new ArrayList<>(); private final List<String> protectIpV4 = new ArrayList<>();
/* /**
The Protect ip v 6. * The Protect ip v 6.
*/ */
//private final List<String> protectIpV6 = new ArrayList<>(); private final List<String> protectIpV6 = new ArrayList<>();
/** /**
* The Restful interface. * The Restful interface.
*/ */
private final PengXinInterface restfulInterface = new PengXinInterface(); private final CmhiDisposeInterface restfulInterface = new CmhiDisposeInterface();
/** /**
* The Peng xin dispose type. * The Peng xin dispose type.
*/ */
@ -124,7 +128,7 @@ public class PengXinAbilityImpl implements DisposeAbility {
public void initDeviceEnv(String urlPath, String username, String password) { public void initDeviceEnv(String urlPath, String username, String password) {
this.urlRootPath = urlPath; this.urlRootPath = urlPath;
this.username = username; this.username = username;
this.password = new String(CryptoHelper.base64Decryption(password)); this.password = password;
restfulInterface.setParams(1, 0); restfulInterface.setParams(1, 0);
upgradeToken(); upgradeToken();
@ -147,31 +151,28 @@ public class PengXinAbilityImpl implements DisposeAbility {
@Nullable NetflowDirection nfDirection, @Nullable NetflowDirection nfDirection,
@Nullable Integer attackType, @Nullable Integer attackType,
@Nullable Long duration) { @Nullable Long duration) {
List<PengXinStartTaskItem> reqItems = new ArrayList<>(); List<CmhiDisposeStartTaskItem> reqItems = new ArrayList<>();
String url = urlRootPath + "dispose_device/task/start"; String url = urlRootPath + "dispose_device/task/start";
if (token == null || token.length() == 0) { if (token == null || token.length() == 0) {
upgradeToken();
return new MulReturnType<>(ErrorCode.ERR_LOGOUT, ""); return new MulReturnType<>(ErrorCode.ERR_LOGOUT, "");
} }
try { try {
log.info("++++Begging PengXin Start Cleanup Task: {}", disposeObject); log.info("++++Begging PengXin Start Cleanup Task: {}", disposeObject);
if (capType != DisposeCapacityType.BLACKHOOL) {
// 集团一键处置线上环境移除对处置能力检测操作 log.error("----Error PengXin don't support dispose capacity type: {}", capType);
// if (capType != DisposeCapacityType.BLACKHOOL) { return new MulReturnType<>(ErrorCode.ERR_UNSUPPORT, null);
// log.error("----Error PengXin don't support dispose capacity type: {}", capType); }
// return new MulReturnType<>(ErrorCode.ERR_UNSUPPORT, null);
// }
// 适配处置时间参数 -1为不限制处置时间 // 适配处置时间参数 -1为不限制处置时间
if (duration == null || duration < 0) { if (duration == null || duration < 0) {
duration = -1L; duration = -1L;
} }
reqItems.add(PengXinStartTaskItem.builder() reqItems.add(CmhiDisposeStartTaskItem.builder()
.type(getPengXinTaskType(capType)) .type(getPengXinTaskType(capType))
.disposeObject(disposeObject) .disposeObject(disposeObject)
.objectType(getPengXinObjectType(objectType)) .objectType(getPengXinObjectType(objectType))
@ -179,22 +180,16 @@ public class PengXinAbilityImpl implements DisposeAbility {
.taskReqId(String.valueOf(taskReqId++)) .taskReqId(String.valueOf(taskReqId++))
.build()); .build());
ProtocolRespDTO<PengXinStartTaskRsp> rspInfo = restfulInterface.startDisposeTask(url, token, reqItems); ProtocolRespDTO<CmhiDisposeStartTaskRsp> rspInfo = restfulInterface.startDisposeTask(url, token, reqItems);
ErrorCode err = verifyInterfaceResp(rspInfo); // 判断是否token过期
if (rspInfo != null && reLogin(rspInfo, rspInfo.getMsgContent().getItems().get(0).getStatus())) {
if (err != ErrorCode.ERR_OK) { rspInfo = restfulInterface.startDisposeTask(url, token, reqItems);
log.error("----Error PengXin start clean {} server return {}", disposeObject, err.getMsg());
return new MulReturnType<>(err, disposeObject);
} }
err = verifyRespStatus(rspInfo.getMsgContent().getItems().get(0).getStatus()); if (rspInfo == null || rspInfo.getCode() != ErrorCode.ERR_OK.getHttpCode()) {
log.error("----Error PengXin start clean {} server return error", disposeObject);
if (err != ErrorCode.ERR_OK) { return new MulReturnType<>(ErrorCode.ERR_PENGXIN_ERROR, null);
log.error("----Error PengXin start clean {} server return {}({})", disposeObject,
rspInfo.getMsgContent().getItems().get(0).getStatus(),
rspInfo.getMsgContent().getItems().get(0).getMessage());
return new MulReturnType<>(err, disposeObject);
} }
if (rspInfo.getMsgContent().getItems().size() == 0) { if (rspInfo.getMsgContent().getItems().size() == 0) {
@ -208,7 +203,7 @@ public class PengXinAbilityImpl implements DisposeAbility {
return new MulReturnType<>(ErrorCode.ERR_PENGXIN_ERROR, null); return new MulReturnType<>(ErrorCode.ERR_PENGXIN_ERROR, null);
} }
log.info("----Finish PengXin Start Cleanup Task: {}", disposeObject); log.debug("----Finish PengXin Start Cleanup Task: {}", disposeObject);
return new MulReturnType<>(ErrorCode.ERR_OK, rspInfo.getMsgContent().getItems().get(0).getTaskId()); return new MulReturnType<>(ErrorCode.ERR_OK, rspInfo.getMsgContent().getItems().get(0).getTaskId());
} }
} catch (Exception ex) { } catch (Exception ex) {
@ -235,7 +230,6 @@ public class PengXinAbilityImpl implements DisposeAbility {
String url = urlRootPath + "dispose_device/task/stop"; String url = urlRootPath + "dispose_device/task/stop";
if (token == null || token.length() == 0) { if (token == null || token.length() == 0) {
upgradeToken();
return new MulReturnType<>(ErrorCode.ERR_LOGOUT, null); return new MulReturnType<>(ErrorCode.ERR_LOGOUT, null);
} }
@ -251,21 +245,17 @@ public class PengXinAbilityImpl implements DisposeAbility {
return new MulReturnType<>(ErrorCode.ERR_PARAMS, null); return new MulReturnType<>(ErrorCode.ERR_PARAMS, null);
} }
ProtocolRespDTO<PengXinStopTaskRsp> rspInfo = restfulInterface.stopDisposeTask(url, token, ProtocolRespDTO<CmhiDisposeStopTaskRsp> rspInfo = restfulInterface.stopDisposeTask(url, token,
new String[]{taskId}); new String[]{taskId});
ErrorCode err = verifyInterfaceResp(rspInfo); // 判断是否token过期
if (rspInfo != null && reLogin(rspInfo, rspInfo.getMsgContent().getItems().get(0).getStatus())) {
if (err != ErrorCode.ERR_OK) { rspInfo = restfulInterface.stopDisposeTask(url, token, new String[]{taskId});
log.error("----Error PengXin start clean {} server return {}", taskId, err.getMsg());
return new MulReturnType<>(err, null);
} }
err = verifyRespStatus(rspInfo.getMsgContent().getItems().get(0).getStatus()); if (rspInfo == null || rspInfo.getCode() != ErrorCode.ERR_OK.getHttpCode()) {
log.error("----Error PengXin stop task{} server return error", taskId);
if (err != ErrorCode.ERR_OK) { return new MulReturnType<>(ErrorCode.ERR_CALLDEVICE, null);
log.error("----Error PengXin start clean {} server return {}", taskId, err.getMsg());
return new MulReturnType<>(err, null);
} }
if (rspInfo.getMsgContent().getItems().size() == 0) { if (rspInfo.getMsgContent().getItems().size() == 0) {
@ -279,7 +269,7 @@ public class PengXinAbilityImpl implements DisposeAbility {
return new MulReturnType<>(ErrorCode.ERR_PENGXIN_ERROR, null); return new MulReturnType<>(ErrorCode.ERR_PENGXIN_ERROR, null);
} }
log.info("----Finish PengXin Stop Cleanup Task: {}", taskId); log.debug("----Finish PengXin Stop Cleanup Task: {}", taskId);
return new MulReturnType<>(ErrorCode.ERR_OK, null); return new MulReturnType<>(ErrorCode.ERR_OK, null);
} }
} catch (Exception ex) { } catch (Exception ex) {
@ -335,9 +325,8 @@ public class PengXinAbilityImpl implements DisposeAbility {
* Dev get link status. * Dev get link status.
*/ */
private void devGetLinkStatus() { private void devGetLinkStatus() {
String url = urlRootPath + "dispose_device/information/linkstatus";
try { try {
String url = urlRootPath + "dispose_device/information/linkstatus";
if (token == null || token.length() == 0) { if (token == null || token.length() == 0) {
deviceLinkStatus = false; deviceLinkStatus = false;
@ -358,7 +347,7 @@ public class PengXinAbilityImpl implements DisposeAbility {
return; return;
} catch (Exception ex) { } catch (Exception ex) {
log.error("Exception: {}, {}", url, ex.getMessage()); log.error(ex.getMessage());
} }
deviceLinkStatus = false; deviceLinkStatus = false;
@ -369,59 +358,54 @@ public class PengXinAbilityImpl implements DisposeAbility {
*/ */
@Override @Override
public void getDisposeDeviceProtectObject() { public void getDisposeDeviceProtectObject() {
// 集团一键处置线上环境移除从设备获取能力信息相关接口调用
// if (token == null || token.length() == 0) { if (token == null || token.length() == 0) {
// return; return;
// } }
//
// String url = urlRootPath + "dispose_device/information/capacity"; try {
// String url = urlRootPath + "dispose_device/information/capacity";
// try {
// ProtocolRespDTO<PengXinDisposeAbilityRsp> rspInfo = restfulInterface.getDeviceDisposeAbility(url, token); ProtocolRespDTO<CmhiDisposeAbilityRsp> rspInfo = restfulInterface.getDeviceDisposeAbility(url, token);
//
// ErrorCode err = verifyInterfaceResp(rspInfo); // 判断是否token过期
// if (rspInfo != null && reLogin(rspInfo, rspInfo.getMsgContent().getStatus())) {
// if (err != ErrorCode.ERR_OK) { rspInfo = restfulInterface.getDeviceDisposeAbility(url, token);
// log.error("----Error PengXin get dispose device protect object server {} return {}", url, token); }
// return;
// } if (rspInfo != null && rspInfo.getCode() == ErrorCode.ERR_OK.getHttpCode()
// && rspInfo.getMsgContent().getStatus() == ErrorCode.ERR_OK.getCode()) {
// err = verifyRespStatus(rspInfo.getMsgContent().getStatus());
// rspInfo.getMsgContent().getCapacity().forEach(v -> {
// if (err != ErrorCode.ERR_OK) { if (v.getObjectType().equals(DisposeObjectType.DOMAIN.getValue())) {
// log.error("---Error PengXin get dispose device protect object server {} return {}", url, err.getMsg()); log.error("Unsupported: {}", v.getObjectType());
// return; } else if (v.getObjectType().equals(DisposeObjectType.URL.getValue())) {
// } log.error("Unsupported: {}", v.getObjectType());
// } else {
// rspInfo.getMsgContent().getCapacity().forEach(v -> { synchronized (this) {
// if (v.getObjectType().equals(DisposeObjectType.DOMAIN.getValue())) {
// log.error("Unsupported: {}", v.getObjectType()); protectIpV4.clear();
// } else if (v.getObjectType().equals(DisposeObjectType.URL.getValue())) { protectIpV6.clear();
// log.error("Unsupported: {}", v.getObjectType());
// } else { if (v.getIpType() == null || v.getIpType().equals(IpAddrType.IPV4_IPV6.getValue())) {
// synchronized (this) { String [] allIpAddr = {null, "0.0.0.0", "0.0.0.0,::"};
//
// protectIpV4.clear(); if(Arrays.asList(allIpAddr).contains(v.getDisposeIp())) {
// protectIpV6.clear(); protectIpV4.add("");
// protectIpV6.add("");
// if (v.getIpType() == null || v.getIpType().equals(IpAddrType.IPV4_IPV6.getValue())) { }
// String [] allIpAddr = {null, "0.0.0.0", "0.0.0.0,::"}; } else if (v.getIpType().equals(IpAddrType.IPV4.getValue())) {
// protectIpV4.add("");
// if(Arrays.asList(allIpAddr).contains(v.getDisposeIp())) { } else if (v.getIpType().equals(IpAddrType.IPV6.getValue())) {
// protectIpV4.add(""); protectIpV6.add("");
// protectIpV6.add(""); }
// } }
// } else if (v.getIpType().equals(IpAddrType.IPV4.getValue())) { }
// protectIpV4.add(""); });
// } else if (v.getIpType().equals(IpAddrType.IPV6.getValue())) {
// protectIpV6.add(""); }
// } } catch (Exception ignored) {
// } }
// }
// });
// } catch (Exception ex) {
// log.error("server {}({}) exception: {}", url, token, ex);
// }
} }
/** /**
@ -432,36 +416,34 @@ public class PengXinAbilityImpl implements DisposeAbility {
*/ */
@Override @Override
public boolean isCarryProtectIp(String ipAddr) { public boolean isCarryProtectIp(String ipAddr) {
// 集团一键处置线上环境默认支持所有IP地址 boolean ret = false;
return true; IPAddress addr = new IPAddressString(ipAddr).getAddress();
// boolean ret = false; synchronized (this) {
// IPAddress addr = new IPAddressString(ipAddr).getAddress(); if (addr.isIPv4()) {
// synchronized (this) { ret = protectIpV4.stream().anyMatch(v -> Helper.ipInRange(v, ipAddr));
// if (addr.isIPv4()) { }
// ret = protectIpV4.stream().anyMatch(v -> Helper.ipInRange(v, ipAddr));
// } if (addr.isIPv6()) {
// ret = protectIpV6.stream().anyMatch(v -> Helper.ipInRange(v, ipAddr));
// if (addr.isIPv6()) { }
// ret = protectIpV6.stream().anyMatch(v -> Helper.ipInRange(v, ipAddr)); }
// }
// } if (!ret) {
// // 更新设备防护IP
// if (!ret) { getDisposeDeviceProtectObject();
// // 更新设备防护IP
// getDisposeDeviceProtectObject(); synchronized (this) {
// if (addr.isIPv4()) {
// synchronized (this) { ret = protectIpV4.stream().anyMatch(v -> Helper.ipInRange(v, ipAddr));
// if (addr.isIPv4()) { }
// ret = protectIpV4.stream().anyMatch(v -> Helper.ipInRange(v, ipAddr));
// } if (addr.isIPv6()) {
// ret = protectIpV6.stream().anyMatch(v -> Helper.ipInRange(v, ipAddr));
// if (addr.isIPv6()) { }
// ret = protectIpV6.stream().anyMatch(v -> Helper.ipInRange(v, ipAddr)); }
// } }
// }
// } return ret;
//
// return ret;
} }
/** /**
@ -473,35 +455,32 @@ public class PengXinAbilityImpl implements DisposeAbility {
@Override @Override
public MulReturnType<ErrorCode, Long> taskStatus(String taskId) { public MulReturnType<ErrorCode, Long> taskStatus(String taskId) {
if (token == null || token.length() == 0) { if (token == null || token.length() == 0) {
upgradeToken();
return new MulReturnType<>(ErrorCode.ERR_LOGOUT, -1L); return new MulReturnType<>(ErrorCode.ERR_LOGOUT, -1L);
} }
try { try {
String url = urlRootPath + "dispose_device/task/get"; String url = urlRootPath + "dispose_device/task/get";
ProtocolRespDTO<PengXinTaskStatusRsp> rspInfo = restfulInterface.getDeviceTaskStatus(url, token, ProtocolRespDTO<CmhiDisposeTaskStatusRsp> rspInfo = restfulInterface.getDeviceTaskStatus(url, token,
new String[]{taskId}); new String[]{taskId});
ErrorCode err = verifyInterfaceResp(rspInfo); // 判断是否token过期
if (rspInfo != null && reLogin(rspInfo, rspInfo.getMsgContent().getItems().get(0).getStatus())) {
if (err != ErrorCode.ERR_OK) { rspInfo = restfulInterface.getDeviceTaskStatus(url, token, new String[]{taskId});
log.error("----Error PengXin start clean {} server return {}", taskId, err.getMsg());
return new MulReturnType<>(err, -1L);
} }
err = verifyRespStatus(rspInfo.getMsgContent().getItems().get(0).getStatus()); if (rspInfo != null && rspInfo.getCode() == ErrorCode.ERR_OK.getHttpCode()) {
if (err != ErrorCode.ERR_OK) { int errCode = rspInfo.getMsgContent().getItems().get(0).getStatus();
log.error("----Error PengXin start clean {} server return {}", taskId, err.getMsg()); if (rspInfo.getMsgContent().getItems().size() == 0 || errCode != ErrorCode.ERR_OK.getCode()) {
return new MulReturnType<>(err, -1L); return new MulReturnType<>(ErrorCode.ERR_NOSUCHTASK, -1L);
}
return new MulReturnType<>(ErrorCode.ERR_OK,
rspInfo.getMsgContent().getItems().get(0).getTaskStatus());
} else {
return new MulReturnType<>(ErrorCode.ERR_CALLDEVICE, -1L);
} }
if (rspInfo.getMsgContent().getItems().size() == 0) {
return new MulReturnType<>(ErrorCode.ERR_NOSUCHTASK, -1L);
}
return new MulReturnType<>(ErrorCode.ERR_OK, rspInfo.getMsgContent().getItems().get(0).getTaskStatus());
} catch (Exception ignored) { } catch (Exception ignored) {
return new MulReturnType<>(ErrorCode.ERR_SYSTEMEXCEPTION, -1L); return new MulReturnType<>(ErrorCode.ERR_SYSTEMEXCEPTION, -1L);
} }
@ -511,71 +490,41 @@ public class PengXinAbilityImpl implements DisposeAbility {
* Upgrade token. * Upgrade token.
*/ */
private void upgradeToken() { private void upgradeToken() {
String url = urlRootPath + "dispose_device/auth/login";
try { try {
ProtocolRespDTO<PengXinLoginRsp> logInfo = restfulInterface.login(url, username, password); String url = urlRootPath + "dispose_device/auth/login";
ProtocolRespDTO<CmhiDisposeLoginRsp> logInfo = restfulInterface.login(url, username, password);
if (logInfo != null && logInfo.getMsgContent().getStatus() == ErrorCode.ERR_OK.getCode()) { if (logInfo != null && logInfo.getMsgContent().getStatus() == ErrorCode.ERR_OK.getCode()) {
this.token = logInfo.getMsgContent().getToken(); this.token = logInfo.getMsgContent().getToken();
} }
} catch (Exception ex) {
log.error("Exception: {}, {}", url, ex.getMessage());
}
}
/**
* Verify interface resp error code.
*
* @param <T> the type parameter
* @param rspInfo the rsp info
* @return the error code
*/
private <T> ErrorCode verifyInterfaceResp(ProtocolRespDTO<T> rspInfo) {
if (rspInfo == null) {
return ErrorCode.ERR_PENGXIN_ERROR;
} else if (rspInfo.getCode() == HttpServletResponse.SC_UNAUTHORIZED) {
upgradeToken();
return ErrorCode.ERR_TOKENTIMEOUT;
} else if (rspInfo.getCode() != HttpServletResponse.SC_OK) {
return ErrorCode.ERR_PENGXIN_ERROR;
}
if (rspInfo.getMsgContent() == null) {
return ErrorCode.ERR_PARAMS;
}
return ErrorCode.ERR_OK;
}
/**
* Verify resp status error code.
*
* @param status the status
* @return the error code
*/
private ErrorCode verifyRespStatus(int status) {
if (status == ErrorCode.ERR_LOGOUT.getCode()
|| status == ErrorCode.ERR_TOKENTIMEOUT.getCode()
|| status == ErrorCode.ERR_TOKENNOTFOUND.getCode()) {
upgradeToken();
return ErrorCode.ERR_TOKENTIMEOUT;
}
try {
ErrorCode err = CommonEnumHandler.codeOf(ErrorCode.class, status);
if (err == null) {
return ErrorCode.ERR_CALLDEVICE;
} else {
return err;
}
} catch (Exception ignored) { } catch (Exception ignored) {
if (status == ErrorCode.ERR_OK.getCode()) { }
return ErrorCode.ERR_OK; }
} else {
return ErrorCode.ERR_CALLDEVICE; /**
* reLogin.
*/
private <T> boolean reLogin(ProtocolRespDTO<T> rspInfo, int status) {
try {
// 判断是否token过期
if (rspInfo.getCode() == HttpServletResponse.SC_UNAUTHORIZED) {
// 重新登录获取 token
upgradeToken();
return true;
} }
if (rspInfo.getCode() == HttpServletResponse.SC_OK) {
if (status == ErrorCode.ERR_LOGOUT.getCode() ||
status == ErrorCode.ERR_TOKENTIMEOUT.getCode() ||
status == ErrorCode.ERR_TOKENNOTFOUND.getCode()) {
upgradeToken();
return true;
}
}
return false;
} catch (Exception ignored) {
return false;
} }
} }
@ -584,14 +533,17 @@ public class PengXinAbilityImpl implements DisposeAbility {
*/ */
@Override @Override
public void periodTaskRuntime() { public void periodTaskRuntime() {
// 集团一键处置线上环境不再定时获取设备能力信息 log.debug("++++PengXin Period Task Running");
// 更新防护对象 // 更新防护对象
//getDisposeDeviceProtectObject(); getDisposeDeviceProtectObject();
// 更新心跳状态 // 更新心跳状态
if (timerCnt++ % DisposeConfigValue.HEART_PERIOD_OF_SECOND == 0) { if (timerCnt++ % DisposeConfigValue.HEART_PERIOD_OF_SECOND == 0) {
devGetLinkStatus(); devGetLinkStatus();
} }
log.debug("----PengXin Period Task Running");
} }
/** /**

View File

@ -14,7 +14,6 @@ import com.dispose.common.NetflowDirection;
import com.dispose.pojo.entity.ServiceInfo; import com.dispose.pojo.entity.ServiceInfo;
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.security.arithmetic.CryptoHelper;
import com.dptech.dispose.AbnormalFlowCleaningServicePortType; import com.dptech.dispose.AbnormalFlowCleaningServicePortType;
import com.dptech.dispose.ArrayOfProtectionObjectDataForService; import com.dptech.dispose.ArrayOfProtectionObjectDataForService;
import com.dptech.dispose.NtcRequestResultInfo; import com.dptech.dispose.NtcRequestResultInfo;
@ -102,7 +101,7 @@ public class DpTechAbilityImpl implements DisposeAbility {
this.cleanTypePort = (AbnormalFlowCleaningServicePortType) jaxWsProxyFactoryBean.create(); this.cleanTypePort = (AbnormalFlowCleaningServicePortType) jaxWsProxyFactoryBean.create();
Map<String, Object> ctx = ((BindingProvider) this.cleanTypePort).getRequestContext(); Map<String, Object> ctx = ((BindingProvider) this.cleanTypePort).getRequestContext();
ctx.put("password", new String(CryptoHelper.base64Decryption(password))); ctx.put("password", password);
ctx.put("username", username); ctx.put("username", username);
// 配置连接访问超时时间 // 配置连接访问超时时间

View File

@ -10,7 +10,6 @@ import com.dispose.common.NetflowDirection;
import com.dispose.pojo.entity.ServiceInfo; import com.dispose.pojo.entity.ServiceInfo;
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.security.arithmetic.CryptoHelper;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.huawei.dispose.common.HuaWeiLoginResp; import com.huawei.dispose.common.HuaWeiLoginResp;
import com.huawei.dispose.protocol.HuaWeiInterface; import com.huawei.dispose.protocol.HuaWeiInterface;
@ -86,7 +85,7 @@ public class HuaWeiAbilityImpl implements DisposeAbility {
public void initDeviceEnv(String urlPath, String username, String password) { public void initDeviceEnv(String urlPath, String username, String password) {
this.urlRootPath = urlPath; this.urlRootPath = urlPath;
this.username = username; this.username = username;
this.password = new String(CryptoHelper.base64Decryption(password)); this.password = password;
upgradeToken(); upgradeToken();
} }

View File

@ -85,7 +85,7 @@ public class HuaWeiFireWallAbilityImpl implements DisposeAbility {
public void initDeviceEnv(String urlPath, String username, String password) { public void initDeviceEnv(String urlPath, String username, String password) {
this.urlRootPath = urlPath; this.urlRootPath = urlPath;
this.username = username; this.username = username;
this.password = new String(CryptoHelper.base64Decryption(password)); this.password = password;
upgradeToken(); upgradeToken();
} }

View File

@ -1,5 +1,10 @@
package com.dispose.ability.impl; package com.dispose.ability.impl;
import com.cmhi.dispose.common.CmhiDisposeStartTaskItem;
import com.cmhi.dispose.common.CmhiDisposeStartTaskRsp;
import com.cmhi.dispose.common.CmhiDisposeStopTaskRsp;
import com.cmhi.dispose.common.CmhiDisposeTaskStatusRsp;
import com.cmhi.dispose.protocol.CmhiDisposeInterface;
import com.dispose.common.DisposeCapacityType; import com.dispose.common.DisposeCapacityType;
import com.dispose.common.DisposeObjectType; import com.dispose.common.DisposeObjectType;
import com.dispose.common.ErrorCode; import com.dispose.common.ErrorCode;
@ -8,12 +13,6 @@ import com.dispose.pojo.dto.protocol.base.ProtocolRespDTO;
import com.dispose.pojo.entity.ServiceInfo; import com.dispose.pojo.entity.ServiceInfo;
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.security.arithmetic.CryptoHelper;
import com.pengxin.dispose.common.PengXinStartTaskItem;
import com.pengxin.dispose.common.PengXinStartTaskRsp;
import com.pengxin.dispose.common.PengXinStopTaskRsp;
import com.pengxin.dispose.common.PengXinTaskStatusRsp;
import com.pengxin.dispose.protocol.PengXinInterface;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -29,11 +28,11 @@ import java.util.List;
* @author Nicole * @author Nicole
*/ */
@Slf4j @Slf4j
public class UpfAbilityImpl extends PengXinAbilityImpl { public class UpfAbilityImpl extends CmhiAbilityImpl {
/** /**
* The Restful interface. * The Restful interface.
*/ */
private final PengXinInterface restfulInterface = new PengXinInterface(); private final CmhiDisposeInterface restfulInterface = new CmhiDisposeInterface();
/** /**
* The upf dispose type. * The upf dispose type.
*/ */
@ -103,7 +102,7 @@ public class UpfAbilityImpl extends PengXinAbilityImpl {
public void initDeviceEnv(String urlPath, String username, String password) { public void initDeviceEnv(String urlPath, String username, String password) {
this.urlRootPath = urlPath; this.urlRootPath = urlPath;
this.username = username; this.username = username;
this.password = new String(CryptoHelper.base64Decryption(password)); this.password = password;
restfulInterface.setParams(1, 0); restfulInterface.setParams(1, 0);
//获取token值 //获取token值
upgradeToken(); upgradeToken();
@ -126,7 +125,7 @@ public class UpfAbilityImpl extends PengXinAbilityImpl {
@Nullable NetflowDirection nfDirection, @Nullable NetflowDirection nfDirection,
@Nullable Integer attackType, @Nullable Integer attackType,
@Nullable Long duration) { @Nullable Long duration) {
List<PengXinStartTaskItem> reqItems = new ArrayList<>(); List<CmhiDisposeStartTaskItem> reqItems = new ArrayList<>();
String url = urlRootPath + "dispose_device/task/start"; String url = urlRootPath + "dispose_device/task/start";
//1.调用upf设备登录接口生成token值2.upf不提供登录接口随机生成token值保证有token值 //1.调用upf设备登录接口生成token值2.upf不提供登录接口随机生成token值保证有token值
if (token == null || token.length() == 0) { if (token == null || token.length() == 0) {
@ -143,7 +142,7 @@ public class UpfAbilityImpl extends PengXinAbilityImpl {
// 适配处置时间参数 -1为不限制处置时间 // 适配处置时间参数 -1为不限制处置时间
duration = -1L; duration = -1L;
reqItems.add(PengXinStartTaskItem.builder() reqItems.add(CmhiDisposeStartTaskItem.builder()
.type(getUpfTaskType(capType)) .type(getUpfTaskType(capType))
.disposeObject(disposeObject) .disposeObject(disposeObject)
.objectType(getUpfObjectType(objectType)) .objectType(getUpfObjectType(objectType))
@ -151,7 +150,7 @@ public class UpfAbilityImpl extends PengXinAbilityImpl {
.taskReqId(String.valueOf(taskReqId++)) .taskReqId(String.valueOf(taskReqId++))
.build()); .build());
ProtocolRespDTO<PengXinStartTaskRsp> rspInfo = restfulInterface.startDisposeTask(url, token, reqItems); ProtocolRespDTO<CmhiDisposeStartTaskRsp> rspInfo = restfulInterface.startDisposeTask(url, token, reqItems);
// upf设备不判断header认证消息中的token值 // upf设备不判断header认证消息中的token值
if (rspInfo == null || rspInfo.getCode() != ErrorCode.ERR_OK.getHttpCode()) { if (rspInfo == null || rspInfo.getCode() != ErrorCode.ERR_OK.getHttpCode()) {
@ -210,8 +209,8 @@ public class UpfAbilityImpl extends PengXinAbilityImpl {
return new MulReturnType<>(ErrorCode.ERR_PARAMS, null); return new MulReturnType<>(ErrorCode.ERR_PARAMS, null);
} }
ProtocolRespDTO<PengXinStopTaskRsp> rspInfo = restfulInterface.stopDisposeTask(url, token, ProtocolRespDTO<CmhiDisposeStopTaskRsp> rspInfo = restfulInterface.stopDisposeTask(url, token,
new String[]{taskId}); new String[]{taskId});
if (rspInfo == null || rspInfo.getCode() != ErrorCode.ERR_OK.getHttpCode()) { if (rspInfo == null || rspInfo.getCode() != ErrorCode.ERR_OK.getHttpCode()) {
log.error("----Error UPF stop task{} server return error", taskId); log.error("----Error UPF stop task{} server return error", taskId);
@ -316,8 +315,8 @@ public class UpfAbilityImpl extends PengXinAbilityImpl {
try { try {
String url = urlRootPath + "dispose_device/task/get"; String url = urlRootPath + "dispose_device/task/get";
ProtocolRespDTO<PengXinTaskStatusRsp> rspInfo = restfulInterface.getDeviceTaskStatus(url, token, ProtocolRespDTO<CmhiDisposeTaskStatusRsp> rspInfo = restfulInterface.getDeviceTaskStatus(url, token,
new String[]{taskId}); new String[]{taskId});
if (rspInfo != null && rspInfo.getCode() == ErrorCode.ERR_OK.getHttpCode()) { if (rspInfo != null && rspInfo.getCode() == ErrorCode.ERR_OK.getHttpCode()) {
int errCode = rspInfo.getMsgContent().getItems().get(0).getStatus(); int errCode = rspInfo.getMsgContent().getItems().get(0).getStatus();

View File

@ -0,0 +1,112 @@
package com.dispose.common;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/**
* The emos constants.
*
* @author <chenling@cmhi.chinamoblie.com>
*/
public class Constants {
/**
* DDoS具体攻击类型
*/
public static final Map<String, String> ATTACK_TYPE;
static {
Map<String, String> attTypeMap = new HashMap<>();
attTypeMap.put("hosttotaltraffic", "Host total traffic|1|2");
attTypeMap.put("RSTFlood", "RST Flood|3|4");
attTypeMap.put("SYNFlood", "SYN Flood|5|6");
attTypeMap.put("ACKFlood", "ACK Flood|7|8");
attTypeMap.put("TCPnullFlood", "TCP null|9|10");
attTypeMap.put("SYNACKAmplification", "SYN/ACK Amplification|11|12");
attTypeMap.put("tcpmisuse", "TCP Misuse|13|14");
attTypeMap.put("FINFlood", "FIN Flood|15|16");
attTypeMap.put("TCPFragment", "TCP Fragment|17|18");
attTypeMap.put("HTTPFlood", "HTTP Flood|19|20");
attTypeMap.put("HTTPSFlood", "HTTPS Flood|21|22");
attTypeMap.put("SIPFlood", "SIP Flood|23|24");
attTypeMap.put("DNS", "DNS|25|26");
attTypeMap.put("UDPFragment", "UDP Fragment|27|28");
attTypeMap.put("chargenAmplification", "chargen Amplification|29|30");
attTypeMap.put("L2TPAmplification", "L2TP Amplification|31|32");
attTypeMap.put("mDNSAmplification", "mDNS Amplification|33|34");
attTypeMap.put("MSSQLRSAmplification", "MS SQL RS Amplification|35|36");
attTypeMap.put("NetBIOSAmplification", "NetBIOS Amplification|37|38");
attTypeMap.put("NTPAmplification", "NTP Amplification|39|40");
attTypeMap.put("RIPv1Amplification", "RIPv1 Amplification|41|42");
attTypeMap.put("rpcbindAmplification", "rpcbind Amplification|43|44");
attTypeMap.put("SNMPAmplification", "SNMP Amplification|45|46");
attTypeMap.put("SSDPAmplification", "SSDP Amplification|47|48");
attTypeMap.put("DNSAmplification", "DNS Amplification|49|50");
attTypeMap.put("QOTDAmplification", "QOTD Amplification|51|52");
attTypeMap.put("Quake3Amplification", "Quake3 Amplification|53|54");
attTypeMap.put("SteamAmplification", "Steam Amplification|55|56");
attTypeMap.put("CLADPAmplification", "CLADP Amplification|57|58");
attTypeMap.put("MemcacheAmplification", "Memcache Amplification|59|60");
attTypeMap.put("UDPFlood", "UDP Flood|61|62");
attTypeMap.put("smurf", "Smurf|63|64");
attTypeMap.put("icmpfrgment", "ICMP Fragment|65|66");
attTypeMap.put("ICMPFlood", "ICMP Flood|67|68");
attTypeMap.put("IPv4Protocol0", "IPv4 Protocol 0|69|70");
attTypeMap.put("IPPrivate", "IP Private|71|72");
attTypeMap.put("landflood", "Land flood|73|74");
attTypeMap.put("IGMPFlood", "IGMP Flood|75|76");
ATTACK_TYPE = Collections.unmodifiableMap(attTypeMap);
}
/**
* 各省份城市
*/
public static final String REGION_BEIJING = "北京";
public static final String REGION_SHANGHAI = "上海";
public static final String REGION_TIANJIN = "天津";
public static final String REGION_CHONGQING = "重庆";
/**
* 处置类型(1:清洗,2:黑洞,3:高防)
*/
public static final int CLEANUP = 1;
public static final int BLACKHOOL = 2;
public static final int HIDEPEND = 3;
/**
* 派单eoms模板
*/
public static final String DISPATCH_TEMPLATE = "<AlarmStart>\nMsgSerial:{0}\nSDN:{1}\nNeName:{2}\nEquipmentClass:99236\n" +
"AlarmUniqueId:{3}\nAlarmUniqueClearId:{4}\nLocateNeName:{5}\nLocateNeType:99236\nLocateNeSDN:{6}\nLocateInfo:{7}\n" +
"EventTime:{8}\nCancelTime:{9}\nVendorAlarmType:{10}\nVendorSeverity:{11}\nVendorAlarmId:{12}\nAlarmTitle:{13}\n" +
"ProbableCauseTxt:{14}\nRLocateSDN: \nRLocateNeName: \nRLocateNeType: \nRate: \nAlarmLocation: \nAlarmCheck: \n" +
"HolderType: \nAlarmStatus:{15}\nCorrelateAlarmFlag: \nAlarmActCount: \nNeIp:\nEmsId: \nVendor:99083\nAlarmText:{16}\n" +
"NeAlias: \nVersion: \nRemoteNe: \nAlarmProvince:{17}\nAlarmRegion:{18}\nAlarmCounty: \nSite: \nSiteType: \nSiteProperty: \n" +
"MachineroomIDofZGTT: \nBusinessSystem:{19}\nCircuitNo: \nMac: \nSpecialty:9\nNetworkType:903\nNeSubType: \nEffectCircuitNum: \n" +
"CircuitLevel: \nAlarmSeverity:3\nNmsAlarmId:0903-083-056-10-900001\nStandardAlarmName:{20}\nAlarmLogicClass:{21}\n" +
"AlarmLogicSubClass:{22}\nEffectOnEquipment:5\nEffectOnBusiness:4\nNmsAlarmType:1\nSendGroupFlag: \nStandardFlag:2\n" +
"AlarmExplanation:{23}\nBusinessType: \nBusinessInfo:{24}\nIsRelatedRemote: \nLocateNeStatus:1300\nProjectNo: \n" +
"ProjectName: \nProjectStartTime: \nProjectEndTime: \nGroupCustomer: \nCustomerLevel: \nServiceType: \nServiceLevel: \n" +
"ServiceName: \nServiceCrossDomainType: \nInterruptCircuitState: \nCircuitLocateInfo: \nHomeClientNum: \nHomeCellNum: \n" +
"LinkOnuNum: \n<AlarmEnd>";
/**
* 0网元自动清除 --收到从采集源发送的清除告警
*/
public static final int NE_AUTO_CLEARED_STATUS = 0;
/**
* 1活动告警---告警当前为活动状态
*/
public static final int ACTIVE_ALARM_STATUS = 1;
/**
* 2同步清除---已采集活动告警但采集平台从告警源同步时发现已经没有对应的活动告警由采集平台产生的清除告警
*/
public static final int SYNCHRONIZATION_CLEAR_STATUS = 2;
}

View File

@ -17,7 +17,7 @@ public enum DisposeDeviceType implements BaseEnum {
/** /**
* The Pengxin platform. * The Pengxin platform.
*/ */
PENGXIN_PLATFORM(2, "鹏信处置设备"), CMHI_PLATFORM(2, "集团一键处置设备"),
/** /**
* The Huawei platform. * The Huawei platform.
*/ */

View File

@ -293,6 +293,10 @@ public enum ErrorCode implements BaseEnum {
* The Err huawei firewall error. * The Err huawei firewall error.
*/ */
ERR_HUAWEIFIREWALL_ERROR(305, "华为防火墙返回错误"), ERR_HUAWEIFIREWALL_ERROR(305, "华为防火墙返回错误"),
/**
* The Err emos create message error.
*/
EMOS_CREATEMESSAGE_ERROR(306, "EMOS发送信息错误"),
; ;
/** /**

View File

@ -0,0 +1,111 @@
package com.dispose.config;
import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.producer.ProducerConfig;
import org.apache.kafka.common.serialization.StringSerializer;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.kafka.annotation.EnableKafka;
import org.springframework.kafka.core.DefaultKafkaProducerFactory;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.kafka.core.ProducerFactory;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
/**
* The type Kafka configuration.
*
* @author <huangxin@cmhi.chinamoblie.com>
*/
@EnableKafka
@ConfigurationProperties(prefix = "kafka")
@Configuration
@Component
@Slf4j
public class KafkaConfiguration {
/**
* The Producer servers.
*/
@Value("${kafka.producer.servers}")
private String producerServers;
/**
* The Producer retries.
*/
@Value("${kafka.producer.retries}")
private Integer producerRetries;
/**
* The Producer batch size.
*/
@Value("${kafka.producer.batch.size}")
private Integer producerBatchSize;
/**
* The Producer linger.
*/
@Value("${kafka.producer.linger}")
private Integer producerLinger;
/**
* The Buffer memory.
*/
@Value("${kafka.producer.buffer.memory}")
private Integer bufferMemory;
/**
* The Kafka topic.
*/
@Value("${kafka.dispose.topic}")
private String kafkaTopic;
/**
* Producer configs map.
*
* @return the map
*/
public Map<String, Object> producerConfigs() {
Map<String, Object> props = new HashMap<>(1);
log.info("-----------------servers---------: {}", producerServers);
props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, producerServers);
props.put(ProducerConfig.RETRIES_CONFIG, producerRetries);
props.put(ProducerConfig.BATCH_SIZE_CONFIG, producerBatchSize);
props.put(ProducerConfig.LINGER_MS_CONFIG, producerLinger);
props.put(ProducerConfig.BUFFER_MEMORY_CONFIG, bufferMemory);
props.put(ProducerConfig.RECONNECT_BACKOFF_MS_CONFIG, 5000);
props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
return props;
}
/**
* Gets kafka topic.
*
* @return the kafka topic
*/
public String getKafkaTopic() {
return kafkaTopic;
}
/**
* Producer factory producer factory.
*
* @return the producer factory
*/
public ProducerFactory<String, String> producerFactory() {
return new DefaultKafkaProducerFactory<>(producerConfigs());
}
/**
* Kafka template kafka template.
*
* @return the kafka template
*/
@Bean
public KafkaTemplate<String, String> kafkaTemplate() {
KafkaTemplate<String, String> kafkaTemplate = new KafkaTemplate<>(producerFactory());
kafkaTemplate.setDefaultTopic(kafkaTopic);
return kafkaTemplate;
}
}

View File

@ -0,0 +1,30 @@
package com.dispose.config;
import io.undertow.server.DefaultByteBufferPool;
import io.undertow.websockets.jsr.WebSocketDeploymentInfo;
import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.stereotype.Component;
/**
* The type Undertow pool customizer.
*
* @author <huangxin@cmhi.chinamoblie.com>
*/
@Component
public class UndertowPoolCustomizer implements WebServerFactoryCustomizer<UndertowServletWebServerFactory> {
/**
* Customize.
*
* @param factory the factory
*/
@Override
public void customize(UndertowServletWebServerFactory factory) {
factory.addDeploymentInfoCustomizers(deploymentInfo -> {
WebSocketDeploymentInfo webSocketDeploymentInfo = new WebSocketDeploymentInfo();
webSocketDeploymentInfo.setBuffers(new DefaultByteBufferPool(false, 1024));
deploymentInfo.addServletContextAttribute("io.undertow.websockets.jsr.WebSocketDeploymentInfo", webSocketDeploymentInfo);
});
}
}

View File

@ -0,0 +1,252 @@
package com.dispose.controller;
import com.alibaba.fastjson.JSONObject;
import com.dispose.common.Constants;
import com.dispose.common.ErrorCode;
import com.dispose.config.KafkaConfiguration;
import com.dispose.manager.AlarmInfoManager;
import com.dispose.pojo.dto.protocol.base.BaseRespStatus;
import com.dispose.pojo.dto.protocol.base.ProtocolReqDTO;
import com.dispose.pojo.dto.protocol.base.ProtocolRespDTO;
import com.dispose.pojo.dto.protocol.kafka.AlarmInfoReq;
import com.dispose.pojo.dto.protocol.kafka.EmosAlarmInfo;
import com.dispose.pojo.entity.AlarmInformation;
import com.dispose.pojo.po.MulReturnType;
import com.dispose.security.annotation.Decryption;
import com.dispose.security.annotation.Encryption;
import com.dispose.service.MsgSerialService;
import com.dispose.validation.group.ValidGroups;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.springframework.kafka.support.SendResult;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.util.concurrent.ListenableFuture;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.text.MessageFormat;
import java.util.Objects;
/**
* The type Auth controller.
*
* @author <chenling@cmhi.chinamoblie.com>
*/
@Controller
@RequestMapping(value = "/kafka")
@Slf4j
@Api(value = "处置平台发送消息接口", tags = "处置平台发送消息接口")
@Component
@Validated
@Encryption
@Decryption
public class KafkaController {
/**
* The Kafka configuration.
*/
@Resource
private KafkaConfiguration kafkaConfiguration;
/**
* The message serial service.
*/
@Resource
private MsgSerialService msgSerialService;
/**
* The alarm information manager.
*/
@Resource
private AlarmInfoManager alarmInfoManager;
/**
* Dispatch command sent to kafka.
*
* @param mr the mr
* @return the protocol resp dto
*/
@PostMapping("/dispatchCommand")
@ResponseBody
@ApiOperation("发送消息")
public ProtocolRespDTO<BaseRespStatus> dispatchCommand(
@Validated(ValidGroups.ProtocolCommonValid.class)
@RequestBody ProtocolReqDTO<AlarmInfoReq> mr) {
//获取入参信息
BaseRespStatus rspInfo = new BaseRespStatus();
log.info("emos alarm is:{}", mr.getMsgContent().getAlarmInfo());
EmosAlarmInfo alarmInfo = JSONObject.parseObject(mr.getMsgContent().getAlarmInfo(), EmosAlarmInfo.class);
//拼接emos据格式
String content = createSendContent(alarmInfo);
if (content == null) {
rspInfo.setStatus(ErrorCode.EMOS_CREATEMESSAGE_ERROR.getCode());
rspInfo.setMessage(new String[]{ErrorCode.EMOS_CREATEMESSAGE_ERROR.getMsg()});
return ProtocolRespDTO.result(ErrorCode.EMOS_CREATEMESSAGE_ERROR, rspInfo);
}
//保存数据格式到数据库
log.info("send alarm :{}", content);
AlarmInformation alarmInformation = AlarmInformation.builder().alarmInfo(content).build();
alarmInfoManager.addAlarmInfo(alarmInformation);
//推动数据格式到kafka
ListenableFuture<SendResult<String, String>> sendResult = kafkaConfiguration
.kafkaTemplate()
.sendDefault(0, System.currentTimeMillis(), "dispose", content);
sendResult.addCallback(v -> log.info("Kafka send {} to {} at {}", content,
Objects.requireNonNull(v)
.getRecordMetadata()
.topic(), v.getRecordMetadata().partition()),
ex -> log.error("Kafka send error: {}", ex.getMessage()));
rspInfo.setStatus(ErrorCode.ERR_OK.getCode());
rspInfo.setMessage(new String[]{ErrorCode.ERR_OK.getMsg()});
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);
}
/**
* @param alarmInfo emos告警信息
* @return 发送的消息
*/
private String createSendContent(EmosAlarmInfo alarmInfo) {
try {
long dbIncrement = msgSerialService.getMaxMessageSerial();
long increment = dbIncrement + 1;
MulReturnType<ErrorCode, Long> returnType = msgSerialService.updateMessageSerial(increment);
if (returnType.getFirstParam() == ErrorCode.ERR_OK) {
increment = returnType.getSecondParam();
} else {
increment = dbIncrement;
}
String dstIp = alarmInfo.getDstIp();
String alarmId = alarmInfo.getAlarmId();
//LocateInfo: 192.168.11.6 ddos attack alarmMemcache , 2019-08-01 12:31, 2.1Gbps, 1.01Mpps
String locateInfo = getAlarmEvent(alarmInfo);
String eventTime = alarmInfo.getStartTime();
String cancelTime = alarmInfo.getEndTime();
//告警类型vendorAlarmType告警级别vendorSeverity告警号vendorAlarmId告警标题AlarmTitle告警可能原因ProbableCauseTxt
String type = Constants.ATTACK_TYPE.get(alarmInfo.getAttackType());
String vendorSeverity = characterEncode("一级");
String vendorAlarmType;
String vendorAlarmId;
if (type != null) {
String[] arr = type.split("\\|");
String bps = "bps";
vendorAlarmType = arr[0];
if (bps.equals(alarmInfo.getBpspps())) {
vendorAlarmId = arr[1];
} else {
vendorAlarmId = arr[2];
}
} else {
vendorAlarmType = alarmInfo.getAttackType();
vendorAlarmId = "0";
log.info("unKnown attack type:" + vendorAlarmType);
}
String alarmStatus = String.valueOf(Constants.ACTIVE_ALARM_STATUS);
String alarmText = characterEncode(getAlarmText(alarmInfo));
String alarmExplanation = characterEncode(getAlarmExplanation(alarmInfo));
return MessageFormat.format(Constants.DISPATCH_TEMPLATE, increment, dstIp,
dstIp, alarmId, alarmId, dstIp, dstIp, locateInfo, eventTime, cancelTime,
vendorAlarmType, vendorSeverity, vendorAlarmId, characterEncode("重保攻击事件告警"),
characterEncode("DDos攻击事件"), alarmStatus, alarmText,
characterEncode(alarmInfo.getDstProvince()), characterEncode(alarmInfo.getDstCity()),
characterEncode("网络部集中抗D系统"), characterEncode("DDOS攻击事件告警"),
characterEncode("安全告警"), characterEncode("DDOS告警"),
alarmExplanation, characterEncode("集中抗D"));
} catch (Exception e) {
log.error("createSendContent告警消息异常详细信息{}", ExceptionUtils.getStackTrace(e));
return null;
}
}
/**
* 获取告警事件AlarmEvent
*/
private String getAlarmEvent(EmosAlarmInfo a) {
return a.getDstIp() + " ddos attack alarm, " + a.getAttackType() + ", " + a.getStartTime() +
", " + a.getMaxBps() + ", " + a.getMaxPps();
}
/**
* 数据编码都采用GBK编码方式
*/
private String characterEncode(String character) {
try {
return new String(character.getBytes("GBK"), "GBK");
} catch (Exception e) {
log.info("character encoding failed:" + e.getMessage());
return character;
}
}
/**
* 获取告警区域
*/
private String getAreaDes(String province, String city) {
String areaDes;
if (Constants.REGION_BEIJING.equals(province)) {
areaDes = "北京市";
} else if (Constants.REGION_SHANGHAI.equals(province)) {
areaDes = "上海市";
} else if (Constants.REGION_TIANJIN.equals(province)) {
areaDes = "天津市";
} else if (Constants.REGION_CHONGQING.equals(province)) {
areaDes = "重庆市";
} else {
areaDes = province + "" + city + "";
}
return areaDes;
}
/**
* 获取处置类型(1:清洗,2:黑洞,3:高防)
*/
private String getOperateType(Integer disposeType) {
String operateType = null;
if (Constants.CLEANUP == disposeType) {
operateType = "清洗";
} else if (Constants.BLACKHOOL == disposeType) {
operateType = "流控";
} else if (Constants.HIDEPEND == disposeType) {
operateType = "黑洞";
}
return operateType;
}
/**
* 获取告警正文AlarmText
*/
private String getAlarmText(EmosAlarmInfo a) {
String area = getAreaDes(a.getDstProvince(), a.getDstCity());
String operateType = getOperateType(a.getDisposeType());
return "攻击目的IP" + a.getDstIp() + "," + area + "," + "处置操作:" + operateType + "," + "处置时长:" + a.getDisposeTime() + "分钟";
}
/**
* 获取告警解释AlarmExplanation
*/
private String getAlarmExplanation(EmosAlarmInfo a) {
String operateType = getOperateType(a.getDisposeType());
StringBuilder srcIp = new StringBuilder();
for (String ip : a.getSrcIpLs()) {
srcIp.append(ip).append(",");
}
if (srcIp.length() > 0) {
srcIp = new StringBuilder(srcIp.substring(0, srcIp.length() - 1));
}
return "攻击目的IP" + a.getDstIp() + "," + "攻击源地址:(" + srcIp + ")," + "处置操作:" + operateType + "," + "处置时长:" + a.getDisposeTime() + "分钟";
}
}

View File

@ -69,8 +69,7 @@ public class GlobalExceptionHandler {
log.error("Interface [{}] request <{}> from {}, token = <{}>\n" + log.error("Interface [{}] request <{}> from {}, token = <{}>\n" +
"+++ Request: {}\n" + "+++ Request: {}\n" +
"--- Verify params failed: {}", "--- Verify params failed: {}",
reqType, reqPath, reqIp, reqToken, Helper.inputStream2String(req.getInputStream()), reqType, reqPath, reqIp, reqToken, Helper.inputStream2String(req.getInputStream()), sb);
sb.toString());
} catch (Exception ignored) { } catch (Exception ignored) {
} }

View File

@ -1,7 +1,6 @@
package com.dispose.config; package com.dispose.interceptor;
import com.dispose.common.AuthConfigValue; import com.dispose.common.AuthConfigValue;
import com.dispose.interceptor.TokenInterceptor;
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;
@ -24,7 +23,7 @@ import java.util.Optional;
@Component @Component
@ConfigurationProperties(prefix = "auth") @ConfigurationProperties(prefix = "auth")
@Configuration @Configuration
public class AuthConfigure implements WebMvcConfigurer { public class AuthConfigureFilter implements WebMvcConfigurer {
/** /**
* The Token timeout minute. * The Token timeout minute.
*/ */

View File

@ -0,0 +1,17 @@
package com.dispose.manager;
import com.dispose.pojo.entity.AlarmInformation;
/**
* The interface alarm information manager.
*
* @author <chenlinghy@cmhi.chinamoblie.com>
*/
public interface AlarmInfoManager {
/**
* Add alarm information.
*
* @param alarmInformation the alarm information
*/
void addAlarmInfo(AlarmInformation alarmInformation);
}

View File

@ -0,0 +1,25 @@
package com.dispose.manager;
import com.dispose.common.ErrorCode;
/**
* The interface Msg serial manager.
*
* @author <huangxin@cmhi.chinamoblie.com>
*/
public interface MsgSerialManager {
/**
* Update msg serial number error code.
*
* @param msgSerial the msg serial
* @return the error code
*/
ErrorCode updateMsgSerialNumber(Long msgSerial);
/**
* Gets max msg serial.
*
* @return the max msg serial
*/
Long getMaxMsgSerial();
}

View File

@ -0,0 +1,34 @@
package com.dispose.manager.impl;
import com.dispose.manager.AlarmInfoManager;
import com.dispose.mapper.AlarmInformationMapper;
import com.dispose.pojo.entity.AlarmInformation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
/**
* The interface alarm information manager.
*
* @author <chenlinghy@cmhi.chinamoblie.com>
*/
@Component
@Slf4j
public class AlarmInfoManagerImpl implements AlarmInfoManager {
/**
* The alarm information mapper.
*/
@Resource
private AlarmInformationMapper alarmInformationMapper;
/**
* Add alarm information.
*
* @param alarmInformation the alarm information
*/
@Override
public void addAlarmInfo(AlarmInformation alarmInformation) {
alarmInformationMapper.addAlarmInfo(alarmInformation);
}
}

View File

@ -57,7 +57,7 @@ public class DisposeDeviceManagerImpl implements DisposeDeviceManager {
@Override @Override
public MulReturnType<ErrorCode, Long> addDisposeDevice(DisposeDevice dev) { public MulReturnType<ErrorCode, Long> addDisposeDevice(DisposeDevice dev) {
List<DisposeDevice> tmpDev = disposeDeviceMapper.getDeviceByIpAndType(dev.getIpAddr(), List<DisposeDevice> tmpDev = disposeDeviceMapper.getDeviceByIpAndType(dev.getIpAddr(),
dev.getDeviceType().getValue()); dev.getDeviceType().getValue());
for (DisposeDevice v : tmpDev) { for (DisposeDevice v : tmpDev) {
if (dev.getIpPort().equals(HttpType.getDefaultPort(v.getUrlType())) || dev.getIpPort() if (dev.getIpPort().equals(HttpType.getDefaultPort(v.getUrlType())) || dev.getIpPort()
@ -112,7 +112,7 @@ public class DisposeDeviceManagerImpl implements DisposeDeviceManager {
fdDest.setAccessible(true); fdDest.setAccessible(true);
if (!obj.equals(fdDest.get(destDev))) { if (!obj.equals(fdDest.get(destDev))) {
log.debug("Upgrade field [{}] value form [{}] to [{}]", fdSrc.getName(), fdDest.get(destDev), log.debug("Upgrade field [{}] value form [{}] to [{}]", fdSrc.getName(), fdDest.get(destDev),
obj); obj);
fdDest.set(destDev, obj); fdDest.set(destDev, obj);
} }
fdDest.setAccessible(false); fdDest.setAccessible(false);
@ -135,7 +135,7 @@ public class DisposeDeviceManagerImpl implements DisposeDeviceManager {
DisposeDevice tDev = null; DisposeDevice tDev = null;
// 根据Ip和设备类型获取设备 // 根据Ip和设备类型获取设备
List<DisposeDevice> devList = disposeDeviceMapper.getDeviceByIpAndType(dev.getIpAddr(), List<DisposeDevice> devList = disposeDeviceMapper.getDeviceByIpAndType(dev.getIpAddr(),
dev.getDeviceType().getValue()); dev.getDeviceType().getValue());
if (devList == null || devList.size() == 0) { if (devList == null || devList.size() == 0) {
return new MulReturnType<>(ErrorCode.ERR_NOSUCHDEVICE, -1L); return new MulReturnType<>(ErrorCode.ERR_NOSUCHDEVICE, -1L);

View File

@ -0,0 +1,50 @@
package com.dispose.manager.impl;
import com.dispose.common.ErrorCode;
import com.dispose.manager.MsgSerialManager;
import com.dispose.mapper.MsgSerialMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
/**
* The interface message serial manager.
*
* @author <chenlinghy@cmhi.chinamoblie.com>
*/
@Component
@Slf4j
public class MsgSerialManagerImpl implements MsgSerialManager {
/**
* The message serial mapper.
*/
@Resource
private MsgSerialMapper msgSerialMapper;
/**
* Add user business error code.
*
* @param msgSerial the message serial
* @return the error code
*/
@Override
public ErrorCode updateMsgSerialNumber(Long msgSerial) {
if (msgSerialMapper.updateMsgSerial(msgSerial) == 1) {
return ErrorCode.ERR_OK;
} else {
return ErrorCode.ERR_DATABASE;
}
}
/**
* get new max message serial.
*
* @return the long
*/
@Override
public Long getMaxMsgSerial() {
return msgSerialMapper.getMaxMsgSerial();
}
}

View File

@ -0,0 +1,18 @@
package com.dispose.mapper;
import com.dispose.pojo.entity.AlarmInformation;
/**
* The interface alarm information mapper.
*
* @author <chenlinghy@cmhi.chinamoblie.com>
*/
public interface AlarmInformationMapper {
/**
* Add alarm information.
*
* @param alarmInformation the alarm information
* @return the int
*/
int addAlarmInfo(AlarmInformation alarmInformation);
}

View File

@ -0,0 +1,24 @@
package com.dispose.mapper;
/**
* The interface message serial mapper.
*
* @author <chenlinghy@cmhi.chinamoblie.com>
*/
public interface MsgSerialMapper {
/**
* Update new task int.
*
* @param msgSerial the msgSerial number
* @return the int
*/
int updateMsgSerial(Long msgSerial);
/**
* get new max message serial.
*
* @return the long
*/
long getMaxMsgSerial();
}

View File

@ -0,0 +1,29 @@
package com.dispose.pojo.dto.protocol.kafka;
import com.dispose.validation.group.ValidGroups;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank;
/**
* The type Login req.
*
* @author <huangxin@cmhi.chinamoblie.com>
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
public class AlarmInfoReq {
/**
* 告警信息.
*/
@NotBlank(message = "alarmInfo 告警信息不能为空", groups = ValidGroups.ProtocolCommonValid.class)
private String alarmInfo;
}

View File

@ -0,0 +1,89 @@
package com.dispose.pojo.dto.protocol.kafka;
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 java.util.List;
/**
* The type Emos alarm info.
*
* @author <huangxin@cmhi.chinamoblie.com>
*/
@EqualsAndHashCode()
@Data
@Builder
@AllArgsConstructor
@JsonPropertyOrder({"alarmId", "dstIp", "attackType", "bpspps", "dstProvince", "dstCity", "srcIpLs", "startTime",
"endTime", "disposeType", "disposeTime", "maxBps", "maxPps"})
@JsonInclude(JsonInclude.Include.NON_NULL)
public class EmosAlarmInfo {
/**
* The Alarm id.
*/
private String alarmId;
/**
* The Dst ip.
*/
private String dstIp;
/**
* The Attack type.
*/
private String attackType;
/**
* The Bpspps.
*/
private String bpspps;
/**
* The Dst province.
*/
private String dstProvince;
/**
* The Dst city.
*/
private String dstCity;
/**
* The Src ip ls.
*/
private List<String> srcIpLs;
/**
* The Start time.
*/
private String startTime;
/**
* The End time.
*/
private String endTime;
/**
* The Dispose type.
*/
private Integer disposeType;
/**
* The Dispose time.
*/
private Integer disposeTime;
/**
* The Max bps.
*/
private String maxBps;
/**
* The Max pps.
*/
private String maxPps;
}

View File

@ -0,0 +1,51 @@
package com.dispose.pojo.entity;
import com.fasterxml.jackson.annotation.JsonInclude;
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 emos alarm information.
*
* @author <chenlinghy@cmhi.chinamoblie.com>
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@JsonInclude(JsonInclude.Include.NON_NULL)
@Table(name = "alarm_information")
@NameStyle(Style.normal)
public class AlarmInformation implements Serializable {
/**
* The constant serialVersionUID.
*/
private static final long serialVersionUID = 1L;
/**
* The id.
*/
@Id
@KeySql(useGeneratedKeys = true)
private Long id;
/**
* The alarm information.
*/
private String alarmInfo;
/**
* The creating time.
*/
private String createTime;
}

View File

@ -0,0 +1,46 @@
package com.dispose.pojo.entity;
import com.fasterxml.jackson.annotation.JsonInclude;
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 message serial.
*
* @author <chenlinghy@cmhi.chinamoblie.com>
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@JsonInclude(JsonInclude.Include.NON_NULL)
@Table(name = "msg_serial")
@NameStyle(Style.normal)
public class MsgSerial implements Serializable {
/**
* The constant serialVersionUID.
*/
private static final long serialVersionUID = 1L;
/**
* The id.
*/
@Id
@KeySql(useGeneratedKeys = true)
private Long id;
/**
* The message serial.
*/
private Long msgSerial;
}

View File

@ -0,0 +1,27 @@
package com.dispose.service;
import com.dispose.common.ErrorCode;
import com.dispose.pojo.po.MulReturnType;
/**
* The interface Msg serial service.
*
* @author <huangxin@cmhi.chinamoblie.com>
*/
public interface MsgSerialService {
/**
* Update message serial mul return type.
*
* @param msgSerial the msg serial
* @return the mul return type
*/
MulReturnType<ErrorCode, Long> updateMessageSerial(Long msgSerial);
/**
* Gets max message serial.
*
* @return the max message serial
*/
Long getMaxMessageSerial();
}

View File

@ -1,5 +1,6 @@
package com.dispose.service.impl; package com.dispose.service.impl;
import com.cmhi.dispose.common.CmhiDisposeTaskStatus;
import com.dispose.common.DisposeConfigValue; import com.dispose.common.DisposeConfigValue;
import com.dispose.common.DisposeDeviceType; import com.dispose.common.DisposeDeviceType;
import com.dispose.common.DisposeObjectType; import com.dispose.common.DisposeObjectType;
@ -18,7 +19,6 @@ import com.dispose.pojo.po.AbilityInfo;
import com.dispose.pojo.po.MulReturnType; import com.dispose.pojo.po.MulReturnType;
import com.dispose.service.DeviceTaskManagerService; import com.dispose.service.DeviceTaskManagerService;
import com.dispose.service.DisposeAbilityRouterService; import com.dispose.service.DisposeAbilityRouterService;
import com.pengxin.dispose.common.PengXinTaskStatus;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
@ -429,7 +429,7 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
//任务出错设备任务状态为启动处置任务失败 //任务出错设备任务状态为启动处置任务失败
deviceTaskManager.changeDisposeDeviceTaskInfoDevStatus(deviceTask.getId(), deviceTaskManager.changeDisposeDeviceTaskInfoDevStatus(deviceTask.getId(),
(long) PengXinTaskStatus.TASK_STARTED_FAILED.getValue()); (long) CmhiDisposeTaskStatus.TASK_STARTED_FAILED.getValue());
// 记录任务出错重试次数 // 记录任务出错重试次数
deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), 0); deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), 0);
@ -596,8 +596,8 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
virtualDeviceTaskRun(ai, v, task); virtualDeviceTaskRun(ai, v, task);
break; break;
case PENGXIN_PLATFORM: case CMHI_PLATFORM:
restfulDeviceTaskRun(ai, v, task, DisposeDeviceType.PENGXIN_PLATFORM); restfulDeviceTaskRun(ai, v, task, DisposeDeviceType.CMHI_PLATFORM);
break; break;
case HUAWEI_PLATFORM: case HUAWEI_PLATFORM:
@ -681,8 +681,8 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
virtualDeviceTaskStop(ai, v, task); virtualDeviceTaskStop(ai, v, task);
break; break;
case PENGXIN_PLATFORM: case CMHI_PLATFORM:
restfulDeviceTaskStop(ai, v, task, DisposeDeviceType.PENGXIN_PLATFORM); restfulDeviceTaskStop(ai, v, task, DisposeDeviceType.CMHI_PLATFORM);
break; break;
case HUAWEI_PLATFORM: case HUAWEI_PLATFORM:

View File

@ -6,7 +6,7 @@ import com.dispose.ability.impl.DpTechBypassAbilityImpl;
import com.dispose.ability.impl.HaoHanAbilityImpl; import com.dispose.ability.impl.HaoHanAbilityImpl;
import com.dispose.ability.impl.HuaWeiAbilityImpl; import com.dispose.ability.impl.HuaWeiAbilityImpl;
import com.dispose.ability.impl.HuaWeiFireWallAbilityImpl; import com.dispose.ability.impl.HuaWeiFireWallAbilityImpl;
import com.dispose.ability.impl.PengXinAbilityImpl; import com.dispose.ability.impl.CmhiAbilityImpl;
import com.dispose.ability.impl.UpfAbilityImpl; import com.dispose.ability.impl.UpfAbilityImpl;
import com.dispose.ability.impl.VirtualAbilityImpl; import com.dispose.ability.impl.VirtualAbilityImpl;
import com.dispose.common.DisposeCapacityType; import com.dispose.common.DisposeCapacityType;
@ -17,6 +17,7 @@ import com.dispose.manager.DisposeDeviceManager;
import com.dispose.mapper.ServiceGroupMapper; import com.dispose.mapper.ServiceGroupMapper;
import com.dispose.pojo.entity.DisposeDevice; import com.dispose.pojo.entity.DisposeDevice;
import com.dispose.pojo.po.AbilityInfo; import com.dispose.pojo.po.AbilityInfo;
import com.dispose.security.arithmetic.CryptoHelper;
import com.dispose.service.DisposeAbilityRouterService; import com.dispose.service.DisposeAbilityRouterService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
@ -91,7 +92,7 @@ public class DisposeAbilityRouterServiceImpl implements DisposeAbilityRouterServ
if (dev != null) { if (dev != null) {
return disposeAbilityMap.get(getAbilityDeviceHashKey(dev.getIpAddr(), dev.getIpPort(), return disposeAbilityMap.get(getAbilityDeviceHashKey(dev.getIpAddr(), dev.getIpPort(),
String.valueOf(dev.getDeviceType()))); String.valueOf(dev.getDeviceType())));
} }
return null; return null;
@ -121,7 +122,7 @@ public class DisposeAbilityRouterServiceImpl implements DisposeAbilityRouterServ
@Override @Override
public void deleteDisposeDevice(DisposeDevice dev) { public void deleteDisposeDevice(DisposeDevice dev) {
String hashKey = getAbilityDeviceHashKey(dev.getIpAddr(), dev.getIpPort(), String hashKey = getAbilityDeviceHashKey(dev.getIpAddr(), dev.getIpPort(),
String.valueOf(dev.getDeviceType())); String.valueOf(dev.getDeviceType()));
disposeAbilityMap.remove(hashKey); disposeAbilityMap.remove(hashKey);
} }
@ -165,8 +166,8 @@ public class DisposeAbilityRouterServiceImpl implements DisposeAbilityRouterServ
case HAOHAN_PLATFORM: case HAOHAN_PLATFORM:
db = new HaoHanAbilityImpl(); db = new HaoHanAbilityImpl();
break; break;
case PENGXIN_PLATFORM: case CMHI_PLATFORM:
db = new PengXinAbilityImpl(); db = new CmhiAbilityImpl();
break; break;
case HUAWEI_PLATFORM: case HUAWEI_PLATFORM:
db = new HuaWeiAbilityImpl(); db = new HuaWeiAbilityImpl();
@ -190,11 +191,12 @@ public class DisposeAbilityRouterServiceImpl implements DisposeAbilityRouterServ
} }
// 初始化设备 // 初始化设备
dev.setPassword(new String(CryptoHelper.base64Decryption(dev.getPassword())));
db.initDeviceEnv(url, dev.getUserName(), dev.getPassword()); db.initDeviceEnv(url, dev.getUserName(), dev.getPassword());
db.getDisposeDeviceProtectObject(); db.getDisposeDeviceProtectObject();
String hashKey = getAbilityDeviceHashKey(dev.getIpAddr(), dev.getIpPort(), String hashKey = getAbilityDeviceHashKey(dev.getIpAddr(), dev.getIpPort(),
String.valueOf(dev.getDeviceType())); String.valueOf(dev.getDeviceType()));
// 缓存处置设备到Hash表中 // 缓存处置设备到Hash表中
disposeAbilityMap.put(hashKey, AbilityInfo.builder() disposeAbilityMap.put(hashKey, AbilityInfo.builder()
@ -256,7 +258,7 @@ public class DisposeAbilityRouterServiceImpl implements DisposeAbilityRouterServ
if (dev == null || !dev.getStatus().equals(ObjectStatus.NORMAL)) { if (dev == null || !dev.getStatus().equals(ObjectStatus.NORMAL)) {
String hashKey = getAbilityDeviceHashKey(v.getDev().getIpAddr(), v.getDev().getIpPort(), String hashKey = getAbilityDeviceHashKey(v.getDev().getIpAddr(), v.getDev().getIpPort(),
String.valueOf(v.getDev().getDeviceType())); String.valueOf(v.getDev().getDeviceType()));
disposeAbilityMap.remove(hashKey); disposeAbilityMap.remove(hashKey);
} else { } else {

View File

@ -0,0 +1,56 @@
package com.dispose.service.impl;
import com.dispose.common.ErrorCode;
import com.dispose.manager.MsgSerialManager;
import com.dispose.pojo.po.MulReturnType;
import com.dispose.service.MsgSerialService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* The type Msg serial service.
*
* @author <huangxin@cmhi.chinamoblie.com>
*/
@Service
public class MsgSerialServiceImpl implements MsgSerialService {
/**
* The Msg serial manager.
*/
@Resource
private MsgSerialManager msgSerialManager;
/**
* Update message serial mul return type.
*
* @param msgSerial the msg serial
* @return the mul return type
*/
@Override
public MulReturnType<ErrorCode, Long> updateMessageSerial(Long msgSerial) {
//告警序号的最大值2^32-1
long indexEnd = 4294967295L;
long indexStart = 1L;
//编号从1开始以实时消息发布通道为单位进行编号如果编号超过最大正整数(2^32-1)重新从1开始编号
if (msgSerial > indexEnd) {
msgSerial = indexStart;
}
if (msgSerialManager.updateMsgSerialNumber(msgSerial) == ErrorCode.ERR_OK) {
return new MulReturnType<>(ErrorCode.ERR_OK, msgSerial);
} else {
return new MulReturnType<>(ErrorCode.ERR_DATABASE, null);
}
}
/**
* Gets max message serial.
*
* @return the max message serial
*/
@Override
public Long getMaxMessageSerial() {
return msgSerialManager.getMaxMsgSerial();
}
}

View File

@ -81,7 +81,7 @@ public class ValidAddCapacityInfoImpl implements ConstraintValidator<ValidAddCap
if (Arrays.stream(IpAddrType.values()).noneMatch(v -> v.getValue().equals(addCapacityInfo.getIpType()))) { if (Arrays.stream(IpAddrType.values()).noneMatch(v -> v.getValue().equals(addCapacityInfo.getIpType()))) {
List<Integer> val = Arrays.stream(IpAddrType.values()).map(IpAddrType::getValue).collect(Collectors.toList()); List<Integer> val = Arrays.stream(IpAddrType.values()).map(IpAddrType::getValue).collect(Collectors.toList());
errMsg.add("字段 ipType 值 {}, 错误, 合理取值范围为:" + val.toString()); errMsg.add("字段 ipType 值 {}, 错误, 合理取值范围为:" + val);
ret = false; ret = false;
} }
@ -106,7 +106,7 @@ public class ValidAddCapacityInfoImpl implements ConstraintValidator<ValidAddCap
// 重新设置消息 // 重新设置消息
ctx.disableDefaultConstraintViolation(); ctx.disableDefaultConstraintViolation();
ctx.buildConstraintViolationWithTemplate(this.message + " " + errMsg.toString()).addConstraintViolation(); ctx.buildConstraintViolationWithTemplate(this.message + " " + errMsg).addConstraintViolation();
return ret; return ret;
} }

View File

@ -58,7 +58,7 @@ public class ValidBaseEnumArrayImpl implements ConstraintValidator<ValidBaseEnum
String errMsg = this.message + " 字段 " + String errMsg = this.message + " 字段 " +
((ConstraintValidatorContextImpl) ctx).getConstraintViolationCreationContexts() ((ConstraintValidatorContextImpl) ctx).getConstraintViolationCreationContexts()
.get(0).getPath().getLeafNode().getName() .get(0).getPath().getLeafNode().getName()
+ " 值 {" + Arrays.toString(integers) + "} 错误, 字段取值范围:" + enumValues.toString(); + " 值 {" + Arrays.toString(integers) + "} 错误, 字段取值范围:" + enumValues;
// 重新设置消息 // 重新设置消息
ctx.disableDefaultConstraintViolation(); ctx.disableDefaultConstraintViolation();

View File

@ -61,7 +61,7 @@ public class ValidBaseEnumImpl implements ConstraintValidator<ValidBaseEnum, Int
String errMsg = this.message + " 字段 " + String errMsg = this.message + " 字段 " +
((ConstraintValidatorContextImpl) ctx).getConstraintViolationCreationContexts() ((ConstraintValidatorContextImpl) ctx).getConstraintViolationCreationContexts()
.get(0).getPath().getLeafNode().getName() .get(0).getPath().getLeafNode().getName()
+ " 值 {" + integer + "} 错误, 字段取值范围:" + enumValues.toString(); + " 值 {" + integer + "} 错误, 字段取值范围:" + enumValues;
// 重新设置消息 // 重新设置消息
ctx.disableDefaultConstraintViolation(); ctx.disableDefaultConstraintViolation();

View File

@ -63,7 +63,7 @@ public class ValidDisposeObjectImpl implements ConstraintValidator<ValidDisposeO
// 重新设置消息 // 重新设置消息
ctx.disableDefaultConstraintViolation(); ctx.disableDefaultConstraintViolation();
ctx.buildConstraintViolationWithTemplate(this.message + " " + errMsg.toString()).addConstraintViolation(); ctx.buildConstraintViolationWithTemplate(this.message + " " + errMsg).addConstraintViolation();
return ret; return ret;
} }

View File

@ -55,7 +55,7 @@ public class ValidSplitPageSizeImpl implements ConstraintValidator<ValidSplitPag
String errMsg = this.message + " 字段 " + String errMsg = this.message + " 字段 " +
((ConstraintValidatorContextImpl) ctx).getConstraintViolationCreationContexts() ((ConstraintValidatorContextImpl) ctx).getConstraintViolationCreationContexts()
.get(0).getPath().getLeafNode().getName() + .get(0).getPath().getLeafNode().getName() +
" 值 {" + integer + "} 错误, 字段取值范围:" + rang.toString(); " 值 {" + integer + "} 错误, 字段取值范围:" + rang;
// 重新设置消息 // 重新设置消息
ctx.disableDefaultConstraintViolation(); ctx.disableDefaultConstraintViolation();

View File

@ -9,3 +9,11 @@ INSERT INTO `user_account`
VALUES (1, 'admin', 'c3855e6b6bb120450f160ba91134522868f89d36062f2061ebeefd80817e1d58', '2020-11-13 09:25:19', '', VALUES (1, 'admin', 'c3855e6b6bb120450f160ba91134522868f89d36062f2061ebeefd80817e1d58', '2020-11-13 09:25:19', '',
'2021-01-20 10:18:56', '1db9ddc47de514eb16b7ec07d7f7f96f7a714ae00e1209755bab30d543a0a2c3', '2021-01-20 10:18:56', '1db9ddc47de514eb16b7ec07d7f7f96f7a714ae00e1209755bab30d543a0a2c3',
'2021-01-20 10:20:57', '1970-01-02 00:00:00', 0, 0); '2021-01-20 10:20:57', '1970-01-02 00:00:00', 0, 0);
-- ----------------------------
-- Records of msg_serial
-- ----------------------------
INSERT INTO `msg_serial` VALUES ('1', '1');

View File

@ -15,7 +15,8 @@
*/ */
SET NAMES utf8mb4; SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0; SET
FOREIGN_KEY_CHECKS = 0;
-- ---------------------------- -- ----------------------------
-- Table structure for device_task -- Table structure for device_task
@ -23,23 +24,23 @@ SET FOREIGN_KEY_CHECKS = 0;
DROP TABLE IF EXISTS `device_task`; DROP TABLE IF EXISTS `device_task`;
CREATE TABLE `device_task` CREATE TABLE `device_task`
( (
`id` bigint(11) NOT NULL AUTO_INCREMENT COMMENT '任务信息唯一标识符', `id` bigint(11) NOT NULL AUTO_INCREMENT COMMENT '任务信息唯一标识符',
`taskId` bigint(11) NOT NULL COMMENT '处置任务唯一标识符', `taskId` bigint(11) NOT NULL COMMENT '处置任务唯一标识符',
`deviceId` bigint(11) NOT NULL COMMENT '处置设备唯一标识符', `deviceId` bigint(11) NOT NULL COMMENT '处置设备唯一标识符',
`beginTime` timestamp(0) NULL DEFAULT NULL COMMENT '任务开始时间', `beginTime` timestamp(0) NULL DEFAULT NULL COMMENT '任务开始时间',
`endTime` timestamp(0) NULL DEFAULT NULL COMMENT '任务结束时间', `endTime` timestamp(0) NULL DEFAULT NULL COMMENT '任务结束时间',
`taskAttackType` bigint(255) UNSIGNED NOT NULL DEFAULT 0 COMMENT '需要处置的攻击类型', `taskAttackType` bigint(255) UNSIGNED NOT NULL DEFAULT 0 COMMENT '需要处置的攻击类型',
`execAttackTypeIn` bigint(255) UNSIGNED NOT NULL DEFAULT 0 COMMENT '已经执行处置的攻击类型(Input)', `execAttackTypeIn` bigint(255) UNSIGNED NOT NULL DEFAULT 0 COMMENT '已经执行处置的攻击类型(Input)',
`attackTypeStatusIn` bigint(255) UNSIGNED NOT NULL DEFAULT 0 COMMENT '执行的攻击类型状态(Input)', `attackTypeStatusIn` bigint(255) UNSIGNED NOT NULL DEFAULT 0 COMMENT '执行的攻击类型状态(Input)',
`execAttackTypeOut` bigint(255) UNSIGNED NOT NULL DEFAULT 0 COMMENT '已经执行处置的攻击类型(Output)', `execAttackTypeOut` bigint(255) UNSIGNED NOT NULL DEFAULT 0 COMMENT '已经执行处置的攻击类型(Output)',
`attackTypeStatusOut` bigint(255) UNSIGNED NOT NULL DEFAULT 0 COMMENT '执行的攻击类型状态(Input)', `attackTypeStatusOut` bigint(255) UNSIGNED NOT NULL DEFAULT 0 COMMENT '执行的攻击类型状态(Input)',
`externId` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '扩展任务ID', `externId` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '扩展任务ID',
`errRetry` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '调用失败重试次数', `errRetry` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '调用失败重试次数',
`status` int(11) NOT NULL DEFAULT 0 COMMENT '任务状态', `status` int(11) NOT NULL DEFAULT 0 COMMENT '任务状态',
`devStatus` int(11) NOT NULL DEFAULT 0 COMMENT '设备任务状态', `devStatus` int(11) NOT NULL DEFAULT 0 COMMENT '设备任务状态',
PRIMARY KEY (`id`) USING BTREE, PRIMARY KEY (`id`) USING BTREE,
INDEX `task_info_ibfk_1` (`taskId`) USING BTREE, INDEX `task_info_ibfk_1` (`taskId`) USING BTREE,
INDEX `task_info_ibfk_2` (`deviceId`) 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_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 CONSTRAINT `device_task_ibfk_2` FOREIGN KEY (`deviceId`) REFERENCES `dispose_device` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE = InnoDB ) ENGINE = InnoDB
@ -54,15 +55,15 @@ CREATE TABLE `device_task`
DROP TABLE IF EXISTS `dispose_capacity`; DROP TABLE IF EXISTS `dispose_capacity`;
CREATE TABLE `dispose_capacity` CREATE TABLE `dispose_capacity`
( (
`id` bigint(11) NOT NULL AUTO_INCREMENT COMMENT '设备处置能力唯一标识符', `id` bigint(11) NOT NULL AUTO_INCREMENT COMMENT '设备处置能力唯一标识符',
`deviceId` bigint(11) NOT NULL COMMENT '设备ID', `deviceId` bigint(11) NOT NULL COMMENT '设备ID',
`capacityType` int(11) NOT NULL COMMENT '处置能力:\r\n0清洗\r\n1高防 \r\n2路由黑洞 \r\n3检测\r\n4WAF封堵\r\n', `capacityType` int(11) NOT NULL COMMENT '处置能力:\r\n0清洗\r\n1高防 \r\n2路由黑洞 \r\n3检测\r\n4WAF封堵\r\n',
`objectType` int(11) NOT NULL COMMENT '处置对象类型:\r\n0IP\r\n1域名 \r\n2URL', `objectType` int(11) NOT NULL COMMENT '处置对象类型:\r\n0IP\r\n1域名 \r\n2URL',
`ipType` int(11) NOT NULL DEFAULT 3 COMMENT 'IP 地址类型:\r\n1 << 0支持IPV4\r\n1 << 1支持IPV6', `ipType` int(11) NOT NULL DEFAULT 3 COMMENT 'IP 地址类型:\r\n1 << 0支持IPV4\r\n1 << 1支持IPV6',
`protectIp` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '该处置能力能够处置的IP', `protectIp` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '该处置能力能够处置的IP',
`reserveNetflow` int(11) NULL DEFAULT NULL COMMENT '清洗能力储备流量值,单位(G)', `reserveNetflow` int(11) NULL DEFAULT NULL COMMENT '清洗能力储备流量值,单位(G)',
PRIMARY KEY (`id`) USING BTREE, 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 CONSTRAINT `dispose_capacity_ibfk_1` FOREIGN KEY (`deviceId`) REFERENCES `dispose_device` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE = InnoDB ) ENGINE = InnoDB
AUTO_INCREMENT = 1 AUTO_INCREMENT = 1
@ -76,23 +77,23 @@ CREATE TABLE `dispose_capacity`
DROP TABLE IF EXISTS `dispose_device`; DROP TABLE IF EXISTS `dispose_device`;
CREATE TABLE `dispose_device` CREATE TABLE `dispose_device`
( (
`id` bigint(11) NOT NULL AUTO_INCREMENT COMMENT '设备唯一标识符', `id` bigint(11) NOT NULL AUTO_INCREMENT COMMENT '设备唯一标识符',
`ipAddr` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '设备IP地址, IPv4/IPv6', `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 '端口', `ipPort` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '端口',
`deviceType` int(11) NOT NULL DEFAULT 0 COMMENT '能力节点类型0迪普UMC平台1浩瀚设备', `deviceType` int(11) NOT NULL DEFAULT 0 COMMENT '能力节点类型0迪普UMC平台1浩瀚设备',
`areaCode` int(11) NOT NULL COMMENT '设备物理位置区域码', `areaCode` int(11) NOT NULL COMMENT '设备物理位置区域码',
`deviceName` varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '设备名称', `deviceName` varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '设备名称',
`manufacturer` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '生产厂商', `manufacturer` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '生产厂商',
`model` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '型号', `model` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '型号',
`version` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '软件版本', `version` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '软件版本',
`userName` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '系统管理用户名', `userName` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '系统管理用户名',
`password` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '系统管理密码', `password` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '系统管理密码',
`urlPath` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT 'URL路径', `urlPath` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT 'URL路径',
`urlType` int(11) NOT NULL DEFAULT 0 COMMENT 'URL类型: 0: HTTP, 1: HTTPS', `urlType` int(11) NOT NULL DEFAULT 0 COMMENT 'URL类型: 0: HTTP, 1: HTTPS',
`readme` varchar(1024) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '备注', `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删除', `status` int(11) NOT NULL DEFAULT 0 COMMENT '状态0正常1锁定2禁用 3删除',
PRIMARY KEY (`id`) USING BTREE, PRIMARY KEY (`id`) USING BTREE,
INDEX `ipAddr` (`ipAddr`) USING BTREE INDEX `ipAddr` (`ipAddr`) USING BTREE
) ENGINE = InnoDB ) ENGINE = InnoDB
AUTO_INCREMENT = 1 AUTO_INCREMENT = 1
CHARACTER SET = utf8 CHARACTER SET = utf8
@ -105,23 +106,23 @@ CREATE TABLE `dispose_device`
DROP TABLE IF EXISTS `dispose_task`; DROP TABLE IF EXISTS `dispose_task`;
CREATE TABLE `dispose_task` CREATE TABLE `dispose_task`
( (
`id` bigint(11) NOT NULL AUTO_INCREMENT COMMENT '处置任务唯一标识符', `id` bigint(11) NOT NULL AUTO_INCREMENT COMMENT '处置任务唯一标识符',
`deviceId` bigint(11) NOT NULL COMMENT '处置设备唯一标识符', `deviceId` bigint(11) NOT NULL COMMENT '处置设备唯一标识符',
`accountId` bigint(11) NOT NULL COMMENT '用户唯一标识符', `accountId` bigint(11) NOT NULL COMMENT '用户唯一标识符',
`areaCode` int(11) NOT NULL DEFAULT -1 COMMENT '设备物理位置区域码', `areaCode` int(11) NOT NULL DEFAULT -1 COMMENT '设备物理位置区域码',
`disposeCapacity` int(11) NOT NULL COMMENT '处置能力类型0清洗 1高防 2黑洞 3检测', `disposeCapacity` int(11) NOT NULL COMMENT '处置能力类型0清洗 1高防 2黑洞 3检测',
`disposeObject` varchar(4096) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '处置对象', `disposeObject` varchar(4096) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '处置对象',
`objectType` int(8) NOT NULL COMMENT '处置对象类型:\r\n0IP\r\n1域名 \r\n2URL', `objectType` int(8) NOT NULL COMMENT '处置对象类型:\r\n0IP\r\n1域名 \r\n2URL',
`createTime` timestamp(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '开始时间', `createTime` timestamp(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '开始时间',
`planEndTime` timestamp(0) NOT NULL DEFAULT '1970-01-02 00:00:00' COMMENT '计划结束时间', `planEndTime` timestamp(0) NOT NULL DEFAULT '1970-01-02 00:00:00' COMMENT '计划结束时间',
`endTime` timestamp(0) NULL DEFAULT '1970-01-02 00:00:00' COMMENT '实际结束时间', `endTime` timestamp(0) NULL DEFAULT '1970-01-02 00:00:00' COMMENT '实际结束时间',
`flowDirection` int(11) NOT NULL DEFAULT 2 COMMENT '流量方向, 0流入1流出2双向', `flowDirection` int(11) NOT NULL DEFAULT 2 COMMENT '流量方向, 0流入1流出2双向',
`attackType` bigint(20) NOT NULL DEFAULT 0 COMMENT '攻击类型默认0 全部攻击', `attackType` bigint(20) NOT NULL DEFAULT 0 COMMENT '攻击类型默认0 全部攻击',
`flowBandWidth` int(11) UNSIGNED NULL DEFAULT 1024 COMMENT '攻击流量占用带宽(MB)', `flowBandWidth` int(11) UNSIGNED NULL DEFAULT 1024 COMMENT '攻击流量占用带宽(MB)',
`currentStatus` int(11) NOT NULL DEFAULT 0 COMMENT '状态0停止。1启动', `currentStatus` int(11) NOT NULL DEFAULT 0 COMMENT '状态0停止。1启动',
PRIMARY KEY (`id`) USING BTREE, PRIMARY KEY (`id`) USING BTREE,
INDEX `dispose_task_device_capacity_id_fk` (`disposeCapacity`) USING BTREE, INDEX `dispose_task_device_capacity_id_fk` (`disposeCapacity`) USING BTREE,
INDEX `dispose_task_user_account_id_fk` (`accountId`) USING BTREE INDEX `dispose_task_user_account_id_fk` (`accountId`) USING BTREE
) ENGINE = InnoDB ) ENGINE = InnoDB
AUTO_INCREMENT = 1 AUTO_INCREMENT = 1
CHARACTER SET = utf8 CHARACTER SET = utf8
@ -134,10 +135,10 @@ CREATE TABLE `dispose_task`
DROP TABLE IF EXISTS `service_group`; DROP TABLE IF EXISTS `service_group`;
CREATE TABLE `service_group` CREATE TABLE `service_group`
( (
`id` bigint(11) NOT NULL AUTO_INCREMENT COMMENT '业务ID唯一标识符', `id` bigint(11) NOT NULL AUTO_INCREMENT COMMENT '业务ID唯一标识符',
`serviceId` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '业务ID', `serviceId` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '业务ID',
`serviceType` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '业务类型SERVER,WEB,DNS,GAME', `serviceType` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '业务类型SERVER,WEB,DNS,GAME',
`serviceBandwidth` int(11) NOT NULL DEFAULT 1 COMMENT '业务带宽单位M', `serviceBandwidth` int(11) NOT NULL DEFAULT 1 COMMENT '业务带宽单位M',
`serviceIp` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '业务IP地址逗号分割', `serviceIp` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '业务IP地址逗号分割',
PRIMARY KEY (`id`) USING BTREE PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB ) ENGINE = InnoDB
@ -152,17 +153,17 @@ CREATE TABLE `service_group`
DROP TABLE IF EXISTS `user_account`; DROP TABLE IF EXISTS `user_account`;
CREATE TABLE `user_account` CREATE TABLE `user_account`
( (
`id` bigint(11) NOT NULL AUTO_INCREMENT COMMENT '账户唯一编号', `id` bigint(11) NOT NULL AUTO_INCREMENT COMMENT '账户唯一编号',
`username` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL 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 '密码', `password` varchar(512) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '密码',
`createTime` timestamp(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '创建时间', `createTime` timestamp(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '创建时间',
`operators` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '操作员', `operators` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '操作员',
`lastLoginTime` timestamp(0) NOT NULL DEFAULT '1970-01-02 00:00:00' COMMENT '最后一次成功登录时间', `lastLoginTime` timestamp(0) NOT NULL DEFAULT '1970-01-02 00:00:00' COMMENT '最后一次成功登录时间',
`token` varchar(512) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '用户token', `token` varchar(512) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '用户token',
`lastAccess` timestamp(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '最后一次访问时间戳', `lastAccess` timestamp(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '最后一次访问时间戳',
`lockTime` timestamp(0) NOT NULL DEFAULT '1970-01-02 00:00:00' COMMENT '账户锁定时间', `lockTime` timestamp(0) NOT NULL DEFAULT '1970-01-02 00:00:00' COMMENT '账户锁定时间',
`pwdErrTimes` int(11) NOT NULL DEFAULT 0 COMMENT '密码错误次数', `pwdErrTimes` int(11) NOT NULL DEFAULT 0 COMMENT '密码错误次数',
`status` int(11) NULL DEFAULT 0 COMMENT '账户状态', `status` int(11) NULL DEFAULT 0 COMMENT '账户状态',
PRIMARY KEY (`id`) USING BTREE, PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `USERNAME` (`username`) USING BTREE UNIQUE INDEX `USERNAME` (`username`) USING BTREE
) ENGINE = InnoDB ) ENGINE = InnoDB
@ -171,4 +172,30 @@ CREATE TABLE `user_account`
COLLATE = utf8_general_ci COLLATE = utf8_general_ci
ROW_FORMAT = DYNAMIC; ROW_FORMAT = DYNAMIC;
SET FOREIGN_KEY_CHECKS = 1; SET
FOREIGN_KEY_CHECKS = 1;
-- ----------------------------
-- Table structure for msg_serial
-- ----------------------------
DROP TABLE IF EXISTS `msg_serial`;
CREATE TABLE `msg_serial`
(
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`msgSerial` bigint(20) NOT NULL DEFAULT '1' COMMENT '连续消息序号',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=50 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Table structure for alarm_information
-- ----------------------------
DROP TABLE IF EXISTS `alarm_information`;
CREATE TABLE `alarm_information`
(
`id` bigint(11) NOT NULL AUTO_INCREMENT,
`alarmInfo` varchar(255) NOT NULL COMMENT 'emos告警内容',
`createTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8;

View File

@ -0,0 +1,19 @@
<?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.AlarmInformationMapper">
<resultMap id="msg_serial" type="com.dispose.pojo.entity.AlarmInformation">
<id column="id" property="id"/>
<result column="alarmInfo" property="alarmInfo"/>
<result column="createTime" property="createTime"/>
</resultMap>
<insert id="addAlarmInfo" useGeneratedKeys="true" keyProperty="id"
parameterType="com.dispose.pojo.entity.AlarmInformation">
INSERT
IGNORE INTO alarm_information(alarmInfo)
VALUES (
#{alarmInfo}
)
</insert>
</mapper>

View File

@ -150,9 +150,9 @@
SELECT dt.*, dd.* SELECT dt.*, dd.*
FROM device_task dt FROM device_task dt
LEFT JOIN dispose_device dd ON dt.deviceId = dd.id LEFT JOIN dispose_device dd ON dt.deviceId = dd.id
WHERE dd.deviceType = ${@com.dispose.common.DisposeDeviceType@PENGXIN_PLATFORM.getValue()} WHERE dd.deviceType = ${@com.dispose.common.DisposeDeviceType@CMHI_PLATFORM.getValue()}
AND dt.devStatus != ${@com.pengxin.dispose.common.PengXinTaskStatus@TASK_FINISHED_USER.getValue()} AND dt.devStatus != ${@com.cmhi.dispose.common.CmhiDisposeTaskStatus@TASK_FINISHED_USER.getValue()}
AND dt.devStatus != ${@com.pengxin.dispose.common.PengXinTaskStatus@TASK_FINISHED_TIME.getValue()} AND dt.devStatus != ${@com.cmhi.dispose.common.CmhiDisposeTaskStatus@TASK_FINISHED_TIME.getValue()}
AND dt.devStatus != ${@com.pengxin.dispose.common.PengXinTaskStatus@TASK_REVIEWED_FAILED.getValue()} AND dt.devStatus != ${@com.cmhi.dispose.common.CmhiDisposeTaskStatus@TASK_REVIEWED_FAILED.getValue()}
</select> </select>
</mapper> </mapper>

View File

@ -0,0 +1,21 @@
<?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.MsgSerialMapper">
<resultMap id="msg_serial" type="com.dispose.pojo.entity.MsgSerial">
<id column="id" property="id"/>
<result column="msgSerial" property="msgSerial"/>
</resultMap>
<update id="updateMsgSerial">
UPDATE
msg_serial
SET msgSerial = #{msgSerial}
WHERE id = 1;
</update>
<select id="getMaxMsgSerial" resultType="java.lang.Long">
SELECT msgSerial
FROM msg_serial
ORDER BY ID DESC LIMIT 1
</select>
</mapper>

View File

@ -0,0 +1,126 @@
package com.dispose.test.dev.controller;
import cn.hutool.json.JSONObject;
import com.dispose.common.ConstValue;
import com.dispose.common.ErrorCode;
import com.dispose.common.ProtoCryptoType;
import com.dispose.pojo.dto.protocol.base.BaseRespStatus;
import com.dispose.pojo.dto.protocol.base.ProtocolReqDTO;
import com.dispose.pojo.dto.protocol.base.ProtocolRespDTO;
import com.dispose.pojo.dto.protocol.kafka.AlarmInfoReq;
import com.dispose.test.dev.Global.InitTestEnvironment;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import jodd.net.HttpStatus;
import lombok.extern.slf4j.Slf4j;
import org.junit.Assert;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
/**
* The type Auth controller test.
*
* @author <huangxin@cmhi.chinamoblie.com>
*/
@AutoConfigureMockMvc
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Transactional
@Rollback
@Slf4j
public class KafkaControllerTest extends InitTestEnvironment {
/**
* The Mock mvc.
*/
@Resource
private MockMvc mockMvc;
/**
* The Object mapper.
*/
@Resource
private ObjectMapper objectMapper;
/**
* A 1 login.
*
* @throws Exception the exception
*/
@Test
public void a1_dispatchCommand() throws Exception {
JSONObject disposeParam = new JSONObject();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
disposeParam.set("alarmId", "1");
disposeParam.set("dstIp", "192.168.1.1");
disposeParam.set("attackType", "RSTFlood");
disposeParam.set("bpspps", "bps");
disposeParam.set("dstProvince", "浙江");
disposeParam.set("dstCity", "杭州");
disposeParam.set("startTime", sdf.format(new Date()));
// 1清洗2流控3黑洞
disposeParam.set("disposeType", 1);
disposeParam.set("disposeTime", 30);
disposeParam.set("endTime", sdf.format(new Date()));
List<String> srcIp = new ArrayList<>();
srcIp.add("192.168.10.1");
srcIp.add("192.168.10.2");
disposeParam.set("srcIpLs", srcIp);
disposeParam.set("maxBps", "20bps");
disposeParam.set("maxPps", "20pps");
String jsonAlarmInfo = disposeParam.toString();
log.info("============ jsonAlarmInfo :{}", jsonAlarmInfo);
AlarmInfoReq alarmInfoReq = AlarmInfoReq.builder()
.alarmInfo(jsonAlarmInfo).build();
ProtocolReqDTO<AlarmInfoReq> reqInfo = new ProtocolReqDTO<>();
reqInfo.setVer(ConstValue.Protocol.VERSION);
reqInfo.setCryptoType(ProtoCryptoType.CRYPTO_NONE.getCode());
reqInfo.setTimeStamp(System.currentTimeMillis());
reqInfo.setMsgContent(alarmInfoReq);
String ret = mockMvc.perform(MockMvcRequestBuilders
.post("/kafka/dispatchCommand")
.contentType(MediaType.APPLICATION_JSON)
.header("Authorization", ConstValue.STRING_HTTP_AUTH_HEAD + getLoginToken())
.content(objectMapper.writeValueAsString(reqInfo)))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(HttpStatus.ok().status()))
.andReturn()
.getResponse()
.getContentAsString();
ProtocolRespDTO<BaseRespStatus> rspInfo = objectMapper.readValue(ret,
new TypeReference<ProtocolRespDTO<BaseRespStatus>>() {
});
verifyRespProtocol(rspInfo);
log.debug(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(rspInfo));
Assert.assertEquals(ErrorCode.ERR_OK.getCode(), (long) rspInfo.getMsgContent().getStatus());
}
}

View File

@ -1,6 +1,10 @@
package com.dispose.test.dev.debug; package com.dispose.test.dev.debug;
<<<<<<< HEAD
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
=======
import cn.hutool.json.JSONObject;
>>>>>>> origin/v2.0.9_dev
import com.dispose.common.ConstValue; import com.dispose.common.ConstValue;
import com.dispose.common.DDoSAttackType; import com.dispose.common.DDoSAttackType;
import com.dispose.common.DisposeConfigValue; import com.dispose.common.DisposeConfigValue;
@ -32,8 +36,10 @@ import java.lang.reflect.Type;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.security.InvalidKeyException; import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -176,29 +182,29 @@ public class demo {
@Test @Test
public void classEnumValue() throws JsonProcessingException { public void classEnumValue() throws JsonProcessingException {
DisposeDevice dev = DisposeDevice.builder() DisposeDevice dev = DisposeDevice.builder()
.ipAddr("10.88.77.15") .ipAddr("10.88.77.15")
.ipPort("") .ipPort("")
.deviceType(DisposeDeviceType.DPTECH_UMC) .deviceType(DisposeDeviceType.DPTECH_UMC)
.areaCode(0) .areaCode(0)
.deviceName("中移杭研实验室迪普清洗设备") .deviceName("中移杭研实验室迪普清洗设备")
.manufacturer("DPTech") .manufacturer("DPTech")
.model("UMC") .model("UMC")
.version("5.7.13") .version("5.7.13")
.userName("admin") .userName("admin")
.password("UMCAdministrator") .password("UMCAdministrator")
.urlPath("UMC/service/AbnormalFlowCleaningService") .urlPath("UMC/service/AbnormalFlowCleaningService")
.urlType(HttpType.HTTP) .urlType(HttpType.HTTP)
.readme("实验室测试设备") .readme("实验室测试设备")
.status(ObjectStatus.NORMAL) .status(ObjectStatus.NORMAL)
.build(); .build();
DisposeDevice dev2 = DisposeDevice.builder() DisposeDevice dev2 = DisposeDevice.builder()
.version("5.7.135") .version("5.7.135")
.build(); .build();
log.debug(new ObjectMapper() log.debug(new ObjectMapper()
.writerWithDefaultPrettyPrinter() .writerWithDefaultPrettyPrinter()
.writeValueAsString(upgradeDisposeDeviceProperties(dev, dev2))); .writeValueAsString(upgradeDisposeDeviceProperties(dev, dev2)));
} }
/** /**
@ -239,250 +245,250 @@ public class demo {
@Test @Test
public void ipRang() { public void ipRang() {
String[] src = new String[]{"112.13.86.0-112.13.86.255", "112.13.82.0-112.13.82.255", "117.148.175.0-117.148" + String[] src = new String[]{"112.13.86.0-112.13.86.255", "112.13.82.0-112.13.82.255", "117.148.175.0-117.148" +
".175.255", "117.148.174.0-117.148.174.255", "117.148.172.0-117.148.172.255", "117.148.142.0-117.148.142" + ".175.255", "117.148.174.0-117.148.174.255", "117.148.172.0-117.148.172.255", "117.148.142.0-117.148.142" +
".255", "117.148.141.0-117.148.141.255", "117.148.140.0-117.148.140.255", "117.148.131.0-117.148.131.255" ".255", "117.148.141.0-117.148.141.255", "117.148.140.0-117.148.140.255", "117.148.131.0-117.148.131.255"
, "117.148.130.0-117.148.130.255", "117.148.129.0-117.148.129.255", "117.148.128.0-117.148.128.255", "112" + , "117.148.130.0-117.148.130.255", "117.148.129.0-117.148.129.255", "117.148.128.0-117.148.128.255", "112" +
".17.42.0-112.17.42.255", "112.17.41.0-112.17.41.255", "112.17.40.0-112.17.40.255", "112.17.29.0-112.17" + ".17.42.0-112.17.42.255", "112.17.41.0-112.17.41.255", "112.17.40.0-112.17.40.255", "112.17.29.0-112.17" +
".29.255", "112.17.28.0-112.17.28.255", "112.17.27.0-112.17.27.255", "112.17.14.0-112.17.14.255", "112.13" + ".29.255", "112.17.28.0-112.17.28.255", "112.17.27.0-112.17.27.255", "112.17.14.0-112.17.14.255", "112.13" +
".218.0-112.13.218.255", "112.13.217.0-112.13.217.255", "112.13.216.0-112.13.216.255", "112.13.210.0-112" + ".218.0-112.13.218.255", "112.13.217.0-112.13.217.255", "112.13.216.0-112.13.216.255", "112.13.210.0-112" +
".13.210.255", "112.13.209.0-112.13.209.255", "112.13.208.0-112.13.208.255", "112.13.170.171-112.13.170" + ".13.210.255", "112.13.209.0-112.13.209.255", "112.13.208.0-112.13.208.255", "112.13.170.171-112.13.170" +
".255", "112.13.111.0-112.13.111.255", "112.13.108.0-112.13.108.255", "112.13.107.0-112.13.107.255", "112" + ".255", "112.13.111.0-112.13.111.255", "112.13.108.0-112.13.108.255", "112.13.107.0-112.13.107.255", "112" +
".13.106.0-112.13.106.255", "112.13.105.0-112.13.105.255", "112.13.81.0-112.13.81.255", "112.13.87.0-112" + ".13.106.0-112.13.106.255", "112.13.105.0-112.13.105.255", "112.13.81.0-112.13.81.255", "112.13.87.0-112" +
".13.87.255", "111.2.176.0-111.2.176.7", "112.13.80.0-112.13.80.255", "112.13.83.0-112.13.83.255", "112" + ".13.87.255", "111.2.176.0-111.2.176.7", "112.13.80.0-112.13.80.255", "112.13.83.0-112.13.83.255", "112" +
".13.84.0-112.13.84.255", "112.13.85.0-112.13.85.255", "112.13.170.0-112.13.170.169", "111.2.176.9-111.2" + ".13.84.0-112.13.84.255", "112.13.85.0-112.13.85.255", "112.13.170.0-112.13.170.169", "111.2.176.9-111.2" +
".179.255", "117.147.196.0-117.147.199.255", "183.247.240.0-183.247.255.255", "117.148.170.0-117.148.170" + ".179.255", "117.147.196.0-117.147.199.255", "183.247.240.0-183.247.255.255", "117.148.170.0-117.148.170" +
".255", "117.148.169.0-117.148.169.255", "112.17.43.0-112.17.43.255", "112.17.15.0-112.17.15.255", "112" + ".255", "117.148.169.0-117.148.169.255", "112.17.43.0-112.17.43.255", "112.17.15.0-112.17.15.255", "112" +
".13.103.0-112.13.103.255", "112.13.97.0-112.13.97.255", "112.13.112.0-112.13.127.255", "218.205.90.0-218" + ".13.103.0-112.13.103.255", "112.13.97.0-112.13.97.255", "112.13.112.0-112.13.127.255", "218.205.90.0-218" +
".205.91.255", "218.205.88.0-218.205.88.255", "112.13.215.0-112.13.215.255", "112.13.214.0-112.13.214" + ".205.91.255", "218.205.88.0-218.205.88.255", "112.13.215.0-112.13.215.255", "112.13.214.0-112.13.214" +
".255", "112.13.212.0-112.13.212.255", "112.13.211.0-112.13.211.255", "112.13.75.0-112.13.75.63", "112.13" + ".255", "112.13.212.0-112.13.212.255", "112.13.211.0-112.13.211.255", "112.13.75.0-112.13.75.63", "112.13" +
".67.0-112.13.67.255", "112.13.66.0-112.13.66.255", "117.148.177.0-117.148.177.255", "117.148.176.0-117" + ".67.0-112.13.67.255", "112.13.66.0-112.13.66.255", "117.148.177.0-117.148.177.255", "117.148.176.0-117" +
".148.176.255", "112.13.166.0-112.13.166.255", "112.17.252.0-112.17.252.255", "112.17.251.0-112.17.251" + ".148.176.255", "112.13.166.0-112.13.166.255", "112.17.252.0-112.17.252.255", "112.17.251.0-112.17.251" +
".255", "112.17.250.0-112.17.250.255", "117.148.167.0-117.148.167.255", "112.13.174.0-112.13.174.255", ".255", "112.17.250.0-112.17.250.255", "117.148.167.0-117.148.167.255", "112.13.174.0-112.13.174.255",
"112.13.172.0-112.13.172.255", "211.138.129.128-211.138.129.255", "112.17.0.0-112.17.7.255", "218.205.80" + "112.13.172.0-112.13.172.255", "211.138.129.128-211.138.129.255", "112.17.0.0-112.17.7.255", "218.205.80" +
".0-218.205.86.255", "218.205.79.0-218.205.79.255", "218.205.78.0-218.205.78.255", "218.205.77.0-218.205" + ".0-218.205.86.255", "218.205.79.0-218.205.79.255", "218.205.78.0-218.205.78.255", "218.205.77.0-218.205" +
".77.255", "218.205.76.0-218.205.76.255", "218.205.74.0-218.205.74.255", "218.205.73.0-218.205.73.255", ".77.255", "218.205.76.0-218.205.76.255", "218.205.74.0-218.205.74.255", "218.205.73.0-218.205.73.255",
"218.205.72.0-218.205.72.255", "211.138.126.128-211.138.126.255", "211.138.126.112-211.138.126.127", "211" + "218.205.72.0-218.205.72.255", "211.138.126.128-211.138.126.255", "211.138.126.112-211.138.126.127", "211" +
".138.126.104-211.138.126.111", "211.138.126.64-211.138.126.95", "211.138.124.0-211.138.124.255", "211" + ".138.126.104-211.138.126.111", "211.138.126.64-211.138.126.95", "211.138.124.0-211.138.124.255", "211" +
".138.120.0-211.138.123.255", "120.193.8.0-120.193.11.255", "111.1.52.0-111.1.55.255", "111.1.44.0-111.1" + ".138.120.0-211.138.123.255", "120.193.8.0-120.193.11.255", "111.1.52.0-111.1.55.255", "111.1.44.0-111.1" +
".47.255", "111.1.36.0-111.1.39.255", "111.1.34.0-111.1.35.255", "111.1.33.0-111.1.33.255", "111.1.16" + ".47.255", "111.1.36.0-111.1.39.255", "111.1.34.0-111.1.35.255", "111.1.33.0-111.1.33.255", "111.1.16" +
".0-111.1.23.255", "111.0.37.0-111.0.37.255", "111.0.36.0-111.0.36.255", "111.0.35.0-111.0.35.255", "111" + ".0-111.1.23.255", "111.0.37.0-111.0.37.255", "111.0.36.0-111.0.36.255", "111.0.35.0-111.0.35.255", "111" +
".0.34.0-111.0.34.255", "111.0.33.0-111.0.33.255", "111.0.32.0-111.0.32.255", "111.0.31.0-111.0.31.255", ".0.34.0-111.0.34.255", "111.0.33.0-111.0.33.255", "111.0.32.0-111.0.32.255", "111.0.31.0-111.0.31.255",
"111.0.30.0-111.0.30.255", "112.17.48.0-112.17.63.255", "111.3.80.0-111.3.95.255", "117.149.154.0-117.149" + "111.0.30.0-111.0.30.255", "112.17.48.0-112.17.63.255", "111.3.80.0-111.3.95.255", "117.149.154.0-117.149" +
".154.255", "117.147.184.0-117.147.184.255", "112.17.30.0-112.17.30.255", "111.3.76.0-111.3.76.255", "111" + ".154.255", "117.147.184.0-117.147.184.255", "112.17.30.0-112.17.30.255", "111.3.76.0-111.3.76.255", "111" +
".0.29.0-111.0.29.255", "111.0.28.0-111.0.28.255", "111.0.27.0-111.0.27.255", "111.0.26.0-111.0.26.255", ".0.29.0-111.0.29.255", "111.0.28.0-111.0.28.255", "111.0.27.0-111.0.27.255", "111.0.26.0-111.0.26.255",
"111.0.25.0-111.0.25.255", "111.0.24.0-111.0.24.255", "111.0.23.0-111.0.23.255", "111.0.22.0-111.0.22" + "111.0.25.0-111.0.25.255", "111.0.24.0-111.0.24.255", "111.0.23.0-111.0.23.255", "111.0.22.0-111.0.22" +
".255", "218.205.75.0-218.205.75.255", "211.138.126.32-211.138.126.39", "117.148.166.0-117.148.166.255", ".255", "218.205.75.0-218.205.75.255", "211.138.126.32-211.138.126.39", "117.148.166.0-117.148.166.255",
"117.148.165.0-117.148.165.255", "117.148.164.0-117.148.164.255", "117.148.163.0-117.148.163.255", "117" + "117.148.165.0-117.148.165.255", "117.148.164.0-117.148.164.255", "117.148.163.0-117.148.163.255", "117" +
".148.162.0-117.148.162.255", "117.148.161.0-117.148.161.255", "117.148.160.0-117.148.160.255", "112.13" + ".148.162.0-117.148.162.255", "117.148.161.0-117.148.161.255", "117.148.160.0-117.148.160.255", "112.13" +
".223.0-112.13.223.255", "112.13.222.0-112.13.222.255", "112.13.221.0-112.13.221.255", "112.13.220.0-112" + ".223.0-112.13.223.255", "112.13.222.0-112.13.222.255", "112.13.221.0-112.13.221.255", "112.13.220.0-112" +
".13.220.255", "112.13.213.0-112.13.213.255", "112.13.175.0-112.13.175.255", "112.13.173.0-112.13.173" + ".13.220.255", "112.13.213.0-112.13.213.255", "112.13.175.0-112.13.175.255", "112.13.173.0-112.13.173" +
".255", "112.13.79.0-112.13.79.255", "112.13.78.0-112.13.78.255", "112.13.77.0-112.13.77.255", "112.13.76" + ".255", "112.13.79.0-112.13.79.255", "112.13.78.0-112.13.78.255", "112.13.77.0-112.13.77.255", "112.13.76" +
".0-112.13.76.255", "112.13.74.0-112.13.74.255", "112.13.73.0-112.13.73.255", "112.13.72.0-112.13.72.255" ".0-112.13.76.255", "112.13.74.0-112.13.74.255", "112.13.73.0-112.13.73.255", "112.13.72.0-112.13.72.255"
, "112.13.71.0-112.13.71.255", "112.13.70.0-112.13.70.255", "112.13.69.0-112.13.69.255", "112.13.68.0-112" + , "112.13.71.0-112.13.71.255", "112.13.70.0-112.13.70.255", "112.13.69.0-112.13.69.255", "112.13.68.0-112" +
".13.68.255", "112.13.65.0-112.13.65.255", "112.13.64.0-112.13.64.255", "111.2.184.0-111.2.184.255", "111" + ".13.68.255", "112.13.65.0-112.13.65.255", "112.13.64.0-112.13.64.255", "111.2.184.0-111.2.184.255", "111" +
".1.32.0-111.1.32.255", "111.1.41.36-111.1.41.39", "111.1.41.64-111.1.41.79", "120.199.68.38-120.199.68" + ".1.32.0-111.1.32.255", "111.1.41.36-111.1.41.39", "111.1.41.64-111.1.41.79", "120.199.68.38-120.199.68" +
".38", "111.1.41.34-111.1.41.34", "111.1.41.30-111.1.41.30", "111.1.41.22-111.1.41.22", "120.199.68" + ".38", "111.1.41.34-111.1.41.34", "111.1.41.30-111.1.41.30", "111.1.41.22-111.1.41.22", "120.199.68" +
".46-120.199.68.46", "120.199.68.115-120.199.68.115", "120.199.68.114-120.199.68.114", "111.1.41.252-111" + ".46-120.199.68.46", "120.199.68.115-120.199.68.115", "120.199.68.114-120.199.68.114", "111.1.41.252-111" +
".1.41.252", "111.1.41.184-111.1.41.191", "120.199.68.96-120.199.68.111", "120.199.68.93-120.199.68.93", ".1.41.252", "111.1.41.184-111.1.41.191", "120.199.68.96-120.199.68.111", "120.199.68.93-120.199.68.93",
"120.199.68.92-120.199.68.92", "120.199.68.91-120.199.68.91", "120.199.68.90-120.199.68.90", "111.1.41" + "120.199.68.92-120.199.68.92", "120.199.68.91-120.199.68.91", "120.199.68.90-120.199.68.90", "111.1.41" +
".26-111.1.41.26", "120.199.82.6-120.199.82.6", "111.1.41.0-111.1.41.7", "111.1.41.118-111.1.41.118", ".26-111.1.41.26", "120.199.82.6-120.199.82.6", "111.1.41.0-111.1.41.7", "111.1.41.118-111.1.41.118",
"120.199.93.54-120.199.93.54", "111.1.41.29-111.1.41.29", "111.1.41.43-111.1.41.43", "111.1.41.42-111.1" + "120.199.93.54-120.199.93.54", "111.1.41.29-111.1.41.29", "111.1.41.43-111.1.41.43", "111.1.41.42-111.1" +
".41.42", "120.199.80.32-120.199.80.47", "120.199.85.176-120.199.85.176", "120.199.85.184-120.199.85.191" ".41.42", "120.199.80.32-120.199.80.47", "120.199.85.176-120.199.85.176", "120.199.85.184-120.199.85.191"
, "120.199.85.183-120.199.85.183", "120.199.85.182-120.199.85.182", "120.199.85.181-120.199.85.181", "120" + , "120.199.85.183-120.199.85.183", "120.199.85.182-120.199.85.182", "120.199.85.181-120.199.85.181", "120" +
".199.85.180-120.199.85.180", "120.199.71.128-120.199.71.255", "120.199.85.160-120.199.85.175", "120.199" + ".199.85.180-120.199.85.180", "120.199.71.128-120.199.71.255", "120.199.85.160-120.199.85.175", "120.199" +
".68.122-120.199.68.122", "120.199.78.144-120.199.78.144", "120.199.90.0-120.199.90.255", "120.199.78" + ".68.122-120.199.68.122", "120.199.78.144-120.199.78.144", "120.199.90.0-120.199.90.255", "120.199.78" +
".145-120.199.78.145", "120.199.78.148-120.199.78.148", "120.199.78.147-120.199.78.147", "120.199.78" + ".145-120.199.78.145", "120.199.78.148-120.199.78.148", "120.199.78.147-120.199.78.147", "120.199.78" +
".151-120.199.78.151", "120.199.78.150-120.199.78.150", "120.199.78.149-120.199.78.149", "120.199.78" + ".151-120.199.78.151", "120.199.78.150-120.199.78.150", "120.199.78.149-120.199.78.149", "120.199.78" +
".146-120.199.78.146", "120.199.94.160-120.199.94.191", "120.199.69.0-120.199.69.255", "120.199.94.0-120" + ".146-120.199.78.146", "120.199.94.160-120.199.94.191", "120.199.69.0-120.199.69.255", "120.199.94.0-120" +
".199.94.127", "120.199.95.0-120.199.95.255", "120.199.79.0-120.199.79.127", "120.199.71.0-120.199.71" + ".199.94.127", "120.199.95.0-120.199.95.255", "120.199.79.0-120.199.79.127", "120.199.71.0-120.199.71" +
".127", "120.199.78.139-120.199.78.139", "120.199.78.138-120.199.78.138", "120.199.78.137-120.199.78.137" ".127", "120.199.78.139-120.199.78.139", "120.199.78.138-120.199.78.138", "120.199.78.137-120.199.78.137"
, "120.199.78.136-120.199.78.136", "120.199.78.135-120.199.78.135", "120.199.78.134-120.199.78.134", "120" + , "120.199.78.136-120.199.78.136", "120.199.78.135-120.199.78.135", "120.199.78.134-120.199.78.134", "120" +
".199.78.133-120.199.78.133", "120.199.78.132-120.199.78.132", "120.199.78.131-120.199.78.131", "120.199" + ".199.78.133-120.199.78.133", "120.199.78.132-120.199.78.132", "120.199.78.131-120.199.78.131", "120.199" +
".78.130-120.199.78.130", "120.199.78.141-120.199.78.141", "120.199.78.140-120.199.78.140", "111.1.42" + ".78.130-120.199.78.130", "120.199.78.141-120.199.78.141", "120.199.78.140-120.199.78.140", "111.1.42" +
".128-111.1.42.191", "120.199.92.64-120.199.92.127", "120.199.86.0-120.199.86.31", "120.199.85.64-120.199" + ".128-111.1.42.191", "120.199.92.64-120.199.92.127", "120.199.86.0-120.199.86.31", "120.199.85.64-120.199" +
".85.95", "120.199.86.192-120.199.86.255", "120.199.91.0-120.199.91.255", "120.199.92.0-120.199.92.63", ".85.95", "120.199.86.192-120.199.86.255", "120.199.91.0-120.199.91.255", "120.199.92.0-120.199.92.63",
"120.199.84.160-120.199.84.191", "120.199.84.128-120.199.84.159", "120.199.83.64-120.199.83.127", "120" + "120.199.84.160-120.199.84.191", "120.199.84.128-120.199.84.159", "120.199.83.64-120.199.83.127", "120" +
".199.70.0-120.199.70.255", "120.199.85.192-120.199.85.255", "120.199.80.192-120.199.80.255", "120.199.80" + ".199.70.0-120.199.70.255", "120.199.85.192-120.199.85.255", "120.199.80.192-120.199.80.255", "120.199.80" +
".64-120.199.80.127", "120.199.80.48-120.199.80.63", "120.199.85.0-120.199.85.63", "120.199.93.64-120.199" + ".64-120.199.80.127", "120.199.80.48-120.199.80.63", "120.199.85.0-120.199.85.63", "120.199.93.64-120.199" +
".93.127", "111.1.41.128-111.1.41.159", "112.17.33.80-112.17.33.83", "112.17.38.112-112.17.38.127", "183" + ".93.127", "111.1.41.128-111.1.41.159", "112.17.33.80-112.17.33.83", "112.17.38.112-112.17.38.127", "183" +
".247.184.0-183.247.184.63", "112.17.37.64-112.17.37.127", "112.17.37.128-112.17.37.255", "112.17.37" + ".247.184.0-183.247.184.63", "112.17.37.64-112.17.37.127", "112.17.37.128-112.17.37.255", "112.17.37" +
".16-112.17.37.31", "183.247.184.80-183.247.184.95", "183.247.184.96-183.247.184.127", "183.247.184" + ".16-112.17.37.31", "183.247.184.80-183.247.184.95", "183.247.184.96-183.247.184.127", "183.247.184" +
".64-183.247.184.79", "112.17.38.32-112.17.38.47", "112.17.33.0-112.17.33.7", "218.205.113.160-218.205" + ".64-183.247.184.79", "112.17.38.32-112.17.38.47", "112.17.33.0-112.17.33.7", "218.205.113.160-218.205" +
".113.175", "112.17.33.84-112.17.33.87", "112.17.32.128-112.17.32.143", "112.17.33.128-112.17.33.255", ".113.175", "112.17.33.84-112.17.33.87", "112.17.32.128-112.17.32.143", "112.17.33.128-112.17.33.255",
"112.17.38.128-112.17.38.255", "218.205.114.208-218.205.114.223", "112.17.32.32-112.17.32.63", "112.17.33" + "112.17.38.128-112.17.38.255", "218.205.114.208-218.205.114.223", "112.17.32.32-112.17.32.63", "112.17.33" +
".16-112.17.33.31", "112.17.38.0-112.17.38.15", "218.205.114.252-218.205.114.252", "218.205.113.190-218" + ".16-112.17.33.31", "112.17.38.0-112.17.38.15", "218.205.114.252-218.205.114.252", "218.205.113.190-218" +
".205.113.190", "218.205.113.189-218.205.113.189", "218.205.113.188-218.205.113.188", "218.205.113" + ".205.113.190", "218.205.113.189-218.205.113.189", "218.205.113.188-218.205.113.188", "218.205.113" +
".187-218.205.113.187", "218.205.113.186-218.205.113.186", "218.205.113.200-218.205.113.200", "218.205" + ".187-218.205.113.187", "218.205.113.186-218.205.113.186", "218.205.113.200-218.205.113.200", "218.205" +
".113.202-218.205.113.202", "112.17.33.8-112.17.33.11", "112.17.33.12-112.17.33.15", "218.205.113.222-218" + ".113.202-218.205.113.202", "112.17.33.8-112.17.33.11", "112.17.33.12-112.17.33.15", "218.205.113.222-218" +
".205.113.222", "218.205.113.251-218.205.113.251", "183.247.184.158-183.247.184.158", "112.17.37.8-112.17" + ".205.113.222", "218.205.113.251-218.205.113.251", "183.247.184.158-183.247.184.158", "112.17.37.8-112.17" +
".37.15", "183.247.184.143-183.247.184.143", "112.17.32.64-112.17.32.95", "112.17.32.104-112.17.32.111", ".37.15", "183.247.184.143-183.247.184.143", "112.17.32.64-112.17.32.95", "112.17.32.104-112.17.32.111",
"218.205.113.16-218.205.113.31", "112.17.33.96-112.17.33.111", "112.17.38.80-112.17.38.95", "112.17.33" + "218.205.113.16-218.205.113.31", "112.17.33.96-112.17.33.111", "112.17.38.80-112.17.38.95", "112.17.33" +
".88-112.17.33.95", "112.17.32.96-112.17.32.99", "112.17.33.32-112.17.33.63", "218.205.114.192-218.205" + ".88-112.17.33.95", "112.17.32.96-112.17.32.99", "112.17.33.32-112.17.33.63", "218.205.114.192-218.205" +
".114.207", "218.205.114.247-218.205.114.247", "183.247.184.192-183.247.184.255", "183.247.184.139-183" + ".114.207", "218.205.114.247-218.205.114.247", "183.247.184.192-183.247.184.255", "183.247.184.139-183" +
".247.184.139", "183.247.184.136-183.247.184.136", "218.205.113.8-218.205.113.15", "183.247.184.133-183" + ".247.184.139", "183.247.184.136-183.247.184.136", "218.205.113.8-218.205.113.15", "183.247.184.133-183" +
".247.184.133", "112.17.35.120-112.17.35.123", "112.17.36.0-112.17.36.127", "218.205.115.192-218.205.115" + ".247.184.133", "112.17.35.120-112.17.35.123", "112.17.36.0-112.17.36.127", "218.205.115.192-218.205.115" +
".255", "112.17.36.160-112.17.36.167", "112.17.36.128-112.17.36.159", "218.205.113.247-218.205.113.247", ".255", "112.17.36.160-112.17.36.167", "112.17.36.128-112.17.36.159", "218.205.113.247-218.205.113.247",
"218.205.113.254-218.205.113.254", "111.3.71.35-111.3.71.35", "111.3.71.7-111.3.71.7", "111.3.71.128-111" + "218.205.113.254-218.205.113.254", "111.3.71.35-111.3.71.35", "111.3.71.7-111.3.71.7", "111.3.71.128-111" +
".3.71.159", "111.3.71.36-111.3.71.36", "111.3.71.37-111.3.71.37", "111.3.71.38-111.3.71.38", "111.3.71" + ".3.71.159", "111.3.71.36-111.3.71.36", "111.3.71.37-111.3.71.37", "111.3.71.38-111.3.71.38", "111.3.71" +
".34-111.3.71.34", "112.15.32.0-112.15.32.255", "112.15.31.128-112.15.31.255", "112.15.29.0-112.15.29" + ".34-111.3.71.34", "112.15.32.0-112.15.32.255", "112.15.31.128-112.15.31.255", "112.15.29.0-112.15.29" +
".255", "112.15.28.0-112.15.28.255", "112.15.31.0-112.15.31.63", "112.15.30.0-112.15.30.255", "218.205" + ".255", "112.15.28.0-112.15.28.255", "112.15.31.0-112.15.31.63", "112.15.30.0-112.15.30.255", "218.205" +
".121.0-218.205.121.127", "218.205.120.0-218.205.120.255", "218.205.121.128-218.205.121.255", "218.205" + ".121.0-218.205.121.127", "218.205.120.0-218.205.120.255", "218.205.121.128-218.205.121.255", "218.205" +
".119.36-218.205.119.39", "218.205.123.65-218.205.123.65", "218.205.123.66-218.205.123.66", "218.205.123" + ".119.36-218.205.119.39", "218.205.123.65-218.205.123.65", "218.205.123.66-218.205.123.66", "218.205.123" +
".67-218.205.123.67", "218.205.123.68-218.205.123.68", "218.205.123.69-218.205.123.69", "218.205.123" + ".67-218.205.123.67", "218.205.123.68-218.205.123.68", "218.205.123.69-218.205.123.69", "218.205.123" +
".70-218.205.123.70", "112.15.37.128-112.15.37.191", "112.15.38.208-112.15.38.223", "112.15.38.224-112.15" + ".70-218.205.123.70", "112.15.37.128-112.15.37.191", "112.15.38.208-112.15.38.223", "112.15.38.224-112.15" +
".38.255", "117.149.150.0-117.149.150.31", "218.205.123.109-218.205.123.109", "218.205.123.17-218.205.123" + ".38.255", "117.149.150.0-117.149.150.31", "218.205.123.109-218.205.123.109", "218.205.123.17-218.205.123" +
".17", "218.205.123.90-218.205.123.90", "117.149.150.114-117.149.150.114", "117.149.150.115-117.149.150" + ".17", "218.205.123.90-218.205.123.90", "117.149.150.114-117.149.150.114", "117.149.150.115-117.149.150" +
".115", "117.149.150.116-117.149.150.116", "117.149.150.117-117.149.150.117", "117.149.150.118-117.149" + ".115", "117.149.150.116-117.149.150.116", "117.149.150.117-117.149.150.117", "117.149.150.118-117.149" +
".150.118", "117.149.150.119-117.149.150.119", "117.149.150.120-117.149.150.120", "117.149.150.121-117" + ".150.118", "117.149.150.119-117.149.150.119", "117.149.150.120-117.149.150.120", "117.149.150.121-117" +
".149.150.121", "111.1.70.146-111.1.70.146", "111.1.70.147-111.1.70.147", "218.205.123.140-218.205.123" + ".149.150.121", "111.1.70.146-111.1.70.146", "111.1.70.147-111.1.70.147", "218.205.123.140-218.205.123" +
".140", "218.205.123.141-218.205.123.141", "218.205.123.72-218.205.123.79", "218.205.123.80-218.205.123" + ".140", "218.205.123.141-218.205.123.141", "218.205.123.72-218.205.123.79", "218.205.123.80-218.205.123" +
".83", "218.205.123.86-218.205.123.86", "218.205.123.98-218.205.123.98", "218.205.123.99-218.205.123.99", ".83", "218.205.123.86-218.205.123.86", "218.205.123.98-218.205.123.98", "218.205.123.99-218.205.123.99",
"112.15.1.0-112.15.1.255", "112.15.2.0-112.15.2.255", "112.15.3.0-112.15.3.255", "112.15.36.0-112.15.36" + "112.15.1.0-112.15.1.255", "112.15.2.0-112.15.2.255", "112.15.3.0-112.15.3.255", "112.15.36.0-112.15.36" +
".255", "112.15.37.0-112.15.37.127", "117.149.150.32-117.149.150.35", "117.149.150.36-117.149.150.39", ".255", "112.15.37.0-112.15.37.127", "117.149.150.32-117.149.150.35", "117.149.150.36-117.149.150.39",
"117.149.150.40-117.149.150.47", "117.149.150.48-117.149.150.51", "117.149.150.52-117.149.150.55", "117" + "117.149.150.40-117.149.150.47", "117.149.150.48-117.149.150.51", "117.149.150.52-117.149.150.55", "117" +
".149.150.56-117.149.150.59", "117.149.144.67-117.149.144.67", "117.149.150.102-117.149.150.102", "117" + ".149.150.56-117.149.150.59", "117.149.144.67-117.149.144.67", "117.149.150.102-117.149.150.102", "117" +
".149.150.103-117.149.150.103", "117.149.150.122-117.149.150.122", "117.149.150.123-117.149.150.123", ".149.150.103-117.149.150.103", "117.149.150.122-117.149.150.122", "117.149.150.123-117.149.150.123",
"117.149.150.124-117.149.150.124", "117.149.151.0-117.149.151.255", "218.205.123.0-218.205.123.7", "117" + "117.149.150.124-117.149.150.124", "117.149.151.0-117.149.151.255", "218.205.123.0-218.205.123.7", "117" +
".149.150.98-117.149.150.98", "218.205.123.30-218.205.123.30", "111.1.163.0-111.1.163.255", "111.1.162" + ".149.150.98-117.149.150.98", "218.205.123.30-218.205.123.30", "111.1.163.0-111.1.163.255", "111.1.162" +
".128-111.1.162.159", "111.1.162.0-111.1.162.127", "111.1.175.0-111.1.175.255", "111.1.166.0-111.1.166" + ".128-111.1.162.159", "111.1.162.0-111.1.162.127", "111.1.175.0-111.1.175.255", "111.1.166.0-111.1.166" +
".255", "111.1.167.0-111.1.167.127", "111.1.169.0-111.1.169.255", "111.1.170.0-111.1.170.255", "111.1.160" + ".255", "111.1.167.0-111.1.167.127", "111.1.169.0-111.1.169.255", "111.1.170.0-111.1.170.255", "111.1.160" +
".0-111.1.160.255", "111.1.161.0-111.1.161.255", "111.1.162.175-111.1.162.175", "111.1.173.0-111.1.173" + ".0-111.1.160.255", "111.1.161.0-111.1.161.255", "111.1.162.175-111.1.162.175", "111.1.173.0-111.1.173" +
".255", "111.1.162.160-111.1.162.167", "120.199.88.30-120.199.88.30", "117.148.171.0-117.148.171.255", ".255", "111.1.162.160-111.1.162.167", "120.199.88.30-120.199.88.30", "117.148.171.0-117.148.171.255",
"117.148.168.0-117.148.168.255", "117.148.143.0-117.148.143.255", "211.140.21.112-211.140.21.119", "111.1" + "117.148.168.0-117.148.168.255", "117.148.143.0-117.148.143.255", "211.140.21.112-211.140.21.119", "111.1" +
".60.0-111.1.60.255", "112.13.169.0-112.13.169.255", "112.13.168.0-112.13.168.255", "218.205.95.0-218.205" + ".60.0-111.1.60.255", "112.13.169.0-112.13.169.255", "112.13.168.0-112.13.168.255", "218.205.95.0-218.205" +
".95.255", "218.205.94.0-218.205.94.255", "218.205.93.0-218.205.93.255", "218.205.92.0-218.205.92.255", ".95.255", "218.205.94.0-218.205.94.255", "218.205.93.0-218.205.93.255", "218.205.92.0-218.205.92.255",
"112.17.26.0-112.17.26.255", "112.17.13.0-112.17.13.255", "112.17.11.0-112.17.11.255", "112.17.10.0-112" + "112.17.26.0-112.17.26.255", "112.17.13.0-112.17.13.255", "112.17.11.0-112.17.11.255", "112.17.10.0-112" +
".17.10.255", "112.17.12.0-112.17.12.255", "112.17.9.0-112.17.9.255", "112.17.8.0-112.17.8.255", "211.138" + ".17.10.255", "112.17.12.0-112.17.12.255", "112.17.9.0-112.17.9.255", "112.17.8.0-112.17.8.255", "211.138" +
".113.0-211.138.113.255", "211.140.23.0-211.140.23.255", "111.1.63.0-111.1.63.255", "111.1.62.0-111.1.62" + ".113.0-211.138.113.255", "211.140.23.0-211.140.23.255", "111.1.63.0-111.1.63.255", "111.1.62.0-111.1.62" +
".255", "111.1.61.0-111.1.61.255", "111.1.59.0-111.1.59.188", "111.1.58.0-111.1.58.255", "111.1.57.0-111" + ".255", "111.1.61.0-111.1.61.255", "111.1.59.0-111.1.59.188", "111.1.58.0-111.1.58.255", "111.1.57.0-111" +
".1.57.255", "111.1.56.0-111.1.56.255", "111.1.51.0-111.1.51.255", "111.1.50.0-111.1.50.255", "111.1.48" + ".1.57.255", "111.1.56.0-111.1.56.255", "111.1.51.0-111.1.51.255", "111.1.50.0-111.1.50.255", "111.1.48" +
".0-111.1.48.255", "111.1.49.0-111.1.49.97", "111.1.59.190-111.1.59.255", "221.131.216.0-221.131.216.255" ".0-111.1.48.255", "111.1.49.0-111.1.49.97", "111.1.59.190-111.1.59.255", "221.131.216.0-221.131.216.255"
, "111.2.186.0-111.2.186.255", "111.2.185.0-111.2.185.255", "111.2.183.0-111.2.183.255", "111.2.182.0-111" + , "111.2.186.0-111.2.186.255", "111.2.185.0-111.2.185.255", "111.2.183.0-111.2.183.255", "111.2.182.0-111" +
".2.182.255", "111.2.181.0-111.2.181.255", "111.2.180.0-111.2.180.255", "112.13.207.0-112.13.207.255", ".2.182.255", "111.2.181.0-111.2.181.255", "111.2.180.0-111.2.180.255", "112.13.207.0-112.13.207.255",
"112.13.206.0-112.13.206.255", "112.13.205.0-112.13.205.255", "112.13.204.0-112.13.204.255", "112.13.203" + "112.13.206.0-112.13.206.255", "112.13.205.0-112.13.205.255", "112.13.204.0-112.13.204.255", "112.13.203" +
".0-112.13.203.255", "112.13.202.0-112.13.202.255", "112.13.201.0-112.13.201.255", "112.13.200.0-112.13" + ".0-112.13.203.255", "112.13.202.0-112.13.202.255", "112.13.201.0-112.13.201.255", "112.13.200.0-112.13" +
".200.255", "112.13.199.0-112.13.199.255", "112.13.198.0-112.13.198.255", "112.13.197.0-112.13.197.255", ".200.255", "112.13.199.0-112.13.199.255", "112.13.198.0-112.13.198.255", "112.13.197.0-112.13.197.255",
"112.13.196.0-112.13.196.255", "112.13.195.0-112.13.195.255", "112.13.194.0-112.13.194.255", "112.13.193" + "112.13.196.0-112.13.196.255", "112.13.195.0-112.13.195.255", "112.13.194.0-112.13.194.255", "112.13.193" +
".0-112.13.193.255", "211.138.112.0-211.138.112.255", "112.13.93.0-112.13.93.255", "112.13.110.0-112.13" + ".0-112.13.193.255", "211.138.112.0-211.138.112.255", "112.13.93.0-112.13.93.255", "112.13.110.0-112.13" +
".110.255", "112.13.95.0-112.13.95.255", "112.13.91.0-112.13.91.255", "112.13.89.0-112.13.89.255", "112" + ".110.255", "112.13.95.0-112.13.95.255", "112.13.91.0-112.13.91.255", "112.13.89.0-112.13.89.255", "112" +
".13.88.0-112.13.88.255", "112.13.109.0-112.13.109.255", "112.13.100.0-112.13.100.255", "112.13.99.0-112" + ".13.88.0-112.13.88.255", "112.13.109.0-112.13.109.255", "112.13.100.0-112.13.100.255", "112.13.99.0-112" +
".13.99.255", "112.13.98.0-112.13.98.255", "117.142.240.214-117.142.240.214", "117.142.240.213-117.142" + ".13.99.255", "112.13.98.0-112.13.98.255", "117.142.240.214-117.142.240.214", "117.142.240.213-117.142" +
".240.213", "117.142.240.212-117.142.240.212", "112.13.171.0-112.13.171.255", "112.13.102.0-112.13.102" + ".240.213", "117.142.240.212-117.142.240.212", "112.13.171.0-112.13.171.255", "112.13.102.0-112.13.102" +
".255", "112.13.101.0-112.13.101.255", "112.13.96.0-112.13.96.255", "112.13.94.0-112.13.94.255", "112.13" + ".255", "112.13.101.0-112.13.101.255", "112.13.96.0-112.13.96.255", "112.13.94.0-112.13.94.255", "112.13" +
".92.0-112.13.92.255", "112.13.90.0-112.13.90.255", "111.3.72.144-111.3.72.159", "111.3.72.160-111.3.72" + ".92.0-112.13.92.255", "112.13.90.0-112.13.90.255", "111.3.72.144-111.3.72.159", "111.3.72.160-111.3.72" +
".191", "111.3.72.192-111.3.72.193", "218.205.117.2-218.205.117.2", "111.3.72.138-111.3.72.138", "218.205" + ".191", "111.3.72.192-111.3.72.193", "218.205.117.2-218.205.117.2", "111.3.72.138-111.3.72.138", "218.205" +
".117.98-218.205.117.98", "218.205.117.114-218.205.117.114", "218.205.117.115-218.205.117.115", "218.205" + ".117.98-218.205.117.98", "218.205.117.114-218.205.117.114", "218.205.117.115-218.205.117.115", "218.205" +
".117.116-218.205.117.116", "111.3.72.194-111.3.72.195", "111.3.72.196-111.3.72.199", "111.3.72.200-111.3" + ".117.116-218.205.117.116", "111.3.72.194-111.3.72.195", "111.3.72.196-111.3.72.199", "111.3.72.200-111.3" +
".72.207", "111.3.72.208-111.3.72.223", "111.3.72.224-111.3.72.255", "183.246.192.0-183.246.192.255", ".72.207", "111.3.72.208-111.3.72.223", "111.3.72.224-111.3.72.255", "183.246.192.0-183.246.192.255",
"183.246.193.0-183.246.193.1", "218.205.117.14-218.205.117.14", "218.205.117.22-218.205.117.22", "218.205" + "183.246.193.0-183.246.193.1", "218.205.117.14-218.205.117.14", "218.205.117.22-218.205.117.22", "218.205" +
".117.74-218.205.117.74", "111.3.72.142-111.3.72.142", "183.246.193.14-183.246.193.14", "218.205.117" + ".117.74-218.205.117.74", "111.3.72.142-111.3.72.142", "183.246.193.14-183.246.193.14", "218.205.117" +
".82-218.205.117.82", "218.205.117.90-218.205.117.90", "218.205.117.94-218.205.117.94", "218.205.117" + ".82-218.205.117.82", "218.205.117.90-218.205.117.90", "218.205.117.94-218.205.117.94", "218.205.117" +
".102-218.205.117.102", "218.205.117.122-218.205.117.122", "111.3.72.130-111.3.72.130", "111.3.72.131-111" + ".102-218.205.117.102", "218.205.117.122-218.205.117.122", "111.3.72.130-111.3.72.130", "111.3.72.131-111" +
".3.72.131", "111.3.72.129-111.3.72.129", "218.205.117.126-218.205.117.126", "218.205.117.26-218.205.117" + ".3.72.131", "111.3.72.129-111.3.72.129", "218.205.117.126-218.205.117.126", "218.205.117.26-218.205.117" +
".26", "218.205.117.58-218.205.117.58", "218.205.117.62-218.205.117.62", "218.205.117.66-218.205.117.66", ".26", "218.205.117.58-218.205.117.58", "218.205.117.62-218.205.117.62", "218.205.117.66-218.205.117.66",
"218.205.117.70-218.205.117.70", "218.205.117.54-218.205.117.54", "218.205.117.36-218.205.117.39", "218" + "218.205.117.70-218.205.117.70", "218.205.117.54-218.205.117.54", "218.205.117.36-218.205.117.39", "218" +
".205.117.32-218.205.117.35", "218.205.117.128-218.205.117.255", "218.205.117.4-218.205.117.7", "218.205" + ".205.117.32-218.205.117.35", "218.205.117.128-218.205.117.255", "218.205.117.4-218.205.117.7", "218.205" +
".117.76-218.205.117.79", "218.205.124.128-218.205.124.159", "218.205.124.100-218.205.124.103", "218.205" + ".117.76-218.205.117.79", "218.205.124.128-218.205.124.159", "218.205.124.100-218.205.124.103", "218.205" +
".124.64-218.205.124.79", "218.205.124.80-218.205.124.83", "218.205.124.244-218.205.124.247", "218.205" + ".124.64-218.205.124.79", "218.205.124.80-218.205.124.83", "218.205.124.244-218.205.124.247", "218.205" +
".124.84-218.205.124.87", "218.205.124.28-218.205.124.31", "218.205.124.8-218.205.124.15", "218.205.124" + ".124.84-218.205.124.87", "218.205.124.28-218.205.124.31", "218.205.124.8-218.205.124.15", "218.205.124" +
".48-218.205.124.63", "218.205.124.192-218.205.124.223", "218.205.124.160-218.205.124.191", "218.205.124" + ".48-218.205.124.63", "218.205.124.192-218.205.124.223", "218.205.124.160-218.205.124.191", "218.205.124" +
".0-218.205.124.7", "218.205.124.16-218.205.124.19", "218.205.125.128-218.205.125.255", "218.205.125" + ".0-218.205.124.7", "218.205.124.16-218.205.124.19", "218.205.125.128-218.205.125.255", "218.205.125" +
".96-218.205.125.127", "120.199.74.4-120.199.74.12", "120.199.74.2-120.199.74.2", "120.199.73.154-120.199" + ".96-218.205.125.127", "120.199.74.4-120.199.74.12", "120.199.74.2-120.199.74.2", "120.199.73.154-120.199" +
".73.157", "112.15.173.46-112.15.173.46", "111.1.43.64-111.1.43.79", "111.1.43.30-111.1.43.30", "111.1.43" + ".73.157", "112.15.173.46-112.15.173.46", "111.1.43.64-111.1.43.79", "111.1.43.30-111.1.43.30", "111.1.43" +
".26-111.1.43.26", "111.1.43.2-111.1.43.2", "111.1.43.154-111.1.43.155", "111.1.43.146-111.1.43.150", ".26-111.1.43.26", "111.1.43.2-111.1.43.2", "111.1.43.154-111.1.43.155", "111.1.43.146-111.1.43.150",
"111.1.43.14-111.1.43.14", "111.1.40.82-111.1.40.84", "111.1.40.190-111.1.40.190", "111.1.40.66-111.1.40" + "111.1.43.14-111.1.43.14", "111.1.40.82-111.1.40.84", "111.1.40.190-111.1.40.190", "111.1.40.66-111.1.40" +
".75", "111.1.40.186-111.1.40.186", "111.1.40.182-111.1.40.182", "111.1.40.162-111.1.40.162", "111.1.40" + ".75", "111.1.40.186-111.1.40.186", "111.1.40.182-111.1.40.182", "111.1.40.162-111.1.40.162", "111.1.40" +
".128-111.1.40.159", "111.1.40.0-111.1.40.7", "111.1.3.74-111.1.3.75", "111.1.3.66-111.1.3.66", "111.1.3" + ".128-111.1.40.159", "111.1.40.0-111.1.40.7", "111.1.3.74-111.1.3.75", "111.1.3.66-111.1.3.66", "111.1.3" +
".208-111.1.3.223", "111.1.3.195-111.1.3.195", "111.1.3.176-111.1.3.191", "111.1.3.170-111.1.3.173", "111" + ".208-111.1.3.223", "111.1.3.195-111.1.3.195", "111.1.3.176-111.1.3.191", "111.1.3.170-111.1.3.173", "111" +
".1.3.128-111.1.3.159", "111.1.3.122-111.1.3.123", "111.1.3.0-111.1.3.31", "111.1.2.98-111.1.2.99", "111" + ".1.3.128-111.1.3.159", "111.1.3.122-111.1.3.123", "111.1.3.0-111.1.3.31", "111.1.2.98-111.1.2.99", "111" +
".1.2.64-111.1.2.79", "111.1.2.58-111.1.2.62", "111.1.2.202-111.1.2.206", "111.1.2.18-111.1.2.30", "111.1" + ".1.2.64-111.1.2.79", "111.1.2.58-111.1.2.62", "111.1.2.202-111.1.2.206", "111.1.2.18-111.1.2.30", "111.1" +
".2.155-111.1.2.155", "111.1.2.146-111.1.2.146", "111.1.2.100-111.1.2.126", "111.1.2.0-111.1.2.15", "111" + ".2.155-111.1.2.155", "111.1.2.146-111.1.2.146", "111.1.2.100-111.1.2.126", "111.1.2.0-111.1.2.15", "111" +
".1.1.90-111.1.1.90", "111.1.1.82-111.1.1.84", "111.1.1.50-111.1.1.53", "111.1.1.238-111.1.1.238", "111.1" + ".1.1.90-111.1.1.90", "111.1.1.82-111.1.1.84", "111.1.1.50-111.1.1.53", "111.1.1.238-111.1.1.238", "111.1" +
".1.234-111.1.1.234", "111.1.1.187-111.1.1.197", "111.1.1.106-111.1.1.107", "111.1.0.98-111.1.0.99", "111" + ".1.234-111.1.1.234", "111.1.1.187-111.1.1.197", "111.1.1.106-111.1.1.107", "111.1.0.98-111.1.0.99", "111" +
".1.0.166-111.1.0.166", "111.1.0.160-111.1.0.163", "111.1.0.101-111.1.0.155", "111.1.0.100-111.1.0.100", ".1.0.166-111.1.0.166", "111.1.0.160-111.1.0.163", "111.1.0.101-111.1.0.155", "111.1.0.100-111.1.0.100",
"112.12.89.128-112.12.89.191", "112.12.88.0-112.12.88.255", "112.12.6.128-112.12.6.255", "112.12.58" + "112.12.89.128-112.12.89.191", "112.12.88.0-112.12.88.255", "112.12.6.128-112.12.6.255", "112.12.58" +
".20-112.12.58.20", "112.12.58.18-112.12.58.18", "112.12.58.0-112.12.58.15", "112.12.31.144-112.12.31" + ".20-112.12.58.20", "112.12.58.18-112.12.58.18", "112.12.58.0-112.12.58.15", "112.12.31.144-112.12.31" +
".159", "112.12.26.128-112.12.26.255", "112.12.18.64-112.12.18.95", "112.12.18.128-112.12.18.255", "112" + ".159", "112.12.26.128-112.12.26.255", "112.12.18.64-112.12.18.95", "112.12.18.128-112.12.18.255", "112" +
".12.18.0-112.12.18.63", "112.12.15.128-112.12.15.191", "112.12.125.0-112.12.125.255", "111.2.127.0-111.2" + ".12.18.0-112.12.18.63", "112.12.15.128-112.12.15.191", "112.12.125.0-112.12.125.255", "111.2.127.0-111.2" +
".127.255", "111.2.122.0-111.2.122.63", "111.1.9.0-111.1.9.255", "111.1.8.68-111.1.8.79", "111.1.8.48-111" + ".127.255", "111.2.122.0-111.2.122.63", "111.1.9.0-111.1.9.255", "111.1.8.68-111.1.8.79", "111.1.8.48-111" +
".1.8.61", "111.1.8.4-111.1.8.15", "111.1.8.36-111.1.8.47", "111.1.8.242-111.1.8.251", "111.1.8.173-111.1" + ".1.8.61", "111.1.8.4-111.1.8.15", "111.1.8.36-111.1.8.47", "111.1.8.242-111.1.8.251", "111.1.8.173-111.1" +
".8.174", "111.1.8.17-111.1.8.28", "111.1.8.164-111.1.8.172", "111.1.8.142-111.1.8.145", "111.1.8.132-111" + ".8.174", "111.1.8.17-111.1.8.28", "111.1.8.164-111.1.8.172", "111.1.8.142-111.1.8.145", "111.1.8.132-111" +
".1.8.134", "111.1.8.123-111.1.8.126", "111.1.8.118-111.1.8.118", "111.1.8.115-111.1.8.116", "111.1.8" + ".1.8.134", "111.1.8.123-111.1.8.126", "111.1.8.118-111.1.8.118", "111.1.8.115-111.1.8.116", "111.1.8" +
".113-111.1.8.113", "111.1.8.111-111.1.8.111", "111.1.8.107-111.1.8.107", "111.1.8.103-111.1.8.103", "111" + ".113-111.1.8.113", "111.1.8.111-111.1.8.111", "111.1.8.107-111.1.8.107", "111.1.8.103-111.1.8.103", "111" +
".1.10.0-111.1.10.255", "117.149.36.104-117.149.36.107", "112.17.25.0-112.17.25.255", "112.17.24.128-112" + ".1.10.0-111.1.10.255", "117.149.36.104-117.149.36.107", "112.17.25.0-112.17.25.255", "112.17.24.128-112" +
".17.24.255", "112.17.24.0-112.17.24.127", "223.95.61.0-223.95.61.255", "223.95.60.0-223.95.60.255", "223" + ".17.24.255", "112.17.24.0-112.17.24.127", "223.95.61.0-223.95.61.255", "223.95.60.0-223.95.60.255", "223" +
".95.58.0-223.95.59.255", "223.95.56.0-223.95.56.255", "223.95.33.0-223.95.33.127", "223.94.74.0-223.94" + ".95.58.0-223.95.59.255", "223.95.56.0-223.95.56.255", "223.95.33.0-223.95.33.127", "223.94.74.0-223.94" +
".74.255", "223.94.66.128-223.94.66.255", "211.140.141.94-211.140.141.94", "211.140.141.67-211.140.141" + ".74.255", "223.94.66.128-223.94.66.255", "211.140.141.94-211.140.141.94", "211.140.141.67-211.140.141" +
".77", "211.140.141.47-211.140.141.47", "211.140.141.214-211.140.141.214", "211.140.141.206-211.140.141" + ".77", "211.140.141.47-211.140.141.47", "211.140.141.214-211.140.141.214", "211.140.141.206-211.140.141" +
".206", "211.140.141.204-211.140.141.204", "211.140.141.179-211.140.141.179", "211.140.141.153-211.140" + ".206", "211.140.141.204-211.140.141.204", "211.140.141.179-211.140.141.179", "211.140.141.153-211.140" +
".141.153", "211.140.140.50-211.140.140.50", "211.140.140.48-211.140.140.48", "211.140.140.38-211.140.140" + ".141.153", "211.140.140.50-211.140.140.50", "211.140.140.48-211.140.140.48", "211.140.140.38-211.140.140" +
".38", "211.140.138.8-211.140.138.9", "211.140.138.28-211.140.138.28", "211.140.138.2-211.140.138.5", ".38", "211.140.138.8-211.140.138.9", "211.140.138.28-211.140.138.28", "211.140.138.2-211.140.138.5",
"211.140.138.146-211.140.138.146", "211.140.138.10-211.140.138.12", "183.248.129.0-183.248.129.255", "183" + "211.140.138.146-211.140.138.146", "211.140.138.10-211.140.138.12", "183.248.129.0-183.248.129.255", "183" +
".248.128.0-183.248.128.255", "123.58.140.0-123.58.143.255", "117.149.39.96-117.149.39.127", "117.149.39" + ".248.128.0-183.248.128.255", "123.58.140.0-123.58.143.255", "117.149.39.96-117.149.39.127", "117.149.39" +
".64-117.149.39.95", "117.149.39.160-117.149.39.191", "117.149.39.128-117.149.39.159", "117.149.39.0-117" + ".64-117.149.39.95", "117.149.39.160-117.149.39.191", "117.149.39.128-117.149.39.159", "117.149.39.0-117" +
".149.39.63", "117.149.38.192-117.149.38.255", "117.149.38.0-117.149.38.63", "117.149.37.128-117.149.37" + ".149.39.63", "117.149.38.192-117.149.38.255", "117.149.38.0-117.149.38.63", "117.149.37.128-117.149.37" +
".255", "117.149.37.0-117.149.37.127", "117.149.36.128-117.149.36.255", "111.1.26.128-111.1.26.255", "111" + ".255", "117.149.37.0-117.149.37.127", "117.149.36.128-117.149.36.255", "111.1.26.128-111.1.26.255", "111" +
".1.26.0-111.1.26.127", "111.1.25.98-111.1.25.99", "111.1.25.6-111.1.25.6", "111.1.25.34-111.1.25.34", ".1.26.0-111.1.26.127", "111.1.25.98-111.1.25.99", "111.1.25.6-111.1.25.6", "111.1.25.34-111.1.25.34",
"111.1.25.2-111.1.25.3", "111.1.25.192-111.1.25.255", "111.1.25.16-111.1.25.31", "111.1.25.12-111.1.25" + "111.1.25.2-111.1.25.3", "111.1.25.192-111.1.25.255", "111.1.25.16-111.1.25.31", "111.1.25.12-111.1.25" +
".15", "111.1.25.114-111.1.25.114", "111.1.25.106-111.1.25.110", "111.1.25.100-111.1.25.102", "111.1.25" + ".15", "111.1.25.114-111.1.25.114", "111.1.25.106-111.1.25.110", "111.1.25.100-111.1.25.102", "111.1.25" +
".10-111.1.25.10", "111.1.24.128-111.1.24.255", "111.1.27.0-111.1.27.255", "111.1.5.119-111.1.5.125", ".10-111.1.25.10", "111.1.24.128-111.1.24.255", "111.1.27.0-111.1.27.255", "111.1.5.119-111.1.5.125",
"111.1.5.130-111.1.5.130", "111.1.5.133-111.1.5.145", "111.1.5.147-111.1.5.149", "111.1.5.152-111.1.5" + "111.1.5.130-111.1.5.130", "111.1.5.133-111.1.5.145", "111.1.5.147-111.1.5.149", "111.1.5.152-111.1.5" +
".154", "111.1.5.162-111.1.5.165", "111.1.5.168-111.1.5.170", "111.1.5.172-111.1.5.179", "111.1.5.182-111" + ".154", "111.1.5.162-111.1.5.165", "111.1.5.168-111.1.5.170", "111.1.5.172-111.1.5.179", "111.1.5.182-111" +
".1.5.185", "111.1.5.189-111.1.5.189", "111.1.5.19-111.1.5.19", "111.1.5.2-111.1.5.2", "111.1.5.20-111.1" + ".1.5.185", "111.1.5.189-111.1.5.189", "111.1.5.19-111.1.5.19", "111.1.5.2-111.1.5.2", "111.1.5.20-111.1" +
".5.23", "111.1.5.25-111.1.5.25", "111.1.5.29-111.1.5.29", "111.1.5.3-111.1.5.3", "111.1.5.35-111.1.5.37" ".5.23", "111.1.5.25-111.1.5.25", "111.1.5.29-111.1.5.29", "111.1.5.3-111.1.5.3", "111.1.5.35-111.1.5.37"
, "111.1.5.4-111.1.5.5", "111.1.5.50-111.1.5.59", "111.1.5.6-111.1.5.6", "111.1.5.67-111.1.5.69", "111.1" + , "111.1.5.4-111.1.5.5", "111.1.5.50-111.1.5.59", "111.1.5.6-111.1.5.6", "111.1.5.67-111.1.5.69", "111.1" +
".5.77-111.1.5.77", "111.1.5.79-111.1.5.79", "111.1.5.8-111.1.5.8", "111.1.5.80-111.1.5.86", "111.1.6" + ".5.77-111.1.5.77", "111.1.5.79-111.1.5.79", "111.1.5.8-111.1.5.8", "111.1.5.80-111.1.5.86", "111.1.6" +
".12-111.1.6.12", "111.1.6.128-111.1.6.143", "111.1.6.13-111.1.6.13", "111.1.6.147-111.1.6.147", "111.1.6" + ".12-111.1.6.12", "111.1.6.128-111.1.6.143", "111.1.6.13-111.1.6.13", "111.1.6.147-111.1.6.147", "111.1.6" +
".149-111.1.6.149", "111.1.6.153-111.1.6.153", "111.1.6.156-111.1.6.158", "111.1.6.16-111.1.6.16", "111.1" + ".149-111.1.6.149", "111.1.6.153-111.1.6.153", "111.1.6.156-111.1.6.158", "111.1.6.16-111.1.6.16", "111.1" +
".6.160-111.1.6.191", "111.1.6.18-111.1.6.19", "111.1.6.192-111.1.6.199", "111.1.6.2-111.1.6.2", "111.1.6" + ".6.160-111.1.6.191", "111.1.6.18-111.1.6.19", "111.1.6.192-111.1.6.199", "111.1.6.2-111.1.6.2", "111.1.6" +
".200-111.1.6.216", "111.1.6.224-111.1.6.255", "111.1.6.35-111.1.6.39", "111.1.6.4-111.1.6.4", "111.1.6" + ".200-111.1.6.216", "111.1.6.224-111.1.6.255", "111.1.6.35-111.1.6.39", "111.1.6.4-111.1.6.4", "111.1.6" +
".40-111.1.6.49", "111.1.6.5-111.1.6.8", "111.1.6.50-111.1.6.50", "111.1.6.84-111.1.6.85", "111.1.6" + ".40-111.1.6.49", "111.1.6.5-111.1.6.8", "111.1.6.50-111.1.6.50", "111.1.6.84-111.1.6.85", "111.1.6" +
".88-111.1.6.91", "111.1.7.128-111.1.7.255", "111.3.64.0-111.3.67.255", "117.148.189.0-117.148.189.255", ".88-111.1.6.91", "111.1.7.128-111.1.7.255", "111.3.64.0-111.3.67.255", "117.148.189.0-117.148.189.255",
"117.148.190.0-117.148.190.63", "117.148.190.128-117.148.190.255", "117.148.191.0-117.148.191.255", "183" + "117.148.190.0-117.148.190.63", "117.148.190.128-117.148.190.255", "117.148.191.0-117.148.191.255", "183" +
".245.10.0-183.245.10.255", "183.245.11.128-183.245.11.255", "183.245.12.0-183.245.12.31", "183.245.12" + ".245.10.0-183.245.10.255", "183.245.11.128-183.245.11.255", "183.245.12.0-183.245.12.31", "183.245.12" +
".32-183.245.12.35", "183.245.5.0-183.245.5.255", "183.245.6.0-183.245.9.255", "39.175.96.0-39.175.97" + ".32-183.245.12.35", "183.245.5.0-183.245.5.255", "183.245.6.0-183.245.9.255", "39.175.96.0-39.175.97" +
".255", "111.1.14.0-111.1.14.31", "111.1.14.32-111.1.14.47", "111.1.15.105-111.1.15.105", "111.1.15" + ".255", "111.1.14.0-111.1.14.31", "111.1.14.32-111.1.14.47", "111.1.15.105-111.1.15.105", "111.1.15" +
".11-111.1.15.11", "111.1.15.130-111.1.15.146", "111.1.15.157-111.1.15.164", "111.1.15.198-111.1.15.200", ".11-111.1.15.11", "111.1.15.130-111.1.15.146", "111.1.15.157-111.1.15.164", "111.1.15.198-111.1.15.200",
"111.1.15.203-111.1.15.203", "111.1.15.240-111.1.15.255", "112.16.2.128-112.16.2.255", "112.16.224.0-112" + "111.1.15.203-111.1.15.203", "111.1.15.240-111.1.15.255", "112.16.2.128-112.16.2.255", "112.16.224.0-112" +
".16.230.255", "112.16.231.128-112.16.231.255", "112.17.18.0-112.17.19.255", "117.149.194.208-117.149.194" + ".16.230.255", "112.16.231.128-112.16.231.255", "112.17.18.0-112.17.19.255", "117.149.194.208-117.149.194" +
".223", "117.149.194.224-117.149.194.255", "117.149.194.80-117.149.194.95", "117.149.195.0-117.149.195" + ".223", "117.149.194.224-117.149.194.255", "117.149.194.80-117.149.194.95", "117.149.195.0-117.149.195" +
".63", "117.149.196.0-117.149.196.127", "117.149.197.0-117.149.197.255", "117.149.198.0-117.149.198.127", ".63", "117.149.196.0-117.149.196.127", "117.149.197.0-117.149.197.255", "117.149.198.0-117.149.198.127",
"117.149.198.128-117.149.198.191", "117.149.198.192-117.149.198.207", "117.149.224.0-117.149.231.255", "117.149.198.128-117.149.198.191", "117.149.198.192-117.149.198.207", "117.149.224.0-117.149.231.255",
"117.149.232.0-117.149.232.255", "117.149.240.0-117.149.241.255", "117.149.244.0-117.149.248.255", "117" + "117.149.232.0-117.149.232.255", "117.149.240.0-117.149.241.255", "117.149.244.0-117.149.248.255", "117" +
".149.249.0-117.149.249.255", "117.149.250.128-117.149.250.255", "117.149.251.128-117.149.251.255", "117" + ".149.249.0-117.149.249.255", "117.149.250.128-117.149.250.255", "117.149.251.128-117.149.251.255", "117" +
".149.251.16-117.149.251.31", "117.149.251.32-117.149.251.63", "117.149.251.8-117.149.251.15", "117.149" + ".149.251.16-117.149.251.31", "117.149.251.32-117.149.251.63", "117.149.251.8-117.149.251.15", "117.149" +
".252.0-117.149.252.255", "117.149.254.0-117.149.254.255", "117.149.255.124-117.149.255.131", "117.149" + ".252.0-117.149.252.255", "117.149.254.0-117.149.254.255", "117.149.255.124-117.149.255.131", "117.149" +
".255.160-117.149.255.243", "120.193.39.105-120.193.39.105", "120.193.39.11-120.193.39.11", "120.193.39" + ".255.160-117.149.255.243", "120.193.39.105-120.193.39.105", "120.193.39.11-120.193.39.11", "120.193.39" +
".13-120.193.39.13", "120.193.39.16-120.193.39.19", "120.193.39.21-120.193.39.21", "120.193.39.24-120.193" + ".13-120.193.39.13", "120.193.39.16-120.193.39.19", "120.193.39.21-120.193.39.21", "120.193.39.24-120.193" +
".39.24", "120.193.39.32-120.193.39.55", "120.193.39.5-120.193.39.8", "120.193.39.56-120.193.39.62", "120" + ".39.24", "120.193.39.32-120.193.39.55", "120.193.39.5-120.193.39.8", "120.193.39.56-120.193.39.62", "120" +
".193.39.74-120.193.39.79", "120.193.39.80-120.193.39.90", "120.193.39.92-120.193.39.92", "120.193.39" + ".193.39.74-120.193.39.79", "120.193.39.80-120.193.39.90", "120.193.39.92-120.193.39.92", "120.193.39" +
".94-120.193.39.94", "120.193.39.96-120.193.39.96", "211.140.62.0-211.140.62.127", "211.140.62.238-211" + ".94-120.193.39.94", "120.193.39.96-120.193.39.96", "211.140.62.0-211.140.62.127", "211.140.62.238-211" +
".140.62.239", "211.140.62.242-211.140.62.243", "211.140.62.247-211.140.62.249", "221.131.255.128-221.131" + ".140.62.239", "211.140.62.242-211.140.62.243", "211.140.62.247-211.140.62.249", "221.131.255.128-221.131" +
".255.143", "221.131.255.16-221.131.255.31", "221.131.255.240-221.131.255.255", "221.131.255.32-221.131" + ".255.143", "221.131.255.16-221.131.255.31", "221.131.255.240-221.131.255.255", "221.131.255.32-221.131" +
".255.47", "221.131.255.64-221.131.255.95", "221.131.255.8-221.131.255.15", "221.131.255.98-221.131.255" + ".255.47", "221.131.255.64-221.131.255.95", "221.131.255.8-221.131.255.15", "221.131.255.98-221.131.255" +
".99", "43.240.156.0-43.240.159.255", "43.240.72.0-43.240.75.255", "43.241.16.0-43.241.19.255", "103.107" + ".99", "43.240.156.0-43.240.159.255", "43.240.72.0-43.240.75.255", "43.241.16.0-43.241.19.255", "103.107" +
".195.0-103.107.195.255", "111.1.29.0-111.1.29.251", "111.1.30.0-111.1.30.255", "111.1.31.11-111.1.31.13" ".195.0-103.107.195.255", "111.1.29.0-111.1.29.251", "111.1.30.0-111.1.30.255", "111.1.31.11-111.1.31.13"
, "111.1.31.119-111.1.31.120", "111.1.31.132-111.1.31.135", "111.1.31.141-111.1.31.141", "111.1.31" + , "111.1.31.119-111.1.31.120", "111.1.31.132-111.1.31.135", "111.1.31.141-111.1.31.141", "111.1.31" +
".158-111.1.31.161", "111.1.31.164-111.1.31.165", "111.1.31.170-111.1.31.170", "111.1.31.172-111.1.31" + ".158-111.1.31.161", "111.1.31.164-111.1.31.165", "111.1.31.170-111.1.31.170", "111.1.31.172-111.1.31" +
".176", "111.1.31.180-111.1.31.181", "111.1.31.184-111.1.31.186", "111.1.31.19-111.1.31.19", "111.1.31" + ".176", "111.1.31.180-111.1.31.181", "111.1.31.184-111.1.31.186", "111.1.31.19-111.1.31.19", "111.1.31" +
".196-111.1.31.200", "111.1.31.20-111.1.31.21", "111.1.31.202-111.1.31.202", "111.1.31.207-111.1.31.207", ".196-111.1.31.200", "111.1.31.20-111.1.31.21", "111.1.31.202-111.1.31.202", "111.1.31.207-111.1.31.207",
"111.1.31.209-111.1.31.213", "111.1.31.2-111.1.31.7", "111.1.31.221-111.1.31.224", "111.1.31.24-111.1.31" + "111.1.31.209-111.1.31.213", "111.1.31.2-111.1.31.7", "111.1.31.221-111.1.31.224", "111.1.31.24-111.1.31" +
".28", "111.1.31.246-111.1.31.246", "111.1.31.30-111.1.31.30", "111.1.31.51-111.1.31.52", "111.1.31" + ".28", "111.1.31.246-111.1.31.246", "111.1.31.30-111.1.31.30", "111.1.31.51-111.1.31.52", "111.1.31" +
".65-111.1.31.69", "111.1.31.74-111.1.31.74", "111.1.31.8-111.1.31.9", "111.1.31.90-111.1.31.92", "111.1" + ".65-111.1.31.69", "111.1.31.74-111.1.31.74", "111.1.31.8-111.1.31.9", "111.1.31.90-111.1.31.92", "111.1" +
".31.99-111.1.31.101", "111.3.68.112-111.3.68.180", "111.3.68.228-111.3.68.236", "111.3.68.238-111.3.68" + ".31.99-111.1.31.101", "111.3.68.112-111.3.68.180", "111.3.68.228-111.3.68.236", "111.3.68.238-111.3.68" +
".238", "111.3.68.96-111.3.68.111", "111.3.69.0-111.3.69.255", "117.149.146.0-117.149.147.255", "183.131" + ".238", "111.3.68.96-111.3.68.111", "111.3.69.0-111.3.69.255", "117.149.146.0-117.149.147.255", "183.131" +
".16.138-183.131.16.139", "183.131.16.148-183.131.16.151", "183.134.107.20-183.134.107.20", "183.134.107" + ".16.138-183.131.16.139", "183.131.16.148-183.131.16.151", "183.134.107.20-183.134.107.20", "183.134.107" +
".7-183.134.107.7", "183.246.188.0-183.246.188.255", "183.246.189.0-183.246.189.127", "218.205.87.94-218" + ".7-183.134.107.7", "183.246.188.0-183.246.188.255", "183.246.189.0-183.246.189.127", "218.205.87.94-218" +
".205.87.94", "112.13.170.170-112.13.170.170", "111.2.176.8-111.2.176.8", "111.1.59.189-111.1.59.189", ".205.87.94", "112.13.170.170-112.13.170.170", "111.2.176.8-111.2.176.8", "111.1.59.189-111.1.59.189",
"112.13.104.0-112.13.104.255", "111.1.49.98-111.1.49.98", "111.3.72.50/32", "117.149.253.197/32", "111.1" + "112.13.104.0-112.13.104.255", "111.1.49.98-111.1.49.98", "111.3.72.50/32", "117.149.253.197/32", "111.1" +
".49.100/32", "218.205.89.35/32", "117.148.173.130/32"}; ".49.100/32", "218.205.89.35/32", "117.148.173.130/32"};
String ip = "117.149.253.197"; String ip = "117.149.253.197";
for (String n : src) { for (String n : src) {
log.info("{} network {}contains {}", n, log.info("{} network {}contains {}", n,
Helper.ipInRange(n, ip) ? "is " : "not ", Helper.ipInRange(n, ip) ? "is " : "not ",
ip); ip);
} }
} }
@ -494,8 +500,8 @@ public class demo {
String n = "0.0.0.0"; String n = "0.0.0.0";
log.info("{} network {}contains {}", n, log.info("{} network {}contains {}", n,
Helper.ipInRange(n, ip) ? "is " : "not ", Helper.ipInRange(n, ip) ? "is " : "not ",
ip); ip);
} }
/** /**
@ -503,7 +509,7 @@ public class demo {
*/ */
public void haohanStartError() { public void haohanStartError() {
String errMsg = "[{ip=192.168.50.2, 任务名称=三方接口任务467}, {ip=192.168.50.2, 任务名称=三方接口任务468}, {ip=192.168" + String errMsg = "[{ip=192.168.50.2, 任务名称=三方接口任务467}, {ip=192.168.50.2, 任务名称=三方接口任务468}, {ip=192.168" +
".50.2, 任务名称=三方接口任务470}, {ip=192.168.50.2, 任务名称=三方接口任务469}]"; ".50.2, 任务名称=三方接口任务470}, {ip=192.168.50.2, 任务名称=三方接口任务469}]";
String reg = "(\\[(.*?)])"; String reg = "(\\[(.*?)])";
@ -512,8 +518,8 @@ public class demo {
while (n.find()) { while (n.find()) {
log.info("\tsub items: {}", n.group(1) log.info("\tsub items: {}", n.group(1)
.substring(n.group(1).lastIndexOf("=") + 1) .substring(n.group(1).lastIndexOf("=") + 1)
.replaceAll("\\D", "")); .replaceAll("\\D", ""));
} }
} }
@ -522,11 +528,11 @@ public class demo {
*/ */
public void ipaddrVariety() { public void ipaddrVariety() {
String[] ipAddrs = new String[]{ String[] ipAddrs = new String[]{
"ffff::8fff:ffff:0:ffff", "ffff::8fff:ffff:0:ffff",
"::1", "::1",
"192.168.0.1", "192.168.0.1",
"192.168.00.1", "192.168.00.1",
"023.0.2.1" "023.0.2.1"
}; };
for (String s : ipAddrs) { for (String s : ipAddrs) {
@ -550,7 +556,7 @@ public class demo {
Map<Boolean, List<Integer>> groupMap = orgList.stream() Map<Boolean, List<Integer>> groupMap = orgList.stream()
.collect(Collectors.groupingBy(diffList::contains)); .collect(Collectors.groupingBy(diffList::contains));
log.info("Result: {}", groupMap); log.info("Result: {}", groupMap);
} }
@ -607,12 +613,12 @@ public class demo {
* @throws NoSuchPaddingException the no such padding exception * @throws NoSuchPaddingException the no such padding exception
*/ */
public void aes() throws IllegalBlockSizeException, InvalidKeyException, BadPaddingException, public void aes() throws IllegalBlockSizeException, InvalidKeyException, BadPaddingException,
NoSuchAlgorithmException, NoSuchPaddingException { NoSuchAlgorithmException, NoSuchPaddingException {
String plainText = "{\"disposeTime\":60,\"flowDirection\":0,\"mulDisposeIp\":[\"1.1.1.1\"],\"type\":0}"; String plainText = "{\"disposeTime\":60,\"flowDirection\":0,\"mulDisposeIp\":[\"1.1.1.1\"],\"type\":0}";
String aesKey = "hkoUV5ZWh0q1jSxMnpjovVn19Qg99HY6DD40"; String aesKey = "hkoUV5ZWh0q1jSxMnpjovVn19Qg99HY6DD40";
byte[] encode = CryptoHelper.aes128Encryption(plainText.getBytes(StandardCharsets.UTF_8), byte[] encode = CryptoHelper.aes128Encryption(plainText.getBytes(StandardCharsets.UTF_8),
aesKey); aesKey);
log.info("AES Key: {}", aesKey); log.info("AES Key: {}", aesKey);
log.info("Src: {}", plainText); log.info("Src: {}", plainText);
log.info("AES256: {}", CryptoHelper.base64Encryption(encode)); log.info("AES256: {}", CryptoHelper.base64Encryption(encode));
@ -628,9 +634,9 @@ public class demo {
* @throws NoSuchPaddingException the no such padding exception * @throws NoSuchPaddingException the no such padding exception
*/ */
public void aesdec() throws IllegalBlockSizeException, InvalidKeyException, BadPaddingException, public void aesdec() throws IllegalBlockSizeException, InvalidKeyException, BadPaddingException,
NoSuchAlgorithmException, NoSuchPaddingException { NoSuchAlgorithmException, NoSuchPaddingException {
String plainText = "6PgUrZa8zZUzDAxAFpV307JfUDVI1gFNo3ZFT7LKtVzRXc3UbwFh6+5i6" + String plainText = "6PgUrZa8zZUzDAxAFpV307JfUDVI1gFNo3ZFT7LKtVzRXc3UbwFh6+5i6" +
"+667frPR5j1p0XOG1i7Nhy85uHUDWUBZUxHF3vXNkgiKtbWLHw="; "+667frPR5j1p0XOG1i7Nhy85uHUDWUBZUxHF3vXNkgiKtbWLHw=";
String aesKey = "hkoUV5ZWh0q1jSxMnpjovVn19Qg99HY6DD40"; String aesKey = "hkoUV5ZWh0q1jSxMnpjovVn19Qg99HY6DD40";
@ -709,14 +715,40 @@ public class demo {
*/ */
@Test @Test
public void ipPortMatchTest() { public void ipPortMatchTest() {
String[] srcPort = new String[] {"", "80", "443", "81", null}; String[] srcPort = new String[]{"", "80", "443", "81", null};
String[] dstPort = new String[] {"", "80", "443", "81", null}; String[] dstPort = new String[]{"", "80", "443", "81", null};
for(String s : srcPort) { for (String s : srcPort) {
for(String d : dstPort) { for (String d : dstPort) {
log.info("HTTP: [{}] match [{}] is {}", s, d, Helper.isIpPortMatch(s, d, HttpType.HTTP)); log.info("HTTP: [{}] match [{}] is {}", s, d, Helper.isIpPortMatch(s, d, HttpType.HTTP));
log.info("HTTPS: [{}] match [{}] is {}", s, d, Helper.isIpPortMatch(s, d, HttpType.HTTPS)); log.info("HTTPS: [{}] match [{}] is {}", s, d, Helper.isIpPortMatch(s, d, HttpType.HTTPS));
} }
} }
} }
@Test
public void alarmInfoTest() {
JSONObject disposeParam = new JSONObject();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
disposeParam.set("alarmId", "1");
disposeParam.set("dstIp", "192.168.1.1");
disposeParam.set("attackType", "1");
disposeParam.set("bpspps", "bps");
disposeParam.set("dstProvince", "ZHEJIANG");
disposeParam.set("dstCity", "HANGZHOU");
disposeParam.set("startTime", sdf.format(new Date()));
// 1清洗2流控3黑洞
disposeParam.set("disposeType", 1);
disposeParam.set("disposeTime", 30);
disposeParam.set("endTime", "");
List<String> srcIp = new ArrayList<>();
srcIp.add("192.168.10.1");
srcIp.add("192.168.10.2");
disposeParam.set("srcIpLs", srcIp);
disposeParam.set("maxBps", "20bps");
disposeParam.set("maxPps", "20pps");
String jsonAlarmInfo = disposeParam.toString();
log.info("============ jsonAlarmInfo :{}", jsonAlarmInfo);
}
} }

View File

@ -0,0 +1,53 @@
package com.dispose.test.dev.mapper;
import com.dispose.mapper.MsgSerialMapper;
import com.dispose.test.dev.Global.InitTestEnvironment;
import lombok.extern.slf4j.Slf4j;
import org.junit.Assert;
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 org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
/**
* The message serial test.
*/
@RunWith(SpringRunner.class)
@SpringBootTest
@Slf4j
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Transactional
public class MsgSerialMapperTest extends InitTestEnvironment {
/**
* The message serial mapper.
*/
@Resource
MsgSerialMapper msgSerialMapper;
/**
* A 1 add new message serial.
*/
@Test
public void a1_addMsgSerial() {
for (long msgSerial = 1L; msgSerial <= 10L; msgSerial++) {
log.info("++++++++++++++++++MsgSerial {}", msgSerial);
msgSerialMapper.updateMsgSerial(msgSerial);
}
}
@Test
public void a2_getMaxMsgSerial() {
for (long msgSerial = 1L; msgSerial <= 16L; msgSerial++) {
msgSerialMapper.updateMsgSerial(msgSerial);
}
long maxMsgSerial = msgSerialMapper.getMaxMsgSerial();
log.info("+++++++++++++++++++ max MsgSerial {}", maxMsgSerial);
Assert.assertEquals(maxMsgSerial, 16);
}
}