move updatePeers directly to the VPN and omit the store layer (#4)

This commit is contained in:
Benedict Schlüter 2022-03-25 16:05:17 +01:00 committed by GitHub
parent 6bbb783af8
commit 6f695892bf
7 changed files with 336 additions and 195 deletions

View file

@ -12,6 +12,7 @@ import (
"github.com/edgelesssys/constellation/coordinator/attestation/vtpm"
"github.com/edgelesssys/constellation/coordinator/core"
"github.com/edgelesssys/constellation/coordinator/kms"
"github.com/edgelesssys/constellation/coordinator/peer"
"github.com/edgelesssys/constellation/coordinator/pubapi"
"github.com/edgelesssys/constellation/coordinator/pubapi/pubproto"
"github.com/edgelesssys/constellation/coordinator/store"
@ -339,6 +340,19 @@ func (v *fakeVPN) RemovePeer(pubKey []byte) error {
panic("dummy")
}
func (v *fakeVPN) UpdatePeers(peers []peer.Peer) error {
for _, peer := range peers {
peerIP, _, err := net.SplitHostPort(peer.PublicEndpoint)
if err != nil {
return err
}
if err := v.AddPeer(peer.VPNPubKey, peerIP, peer.VPNIP); err != nil {
return err
}
}
return nil
}
func (v *fakeVPN) send(dst string, data string) {
pubdst := v.peers[dst]
packets := v.netw.packets