status-go/vendor/github.com/libp2p/go-libp2p/p2p/net/upgrader/conn.go

66 lines
1.4 KiB
Go
Raw Normal View History

2022-04-01 16:16:46 +00:00
package upgrader
import (
"fmt"
2022-11-04 13:57:20 +00:00
"github.com/libp2p/go-libp2p/core/network"
"github.com/libp2p/go-libp2p/core/protocol"
2022-11-04 13:57:20 +00:00
"github.com/libp2p/go-libp2p/core/transport"
)
type transportConn struct {
network.MuxedConn
2019-06-09 07:24:20 +00:00
network.ConnMultiaddrs
network.ConnSecurity
transport transport.Transport
2022-04-01 16:16:46 +00:00
scope network.ConnManagementScope
stat network.ConnStats
muxer protocol.ID
security protocol.ID
usedEarlyMuxerNegotiation bool
}
2022-04-01 16:16:46 +00:00
var _ transport.CapableConn = &transportConn{}
func (t *transportConn) Transport() transport.Transport {
return t.transport
}
func (t *transportConn) String() string {
ts := ""
if s, ok := t.transport.(fmt.Stringer); ok {
ts = "[" + s.String() + "]"
}
return fmt.Sprintf(
"<stream.Conn%s %s (%s) <-> %s (%s)>",
ts,
t.LocalMultiaddr(),
t.LocalPeer(),
t.RemoteMultiaddr(),
t.RemotePeer(),
)
}
2021-10-19 13:43:41 +00:00
2022-04-01 16:16:46 +00:00
func (t *transportConn) Stat() network.ConnStats {
2021-10-19 13:43:41 +00:00
return t.stat
}
2022-04-01 16:16:46 +00:00
func (t *transportConn) Scope() network.ConnScope {
return t.scope
}
func (t *transportConn) Close() error {
defer t.scope.Done()
return t.MuxedConn.Close()
}
func (t *transportConn) ConnState() network.ConnectionState {
return network.ConnectionState{
StreamMultiplexer: t.muxer,
Security: t.security,
Transport: "tcp",
UsedEarlyMuxerNegotiation: t.usedEarlyMuxerNegotiation,
}
}