p2p: Added log for --p2p-host-ip (#4553)

* added log for external addr
* Merge branch 'master' into log-p2p-address
* Merge branch 'master' into log-p2p-address
* Merge branch 'master' into log-p2p-address
This commit is contained in:
Prince Sinha 2020-01-17 16:37:37 +05:30 committed by prylabs-bulldozer[bot]
parent dab87ba252
commit 0605118686

View File

@ -3,6 +3,7 @@ package p2p
import (
"context"
"crypto/ecdsa"
"strconv"
"strings"
"time"
@ -213,6 +214,10 @@ func (s *Service) Start() {
multiAddrs := s.host.Network().ListenAddresses()
logIP4Addr(s.host.ID(), multiAddrs...)
p2pHostAddress := s.cfg.HostAddress
p2pTCPPort := s.cfg.TCPPort
logExternalIP4Addr(s.host.ID(), p2pHostAddress, p2pTCPPort)
}
// Stop the p2p service and terminate all peer connections.
@ -364,3 +369,14 @@ func logIP4Addr(id peer.ID, addrs ...ma.Multiaddr) {
).Info("Node started p2p server")
}
}
func logExternalIP4Addr(id peer.ID, addr string, port uint) {
if addr != "" {
p := strconv.FormatUint(uint64(port), 10)
log.WithField(
"multiAddr",
"/ip4/"+addr+"/tcp/"+p+"/p2p/"+id.String(),
).Info("Node started external p2p server")
}
}