Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove refs to Node.PKA #599

Merged
merged 1 commit into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 13 additions & 16 deletions config/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"net"
"os"
"path/filepath"
"time"

"github.com/gravitl/netclient/ncutils"
"github.com/gravitl/netmaker/logger"
Expand Down Expand Up @@ -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
}

Expand All @@ -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
Expand All @@ -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 {
Expand All @@ -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)
Expand Down
12 changes: 5 additions & 7 deletions config/oldconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"os"
"path/filepath"
"strings"
"time"

"github.com/devilcove/httpclient"
"github.com/google/uuid"
Expand Down Expand Up @@ -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)
Expand All @@ -67,15 +66,15 @@ 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)
if err != nil {
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
}
Expand Down Expand Up @@ -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
}

Expand Down
39 changes: 19 additions & 20 deletions wireguard/iface.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
// }
Expand All @@ -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
}