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
f82d4ec6
Commit
f82d4ec6
authored
Jul 25, 2018
by
Abhishek Upperwal
Browse files
default listener
parent
9f25f923
Changes
1
Hide whitespace changes
Inline
Side-by-side
defaults.go
View file @
f82d4ec6
...
@@ -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
...
...
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