Add canonical peer status logs (#1624)
* Add canonical peer status logs * Move logs to swarm * Remove quic log * Update deps
This commit is contained in:
parent
196acf287e
commit
452ddfbb76
6
go.mod
6
go.mod
|
@ -11,7 +11,7 @@ require (
|
|||
github.com/google/gopacket v1.1.19
|
||||
github.com/gorilla/websocket v1.5.0
|
||||
github.com/hashicorp/golang-lru v0.5.4
|
||||
github.com/ipfs/go-cid v0.1.0
|
||||
github.com/ipfs/go-cid v0.2.0
|
||||
github.com/ipfs/go-datastore v0.5.1
|
||||
github.com/ipfs/go-ipfs-util v0.0.2
|
||||
github.com/ipfs/go-log/v2 v2.5.1
|
||||
|
@ -20,8 +20,8 @@ require (
|
|||
github.com/libp2p/go-buffer-pool v0.0.2
|
||||
github.com/libp2p/go-eventbus v0.2.1
|
||||
github.com/libp2p/go-libp2p-asn-util v0.2.0
|
||||
github.com/libp2p/go-libp2p-core v0.17.0
|
||||
github.com/libp2p/go-libp2p-peerstore v0.7.0
|
||||
github.com/libp2p/go-libp2p-core v0.18.0
|
||||
github.com/libp2p/go-libp2p-peerstore v0.7.1
|
||||
github.com/libp2p/go-libp2p-resource-manager v0.3.0
|
||||
github.com/libp2p/go-libp2p-testing v0.9.2
|
||||
github.com/libp2p/go-mplex v0.7.0
|
||||
|
|
12
go.sum
12
go.sum
|
@ -247,8 +247,8 @@ github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANyt
|
|||
github.com/ipfs/go-cid v0.0.2/go.mod h1:GHWU/WuQdMPmIosc4Yn1bcCT7dSeX4lBafM7iqUPQvM=
|
||||
github.com/ipfs/go-cid v0.0.5/go.mod h1:plgt+Y5MnOey4vO4UlUazGqdbEXuFYitED67FexhXog=
|
||||
github.com/ipfs/go-cid v0.0.7/go.mod h1:6Ux9z5e+HpkQdckYoX1PG/6xqKspzlEIR5SDmgqgC/I=
|
||||
github.com/ipfs/go-cid v0.1.0 h1:YN33LQulcRHjfom/i25yoOZR4Telp1Hr/2RU3d0PnC0=
|
||||
github.com/ipfs/go-cid v0.1.0/go.mod h1:rH5/Xv83Rfy8Rw6xG+id3DYAMUVmem1MowoKwdXmN2o=
|
||||
github.com/ipfs/go-cid v0.2.0 h1:01JTiihFq9en9Vz0lc0VDWvZe/uBonGpzo4THP0vcQ0=
|
||||
github.com/ipfs/go-cid v0.2.0/go.mod h1:P+HXFDF4CVhaVayiEb4wkAy7zBHxBwsJyt0Y5U6MLro=
|
||||
github.com/ipfs/go-datastore v0.5.0/go.mod h1:9zhEApYMTl17C8YDp7JmU7sQZi2/wqiYh73hakZ90Bk=
|
||||
github.com/ipfs/go-datastore v0.5.1 h1:WkRhLuISI+XPD0uk3OskB0fYFSyqK8Ob5ZYew9Qa1nQ=
|
||||
github.com/ipfs/go-datastore v0.5.1/go.mod h1:9zhEApYMTl17C8YDp7JmU7sQZi2/wqiYh73hakZ90Bk=
|
||||
|
@ -325,10 +325,10 @@ github.com/libp2p/go-libp2p-core v0.2.0/go.mod h1:X0eyB0Gy93v0DZtSYbEM7RnMChm9Uv
|
|||
github.com/libp2p/go-libp2p-core v0.5.7/go.mod h1:txwbVEhHEXikXn9gfC7/UDDw7rkxuX0bJvM49Ykaswo=
|
||||
github.com/libp2p/go-libp2p-core v0.12.0/go.mod h1:ECdxehoYosLYHgDDFa2N4yE8Y7aQRAMf0sX9mf2sbGg=
|
||||
github.com/libp2p/go-libp2p-core v0.14.0/go.mod h1:tLasfcVdTXnixsLB0QYaT1syJOhsbrhG7q6pGrHtBg8=
|
||||
github.com/libp2p/go-libp2p-core v0.17.0 h1:QGU8mlxHytwTc4pq/aVQX9VDoAPiCHxfe/oOSwF+YDg=
|
||||
github.com/libp2p/go-libp2p-core v0.17.0/go.mod h1:h/iAbFij28ASmI+tvXfjoipg1g2N33O4UN6LIb6QfoU=
|
||||
github.com/libp2p/go-libp2p-peerstore v0.7.0 h1:2iIUwok3vtmnWJTZeTeLgnBO6GbkXcwSRwgZHEKrQZs=
|
||||
github.com/libp2p/go-libp2p-peerstore v0.7.0/go.mod h1:cdUWTHro83vpg6unCpGUr8qJoX3e93Vy8o97u5ppIM0=
|
||||
github.com/libp2p/go-libp2p-core v0.18.0 h1:giGYfMfEpHnRJdOiEH3+YLm8xch/wBTRxLBnHUqa5c0=
|
||||
github.com/libp2p/go-libp2p-core v0.18.0/go.mod h1:AkA+FUKQfYt1FLNef5fOPlo/naAWjKy/RCjkcPjqzYg=
|
||||
github.com/libp2p/go-libp2p-peerstore v0.7.1 h1:7FpALlqR+3+oOBXdzm3AVt0vjMYLW1b7jM03E4iEHlw=
|
||||
github.com/libp2p/go-libp2p-peerstore v0.7.1/go.mod h1:cdUWTHro83vpg6unCpGUr8qJoX3e93Vy8o97u5ppIM0=
|
||||
github.com/libp2p/go-libp2p-resource-manager v0.3.0 h1:2+cYxUNi33tcydsVLt6K5Fv2E3OTiVeafltecAj15E0=
|
||||
github.com/libp2p/go-libp2p-resource-manager v0.3.0/go.mod h1:K+eCkiapf+ey/LADO4TaMpMTP9/Qde/uLlrnRqV4PLQ=
|
||||
github.com/libp2p/go-libp2p-testing v0.1.1/go.mod h1:xaZWMJrPUM5GlDBxCeGUi7kI4eqnjVyavGroI2nxEM0=
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/canonicallog"
|
||||
"github.com/libp2p/go-libp2p-core/network"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
"github.com/libp2p/go-libp2p-core/transport"
|
||||
|
@ -387,6 +388,7 @@ func (s *Swarm) dialAddr(ctx context.Context, p peer.ID, addr ma.Multiaddr) (tra
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
canonicallog.LogPeerStatus(100, connC.RemotePeer(), connC.RemoteMultiaddr(), "connection_status", "established", "dir", "outbound")
|
||||
|
||||
// Trust the transport? Yeah... right.
|
||||
if connC.RemotePeer() != p {
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/canonicallog"
|
||||
"github.com/libp2p/go-libp2p-core/network"
|
||||
"github.com/libp2p/go-libp2p-core/transport"
|
||||
|
||||
|
@ -124,6 +125,7 @@ func (s *Swarm) AddListenAddr(a ma.Multiaddr) error {
|
|||
if err != nil {
|
||||
return
|
||||
}
|
||||
canonicallog.LogPeerStatus(100, c.RemotePeer(), c.RemoteMultiaddr(), "connection_status", "established", "dir", "inbound")
|
||||
|
||||
log.Debugf("swarm listener accepted connection: %s <-> %s", c.LocalMultiaddr(), c.RemoteMultiaddr())
|
||||
s.refs.Add(1)
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
"github.com/libp2p/go-libp2p-core/crypto"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
"github.com/libp2p/go-libp2p-core/sec"
|
||||
manet "github.com/multiformats/go-multiaddr/net"
|
||||
)
|
||||
|
||||
// ID is the protocol ID for noise
|
||||
|
@ -41,7 +42,10 @@ func New(privkey crypto.PrivKey) (*Transport, error) {
|
|||
func (t *Transport) SecureInbound(ctx context.Context, insecure net.Conn, p peer.ID) (sec.SecureConn, error) {
|
||||
c, err := newSecureSession(t, ctx, insecure, p, false)
|
||||
if err != nil {
|
||||
canonicallog.LogMisbehavingPeerNetAddr(p, insecure.RemoteAddr(), "noise-security-handshake", err, "failed security handshake")
|
||||
addr, maErr := manet.FromNetAddr(insecure.RemoteAddr())
|
||||
if maErr == nil {
|
||||
canonicallog.LogPeerStatus(100, p, addr, "handshake_failure", "noise", "err", err.Error())
|
||||
}
|
||||
}
|
||||
return c, err
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import (
|
|||
ci "github.com/libp2p/go-libp2p-core/crypto"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
"github.com/libp2p/go-libp2p-core/sec"
|
||||
manet "github.com/multiformats/go-multiaddr/net"
|
||||
)
|
||||
|
||||
// ID is the protocol ID (used when negotiating with multistream)
|
||||
|
@ -53,7 +54,10 @@ func (t *Transport) SecureInbound(ctx context.Context, insecure net.Conn, p peer
|
|||
config, keyCh := t.identity.ConfigForPeer(p)
|
||||
cs, err := t.handshake(ctx, tls.Server(insecure, config), keyCh)
|
||||
if err != nil {
|
||||
canonicallog.LogMisbehavingPeerNetAddr(p, insecure.RemoteAddr(), "tls-security-handshake", err, "failed security handshake")
|
||||
addr, maErr := manet.FromNetAddr(insecure.RemoteAddr())
|
||||
if maErr == nil {
|
||||
canonicallog.LogPeerStatus(100, p, addr, "handshake_failure", "tls", "err", err.Error())
|
||||
}
|
||||
insecure.Close()
|
||||
}
|
||||
return cs, err
|
||||
|
|
Loading…
Reference in New Issue