From bde4dba555591d5bea4ca7550c4ea7fc51f2c778 Mon Sep 17 00:00:00 2001 From: Evan Hazlett Date: Sun, 6 Oct 2019 03:11:45 -0400 Subject: [PATCH] rename gateway to endpoint Signed-off-by: Evan Hazlett --- api/v1/heimdall.pb.go | 126 ++++++++++++++++++++++-------------------- api/v1/heimdall.proto | 5 +- client/client.go | 2 +- cmd/hctl/nodes.go | 6 +- cmd/heimdall/main.go | 8 +-- cmd/heimdall/run.go | 4 +- config.go | 6 +- server/node.go | 16 ++++-- server/peer.go | 13 ++--- 9 files changed, 100 insertions(+), 86 deletions(-) diff --git a/api/v1/heimdall.pb.go b/api/v1/heimdall.pb.go index 71cd58d..aaab2b4 100644 --- a/api/v1/heimdall.pb.go +++ b/api/v1/heimdall.pb.go @@ -214,8 +214,9 @@ type Node struct { ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` Addr string `protobuf:"bytes,2,opt,name=addr,proto3" json:"addr,omitempty"` KeyPair *KeyPair `protobuf:"bytes,3,opt,name=keypair,proto3" json:"keypair,omitempty"` - GatewayIP string `protobuf:"bytes,4,opt,name=gateway_ip,json=gatewayIp,proto3" json:"gateway_ip,omitempty"` - GatewayPort uint64 `protobuf:"varint,5,opt,name=gateway_port,json=gatewayPort,proto3" json:"gateway_port,omitempty"` + EndpointIP string `protobuf:"bytes,4,opt,name=endpoint_ip,json=endpointIp,proto3" json:"endpoint_ip,omitempty"` + EndpointPort uint64 `protobuf:"varint,5,opt,name=endpoint_port,json=endpointPort,proto3" json:"endpoint_port,omitempty"` + GatewayIP string `protobuf:"bytes,6,opt,name=gateway_ip,json=gatewayIp,proto3" json:"gateway_ip,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -266,6 +267,20 @@ func (m *Node) GetKeyPair() *KeyPair { return nil } +func (m *Node) GetEndpointIP() string { + if m != nil { + return m.EndpointIP + } + return "" +} + +func (m *Node) GetEndpointPort() uint64 { + if m != nil { + return m.EndpointPort + } + return 0 +} + func (m *Node) GetGatewayIP() string { if m != nil { return m.GatewayIP @@ -273,13 +288,6 @@ func (m *Node) GetGatewayIP() string { return "" } -func (m *Node) GetGatewayPort() uint64 { - if m != nil { - return m.GatewayPort - } - return 0 -} - type NodesRequest struct { XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` @@ -699,56 +707,56 @@ func init() { } var fileDescriptor_b6184fc395da86b1 = []byte{ - // 770 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x5d, 0x6b, 0xe3, 0x46, - 0x14, 0x45, 0xfe, 0x90, 0xed, 0x2b, 0xc7, 0x81, 0xa1, 0x04, 0xe1, 0x52, 0xe4, 0xa8, 0x0f, 0x75, - 0x4a, 0x90, 0x62, 0x97, 0x42, 0xa1, 0x14, 0x1a, 0x27, 0x6d, 0x2a, 0xd2, 0x06, 0x77, 0xda, 0xbc, - 0x94, 0x82, 0x91, 0xad, 0xa9, 0xa3, 0x44, 0xf6, 0x4c, 0x47, 0x63, 0x07, 0x3f, 0xf5, 0x9f, 0xf5, - 0x67, 0xec, 0xa3, 0x1f, 0xfc, 0x47, 0x76, 0x99, 0xd1, 0xc8, 0x6b, 0x6f, 0xc8, 0xae, 0xc2, 0xee, - 0x9b, 0xee, 0x99, 0x7b, 0xcf, 0x9c, 0x7b, 0xe6, 0x4b, 0xf0, 0xdd, 0x34, 0x16, 0x77, 0x8b, 0xb1, - 0x37, 0xa1, 0x33, 0x3f, 0x15, 0x24, 0x49, 0x42, 0xce, 0x38, 0xbd, 0x27, 0x13, 0xe1, 0xdf, 0x91, - 0x78, 0x16, 0x85, 0x49, 0xe2, 0x87, 0x2c, 0xf6, 0x97, 0xbd, 0x6d, 0xec, 0x31, 0x4e, 0x05, 0x45, - 0xc7, 0x31, 0xf5, 0xf6, 0x2b, 0xbc,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76, 0x4d, 0x56, 0xc3, - 0x30, 0xe6, 0x52, 0x01, 0xe3, 0xf1, 0x32, 0x14, 0x44, 0x29, 0x30, 0x32, 0x05, 0x1a, 0xba, 0x26, - 0x2b, 0xf4, 0x05, 0x00, 0x5b, 0x8c, 0x93, 0x78, 0xb2, 0xa3, 0xb0, 0x91, 0x21, 0x52, 0xe0, 0x2b, - 0x03, 0x2a, 0x37, 0x34, 0x22, 0xcf, 0xb6, 0x88, 0xa0, 0x22, 0x6d, 0xd6, 0x95, 0xea, 0x1b, 0xfd, - 0x0e, 0xb5, 0x07, 0xb2, 0x62, 0x61, 0xcc, 0x95, 0x93, 0x56, 0xff, 0xeb, 0x02, 0x3d, 0x68, 0xc5, - 0x03, 0x6b, 0xb3, 0x76, 0x72, 0xf9, 0x38, 0xe7, 0x41, 0xa7, 0x00, 0xd3, 0x50, 0x90, 0xc7, 0x70, - 0x35, 0x8a, 0x99, 0x5d, 0x51, 0x32, 0x0e, 0x36, 0x6b, 0xa7, 0x71, 0x95, 0xa1, 0xc1, 0x10, 0x37, - 0x74, 0x42, 0xc0, 0xd0, 0x31, 0x34, 0xf3, 0x6c, 0x46, 0xb9, 0xb0, 0xab, 0x1d, 0xa3, 0x5b, 0xc1, - 0x96, 0xc6, 0x86, 0x94, 0x0b, 0xb7, 0x05, 0x4d, 0xd9, 0x57, 0xaa, 0x97, 0xd0, 0xbd, 0x81, 0x03, - 0x1d, 0xeb, 0x75, 0xf8, 0x01, 0xaa, 0x73, 0x09, 0xd8, 0x46, 0xa7, 0xdc, 0xb5, 0xfa, 0x5f, 0x15, - 0x68, 0x41, 0x12, 0xe0, 0xac, 0xca, 0xfd, 0xdf, 0x80, 0xca, 0x90, 0xbc, 0x67, 0x93, 0xee, 0x98, - 0x54, 0xfa, 0x44, 0x26, 0xf9, 0x60, 0x85, 0x49, 0x42, 0x1f, 0x49, 0x34, 0x8a, 0x59, 0x6a, 0x97, - 0x3b, 0xe5, 0x6e, 0x63, 0xd0, 0xda,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ec, 0x83, 0xf6, - 0x91, 0x97, 0x3d, 0x25, 0x5e, 0xfe, 0x94, 0x78, 0x3f, 0xc9, 0xa7, 0x44, 0xb2, 0xef, 0x2c, 0x70, - 0x21, 0xf6, 0xa7, 0x1b, 0xe2, 0x59, 0xf6, 0x7b, 0xa8, 0xaa, 0xcb, 0x04, 0xf9, 0x05, 0x6f, 0x8d, - 0xad, 0x51, 0x67, 0xc5, 0x0b, 0xb4, 0x4f, 0xf7, 0x50, 0x55, 0xe7, 0xb2, 0xd0, 0x5c, 0xbb, 0x27, - 0xba, 0xd0, 0x5c, 0x7b, 0x47, 0x7e, 0xe0, 0xfd, 0x75, 0x5a, 0xf8, 0x67, 0xe0, 0xfb, 0x65, 0x6f, - 0x6c, 0x2a, 0x5f, 0xbe, 0x79, 0x13, 0x00, 0x00, 0xff, 0xff, 0x30, 0x53, 0x36, 0x35, 0x43, 0x08, - 0x00, 0x00, + // 784 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xcd, 0x6a, 0xeb, 0x46, + 0x18, 0xc5, 0x7f, 0xb2, 0xfd, 0xc9, 0x76, 0x60, 0x28, 0x41, 0xb8, 0x14, 0xb9, 0xca, 0xa2, 0x4e, + 0x09, 0x52, 0xec, 0x52, 0x28, 0x94, 0x42, 0xf3, 0xd7, 0x54, 0xa4, 0x0d, 0xee, 0xb4, 0xd9, 0x94, + 0x82, 0x91, 0xad, 0xa9, 0xa3, 0x44, 0xf6, 0x4c, 0x47, 0x63, 0x07, 0xaf, 0xba, 0xee, 0x4b, 0xf5, + 0x51, 0xbc, 0xf0, 0x8b, 0xb4, 0xcc, 0x68, 0xa4, 0x6b, 0xdf, 0x90, 0x7b, 0x15, 0xee, 0xdd, 0xf9, + 0x3b, 0xfa, 0xce, 0x99, 0x33, 0x67, 0xfe, 0x0c, 0xdf, 0xcc, 0x22, 0x71, 0xbf, 0x9c, 0xb8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0b, 0xe4, 0x95, 0x8e, 0xae, 0x79, 0xc3, 0xff, 0xaa, 0xd0, 0xf8, 0x51, 0x77, 0x20, + 0x06, 0x75, 0x7d, 0xd9, 0xa0, 0x41, 0x01, 0xa5, 0xfd, 0x3b, 0xae, 0x3b, 0x7c, 0x0d, 0x45, 0x4f, + 0x60, 0x0e, 0x46, 0x3a, 0x25, 0x74, 0x5a, 0xd4, 0x7a, 0x16, 0x47, 0x77, 0xf0, 0x0a, 0x86, 0x1e, + 0xee, 0x0f, 0x30, 0x77, 0xd6, 0x15, 0x7d, 0x5d, 0xc4, 0xf1, 0xb3, 0x7d, 0xd0, 0x3d, 0x74, 0xd3, + 0xd7, 0xc7, 0xcd, 0x5e, 0x1f, 0xf7, 0x4a, 0xbe, 0x3e, 0x52, 0x7d, 0x67, 0x81, 0x0b, 0xa9, 0x3f, + 0xdf, 0x10, 0x2f, 0xaa, 0x3f, 0x40, 0x4d, 0x5d, 0x26, 0xc8, 0x2b, 0x78, 0x6b, 0xe4, 0x41, 0x9d, + 0x16, 0x27, 0xe8, 0x9c, 0x1e, 0xa0, 0xa6, 0xce, 0x65, 0xa1, 0xb1, 0x76, 0x4f, 0x74, 0xa1, 0xb1, + 0xf6, 0x8e, 0xfc, 0xb9, 0xfb, 0xfb, 0x49, 0xe1, 0xff, 0x0f, 0xdf, 0xae, 0x06, 0x13, 0x43, 0xe5, + 0xf2, 0xd5, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x77, 0xf6, 0x3d, 0x3c, 0x76, 0x08, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/api/v1/heimdall.proto b/api/v1/heimdall.proto index b14408e..2f41631 100644 --- a/api/v1/heimdall.proto +++ b/api/v1/heimdall.proto @@ -40,8 +40,9 @@ message Node { string id = 1 [(gogoproto.customname) = "ID"]; string addr = 2; KeyPair keypair = 3 [(gogoproto.customname) = "KeyPair"]; - string gateway_ip = 4 [(gogoproto.customname) = "GatewayIP"]; - uint64 gateway_port = 5; + string endpoint_ip = 4 [(gogoproto.customname) = "EndpointIP"]; + uint64 endpoint_port = 5; + string gateway_ip = 6 [(gogoproto.customname) = "GatewayIP"]; } message NodesRequest {} diff --git a/client/client.go b/client/client.go index 6f52e65..81e7bc2 100644 --- a/client/client.go +++ b/client/client.go @@ -44,7 +44,7 @@ type Client struct { // NewClient returns a new Atlas client configured with the specified address and options func NewClient(id, addr string, opts ...grpc.DialOption) (*Client, error) { - ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) + ctx, cancel := context.WithTimeout(context.Background(), time.Second*2) defer cancel() if len(opts) == 0 { diff --git a/cmd/hctl/nodes.go b/cmd/hctl/nodes.go index 9120933..673651b 100644 --- a/cmd/hctl/nodes.go +++ b/cmd/hctl/nodes.go @@ -53,10 +53,10 @@ var listNodesCommand = cli.Command{ } w := tabwriter.NewWriter(os.Stdout, 20, 1, 3, ' ', 0) - fmt.Fprintf(w, "ID\tADDR\tGATEWAY\tPUBLIC KEY\n") + fmt.Fprintf(w, "ID\tADDR\tENDPOINT\tGATEWAY\tPUBLIC KEY\n") for _, n := range nodes { - gw := fmt.Sprintf("%s:%d", n.GatewayIP, n.GatewayPort) - fmt.Fprintf(w, "%s\t%s\t%s\t%s\n", n.ID, n.Addr, gw, n.KeyPair.PublicKey) + ep := fmt.Sprintf("%s:%d", n.EndpointIP, n.EndpointPort) + fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\n", n.ID, n.Addr, ep, n.GatewayIP, n.KeyPair.PublicKey) } w.Flush() diff --git a/cmd/heimdall/main.go b/cmd/heimdall/main.go index a568c0d..bebb444 100644 --- a/cmd/heimdall/main.go +++ b/cmd/heimdall/main.go @@ -96,16 +96,16 @@ func main() { EnvVar: "HEIMDALL_PEER_NETWORK", }, cli.StringFlag{ - Name: "gateway-ip", + Name: "endpoint-ip", Usage: "IP used for peer communication", Value: heimdall.GetIP(), - EnvVar: "HEIMDALL_GATEWAY_IP", + EnvVar: "HEIMDALL_ENDPOINT_IP", }, cli.IntFlag{ - Name: "gateway-port", + Name: "endpoint-port", Usage: "port for peer communication", Value: 10100, - EnvVar: "HEIMDALL_GATEWAY_PORT", + EnvVar: "HEIMDALL_ENDPOINT_PORT", }, } app.Before = func(c *cli.Context) error { diff --git a/cmd/heimdall/run.go b/cmd/heimdall/run.go index dfce06e..5df07b0 100644 --- a/cmd/heimdall/run.go +++ b/cmd/heimdall/run.go @@ -47,8 +47,8 @@ func runServer(cx *cli.Context) error { ClusterKey: cx.String("cluster-key"), NodeNetwork: cx.String("node-network"), PeerNetwork: cx.String("peer-network"), - GatewayIP: cx.String("gateway-ip"), - GatewayPort: cx.Int("gateway-port"), + EndpointIP: cx.String("endpoint-ip"), + EndpointPort: cx.Int("endpoint-port"), RedisURL: cx.String("redis-url"), AdvertiseRedisURL: cx.String("advertise-redis-url"), } diff --git a/config.go b/config.go index 9c7d8e0..813f5fd 100644 --- a/config.go +++ b/config.go @@ -35,10 +35,10 @@ type Config struct { NodeNetwork string // PeerNetwork is the subnet that is used for cluster peers PeerNetwork string - // GatewayIP is the IP used for peer communication - GatewayIP string + // EndpointIP is the IP used for peer communication + EndpointIP string // GatewayPort is the port used for peer communication - GatewayPort int + EndpointPort int // RedisURL is the uri to the redis backend RedisURL string // AdvertiseRedisURL is the uri to the public redis backend diff --git a/server/node.go b/server/node.go index 5df2e61..6f2745c 100644 --- a/server/node.go +++ b/server/node.go @@ -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) diff --git a/server/peer.go b/server/peer.go index 376b2e8..b46858d 100644 --- a/server/peer.go +++ b/server/peer.go @@ -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, }