p2p: allow listener with no external connection

This commit is contained in:
Ethan Buchman
2017-07-19 15:03:36 -04:00
parent 7f5908b622
commit ddb3d8945d
3 changed files with 9 additions and 16 deletions

View File

@ -309,7 +309,7 @@ func NewNode(config *cfg.Config,
// OnStart starts the Node. It implements cmn.Service.
func (n *Node) OnStart() error {
// Create & add listener
protocol, address := ProtocolAndAddress(n.config.P2P.ListenAddress)
protocol, address := cmn.ProtocolAndAddress(n.config.P2P.ListenAddress)
l := p2p.NewDefaultListener(protocol, address, n.config.P2P.SkipUPNP, n.Logger.With("module", "p2p"))
n.sw.AddListener(l)
@ -535,15 +535,4 @@ func (n *Node) DialSeeds(seeds []string) error {
return n.sw.DialSeeds(n.addrBook, seeds)
}
// ProtocolAndAddress returns the transport protocol
// and the ip address from the given string. Defaults to tcp.
func ProtocolAndAddress(listenAddr string) (string, string) {
protocol, address := "tcp", listenAddr
parts := strings.SplitN(address, "://", 2)
if len(parts) == 2 {
protocol, address = parts[0], parts[1]
}
return protocol, address
}
//------------------------------------------------------------------------------