Skip to content

Commit

Permalink
no listening if NetAddress not set
Browse files Browse the repository at this point in the history
  • Loading branch information
cce committed Jul 17, 2024
1 parent e8feae1 commit a9c883d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion network/p2p/p2p.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ func MakeHost(cfg config.Local, datadir string, pstore *pstore.PeerStore) (host.
listenAddr = parsedListenAddr
}
} else {
listenAddr = "/ip4/0.0.0.0/tcp/0"
// don't listen if NetAddress is not set.
listenAddr = ""
}

var disableMetrics = func(cfg *libp2p.Config) error { return nil }
Expand Down Expand Up @@ -163,6 +164,11 @@ func MakeService(ctx context.Context, log logging.Logger, cfg config.Local, h ho

// Start starts the P2P service
func (s *serviceImpl) Start() error {
if s.listenAddr == "" {
// don't listen if no listen address configured
return nil
}

listenAddr, err := multiaddr.NewMultiaddr(s.listenAddr)
if err != nil {
s.log.Errorf("failed to create multiaddress: %s", err)
Expand Down

0 comments on commit a9c883d

Please sign in to comment.