From a55911865303612cd7ec6b02ecb38732d5bad58a Mon Sep 17 00:00:00 2001 From: vyzo Date: Wed, 17 Feb 2021 09:36:57 +0200 Subject: [PATCH 1/2] gomod: update deps --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 0f22bee..15a7ec7 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.12 require ( github.com/ipfs/go-log v1.0.4 github.com/jbenet/go-temp-err-catcher v0.1.0 - github.com/libp2p/go-libp2p-core v0.8.1 + github.com/libp2p/go-libp2p-core v0.8.2 github.com/libp2p/go-libp2p-mplex v0.4.1 github.com/libp2p/go-libp2p-pnet v0.2.0 github.com/multiformats/go-multiaddr v0.3.1 diff --git a/go.sum b/go.sum index 118998c..38ebf53 100644 --- a/go.sum +++ b/go.sum @@ -76,8 +76,8 @@ github.com/libp2p/go-libp2p-core v0.3.0/go.mod h1:ACp3DmS3/N64c2jDzcV429ukDpicbL github.com/libp2p/go-libp2p-core v0.5.0/go.mod h1:49XGI+kc38oGVwqSBhDEwytaAxgZasHhFfQKibzTls0= github.com/libp2p/go-libp2p-core v0.8.0 h1:5K3mT+64qDTKbV3yTdbMCzJ7O6wbNsavAEb8iqBvBcI= github.com/libp2p/go-libp2p-core v0.8.0/go.mod h1:FfewUH/YpvWbEB+ZY9AQRQ4TAD8sJBt/G1rVvhz5XT8= -github.com/libp2p/go-libp2p-core v0.8.1 h1:+hvGysqSZ1AAWFHU8vNXX05vMSwI/6BSukuyn4DEBPE= -github.com/libp2p/go-libp2p-core v0.8.1/go.mod h1:FfewUH/YpvWbEB+ZY9AQRQ4TAD8sJBt/G1rVvhz5XT8= +github.com/libp2p/go-libp2p-core v0.8.2 h1:/eaSZACWftJZYm07S0nRxdI84v1hSmgnCXrGOvJdpNQ= +github.com/libp2p/go-libp2p-core v0.8.2/go.mod h1:FfewUH/YpvWbEB+ZY9AQRQ4TAD8sJBt/G1rVvhz5XT8= github.com/libp2p/go-libp2p-mplex v0.4.1 h1:/pyhkP1nLwjG3OM+VuaNJkQT/Pqq73WzB3aDN3Fx1sc= github.com/libp2p/go-libp2p-mplex v0.4.1/go.mod h1:cmy+3GfqfM1PceHTLL7zQzAAYaryDu6iPSC+CIb094g= github.com/libp2p/go-libp2p-pnet v0.2.0 h1:J6htxttBipJujEjz1y0a5+eYoiPcFHhSYHH6na5f0/k= From f5212e5843c89188ab75c67ac828bc0c2d3f298d Mon Sep 17 00:00:00 2001 From: vyzo Date: Thu, 4 Feb 2021 13:46:47 +0200 Subject: [PATCH 2/2] thread underlying conn Stat to allow transports to propagate stat information --- conn.go | 5 +++++ upgrader.go | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/conn.go b/conn.go index 2098b15..a4ee0cb 100644 --- a/conn.go +++ b/conn.go @@ -13,6 +13,7 @@ type transportConn struct { network.ConnMultiaddrs network.ConnSecurity transport transport.Transport + stat network.Stat } func (t *transportConn) Transport() transport.Transport { @@ -33,3 +34,7 @@ func (t *transportConn) String() string { t.RemotePeer(), ) } + +func (t *transportConn) Stat() network.Stat { + return t.stat +} diff --git a/upgrader.go b/upgrader.go index 55427e1..26b879c 100644 --- a/upgrader.go +++ b/upgrader.go @@ -66,6 +66,11 @@ func (u *Upgrader) UpgradeInbound(ctx context.Context, t transport.Transport, ma } func (u *Upgrader) upgrade(ctx context.Context, t transport.Transport, maconn manet.Conn, p peer.ID, dir network.Direction) (transport.CapableConn, error) { + var stat network.Stat + if cs, ok := maconn.(network.ConnStat); ok { + stat = cs.Stat() + } + var conn net.Conn = maconn if u.PSK != nil { pconn, err := pnet.NewProtectedConn(u.PSK, conn) @@ -107,6 +112,7 @@ func (u *Upgrader) upgrade(ctx context.Context, t transport.Transport, maconn ma ConnMultiaddrs: maconn, ConnSecurity: sconn, transport: t, + stat: stat, } return tc, nil }