mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 03:30:35 +00:00
6bea17cb54
* Update libp2p to support go 1.19 * gaz * go mod tidy * Only update the minimum deps * go mod tidy * revert .bazelrc * Update go-libp2p to v0.22.0 and update import paths (#11440) * Fix import paths * Fix go-libp2p-peerstore import * Bazel updates * fix * revert some comments changes * revert some comment stuff * fix dependency issues * vendor problematic library * use your brain * remove * tests Co-authored-by: Marco Munizaga <marco@marcopolo.io> Co-authored-by: Nishant Das <nishdas93@gmail.com>
54 lines
1.2 KiB
Go
54 lines
1.2 KiB
Go
package p2p
|
|
|
|
import (
|
|
"strconv"
|
|
"strings"
|
|
|
|
"github.com/libp2p/go-libp2p/core/peer"
|
|
ma "github.com/multiformats/go-multiaddr"
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
var log = logrus.WithField("prefix", "p2p")
|
|
|
|
func logIPAddr(id peer.ID, addrs ...ma.Multiaddr) {
|
|
var correctAddr ma.Multiaddr
|
|
for _, addr := range addrs {
|
|
if strings.Contains(addr.String(), "/ip4/") || strings.Contains(addr.String(), "/ip6/") {
|
|
correctAddr = addr
|
|
break
|
|
}
|
|
}
|
|
if correctAddr != nil {
|
|
log.WithField(
|
|
"multiAddr",
|
|
correctAddr.String()+"/p2p/"+id.String(),
|
|
).Info("Node started p2p server")
|
|
}
|
|
}
|
|
|
|
func logExternalIPAddr(id peer.ID, addr string, port uint) {
|
|
if addr != "" {
|
|
multiAddr, err := MultiAddressBuilder(addr, port)
|
|
if err != nil {
|
|
log.WithError(err).Error("Could not create multiaddress")
|
|
return
|
|
}
|
|
log.WithField(
|
|
"multiAddr",
|
|
multiAddr.String()+"/p2p/"+id.String(),
|
|
).Info("Node started external p2p server")
|
|
}
|
|
}
|
|
|
|
func logExternalDNSAddr(id peer.ID, addr string, port uint) {
|
|
if addr != "" {
|
|
p := strconv.FormatUint(uint64(port), 10)
|
|
|
|
log.WithField(
|
|
"multiAddr",
|
|
"/dns4/"+addr+"/tcp/"+p+"/p2p/"+id.String(),
|
|
).Info("Node started external p2p server")
|
|
}
|
|
}
|