Skip to content

Commit

Permalink
NET-641: Enable/Disable Auto Update From UI (#2622)
Browse files Browse the repository at this point in the history
* add support to disable/enable autoupdate on a host

* setting to older version for QA to test
  • Loading branch information
abhishek9686 authored Oct 19, 2023
1 parent 64d2a48 commit 675c4ec
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 0 additions & 1 deletion logic/hosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ func UpdateHost(newHost, currentHost *models.Host) {
newHost.Nodes = currentHost.Nodes
newHost.PublicKey = currentHost.PublicKey
newHost.TrafficKeyPublic = currentHost.TrafficKeyPublic

// changeable fields
if len(newHost.Version) == 0 {
newHost.Version = currentHost.Version
Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"golang.org/x/exp/slog"
)


var version = "v0.21.2"

// Start DB Connection and start API Request Handler
Expand Down
3 changes: 3 additions & 0 deletions models/api_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type ApiHost struct {
RelayedHosts []string `json:"relay_hosts" yaml:"relay_hosts" bson:"relay_hosts"`
NatType string `json:"nat_type" yaml:"nat_type"`
PersistentKeepalive int `json:"persistentkeepalive" yaml:"persistentkeepalive"`
AutoUpdate bool `json:"autoupdate" yaml:"autoupdate"`
}

// Host.ConvertNMHostToAPI - converts a Netmaker host to an API editable host
Expand Down Expand Up @@ -60,6 +61,7 @@ func (h *Host) ConvertNMHostToAPI() *ApiHost {
a.IsDefault = h.IsDefault
a.NatType = h.NatType
a.PersistentKeepalive = int(h.PersistentKeepalive.Seconds())
a.AutoUpdate = h.AutoUpdate
return &a
}

Expand Down Expand Up @@ -98,5 +100,6 @@ func (a *ApiHost) ConvertAPIHostToNMHost(currentHost *Host) *Host {
h.NatType = currentHost.NatType
h.TurnEndpoint = currentHost.TurnEndpoint
h.PersistentKeepalive = time.Duration(a.PersistentKeepalive) * time.Second
h.AutoUpdate = a.AutoUpdate
return &h
}

0 comments on commit 675c4ec

Please sign in to comment.