From fd7bd804859e4b5966b35e48c68f0ac2e25b928f Mon Sep 17 00:00:00 2001 From: Tim Beatham Date: Mon, 4 Dec 2023 16:40:15 +0000 Subject: [PATCH] BUGFIX Don't get device each time it is an expensive operation. --- pkg/mesh/config.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/pkg/mesh/config.go b/pkg/mesh/config.go index ff51311..ca96e9c 100644 --- a/pkg/mesh/config.go +++ b/pkg/mesh/config.go @@ -180,6 +180,8 @@ func (m *WgMeshConfigApplyer) updateWgConf(mesh MeshProvider) error { routes := m.getRoutes(mesh) installedRoutes := make([]lib.Route, 0) + dev, _ := mesh.GetDevice() + for _, n := range nodes { if NodeEquals(n, self) { continue @@ -202,7 +204,6 @@ func (m *WgMeshConfigApplyer) updateWgConf(mesh MeshProvider) error { continue } - dev, _ := mesh.GetDevice() peer, err := m.convertMeshNode(n, dev, peerToClients, routes) if err != nil { @@ -229,12 +230,6 @@ func (m *WgMeshConfigApplyer) updateWgConf(mesh MeshProvider) error { Peers: peerConfigs, } - dev, err := mesh.GetDevice() - - if err != nil { - return err - } - err = m.meshManager.GetClient().ConfigureDevice(dev.Name, cfg) if err != nil {