1、mtr探测设备增加并发限制。

2、开发防火墙策略区分ipv4和ipv6。
3、脚本执行策略下发时间优化。
This commit is contained in:
gaoyutao
2025-12-03 19:18:12 +08:00
parent a40a6f344e
commit a5b5f5b08d
18 changed files with 249 additions and 32 deletions
@@ -12,6 +12,8 @@ public class RspVo {
private String resMag;
/** 路由 */
private String addRoute;
/** 业务网卡名称 */
private String netName;
/** 时间戳 */
private long timestamp = Instant.now().getEpochSecond();
}
@@ -628,6 +628,7 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
rspVo.setResCode(1);
rspVo.setResMag("注册成功");
rspVo.setAddRoute(JSONObject.toJSONString(routeMsg));
rspVo.setNetName(networkInfo.getName());
messageVo.setData(JSONObject.toJSONString(rspVo));
remoteRocketMqService.sendAsyncProducerMessage(
"tr_agent_down", "", "regist_rsp", JSONObject.toJSONString(messageVo), SecurityConstants.INNER
@@ -745,36 +746,54 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
RmNetworkInterfaceRemote queryParam = new RmNetworkInterfaceRemote();
queryParam.setClientId(clientId);
Optional.ofNullable(remoteRocketMqService.getNetworkInterfaceList(queryParam, SecurityConstants.INNER))
R<List<RmNetworkInterfaceRemote>> netList = remoteRocketMqService.getNetworkInterfaceList(queryParam, SecurityConstants.INNER);
// 获取所有bindIp为1或3的网络接口
List<RmNetworkInterfaceRemote> filteredNetworks = Optional.ofNullable(netList)
.map(R::getData)
.flatMap(list -> list.stream()
.map(list -> list.stream()
.filter(ni -> "1".equals(ni.getBindIp()) || "3".equals(ni.getBindIp()))
.findFirst())
.ifPresent(network -> {
updateData.setRegistrationStatus("1");
.collect(Collectors.toList()))
.orElse(Collections.emptyList());
// 发送注册响应
RouteMsg routeMsg = new RouteMsg();
routeMsg.setName(network.getInterfaceName());
routeMsg.setGateway(network.getGateway());
// 如果有符合条件的网络接口
if (!filteredNetworks.isEmpty()) {
updateData.setRegistrationStatus("1");
MessageVo messageVo = new MessageVo();
messageVo.setClientId(clientId);
messageVo.setDataType(MsgEnum.注册应答.getValue());
// 拼接所有符合条件的网络接口名称,用分号隔开
StringBuilder netNameBuilder = new StringBuilder();
for (int i = 0; i < filteredNetworks.size(); i++) {
if (i > 0) {
netNameBuilder.append(";");
}
netNameBuilder.append(filteredNetworks.get(i).getInterfaceName());
}
String netName = netNameBuilder.toString();
RspVo rspVo = new RspVo();
rspVo.setResCode(1);
rspVo.setResMag("注册成功");
rspVo.setAddRoute(JSONObject.toJSONString(routeMsg));
// 发送注册响应
RouteMsg routeMsg = new RouteMsg();
routeMsg.setName(filteredNetworks.get(0).getInterfaceName()); // 使用拼接后的网络接口名称
routeMsg.setGateway(filteredNetworks.get(0).getGateway()); // 使用第一个网络接口的网关,或者您可以根据需要调整
messageVo.setData(JSONObject.toJSONString(rspVo));
MessageVo messageVo = new MessageVo();
messageVo.setClientId(clientId);
messageVo.setDataType(MsgEnum.注册应答.getValue());
remoteRocketMqService.sendAsyncProducerMessage(
"tr_agent_down", "", "regist_rsp", JSONObject.toJSONString(messageVo), SecurityConstants.INNER
);
// 注册成功,下发优先级为0的策略
remoteRocketMqService.issueDefaultPolicyByClientId(clientId, SecurityConstants.INNER);
});
RspVo rspVo = new RspVo();
rspVo.setResCode(1);
rspVo.setResMag("注册成功");
rspVo.setAddRoute(JSONObject.toJSONString(routeMsg));
rspVo.setNetName(netName);
messageVo.setData(JSONObject.toJSONString(rspVo));
remoteRocketMqService.sendAsyncProducerMessage(
"tr_agent_down", "", "regist_rsp", JSONObject.toJSONString(messageVo), SecurityConstants.INNER
);
// 注册成功,下发优先级为0的策略
remoteRocketMqService.issueDefaultPolicyByClientId(clientId, SecurityConstants.INNER);
}
}
rmResourceRegistrationMapper.updateRmResourceRegistration(updateData);