This commit is contained in:
ryan
2026-06-18 17:08:21 +08:00
parent dfc480c73a
commit 01c28bb88b
11 changed files with 494 additions and 129 deletions
@@ -16,6 +16,7 @@ import (
"strings"
"time"
ofws "github.com/Rain-kl/Wavelet/internal/apps/openflare/websocket"
"github.com/Rain-kl/Wavelet/internal/model"
)
@@ -183,7 +184,23 @@ func computeNodeStatus(node *model.OpenFlareNode) string {
}
func nodeViewLastSeenAt(node *model.OpenFlareNode) any {
if node == nil || node.LastSeenAt == nil {
if node == nil {
return time.Time{}
}
nodeType := strings.TrimSpace(node.NodeType)
if nodeType == "" {
nodeType = "edge_node"
}
if nodeType == "tunnel_relay" && ofws.IsRelayConnected(node.NodeID) {
return ofws.RelayWSConnectedLastSeenValue
}
if nodeType == "tunnel_client" && ofws.IsFlaredConnected(node.NodeID) {
return ofws.FlaredWSConnectedLastSeenValue
}
if ofws.IsAgentConnected(node.NodeID) {
return ofws.AgentWSConnectedLastSeenValue
}
if node.LastSeenAt == nil {
return time.Time{}
}
return *node.LastSeenAt