Commit f82d4ec6 authored by Abhishek Upperwal's avatar Abhishek Upperwal
Browse files

default listener

parent 9f25f923
...@@ -10,6 +10,7 @@ import ( ...@@ -10,6 +10,7 @@ import (
secio "github.com/libp2p/go-libp2p-secio" secio "github.com/libp2p/go-libp2p-secio"
tcp "github.com/libp2p/go-tcp-transport" tcp "github.com/libp2p/go-tcp-transport"
ws "github.com/libp2p/go-ws-transport" ws "github.com/libp2p/go-ws-transport"
multiaddr "github.com/multiformats/go-multiaddr"
mplex "github.com/whyrusleeping/go-smux-multiplex" mplex "github.com/whyrusleeping/go-smux-multiplex"
yamux "github.com/whyrusleeping/go-smux-yamux" yamux "github.com/whyrusleeping/go-smux-yamux"
) )
...@@ -52,6 +53,14 @@ var RandomIdentity = func(cfg *Config) error { ...@@ -52,6 +53,14 @@ var RandomIdentity = func(cfg *Config) error {
return cfg.Apply(Identity(priv)) return cfg.Apply(Identity(priv))
} }
var DefaultListenAddrs = func(cfg *Config) error {
defaultListenAddr, err := multiaddr.NewMultiaddr("/ip4/0.0.0.0/tcp/0")
if err != nil {
return err
}
return cfg.Apply(ListenAddrs(defaultListenAddr))
}
// Complete list of default options and when to fallback on them. // Complete list of default options and when to fallback on them.
// //
// Please *DON'T* specify default options any other way. Putting this all here // Please *DON'T* specify default options any other way. Putting this all here
...@@ -80,6 +89,10 @@ var defaults = []struct { ...@@ -80,6 +89,10 @@ var defaults = []struct {
fallback: func(cfg *Config) bool { return cfg.Peerstore == nil }, fallback: func(cfg *Config) bool { return cfg.Peerstore == nil },
opt: DefaultPeerstore, opt: DefaultPeerstore,
}, },
{
fallback: func(cfg *Config) bool { return cfg.ListenAddrs == nil },
opt: DefaultListenAddrs,
},
} }
// Defaults configures libp2p to use the default options. Can be combined with // Defaults configures libp2p to use the default options. Can be combined with
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment