81-processes

- issue with client client traversal
This commit is contained in:
Tim Beatham 2024-01-04 22:08:14 +00:00
parent 4a92743880
commit 69b1790bb6

View File

@ -1,6 +1,7 @@
package mesh
import (
"fmt"
"net"
"slices"
"strings"
@ -233,8 +234,8 @@ func (m *WgMeshConfigApplyer) getClientConfig(params *GetConfigParams) (*wgtypes
routesForMesh := lib.Map(lib.MapValues(params.routes), func(rns []routeNode) []routeNode {
return lib.Filter(rns, func(rn routeNode) bool {
ip, _, _ := net.ParseCIDR(rn.gateway)
return meshNet.Contains(ip)
_, ipNet, _ := net.ParseCIDR(rn.gateway)
return meshNet.Contains(ipNet.IP) || ipNet.Contains(meshNet.IP)
})
})
@ -253,6 +254,10 @@ func (m *WgMeshConfigApplyer) getClientConfig(params *GetConfigParams) (*wgtypes
return nil, err
}
if len(params.peers) == 0 {
return nil, fmt.Errorf("no peers in the mesh")
}
peer := m.getCorrespondingPeer(params.peers, self)
pubKey, _ := peer.GetPublicKey()