diff --git a/hscontrol/db/db.go b/hscontrol/db/db.go index b219ffe1..e54ea19f 100644 --- a/hscontrol/db/db.go +++ b/hscontrol/db/db.go @@ -356,7 +356,7 @@ func NewHeadscaleDatabase( addrs := strings.Split(node.Addresses, ",") if len(addrs) == 0 { - fmt.Errorf("no addresses found for node(%d)", node.ID) + return fmt.Errorf("no addresses found for node(%d)", node.ID) } var v4 *netip.Addr @@ -377,7 +377,12 @@ func NewHeadscaleDatabase( } } - err = tx.Save(&types.Node{ID: types.NodeID(node.ID), IPv4: v4, IPv6: v6}).Error + err = tx.Model(&types.Node{}).Where("id = ?", node.ID).Update("ipv4", v4.String()).Error + if err != nil { + return fmt.Errorf("saving ip addresses to new columns: %w", err) + } + + err = tx.Model(&types.Node{}).Where("id = ?", node.ID).Update("ipv6", v6.String()).Error if err != nil { return fmt.Errorf("saving ip addresses to new columns: %w", err) } diff --git a/hscontrol/types/config.go b/hscontrol/types/config.go index 5cc11668..f8073608 100644 --- a/hscontrol/types/config.go +++ b/hscontrol/types/config.go @@ -238,7 +238,7 @@ func LoadConfig(path string, isFile bool) error { viper.SetDefault("tuning.batch_change_delay", "800ms") viper.SetDefault("tuning.node_mapsession_buffered_chan_size", 30) - viper.SetDefault("prefixes.allocation", IPAllocationStrategySequential) + viper.SetDefault("prefixes.allocation", string(IPAllocationStrategySequential)) if IsCLIConfigured() { return nil