From cfb0904bd64a915744d4b83b62cf441238f250b4 Mon Sep 17 00:00:00 2001 From: 0xdcarns Date: Mon, 25 Apr 2022 19:33:31 -0400 Subject: [PATCH] refactor + bugs --- netclient/functions/join.go | 3 +++ netclient/functions/pull.go | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/netclient/functions/join.go b/netclient/functions/join.go index 930b8ad9..14a72aa9 100644 --- a/netclient/functions/join.go +++ b/netclient/functions/join.go @@ -144,6 +144,9 @@ func JoinNetwork(cfg *config.ClientConfig, privateKey string) error { return fmt.Errorf("error decoding node from server %w %s", err, string(bodybytes)) } node := nodeGET.Node + if nodeGET.Peers == nil { + nodeGET.Peers = []wgtypes.PeerConfig{} + } // safety check. If returned node from server is local, but not currently configured as local, set to local addr if cfg.Node.IsLocal != "yes" && node.IsLocal == "yes" && node.LocalRange != "" { node.LocalAddress, err = ncutils.GetLocalIP(node.LocalRange) diff --git a/netclient/functions/pull.go b/netclient/functions/pull.go index d82bf8ea..d5d75e29 100644 --- a/netclient/functions/pull.go +++ b/netclient/functions/pull.go @@ -15,6 +15,7 @@ import ( "github.com/gravitl/netmaker/netclient/local" "github.com/gravitl/netmaker/netclient/ncutils" "github.com/gravitl/netmaker/netclient/wireguard" + "golang.zx2c4.com/wireguard/wgctrl/wgtypes" //homedir "github.com/mitchellh/go-homedir" ) @@ -53,6 +54,10 @@ func Pull(network string, iface bool) (*models.Node, error) { resNode := nodeGET.Node // ensure that the OS never changes resNode.OS = runtime.GOOS + if nodeGET.Peers == nil { + nodeGET.Peers = []wgtypes.PeerConfig{} + } + if iface { if err = config.ModConfig(&resNode); err != nil { return nil, err