parent
8c44bb712c
commit
ef6c0c52bf
|
@ -5,6 +5,7 @@ import com.dispose.common.DisposeCapacityType;
|
|||
import com.dispose.common.ErrorCode;
|
||||
import com.dispose.common.NetflowDirection;
|
||||
import com.dispose.pojo.po.MulReturnType;
|
||||
import com.dispose.pojo.vo.DeviceFirewareInfo;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
@ -54,6 +55,13 @@ public interface DisposeAbility {
|
|||
@Nullable DDoSAttackType[] attackType,
|
||||
@Nullable Long taskId);
|
||||
|
||||
/**
|
||||
* Gets ability device fireware.
|
||||
*
|
||||
* @return the ability device fireware
|
||||
*/
|
||||
MulReturnType<ErrorCode, DeviceFirewareInfo> getAbilityDeviceFireware();
|
||||
|
||||
|
||||
/**
|
||||
* Gets device link status.
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.dispose.common.DpTechConfigValue;
|
|||
import com.dispose.common.ErrorCode;
|
||||
import com.dispose.common.NetflowDirection;
|
||||
import com.dispose.pojo.po.MulReturnType;
|
||||
import com.dispose.pojo.vo.DeviceFirewareInfo;
|
||||
import com.dptech.dispose.AbnormalFlowCleaningServicePortType;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.cxf.endpoint.Client;
|
||||
|
@ -210,4 +211,26 @@ public class DpTechAbilityImpl implements DisposeAbility {
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets ability device fireware.
|
||||
*
|
||||
* @return the ability device fireware
|
||||
*/
|
||||
@Override
|
||||
public MulReturnType<ErrorCode, DeviceFirewareInfo> getAbilityDeviceFireware() {
|
||||
return new MulReturnType<>(ErrorCode.ERR_OK,
|
||||
DeviceFirewareInfo.builder()
|
||||
.vendor("DpTech")
|
||||
.model("UMC")
|
||||
.firmware("Unknown")
|
||||
.os("Windows Server")
|
||||
.kernel("Windows")
|
||||
.arch("x86_64")
|
||||
.version("5.7.31")
|
||||
.memory(-1)
|
||||
.freeMemory(-1)
|
||||
.cpuUsed(-1)
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.dispose.common.DisposeCapacityType;
|
|||
import com.dispose.common.ErrorCode;
|
||||
import com.dispose.common.NetflowDirection;
|
||||
import com.dispose.pojo.po.MulReturnType;
|
||||
import com.dispose.pojo.vo.DeviceFirewareInfo;
|
||||
import com.haohan.dispose.common.HaoHanStartCleanResp;
|
||||
import com.haohan.dispose.common.HaoHanStopCleanResp;
|
||||
import com.haohan.dispose.protocol.RestfulInterface;
|
||||
|
@ -130,4 +131,26 @@ public class HaoHanAbilityImpl implements DisposeAbility {
|
|||
// 获取任务信息接口调用成功认为设备心跳正常
|
||||
return (restfulInterface.getCleanTaskStatus(this.urlRootPath, -1) != null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets ability device fireware.
|
||||
*
|
||||
* @return the ability device fireware
|
||||
*/
|
||||
@Override
|
||||
public MulReturnType<ErrorCode, DeviceFirewareInfo> getAbilityDeviceFireware() {
|
||||
return new MulReturnType<>(ErrorCode.ERR_OK,
|
||||
DeviceFirewareInfo.builder()
|
||||
.vendor("HaoHan")
|
||||
.model("Unknown")
|
||||
.firmware("Unknown")
|
||||
.os("Linux Server")
|
||||
.kernel("Linux")
|
||||
.arch("x86_64")
|
||||
.version("Unknown")
|
||||
.memory(-1)
|
||||
.freeMemory(-1)
|
||||
.cpuUsed(-1)
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.dispose.common.DisposeCapacityType;
|
|||
import com.dispose.common.ErrorCode;
|
||||
import com.dispose.common.NetflowDirection;
|
||||
import com.dispose.pojo.po.MulReturnType;
|
||||
import com.dispose.pojo.vo.DeviceFirewareInfo;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
@ -63,6 +64,28 @@ public class VirtualAbilityImpl implements DisposeAbility {
|
|||
return new MulReturnType<>(ErrorCode.ERR_OK, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets ability device fireware.
|
||||
*
|
||||
* @return the ability device fireware
|
||||
*/
|
||||
@Override
|
||||
public MulReturnType<ErrorCode, DeviceFirewareInfo> getAbilityDeviceFireware() {
|
||||
return new MulReturnType<>(ErrorCode.ERR_OK,
|
||||
DeviceFirewareInfo.builder()
|
||||
.vendor("Virtual")
|
||||
.model("Dispose_1000")
|
||||
.firmware("Unknown")
|
||||
.os("Unknown")
|
||||
.kernel("Linux")
|
||||
.arch("x86_64")
|
||||
.version("Virtual_Device_2.0")
|
||||
.memory(-1)
|
||||
.freeMemory(-1)
|
||||
.cpuUsed(-1)
|
||||
.build());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets device link status.
|
||||
*
|
||||
|
|
|
@ -143,7 +143,7 @@ public enum DDoSAttackType implements BaseEnum {
|
|||
*/
|
||||
SENTINEL_AMPLIFICATION ( 33, "SENTINEL_AMPLIFICATION"),
|
||||
/**
|
||||
* The Fraggle.
|
||||
* The Fraggle flood.
|
||||
*/
|
||||
FRAGGLE_FLOOD ( 34, "FRAGGLE_FLOOD"),
|
||||
/**
|
||||
|
@ -177,7 +177,13 @@ public enum DDoSAttackType implements BaseEnum {
|
|||
/**
|
||||
* The Igmp flood.
|
||||
*/
|
||||
IGMP_FLOOD ( 42, "IGMP_FLOOD");
|
||||
IGMP_FLOOD ( 42, "IGMP_FLOOD"),
|
||||
|
||||
/**
|
||||
* All attacks d do s attack type.
|
||||
*/
|
||||
ALL_ATTACKS (-1, "ALL_ATTACKS"),
|
||||
;
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.dispose.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
|
@ -163,8 +164,12 @@ public enum DpTechAttackType implements BaseEnum {
|
|||
attackList.add(ICMP_FLOOD);
|
||||
break;
|
||||
|
||||
case ALL_ATTACKS:
|
||||
attackList.addAll(Arrays.asList(DpTechAttackType.values()));
|
||||
break;
|
||||
|
||||
default:
|
||||
return attackList.stream();
|
||||
break;
|
||||
}
|
||||
|
||||
return attackList.stream();
|
||||
|
|
|
@ -54,5 +54,5 @@ public interface DisposeDeviceManager {
|
|||
*
|
||||
* @return the all dispose devices
|
||||
*/
|
||||
List<DisposeDevice> getAllDisposeDevices();
|
||||
List<DisposeDevice> getAllNormalDisposeDevices();
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import java.lang.reflect.Field;
|
|||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* The type Dispose device manager.
|
||||
|
@ -240,13 +241,9 @@ public class DisposeDeviceManagerImpl implements DisposeDeviceManager {
|
|||
* @return the all dispose devices
|
||||
*/
|
||||
@Override
|
||||
public List<DisposeDevice> getAllDisposeDevices() {
|
||||
List<DisposeDevice> devList = disposeDeviceMapper.selectAll();
|
||||
|
||||
if (devList == null) {
|
||||
devList = new ArrayList<>();
|
||||
}
|
||||
|
||||
return devList;
|
||||
public List<DisposeDevice> getAllNormalDisposeDevices() {
|
||||
return disposeDeviceMapper.selectAll().stream()
|
||||
.filter(v -> v.getStatus() == ObjectStatus.NORMAL)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.dispose.pojo.po;
|
|||
|
||||
import com.dispose.ability.DisposeAbility;
|
||||
import com.dispose.pojo.entity.DisposeDevice;
|
||||
import com.dispose.pojo.vo.DeviceFirewareInfo;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
@ -27,6 +28,11 @@ public class AbilityInfo {
|
|||
*/
|
||||
private DisposeDevice dev;
|
||||
|
||||
/**
|
||||
* The Fireware info.
|
||||
*/
|
||||
private DeviceFirewareInfo firewareInfo;
|
||||
|
||||
/**
|
||||
* The Link status.
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
package com.dispose.pojo.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* The type Device fireware info.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DeviceFirewareInfo {
|
||||
/**
|
||||
* The Vendor.
|
||||
*/
|
||||
private String vendor;
|
||||
/**
|
||||
* The Model.
|
||||
*/
|
||||
private String model;
|
||||
/**
|
||||
* The Firmware.
|
||||
*/
|
||||
private String firmware;
|
||||
/**
|
||||
* The Os.
|
||||
*/
|
||||
private String os;
|
||||
/**
|
||||
* The Kernel.
|
||||
*/
|
||||
private String kernel;
|
||||
/**
|
||||
* The Arch.
|
||||
*/
|
||||
private String arch;
|
||||
/**
|
||||
* The Version.
|
||||
*/
|
||||
private String version;
|
||||
/**
|
||||
* The Memory.
|
||||
*/
|
||||
private int memory;
|
||||
/**
|
||||
* The Free memory.
|
||||
*/
|
||||
private int freeMemory;
|
||||
/**
|
||||
* The Cpu used.
|
||||
*/
|
||||
private int cpuUsed;
|
||||
}
|
|
@ -43,7 +43,7 @@ public class DisposeAbilityRouterServiceImpl implements DisposeAbilityRouterServ
|
|||
*/
|
||||
@PostConstruct
|
||||
private void initDisposeAbility() {
|
||||
List<DisposeDevice> devList = disposeDeviceManager.getAllDisposeDevices();
|
||||
List<DisposeDevice> devList = disposeDeviceManager.getAllNormalDisposeDevices();
|
||||
devList.forEach(this::addDisposeAbilityDevice);
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ public class DisposeAbilityRouterServiceImpl implements DisposeAbilityRouterServ
|
|||
*/
|
||||
@Override
|
||||
public AbilityInfo getAbilityDevice(String ipAddr, String ipPort) {
|
||||
return disposeAbilityMap.get(getAbilityMapKey(ipAddr, ipPort));
|
||||
return disposeAbilityMap.get(getAbilityDeviceHashKey(ipAddr, ipPort));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -80,7 +80,7 @@ public class DisposeAbilityRouterServiceImpl implements DisposeAbilityRouterServ
|
|||
DisposeAbility db;
|
||||
|
||||
String httpType = dev.getUrlType() == HttpType.HTTP ? "http://" : "https://";
|
||||
String addr = getAbilityMapKey(dev.getIpAddr(), dev.getIpPort());
|
||||
String addr = getAbilityDeviceHashKey(dev.getIpAddr(), dev.getIpPort());
|
||||
String url = httpType + addr + "/" + dev.getUrlPath();
|
||||
|
||||
switch (dev.getDeviceType()) {
|
||||
|
@ -112,13 +112,13 @@ public class DisposeAbilityRouterServiceImpl implements DisposeAbilityRouterServ
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets ability map key.
|
||||
* Gets ability device hash key.
|
||||
*
|
||||
* @param ipAddr the ip addr
|
||||
* @param ipPort the ip port
|
||||
* @return the ability map key
|
||||
* @return the ability device hash key
|
||||
*/
|
||||
private String getAbilityMapKey(String ipAddr, String ipPort) {
|
||||
private String getAbilityDeviceHashKey(String ipAddr, String ipPort) {
|
||||
return (ipPort == null || ipPort.length() == 0) ? ipAddr : (ipAddr + ":" + ipPort);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,11 +3,16 @@ package com.dispose.setup;
|
|||
import com.dispose.common.AuthConfigValue;
|
||||
import com.dispose.common.DisposeConfigValue;
|
||||
import com.dispose.common.DpTechConfigValue;
|
||||
import com.dispose.common.ErrorCode;
|
||||
import com.dispose.config.AuthConfigure;
|
||||
import com.dispose.config.DisposeConfigure;
|
||||
import com.dispose.config.DpTechConfigure;
|
||||
import com.dispose.pojo.po.MulReturnType;
|
||||
import com.dispose.pojo.vo.DeviceFirewareInfo;
|
||||
import com.dispose.service.DisposeAbilityRouterService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
@ -38,6 +43,12 @@ public class SystemInitial implements CommandLineRunner {
|
|||
@Resource
|
||||
DpTechConfigure dpTechConfigure;
|
||||
|
||||
/**
|
||||
* The Dispose ability router service.
|
||||
*/
|
||||
@Resource
|
||||
private DisposeAbilityRouterService disposeAbilityRouterService;
|
||||
|
||||
/**
|
||||
* Load configure.
|
||||
*/
|
||||
|
@ -83,6 +94,19 @@ public class SystemInitial implements CommandLineRunner {
|
|||
}
|
||||
}
|
||||
|
||||
@Async("bizExecutor")
|
||||
public void setupAbilityDevice() {
|
||||
disposeAbilityRouterService.getAllAbilityDevices().forEach(v -> {
|
||||
v.setLinkStatus(v.getDb().getDeviceLinkStatus());
|
||||
MulReturnType<ErrorCode, DeviceFirewareInfo> ret = v.getDb().getAbilityDeviceFireware();
|
||||
|
||||
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
|
||||
v.setFirewareInfo(ret.getSecondParam());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Run.
|
||||
*
|
||||
|
@ -92,5 +116,8 @@ public class SystemInitial implements CommandLineRunner {
|
|||
public void run(String... args) {
|
||||
// 系统初始化入口
|
||||
loadConfigure();
|
||||
|
||||
// 初始化处置能力设备
|
||||
setupAbilityDevice();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package com.dispose.task;
|
||||
|
||||
import com.dispose.common.ErrorCode;
|
||||
import com.dispose.pojo.po.MulReturnType;
|
||||
import com.dispose.pojo.vo.DeviceFirewareInfo;
|
||||
import com.dispose.service.DisposeAbilityRouterService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
|
@ -23,15 +26,37 @@ public class DeviceManagerTask {
|
|||
private DisposeAbilityRouterService disposeAbilityRouterService;
|
||||
|
||||
/**
|
||||
* Thread pool task.
|
||||
* Update device link status task.
|
||||
*/
|
||||
@Async("bizExecutor")
|
||||
@Scheduled(cron = "0/5 * * * * ?")
|
||||
public void threadPoolTask() {
|
||||
disposeAbilityRouterService.getAllAbilityDevices().forEach(v -> log.info("{}{} get link status {}",
|
||||
v.getDev().getIpAddr(),
|
||||
((v.getDev().getIpPort() == null || v.getDev().getIpPort().length() == 0) ?
|
||||
"" : ":" + v.getDev().getIpPort()),
|
||||
v.getDb().getDeviceLinkStatus()));
|
||||
@Scheduled(cron = "0/30 * * * * ?")
|
||||
public void updateDeviceLinkStatusTask() {
|
||||
disposeAbilityRouterService.getAllAbilityDevices().forEach(v -> {
|
||||
v.setLinkStatus(v.getDb().getDeviceLinkStatus());
|
||||
log.debug("{}{} get link status {}", v.getDev().getIpAddr(),
|
||||
((v.getDev().getIpPort() == null || v.getDev().getIpPort().length() == 0) ? "" :
|
||||
":" + v.getDev().getIpPort()),
|
||||
v.isLinkStatus());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Update device fireware task.
|
||||
*/
|
||||
@Async("bizExecutor")
|
||||
@Scheduled(cron = "0 */1 * * * ?")
|
||||
public void updateDeviceFirewareTask() {
|
||||
disposeAbilityRouterService.getAllAbilityDevices().forEach(v -> {
|
||||
MulReturnType<ErrorCode, DeviceFirewareInfo> ret = v.getDb().getAbilityDeviceFireware();
|
||||
|
||||
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
|
||||
v.setFirewareInfo(ret.getSecondParam());
|
||||
}
|
||||
|
||||
log.debug("{}{} get fireware status {}", v.getDev().getIpAddr(),
|
||||
((v.getDev().getIpPort() == null || v.getDev().getIpPort().length() == 0) ? "" :
|
||||
":" + v.getDev().getIpPort()),
|
||||
ret.getFirstParam());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue