节点健康信息增加xray状态显示

This commit is contained in:
lys 2026-03-24 15:40:24 +08:00
parent 8a86a56c6b
commit 5ac0c097c6
5 changed files with 27 additions and 16 deletions

View File

@ -133,7 +133,8 @@ public class RemnaNodeHealthcheckJob {
.set(NetNode::getReportStatusTime, new Date())
.set(NetNode::getXrayVersion, responseData.getXrayVersion())
.set(NetNode::getNodeVersion, responseData.getNodeVersion())
.set(NetNode::getOnlineStatus, true);
.set(NetNode::getOnlineStatus, true)
.set(NetNode::getXrayStatus, Boolean.TRUE.equals(responseData.getXrayInternalStatusCached()));
TenantHelper.ignore(() -> netNodeMapper.update(null, updateWrapper));
}
@ -144,7 +145,8 @@ public class RemnaNodeHealthcheckJob {
private void updateNodeOffline(Long nodeId) {
LambdaUpdateWrapper<NetNode> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(NetNode::getId, nodeId)
.set(NetNode::getOnlineStatus, false);
.set(NetNode::getOnlineStatus, false)
.set(NetNode::getXrayStatus, false);
TenantHelper.ignore(() -> netNodeMapper.update(null, updateWrapper));
}

View File

@ -198,18 +198,11 @@ public class RemnaNodeUserStatsJob {
LambdaQueryWrapper<NetNode> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(NetNode::getNodeSoftType, NetNodeSoftTypeEnum.REMNAWAVE.getNodeValue())
.eq(NetNode::getEnableFlag, 1)
.eq(NetNode::getOnlineStatus, true)
.eq(NetNode::getXrayStatus, true)
.isNotNull(NetNode::getReportStatusTime);
List<NetNode> nodes = netNodeMapper.selectList(queryWrapper);
// 过滤掉状态超时的节点
Date timeoutThreshold = new Date(System.currentTimeMillis() - NODE_STATUS_TIMEOUT_MS);
nodes.removeIf(node ->
node.getReportStatusTime() != null &&
node.getReportStatusTime().before(timeoutThreshold)
);
return nodes;
return netNodeMapper.selectList(queryWrapper);
});
}

View File

@ -230,4 +230,9 @@ public class NetNode extends TenantEntity {
*/
private Boolean onlineStatus;
/**
* Xray状态
*/
private Boolean xrayStatus;
}

View File

@ -249,6 +249,11 @@ public class NetNodeVo implements Serializable {
*/
private Boolean onlineStatus;
/**
* xray在线状态true=正常false=异常
*/
private Boolean xrayStatus;
/**
* 节点软件支撑
*/

View File

@ -37,7 +37,6 @@ public class NetNodeConfigServiceImpl implements INetNodeConfigService {
private final NetNodeConfigMapper baseMapper;
private final NetNodeMapper netNodeMapper;
private final INetNodeService netNodeService;
/**
* 默认的Xray API端口起始值
@ -332,7 +331,7 @@ public class NetNodeConfigServiceImpl implements INetNodeConfigService {
@Override
public XrayStartResponse startXray(Long nodeId) {
// 获取节点信息
NetNodeVo node = netNodeService.queryById(nodeId);
NetNodeVo node = netNodeMapper.selectVoById(nodeId);
if (node == null) {
throw new ServiceException("节点不存在");
}
@ -367,7 +366,7 @@ public class NetNodeConfigServiceImpl implements INetNodeConfigService {
@Override
public Boolean stopXray(Long nodeId) {
// 获取节点信息
NetNodeVo node = netNodeService.queryById(nodeId);
NetNodeVo node = netNodeMapper.selectVoById(nodeId);
if (node == null) {
throw new ServiceException("节点不存在");
}
@ -390,6 +389,10 @@ public class NetNodeConfigServiceImpl implements INetNodeConfigService {
log.error("停止节点Xray失败, HTTP状态码: {}, 响应: {}", response.getStatus(), response.body());
return false;
}
LambdaUpdateWrapper<NetNode> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(NetNode::getId, nodeId);
updateWrapper.set(NetNode::getXrayStatus, false);
netNodeMapper.update(updateWrapper);
return true;
} catch (Exception e) {
log.error("停止节点Xray异常: {}", e.getMessage(), e);
@ -400,7 +403,7 @@ public class NetNodeConfigServiceImpl implements INetNodeConfigService {
@Override
public Object getXrayStatus(Long nodeId) {
// 获取节点信息
NetNodeVo node = netNodeService.queryById(nodeId);
NetNodeVo node = netNodeMapper.selectVoById(nodeId);
if (node == null) {
throw new ServiceException("节点不存在");
}
@ -487,6 +490,9 @@ public class NetNodeConfigServiceImpl implements INetNodeConfigService {
updateWrapper.set(NetNode::getNodeVersion, data.getNodeInformation().getVersion());
}
// 更新Xray状态
updateWrapper.set(NetNode::getXrayStatus, true);
// 执行更新
netNodeMapper.update(null, updateWrapper);
}