Skip to content

Commit

Permalink
fix issue preveting get node when disco is missing (#1919)
Browse files Browse the repository at this point in the history
Fixed #1816

Signed-off-by: Kristoffer Dalby <[email protected]>
  • Loading branch information
kradalby authored May 1, 2024
1 parent d5ed8bc commit 55b35f4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions hscontrol/types/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,15 @@ func (node *Node) AfterFind(tx *gorm.DB) error {
}
node.NodeKey = nodeKey

var discoKey key.DiscoPublic
if err := discoKey.UnmarshalText([]byte(node.DiscoKeyDatabaseField)); err != nil {
return fmt.Errorf("unmarshalling disco key from db: %w", err)
// DiscoKey might be empty if a node has not sent it to headscale.
// This means that this might fail if the disco key is empty.
if node.DiscoKeyDatabaseField != "" {
var discoKey key.DiscoPublic
if err := discoKey.UnmarshalText([]byte(node.DiscoKeyDatabaseField)); err != nil {
return fmt.Errorf("unmarshalling disco key from db: %w", err)
}
node.DiscoKey = discoKey
}
node.DiscoKey = discoKey

endpoints := make([]netip.AddrPort, len(node.EndpointsDatabaseField))
for idx, ep := range node.EndpointsDatabaseField {
Expand Down

0 comments on commit 55b35f4

Please sign in to comment.