Skip to content

Commit

Permalink
force listenport/persisentkeepalive to defaults if 0 during migration (
Browse files Browse the repository at this point in the history
  • Loading branch information
mattkasun committed Oct 13, 2023
1 parent eb3ba28 commit d767da1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion controllers/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ func migrate(w http.ResponseWriter, r *http.Request) {
host.Name = data.HostName
host.HostPass = data.Password
host.OS = data.OS
host.PersistentKeepalive = time.Duration(legacy.PersistentKeepalive)
if err := logic.CreateHost(&host); err != nil {
slog.Error("create host", "error", err)
logic.ReturnErrorResponse(w, r, logic.FormatError(err, "badrequest"))
Expand Down Expand Up @@ -141,6 +140,9 @@ func convertLegacyHostNode(legacy models.LegacyNode) (models.Host, models.Node)
host.AutoUpdate = servercfg.AutoUpdateEnabled()
host.Interface = "netmaker"
host.ListenPort = int(legacy.ListenPort)
if host.ListenPort == 0 {
host.ListenPort = 51821
}
host.MTU = int(legacy.MTU)
host.PublicKey, _ = wgtypes.ParseKey(legacy.PublicKey)
host.MacAddress = net.HardwareAddr(legacy.MacAddress)
Expand All @@ -152,6 +154,11 @@ func convertLegacyHostNode(legacy models.LegacyNode) (models.Host, models.Node)
host.IsDocker = models.ParseBool(legacy.IsDocker)
host.IsK8S = models.ParseBool(legacy.IsK8S)
host.IsStatic = models.ParseBool(legacy.IsStatic)
host.PersistentKeepalive = time.Duration(legacy.PersistentKeepalive)
if host.PersistentKeepalive == 0 {
host.PersistentKeepalive = models.DefaultPersistentKeepAlive
}

node := convertLegacyNode(legacy, host.ID)
return host, node
}
Expand Down

0 comments on commit d767da1

Please sign in to comment.