Răsfoiți Sursa

Use int64 for api host pka

gabrielseibel1 1 an în urmă
părinte
comite
459d9dc20e
2 a modificat fișierele cu 18 adăugiri și 16 ștergeri
  1. 6 4
      cli/cmd/host/update.go
  2. 12 12
      models/api_host.go

+ 6 - 4
cli/cmd/host/update.go

@@ -5,9 +5,10 @@ import (
 	"log"
 	"os"
 
+	"github.com/spf13/cobra"
+
 	"github.com/gravitl/netmaker/cli/functions"
 	"github.com/gravitl/netmaker/models"
-	"github.com/spf13/cobra"
 )
 
 var (
@@ -18,7 +19,7 @@ var (
 	mtu             int
 	isStatic        bool
 	isDefault       bool
-	keepAlive       int
+	keepAlive       int64
 )
 
 var hostUpdateCmd = &cobra.Command{
@@ -44,7 +45,7 @@ var hostUpdateCmd = &cobra.Command{
 			apiHost.MTU = mtu
 			apiHost.IsStatic = isStatic
 			apiHost.IsDefault = isDefault
-			apiHost.PersistentKeepalive = int32(keepAlive)
+			apiHost.PersistentKeepalive = keepAlive
 		}
 		functions.PrettyPrint(functions.UpdateHost(args[0], apiHost))
 	},
@@ -56,7 +57,8 @@ 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().IntVar(&keepAlive, "keep_alive", 0, "Interval in which packets are sent to keep connections open with peers")
+	hostUpdateCmd.Flags().
+		Int64Var(&keepAlive, "keep_alive", 0, "Interval 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)

+ 12 - 12
models/api_host.go

@@ -18,20 +18,20 @@ type ApiHost struct {
 	IsStatic            bool     `json:"isstatic"`
 	ListenPort          int      `json:"listenport"`
 	WgPublicListenPort  int      `json:"wg_public_listen_port" yaml:"wg_public_listen_port"`
-	MTU                 int      `json:"mtu" yaml:"mtu"`
-	Interfaces          []Iface  `json:"interfaces" yaml:"interfaces"`
-	DefaultInterface    string   `json:"defaultinterface" yaml:"defautlinterface"`
-	EndpointIP          string   `json:"endpointip" yaml:"endpointip"`
+	MTU                 int      `json:"mtu"                   yaml:"mtu"`
+	Interfaces          []Iface  `json:"interfaces"            yaml:"interfaces"`
+	DefaultInterface    string   `json:"defaultinterface"      yaml:"defautlinterface"`
+	EndpointIP          string   `json:"endpointip"            yaml:"endpointip"`
 	PublicKey           string   `json:"publickey"`
 	MacAddress          string   `json:"macaddress"`
 	Nodes               []string `json:"nodes"`
-	IsDefault           bool     `json:"isdefault" yaml:"isdefault"`
-	IsRelayed           bool     `json:"isrelayed" bson:"isrelayed" yaml:"isrelayed"`
-	RelayedBy           string   `json:"relayed_by" bson:"relayed_by" yaml:"relayed_by"`
-	IsRelay             bool     `json:"isrelay" bson:"isrelay" yaml:"isrelay"`
-	RelayedHosts        []string `json:"relay_hosts" bson:"relay_hosts" yaml:"relay_hosts"`
-	NatType             string   `json:"nat_type" yaml:"nat_type"`
-	PersistentKeepalive int32    `json:"persistentkeepalive" yaml:"persistentkeepalive"`
+	IsDefault           bool     `json:"isdefault"             yaml:"isdefault"`
+	IsRelayed           bool     `json:"isrelayed"             yaml:"isrelayed"             bson:"isrelayed"`
+	RelayedBy           string   `json:"relayed_by"            yaml:"relayed_by"            bson:"relayed_by"`
+	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"`
 }
 
 // Host.ConvertNMHostToAPI - converts a Netmaker host to an API editable host
@@ -59,7 +59,7 @@ func (h *Host) ConvertNMHostToAPI() *ApiHost {
 	a.Version = h.Version
 	a.IsDefault = h.IsDefault
 	a.NatType = h.NatType
-	a.PersistentKeepalive = int32(h.PersistentKeepalive)
+	a.PersistentKeepalive = int64(h.PersistentKeepalive)
 	return &a
 }