Commit 836d042f authored by Abhishek Upperwal's avatar Abhishek Upperwal
Browse files

added ipv6 + checking for default transport

parent d104ff8d
...@@ -55,11 +55,19 @@ var RandomIdentity = func(cfg *Config) error { ...@@ -55,11 +55,19 @@ var RandomIdentity = func(cfg *Config) error {
// DefaultListenAddrs configures libp2p to use default listen address // DefaultListenAddrs configures libp2p to use default listen address
var DefaultListenAddrs = func(cfg *Config) error { var DefaultListenAddrs = func(cfg *Config) error {
defaultListenAddr, err := multiaddr.NewMultiaddr("/ip4/0.0.0.0/tcp/0") defaultIP4ListenAddr, err := multiaddr.NewMultiaddr("/ip4/0.0.0.0/tcp/0")
if err != nil { if err != nil {
return err return err
} }
return cfg.Apply(ListenAddrs(defaultListenAddr))
defaultIP6ListenAddr, err := multiaddr.NewMultiaddr("/ip6/0.0.0.0/tcp/0")
if err != nil {
return err
}
return cfg.Apply(ListenAddrs(
defaultIP4ListenAddr,
defaultIP6ListenAddr,
))
} }
// Complete list of default options and when to fallback on them. // Complete list of default options and when to fallback on them.
...@@ -70,6 +78,10 @@ var defaults = []struct { ...@@ -70,6 +78,10 @@ var defaults = []struct {
fallback func(cfg *Config) bool fallback func(cfg *Config) bool
opt Option opt Option
}{ }{
{
fallback: func(cfg *Config) bool { return cfg.Transports == nil && cfg.ListenAddrs == nil },
opt: DefaultListenAddrs,
},
{ {
fallback: func(cfg *Config) bool { return cfg.Transports == nil }, fallback: func(cfg *Config) bool { return cfg.Transports == nil },
opt: DefaultTransports, opt: DefaultTransports,
...@@ -90,10 +102,6 @@ var defaults = []struct { ...@@ -90,10 +102,6 @@ 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