mirror of
https://github.com/juanfont/headscale.git
synced 2024-12-22 07:57:34 +00:00
Fix crash when a prefix family was empty
This commit is contained in:
parent
40953727cf
commit
c4c8cfe5ea
@ -377,16 +377,20 @@ func NewHeadscaleDatabase(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if v4 != nil {
|
||||||
err = tx.Model(&types.Node{}).Where("id = ?", node.ID).Update("ipv4", v4.String()).Error
|
err = tx.Model(&types.Node{}).Where("id = ?", node.ID).Update("ipv4", v4.String()).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("saving ip addresses to new columns: %w", err)
|
return fmt.Errorf("saving ip addresses to new columns: %w", err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if v6 != nil {
|
||||||
err = tx.Model(&types.Node{}).Where("id = ?", node.ID).Update("ipv6", v6.String()).Error
|
err = tx.Model(&types.Node{}).Where("id = ?", node.ID).Update("ipv6", v6.String()).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("saving ip addresses to new columns: %w", err)
|
return fmt.Errorf("saving ip addresses to new columns: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_ = tx.Migrator().DropColumn(&types.Node{}, "ip_addresses")
|
_ = tx.Migrator().DropColumn(&types.Node{}, "ip_addresses")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user