Skip to content

Commit

Permalink
check node is still valid on enrollment key to act as relay
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishek9686 committed Feb 28, 2024
1 parent 91bfcba commit 1eddb83
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions auth/host_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,15 @@ func CheckNetRegAndHostUpdate(networks []string, h *models.Host, relayNodeId uui
continue
}
if relayNodeId != uuid.Nil && !newNode.IsRelayed {
newNode.IsRelayed = true
newNode.RelayedBy = relayNodeId.String()
slog.Info(fmt.Sprintf("adding relayed node %s to relay %s on network %s", newNode.ID.String(), relayNodeId.String(), network))
if err := logic.UpsertNode(newNode); err != nil {
slog.Error("failed to update node", "nodeid", relayNodeId.String())
// check if relay node exists and acting as relay
relaynode, err := logic.GetNodeByID(relayNodeId.String())
if err == nil && relaynode.IsRelay {
newNode.IsRelayed = true
newNode.RelayedBy = relayNodeId.String()
slog.Info(fmt.Sprintf("adding relayed node %s to relay %s on network %s", newNode.ID.String(), relayNodeId.String(), network))
if err := logic.UpsertNode(newNode); err != nil {
slog.Error("failed to update node", "nodeid", relayNodeId.String())
}
}
}
logger.Log(1, "added new node", newNode.ID.String(), "to host", h.Name)
Expand Down

0 comments on commit 1eddb83

Please sign in to comment.