rename gateway to endpoint

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
This commit is contained in:
Evan Hazlett 2019-10-06 03:11:45 -04:00
parent 87adb7d366
commit bde4dba555
No known key found for this signature in database
GPG key ID: A519480096146526
9 changed files with 100 additions and 86 deletions

View file

@ -280,12 +280,18 @@ func (s *Server) nodeHeartbeat(ctx context.Context) {
logrus.Error(err)
continue
}
nodeIP, _, err := s.getNodeIP(ctx, s.cfg.ID)
if err != nil {
logrus.Error(err)
continue
}
node := &v1.Node{
ID: s.cfg.ID,
Addr: s.cfg.GRPCAddress,
KeyPair: keyPair,
GatewayIP: s.cfg.GatewayIP,
GatewayPort: uint64(s.cfg.GatewayPort),
ID: s.cfg.ID,
Addr: s.cfg.GRPCAddress,
KeyPair: keyPair,
EndpointIP: s.cfg.EndpointIP,
EndpointPort: uint64(s.cfg.EndpointPort),
GatewayIP: nodeIP.String(),
}
data, err := proto.Marshal(node)

View file

@ -95,7 +95,7 @@ func (s *Server) updatePeerInfo(ctx context.Context) error {
return err
}
endpoint := fmt.Sprintf("%s:%d", s.cfg.GatewayIP, s.cfg.GatewayPort)
endpoint := fmt.Sprintf("%s:%d", s.cfg.EndpointIP, s.cfg.EndpointPort)
// build allowedIPs from routes and peer network
allowedIPs := []string{}
@ -104,8 +104,6 @@ func (s *Server) updatePeerInfo(ctx context.Context) error {
return err
}
logrus.Debugf("nodes: %+v", nodes)
for _, node := range nodes {
// only add the route if a peer to prevent route duplicate
if node.ID != s.cfg.ID {
@ -117,7 +115,6 @@ func (s *Server) updatePeerInfo(ctx context.Context) error {
return err
}
logrus.Debugf("peer network %s", gatewayNet)
allowedIPs = append(allowedIPs, gatewayNet.String())
}
@ -219,15 +216,17 @@ func (s *Server) updatePeerConfig(ctx context.Context) error {
return err
}
gatewayIP, _, err := s.getNodeIP(ctx, s.cfg.ID)
gatewayIP, gatewayNet, err := s.getNodeIP(ctx, s.cfg.ID)
if err != nil {
return err
}
size, _ := gatewayNet.Mask.Size()
wireguardCfg := &wireguardConfig{
Iface: defaultWireguardInterface,
PrivateKey: keyPair.PrivateKey,
ListenPort: s.cfg.GatewayPort,
Address: gatewayIP.To4().String() + "/32",
ListenPort: s.cfg.EndpointPort,
Address: fmt.Sprintf("%s/%d", gatewayIP.To4().String(), size),
Peers: peers,
}