Skip to content

Commit

Permalink
add options for disabling the default listen address/transports
Browse files Browse the repository at this point in the history
So, in go-ipfs at least, we *don't* pass the listen addresses into the libp2p
constructor. Instead, we specify them later.

This option allows us to tell libp2p to not listen by default.
  • Loading branch information
Stebalien committed Aug 21, 2018
1 parent c67b87c commit ad5b7b9
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,3 +241,21 @@ func NATManager(nm config.NATManagerC) Option {
return nil
}
}

// NoListen will configure libp2p to not listen by default.
//
// This will both clear any configured listen addrs and prevent libp2p from
// applying the default listen address option.
var NoListen = func(cfg *Config) error {
cfg.ListenAddrs = []ma.Multiaddr{}
return nil
}

// NoTransports will configure libp2p to not enable any transports.
//
// This will both clear any configured transports (specified in prior libp2p
// options) and prevent libp2p from applying the default transports.
var NoTransports = func(cfg *Config) error {
cfg.Transports = []config.TptC{}
return nil
}

0 comments on commit ad5b7b9

Please sign in to comment.