From ba002be27db4b2713bad545f2950afe8a18af38e Mon Sep 17 00:00:00 2001 From: joeycli Date: Wed, 12 Apr 2023 10:17:18 +0800 Subject: [PATCH] feat: add nat manager for p2p (#299) * feat: add nat manager for p2p * feat: add noise security frame to p2p protocol --- pkg/p2p/node.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/p2p/node.go b/pkg/p2p/node.go index 5cdf30fcf..de0dc9a34 100644 --- a/pkg/p2p/node.go +++ b/pkg/p2p/node.go @@ -16,6 +16,7 @@ import ( "github.com/libp2p/go-libp2p/core/peerstore" "github.com/libp2p/go-libp2p/core/protocol" "github.com/libp2p/go-libp2p/p2p/host/peerstore/pstoreds" + "github.com/libp2p/go-libp2p/p2p/security/noise" "github.com/bnb-chain/greenfield-storage-provider/pkg/log" "github.com/bnb-chain/greenfield-storage-provider/pkg/p2p/types" @@ -65,6 +66,9 @@ func NewNode(config *NodeConfig, SPAddr string, signer *signerclient.SignerClien // to the same sp all fail and are replaced, then the sp will be unable to communicate, this requires // dynamic updates permanent nodes libp2p.Ping(false), + libp2p.NATPortMap(), + // support noise connections + libp2p.Security(noise.ID, noise.New), libp2p.WithDialTimeout(time.Duration(DailTimeout)*time.Second), ) if err != nil {