Skip to content

Commit

Permalink
Have api-host pka be specified in seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielseibel1 committed Oct 5, 2023
1 parent 016d0f3 commit 4828648
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 2 additions & 3 deletions cli/cmd/host/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var (
mtu int
isStatic bool
isDefault bool
keepAlive int64
keepAlive int
)

var hostUpdateCmd = &cobra.Command{
Expand Down Expand Up @@ -57,8 +57,7 @@ func init() {
hostUpdateCmd.Flags().StringVar(&name, "name", "", "Host name")
hostUpdateCmd.Flags().IntVar(&listenPort, "listen_port", 0, "Listen port of the host")
hostUpdateCmd.Flags().IntVar(&mtu, "mtu", 0, "Host MTU size")
hostUpdateCmd.Flags().
Int64Var(&keepAlive, "keep_alive", 0, "Interval in which packets are sent to keep connections open with peers")
hostUpdateCmd.Flags().IntVar(&keepAlive, "keep_alive", 0, "Interval (seconds) in which packets are sent to keep connections open with peers")
hostUpdateCmd.Flags().BoolVar(&isStatic, "static", false, "Make Host Static ?")
hostUpdateCmd.Flags().BoolVar(&isDefault, "default", false, "Make Host Default ?")
rootCmd.AddCommand(hostUpdateCmd)
Expand Down
6 changes: 3 additions & 3 deletions models/api_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type ApiHost struct {
IsRelay bool `json:"isrelay" yaml:"isrelay" bson:"isrelay"`
RelayedHosts []string `json:"relay_hosts" yaml:"relay_hosts" bson:"relay_hosts"`
NatType string `json:"nat_type" yaml:"nat_type"`
PersistentKeepalive int64 `json:"persistentkeepalive" yaml:"persistentkeepalive"`
PersistentKeepalive int `json:"persistentkeepalive" yaml:"persistentkeepalive"`
}

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

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

0 comments on commit 4828648

Please sign in to comment.