Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
go-libp2p
Commits
836d042f
Commit
836d042f
authored
Jul 25, 2018
by
Abhishek Upperwal
Browse files
added ipv6 + checking for default transport
parent
d104ff8d
Changes
1
Hide whitespace changes
Inline
Side-by-side
defaults.go
View file @
836d042f
...
...
@@ -55,11 +55,19 @@ var RandomIdentity = func(cfg *Config) error {
// DefaultListenAddrs configures libp2p to use default listen address
var
DefaultListenAddrs
=
func
(
cfg
*
Config
)
error
{
defaultListenAddr
,
err
:=
multiaddr
.
NewMultiaddr
(
"/ip4/0.0.0.0/tcp/0"
)
default
IP4
ListenAddr
,
err
:=
multiaddr
.
NewMultiaddr
(
"/ip4/0.0.0.0/tcp/0"
)
if
err
!=
nil
{
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.
...
...
@@ -70,6 +78,10 @@ var defaults = []struct {
fallback
func
(
cfg
*
Config
)
bool
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
},
opt
:
DefaultTransports
,
...
...
@@ -90,10 +102,6 @@ var defaults = []struct {
fallback
:
func
(
cfg
*
Config
)
bool
{
return
cfg
.
Peerstore
==
nil
},
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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment