mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-26 08:53:05 +00:00
fix issue preveting get node when disco is missing (#1919)
Fixed #1816 Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
parent
d5ed8bc074
commit
55b35f4160
1 changed files with 8 additions and 4 deletions
|
@ -306,11 +306,15 @@ func (node *Node) AfterFind(tx *gorm.DB) error {
|
||||||
}
|
}
|
||||||
node.NodeKey = nodeKey
|
node.NodeKey = nodeKey
|
||||||
|
|
||||||
var discoKey key.DiscoPublic
|
// DiscoKey might be empty if a node has not sent it to headscale.
|
||||||
if err := discoKey.UnmarshalText([]byte(node.DiscoKeyDatabaseField)); err != nil {
|
// This means that this might fail if the disco key is empty.
|
||||||
return fmt.Errorf("unmarshalling disco key from db: %w", err)
|
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))
|
endpoints := make([]netip.AddrPort, len(node.EndpointsDatabaseField))
|
||||||
for idx, ep := range node.EndpointsDatabaseField {
|
for idx, ep := range node.EndpointsDatabaseField {
|
||||||
|
|
Loading…
Reference in a new issue