1
0
forked from extern/smegmesh

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,
AllowedIPs: allowedips,
PersistentKeepaliveInterval: &keepAlive,
ReplaceAllowedIPs: true,
}
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 {
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)
clients, ok := peerToClients[peer.GetWgHost().String()]