From 2fc1c104d117b583de83b2c6ca014a052812ec21 Mon Sep 17 00:00:00 2001 From: gabrielseibel1 Date: Sun, 1 Oct 2023 17:04:39 -0300 Subject: [PATCH] Remove refs to Node.PKA --- config/node.go | 29 +++++++++++++---------------- config/oldconfig.go | 12 +++++------- wireguard/iface.go | 39 +++++++++++++++++++-------------------- 3 files changed, 37 insertions(+), 43 deletions(-) diff --git a/config/node.go b/config/node.go index 0e4a1f91..d7197281 100644 --- a/config/node.go +++ b/config/node.go @@ -7,7 +7,6 @@ import ( "net" "os" "path/filepath" - "time" "github.com/gravitl/netclient/ncutils" "github.com/gravitl/netmaker/logger" @@ -127,30 +126,29 @@ func WriteNodeConfig() error { // ConvertNode accepts a netmaker node struct and converts to the structs used by netclient func ConvertNode(nodeGet *models.NodeGet) *Node { netmakerNode := nodeGet.Node - //server := GetServer(netmakerNode.Server) - //if server == nil { - //server = ConvertServerCfg(nodeGet.ServerConfig) - //} + // server := GetServer(netmakerNode.Server) + // if server == nil { + // server = ConvertServerCfg(nodeGet.ServerConfig) + // } var node Node node.ID = nodeGet.Node.ID - //n.Name = s.Name + // n.Name = s.Name node.Network = netmakerNode.Network - //node.Password = netmakerNode.Password + // node.Password = netmakerNode.Password node.NetworkRange = nodeGet.Node.NetworkRange node.NetworkRange6 = nodeGet.Node.NetworkRange6 - //n.Interface = s.Interface + // n.Interface = s.Interface node.Server = netmakerNode.Server node.Connected = nodeGet.Node.Connected - //node.MacAddress, _ = net.ParseMAC(netmakerNode.MacAddress) + // node.MacAddress, _ = net.ParseMAC(netmakerNode.MacAddress) node.Address = nodeGet.Node.Address node.Address6 = nodeGet.Node.Address6 - node.PersistentKeepalive = time.Second * time.Duration(netmakerNode.PersistentKeepalive) node.Action = netmakerNode.Action node.IsEgressGateway = nodeGet.Node.IsEgressGateway node.IsIngressGateway = nodeGet.Node.IsIngressGateway node.DNSOn = nodeGet.Node.DNSOn - //node.Peers = nodeGet.Peers - //add items not provided by server + // node.Peers = nodeGet.Peers + // add items not provided by server return &node } @@ -159,7 +157,7 @@ func ConvertToNetmakerNode(node *Node, server *Server, host *Config) *models.Leg var netmakerNode models.LegacyNode netmakerNode.ID = node.ID.String() netmakerNode.OS = host.OS - //netmakerNode.HostID = server.MQID.String() + // netmakerNode.HostID = server.MQID.String() netmakerNode.Name = host.Name netmakerNode.Network = node.Network netmakerNode.Password = host.HostPass @@ -171,12 +169,12 @@ func ConvertToNetmakerNode(node *Node, server *Server, host *Config) *models.Leg netmakerNode.Server = node.Server netmakerNode.TrafficKeys.Mine = host.TrafficKeyPublic netmakerNode.TrafficKeys.Server = server.TrafficKey - //only send ip + // only send ip netmakerNode.Endpoint = host.EndpointIP.String() netmakerNode.Connected = FormatBool(node.Connected) netmakerNode.MacAddress = host.MacAddress.String() netmakerNode.ListenPort = int32(host.ListenPort) - //only send ip + // only send ip if node.Address.IP == nil { netmakerNode.Address = "" } else { @@ -189,7 +187,6 @@ func ConvertToNetmakerNode(node *Node, server *Server, host *Config) *models.Leg } netmakerNode.LocalListenPort = int32(host.ListenPort) netmakerNode.MTU = int32(host.MTU) - netmakerNode.PersistentKeepalive = int32(node.PersistentKeepalive.Seconds()) netmakerNode.PublicKey = host.PublicKey.String() netmakerNode.Action = node.Action netmakerNode.IsEgressGateway = FormatBool(node.IsEgressGateway) diff --git a/config/oldconfig.go b/config/oldconfig.go index 4fbbab86..e99bfd27 100644 --- a/config/oldconfig.go +++ b/config/oldconfig.go @@ -11,7 +11,6 @@ import ( "os" "path/filepath" "strings" - "time" "github.com/devilcove/httpclient" "github.com/google/uuid" @@ -42,7 +41,7 @@ func ReadConfig(network string) (*ClientConfig, error) { } home := GetNetclientPath() + "config/" if ncutils.IsWindows() { - //for some reason windows does not use the config dir although it exists + // for some reason windows does not use the config dir although it exists home = GetNetclientPath() } file := fmt.Sprintf(home + "netconfig-" + network) @@ -67,7 +66,7 @@ func GetSystemNetworks() ([]string, error) { var networks []string confPath := GetNetclientPath() + "config/netconfig-*" if ncutils.IsWindows() { - //for some reason windows does not use the config dir although it exists + // for some reason windows does not use the config dir although it exists confPath = GetNetclientPath() + "netconfig-*" } files, err := filepath.Glob(confPath) @@ -75,7 +74,7 @@ func GetSystemNetworks() ([]string, error) { return nil, err } for _, file := range files { - //don't want files such as *.bak, *.swp + // don't want files such as *.bak, *.swp if filepath.Ext(file) != "" { continue } @@ -148,14 +147,13 @@ func ConvertOldNode(netmakerNode *models.LegacyNode) (*Node, *Config) { node.Address.Mask = node.NetworkRange.Mask node.Address6.IP = net.ParseIP(netmakerNode.Address6) node.Address6.Mask = node.NetworkRange6.Mask - node.PersistentKeepalive = time.Second * time.Duration(netmakerNode.PersistentKeepalive) node.Action = netmakerNode.Action node.IsEgressGateway = ParseBool(netmakerNode.IsEgressGateway) node.IsIngressGateway = ParseBool(netmakerNode.IsIngressGateway) host.IsStatic = ParseBool(netmakerNode.IsStatic) node.DNSOn = ParseBool(netmakerNode.DNSOn) - //node.Peers = nodeGet.Peers - //add items not provided by server + // node.Peers = nodeGet.Peers + // add items not provided by server return &node, host } diff --git a/wireguard/iface.go b/wireguard/iface.go index c314b726..3e4a53cc 100644 --- a/wireguard/iface.go +++ b/wireguard/iface.go @@ -24,34 +24,33 @@ func IfaceExists(ifacename string) bool { // IfaceDelta - checks if the new node causes an interface change func IfaceDelta(currentNode *config.Node, newNode *config.Node) bool { // single comparison statements - //newNode.PublicKey != currentNode.PublicKey || + // newNode.PublicKey != currentNode.PublicKey || if newNode.Address.IP.String() != currentNode.Address.IP.String() || newNode.Address6.IP.String() != currentNode.Address6.IP.String() || newNode.IsEgressGateway != currentNode.IsEgressGateway || newNode.IsIngressGateway != currentNode.IsIngressGateway || - //newNode.IsRelay != currentNode.IsRelay || - //newNode.UDPHolePunch != currentNode.UDPHolePunch || - //newNode.ListenPort != currentNode.ListenPort || - //newNode.MTU != currentNode.MTU || - newNode.PersistentKeepalive != currentNode.PersistentKeepalive || + // newNode.IsRelay != currentNode.IsRelay || + // newNode.UDPHolePunch != currentNode.UDPHolePunch || + // newNode.ListenPort != currentNode.ListenPort || + // newNode.MTU != currentNode.MTU || newNode.DNSOn != currentNode.DNSOn || newNode.Connected != currentNode.Connected { return true } // multi-comparison statements - //if newNode.IsEgressGateway { - //if len(currentNode.EgressGatewayRanges) != len(newNode.EgressGatewayRanges) { - //return true - //} - //for _, address := range newNode.EgressGatewayRanges { - //if !StringSliceContains(currentNode.EgressGatewayRanges, address) { - //return true - //} - //} - //} + // if newNode.IsEgressGateway { + // if len(currentNode.EgressGatewayRanges) != len(newNode.EgressGatewayRanges) { + // return true + // } + // for _, address := range newNode.EgressGatewayRanges { + // if !StringSliceContains(currentNode.EgressGatewayRanges, address) { + // return true + // } + // } + // } - //if newNode.IsRelay { + // if newNode.IsRelay { // if len(currentNode.RelayAddrs) != len(newNode.RelayAddrs) { // return true // } @@ -60,12 +59,12 @@ func IfaceDelta(currentNode *config.Node, newNode *config.Node) bool { // return true // } // } - //} + // } - //for _, address := range newNode.AllowedIPs { + // for _, address := range newNode.AllowedIPs { // if !StringSliceContains(currentNode.AllowedIPs, address) { // return true // } - //} + // } return false }