add options for disabling the default listen address/transports
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.
@@ -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
+}
