Skip to content

Commit

Permalink
fix ip migration
Browse files Browse the repository at this point in the history
Signed-off-by: Kristoffer Dalby <[email protected]>
  • Loading branch information
kradalby authored and juanfont committed Apr 17, 2024
1 parent d4af0c3 commit 4095372
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions hscontrol/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion hscontrol/types/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4095372

Please sign in to comment.