parent
5c11f53992
commit
f92bc9a097
|
@ -163,10 +163,12 @@ public class PengXinAbilityImpl implements DisposeAbility {
|
||||||
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);
|
// 集团一键处置线上环境,移除对处置能力检测操作
|
||||||
return new MulReturnType<>(ErrorCode.ERR_UNSUPPORT, null);
|
// if (capType != DisposeCapacityType.BLACKHOOL) {
|
||||||
}
|
// 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) {
|
||||||
|
@ -359,54 +361,55 @@ 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;
|
||||||
}
|
// }
|
||||||
|
|
||||||
try {
|
// try {
|
||||||
String url = urlRootPath + "dispose_device/information/capacity";
|
// String url = urlRootPath + "dispose_device/information/capacity";
|
||||||
|
//
|
||||||
ProtocolRespDTO<PengXinDisposeAbilityRsp> rspInfo = restfulInterface.getDeviceDisposeAbility(url, token);
|
// ProtocolRespDTO<PengXinDisposeAbilityRsp> rspInfo = restfulInterface.getDeviceDisposeAbility(url, token);
|
||||||
|
//
|
||||||
// 判断是否token过期
|
// // 判断是否token过期
|
||||||
if (rspInfo != null && reLogin(rspInfo, rspInfo.getMsgContent().getStatus())) {
|
// if (rspInfo != null && reLogin(rspInfo, rspInfo.getMsgContent().getStatus())) {
|
||||||
rspInfo = restfulInterface.getDeviceDisposeAbility(url, token);
|
// rspInfo = restfulInterface.getDeviceDisposeAbility(url, token);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (rspInfo != null && rspInfo.getCode() == ErrorCode.ERR_OK.getHttpCode()
|
// if (rspInfo != null && rspInfo.getCode() == ErrorCode.ERR_OK.getHttpCode()
|
||||||
&& rspInfo.getMsgContent().getStatus() == ErrorCode.ERR_OK.getCode()) {
|
// && rspInfo.getMsgContent().getStatus() == ErrorCode.ERR_OK.getCode()) {
|
||||||
|
//
|
||||||
rspInfo.getMsgContent().getCapacity().forEach(v -> {
|
// rspInfo.getMsgContent().getCapacity().forEach(v -> {
|
||||||
if (v.getObjectType().equals(DisposeObjectType.DOMAIN.getValue())) {
|
// if (v.getObjectType().equals(DisposeObjectType.DOMAIN.getValue())) {
|
||||||
log.error("Unsupported: {}", v.getObjectType());
|
// log.error("Unsupported: {}", v.getObjectType());
|
||||||
} else if (v.getObjectType().equals(DisposeObjectType.URL.getValue())) {
|
// } else if (v.getObjectType().equals(DisposeObjectType.URL.getValue())) {
|
||||||
log.error("Unsupported: {}", v.getObjectType());
|
// log.error("Unsupported: {}", v.getObjectType());
|
||||||
} else {
|
// } else {
|
||||||
synchronized (this) {
|
// synchronized (this) {
|
||||||
|
//
|
||||||
protectIpV4.clear();
|
// protectIpV4.clear();
|
||||||
protectIpV6.clear();
|
// protectIpV6.clear();
|
||||||
|
//
|
||||||
if (v.getIpType() == null || v.getIpType().equals(IpAddrType.IPV4_IPV6.getValue())) {
|
// if (v.getIpType() == null || v.getIpType().equals(IpAddrType.IPV4_IPV6.getValue())) {
|
||||||
String [] allIpAddr = {null, "0.0.0.0", "0.0.0.0,::"};
|
// String [] allIpAddr = {null, "0.0.0.0", "0.0.0.0,::"};
|
||||||
|
//
|
||||||
if(Arrays.asList(allIpAddr).contains(v.getDisposeIp())) {
|
// if(Arrays.asList(allIpAddr).contains(v.getDisposeIp())) {
|
||||||
protectIpV4.add("");
|
// protectIpV4.add("");
|
||||||
protectIpV6.add("");
|
// protectIpV6.add("");
|
||||||
}
|
// }
|
||||||
} else if (v.getIpType().equals(IpAddrType.IPV4.getValue())) {
|
// } else if (v.getIpType().equals(IpAddrType.IPV4.getValue())) {
|
||||||
protectIpV4.add("");
|
// protectIpV4.add("");
|
||||||
} else if (v.getIpType().equals(IpAddrType.IPV6.getValue())) {
|
// } else if (v.getIpType().equals(IpAddrType.IPV6.getValue())) {
|
||||||
protectIpV6.add("");
|
// protectIpV6.add("");
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
} catch (Exception ignored) {
|
// } catch (Exception ignored) {
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -417,34 +420,36 @@ public class PengXinAbilityImpl implements DisposeAbility {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isCarryProtectIp(String ipAddr) {
|
public boolean isCarryProtectIp(String ipAddr) {
|
||||||
boolean ret = false;
|
// 集团一键处置线上环境,默认支持所有IP地址
|
||||||
IPAddress addr = new IPAddressString(ipAddr).getAddress();
|
return true;
|
||||||
synchronized (this) {
|
// boolean ret = false;
|
||||||
if (addr.isIPv4()) {
|
// IPAddress addr = new IPAddressString(ipAddr).getAddress();
|
||||||
ret = protectIpV4.stream().anyMatch(v -> Helper.ipInRange(v, ipAddr));
|
// synchronized (this) {
|
||||||
}
|
// 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
|
//
|
||||||
getDisposeDeviceProtectObject();
|
// if (!ret) {
|
||||||
|
// // 更新设备防护IP
|
||||||
synchronized (this) {
|
// getDisposeDeviceProtectObject();
|
||||||
if (addr.isIPv4()) {
|
//
|
||||||
ret = protectIpV4.stream().anyMatch(v -> Helper.ipInRange(v, ipAddr));
|
// synchronized (this) {
|
||||||
}
|
// 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -533,8 +538,9 @@ public class PengXinAbilityImpl implements DisposeAbility {
|
||||||
public void periodTaskRuntime() {
|
public void periodTaskRuntime() {
|
||||||
log.debug("++++PengXin Period Task Running");
|
log.debug("++++PengXin Period Task Running");
|
||||||
|
|
||||||
|
// 集团一键处置线上环境,不再定时获取设备能力信息
|
||||||
// 更新防护对象
|
// 更新防护对象
|
||||||
getDisposeDeviceProtectObject();
|
//getDisposeDeviceProtectObject();
|
||||||
|
|
||||||
// 更新心跳状态
|
// 更新心跳状态
|
||||||
if (timerCnt++ % DisposeConfigValue.HEART_PERIOD_OF_SECOND == 0) {
|
if (timerCnt++ % DisposeConfigValue.HEART_PERIOD_OF_SECOND == 0) {
|
||||||
|
|
Loading…
Reference in New Issue