BUGIX Hash client by public key

This commit is contained in:
Tim Beatham 2023-12-04 17:13:51 +00:00
parent 0ff2a8eef9
commit 78d748770c

View File

@ -99,6 +99,7 @@ func (m *WgMeshConfigApplyer) convertMeshNode(node MeshNode, device *wgtypes.Dev
Endpoint: endpoint, Endpoint: endpoint,
AllowedIPs: allowedips, AllowedIPs: allowedips,
PersistentKeepaliveInterval: &keepAlive, PersistentKeepaliveInterval: &keepAlive,
ReplaceAllowedIPs: true,
} }
return &peerConfig, nil return &peerConfig, nil
@ -188,8 +189,10 @@ func (m *WgMeshConfigApplyer) updateWgConf(mesh MeshProvider) error {
if n.GetType() == conf.CLIENT_ROLE && len(peers) > 0 && self.GetType() == conf.CLIENT_ROLE { if n.GetType() == conf.CLIENT_ROLE && len(peers) > 0 && self.GetType() == conf.CLIENT_ROLE {
hashFunc := func(mn MeshNode) int { hashFunc := func(mn MeshNode) int {
return lib.HashString(mn.GetWgHost().String()) pubKey, _ := mn.GetPublicKey()
return lib.HashString(pubKey.String())
} }
peer := lib.ConsistentHash(peers, n, hashFunc, hashFunc) peer := lib.ConsistentHash(peers, n, hashFunc, hashFunc)
clients, ok := peerToClients[peer.GetWgHost().String()] clients, ok := peerToClients[peer.GetWgHost().String()]