Don't get device each time it is an expensive operation.
This commit is contained in:
Tim Beatham 2023-12-04 16:40:15 +00:00
parent 3ef1b68ba5
commit fd7bd80485

View File

@ -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 {