From 9d4f4d9efb3f234ccfb4957e99ad485b7e8ce9c0 Mon Sep 17 00:00:00 2001 From: Poorunga <2744323@qq.com> Date: Wed, 1 Nov 2023 19:40:15 +0800 Subject: [PATCH] The nodeName of edgemesh-gateway is added with a -gateway suffix Signed-off-by: Poorunga <2744323@qq.com> --- cmd/edgemesh-gateway/app/server.go | 3 +++ pkg/tunnel/module.go | 6 +----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/cmd/edgemesh-gateway/app/server.go b/cmd/edgemesh-gateway/app/server.go index a49fce5ea..d83068935 100644 --- a/cmd/edgemesh-gateway/app/server.go +++ b/cmd/edgemesh-gateway/app/server.go @@ -165,6 +165,9 @@ func prepareRun(c *v1alpha1.EdgeMeshGatewayConfig) error { if !exists { return fmt.Errorf("env NODE_NAME not exist") } + // In order to prevent the agent and gateway from having the same peerID on the same node, + // you need to add a -gateway suffix to the nodeName. + nodeName += "-gateway" c.Modules.EdgeGatewayConfig.LoadBalancer.NodeName = nodeName c.Modules.EdgeTunnelConfig.NodeName = nodeName diff --git a/pkg/tunnel/module.go b/pkg/tunnel/module.go index 3514f96ac..eefc18376 100644 --- a/pkg/tunnel/module.go +++ b/pkg/tunnel/module.go @@ -94,11 +94,7 @@ func newEdgeTunnel(c *v1alpha1.EdgeTunnelConfig) (*EdgeTunnel, error) { opts := make([]libp2p.Option, 0) // libp2p options peerSource := make(chan peer.AddrInfo, c.MaxCandidates) - hostName := c.NodeName - if c.Mode == defaults.ClientMode { - hostName += "-gateway" - } - privKey, err := GenerateKeyPairWithString(hostName) + privKey, err := GenerateKeyPairWithString(c.NodeName) if err != nil { return nil, fmt.Errorf("failed to generate private key: %w", err) }