diff --git a/options.go b/options.go index a17fc02e89c4a5c9e06282e1701ffa4b112c4780..ee147fa972b2e93d7a95f726294d65d42441dbcc 100644 --- a/options.go +++ b/options.go @@ -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 +}