mirror of
https://github.com/gravitl/netmaker.git
synced 2025-09-10 23:24:32 +08:00
refactor + bugs
This commit is contained in:
parent
a6ee8101e6
commit
cfb0904bd6
2 changed files with 8 additions and 0 deletions
|
@ -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))
|
return fmt.Errorf("error decoding node from server %w %s", err, string(bodybytes))
|
||||||
}
|
}
|
||||||
node := nodeGET.Node
|
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
|
// 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 != "" {
|
if cfg.Node.IsLocal != "yes" && node.IsLocal == "yes" && node.LocalRange != "" {
|
||||||
node.LocalAddress, err = ncutils.GetLocalIP(node.LocalRange)
|
node.LocalAddress, err = ncutils.GetLocalIP(node.LocalRange)
|
||||||
|
|
|
@ -15,6 +15,7 @@ import (
|
||||||
"github.com/gravitl/netmaker/netclient/local"
|
"github.com/gravitl/netmaker/netclient/local"
|
||||||
"github.com/gravitl/netmaker/netclient/ncutils"
|
"github.com/gravitl/netmaker/netclient/ncutils"
|
||||||
"github.com/gravitl/netmaker/netclient/wireguard"
|
"github.com/gravitl/netmaker/netclient/wireguard"
|
||||||
|
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
|
||||||
//homedir "github.com/mitchellh/go-homedir"
|
//homedir "github.com/mitchellh/go-homedir"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -53,6 +54,10 @@ func Pull(network string, iface bool) (*models.Node, error) {
|
||||||
resNode := nodeGET.Node
|
resNode := nodeGET.Node
|
||||||
// ensure that the OS never changes
|
// ensure that the OS never changes
|
||||||
resNode.OS = runtime.GOOS
|
resNode.OS = runtime.GOOS
|
||||||
|
if nodeGET.Peers == nil {
|
||||||
|
nodeGET.Peers = []wgtypes.PeerConfig{}
|
||||||
|
}
|
||||||
|
|
||||||
if iface {
|
if iface {
|
||||||
if err = config.ModConfig(&resNode); err != nil {
|
if err = config.ModConfig(&resNode); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
Loading…
Add table
Reference in a new issue