From 9a66674a5cc33e3f439c95b681d6c44a78941cce Mon Sep 17 00:00:00 2001 From: afeiszli Date: Sun, 24 Apr 2022 13:47:23 -0400 Subject: [PATCH] minor logic revisions --- logic/peers.go | 8 +++----- logic/server.go | 19 +++++++------------ netclient/functions/localport.go | 2 +- 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/logic/peers.go b/logic/peers.go index c24c92ab..5c751663 100644 --- a/logic/peers.go +++ b/logic/peers.go @@ -209,11 +209,9 @@ func GetPeerUpdate(node *models.Node) (models.PeerUpdate, error) { // set_local if node.LocalAddress != peer.LocalAddress && peer.LocalAddress != "" { peer.Endpoint = peer.LocalAddress - } else { - continue - } - if peer.LocalListenPort != 0 { - peer.ListenPort = peer.LocalListenPort + if peer.LocalListenPort != 0 { + peer.ListenPort = peer.LocalListenPort + } } else { continue } diff --git a/logic/server.go b/logic/server.go index 83635d5f..851f93f6 100644 --- a/logic/server.go +++ b/logic/server.go @@ -225,18 +225,13 @@ func GetServerPeers(serverNode *models.Node) ([]wgtypes.PeerConfig, bool, []stri if serverNode.PublicKey == node.PublicKey { continue } - /* - // Test This: Removed logic to set local address for nodes on same network as server - // This may be causing issues setting nodes on server currently - // Removing may fix but could cause other issues - if serverNode.Endpoint == node.Endpoint { - if serverNode.LocalAddress != node.LocalAddress && node.LocalAddress != "" { - node.Endpoint = node.LocalAddress - } else { - continue - } - } - */ + if serverNode.Endpoint == node.Endpoint { + if serverNode.LocalAddress != node.LocalAddress && node.LocalAddress != "" { + node.Endpoint = node.LocalAddress + } else { + continue + } + } if currentNetworkACL != nil && currentNetworkACL.IsAllowed(acls.AclID(serverNode.ID), acls.AclID(node.ID)) { continue } diff --git a/netclient/functions/localport.go b/netclient/functions/localport.go index 01102e59..81d2b8b7 100644 --- a/netclient/functions/localport.go +++ b/netclient/functions/localport.go @@ -11,7 +11,7 @@ import ( "github.com/gravitl/netmaker/netclient/ncutils" ) -// Get LocalListenPort - Gets the port running on the local interface +// GetLocalListenPort - Gets the port running on the local interface func GetLocalListenPort(ifacename string) (int32, error) { portstring, err := ncutils.RunCmd("wg show "+ifacename+" listen-port", false) if err != nil {