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) }