mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-07-29 01:58:34 -04:00
peer: save PublicIP instead of publicEndpoint / add multi-coord gRPCs
This commit is contained in:
parent
55a1aa783f
commit
f0e35a43d4
31 changed files with 1216 additions and 666 deletions
|
@ -1,14 +1,13 @@
|
|||
package core
|
||||
|
||||
import (
|
||||
"net"
|
||||
|
||||
"github.com/edgelesssys/constellation/coordinator/peer"
|
||||
"github.com/edgelesssys/constellation/coordinator/storewrapper"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
// GetPeers returns the stored peers if the requested version differs from the stored version.
|
||||
// peers include all vpn devices namely Coordinators, Nodes and Admins.
|
||||
func (c *Core) GetPeers(resourceVersion int) (int, []peer.Peer, error) {
|
||||
// Most often there's nothing to do, so first check without an expensive transaction.
|
||||
curVer, err := c.data().GetPeersResourceVersion()
|
||||
|
@ -47,23 +46,17 @@ func (c *Core) AddPeer(peer peer.Peer) error {
|
|||
|
||||
// AddPeerToVPN adds a peer to the the VPN.
|
||||
func (c *Core) AddPeerToVPN(peer peer.Peer) error {
|
||||
publicIP, _, err := net.SplitHostPort(peer.PublicEndpoint)
|
||||
if err != nil {
|
||||
c.zaplogger.Info("SplitHostPort", zap.Error(err))
|
||||
return err
|
||||
}
|
||||
|
||||
// don't add myself to vpn
|
||||
myIP, err := c.vpn.GetInterfaceIP()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if myIP != peer.VPNIP {
|
||||
if err := c.vpn.AddPeer(peer.VPNPubKey, publicIP, peer.VPNIP); err != nil {
|
||||
c.zaplogger.Error("failed to add peer to VPN", zap.Error(err), zap.String("peer public_ip", publicIP), zap.String("peer vpn_ip", peer.VPNIP))
|
||||
if err := c.vpn.AddPeer(peer.VPNPubKey, peer.PublicIP, peer.VPNIP); err != nil {
|
||||
c.zaplogger.Error("failed to add peer to VPN", zap.Error(err), zap.String("peer public_ip", peer.PublicIP), zap.String("peer vpn_ip", peer.VPNIP))
|
||||
return err
|
||||
}
|
||||
c.zaplogger.Info("added peer to VPN", zap.String("peer public_ip", publicIP), zap.String("peer vpn_ip", peer.VPNIP))
|
||||
c.zaplogger.Info("added peer to VPN", zap.String("role", peer.Role.String()), zap.String("coordinator public_ip", peer.PublicIP), zap.String("coordinator vpn_ip", peer.VPNIP))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -86,7 +79,7 @@ func (c *Core) AddPeerToStore(peer peer.Peer) error {
|
|||
if err := tx.Commit(); err != nil {
|
||||
return err
|
||||
}
|
||||
c.zaplogger.Info("added peer to store", zap.String("peer public_endpoint", peer.PublicEndpoint), zap.String("peer vpn_ip", peer.VPNIP))
|
||||
c.zaplogger.Info("added peer to store", zap.String("peer public_ip", peer.PublicIP), zap.String("peer vpn_ip", peer.VPNIP))
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue