2022-04-01 16:16:46 +00:00
|
|
|
package upgrader
|
2018-07-04 10:51:47 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2022-11-04 13:57:20 +00:00
|
|
|
"github.com/libp2p/go-libp2p/core/network"
|
2023-02-22 21:58:17 +00:00
|
|
|
"github.com/libp2p/go-libp2p/core/protocol"
|
2022-11-04 13:57:20 +00:00
|
|
|
"github.com/libp2p/go-libp2p/core/transport"
|
2018-07-04 10:51:47 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type transportConn struct {
|
2022-08-19 16:34:07 +00:00
|
|
|
network.MuxedConn
|
2019-06-09 07:24:20 +00:00
|
|
|
network.ConnMultiaddrs
|
|
|
|
network.ConnSecurity
|
2018-07-04 10:51:47 +00:00
|
|
|
transport transport.Transport
|
2022-04-01 16:16:46 +00:00
|
|
|
scope network.ConnManagementScope
|
|
|
|
stat network.ConnStats
|
2023-02-22 21:58:17 +00:00
|
|
|
|
2023-04-07 18:23:07 +00:00
|
|
|
muxer protocol.ID
|
|
|
|
security protocol.ID
|
|
|
|
usedEarlyMuxerNegotiation bool
|
2018-07-04 10:51:47 +00:00
|
|
|
}
|
|
|
|
|
2022-04-01 16:16:46 +00:00
|
|
|
var _ transport.CapableConn = &transportConn{}
|
|
|
|
|
2018-07-04 10:51:47 +00:00
|
|
|
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()
|
|
|
|
}
|
2023-02-22 21:58:17 +00:00
|
|
|
|
|
|
|
func (t *transportConn) ConnState() network.ConnectionState {
|
|
|
|
return network.ConnectionState{
|
2023-04-07 18:23:07 +00:00
|
|
|
StreamMultiplexer: t.muxer,
|
|
|
|
Security: t.security,
|
|
|
|
Transport: "tcp",
|
|
|
|
UsedEarlyMuxerNegotiation: t.usedEarlyMuxerNegotiation,
|
2023-02-22 21:58:17 +00:00
|
|
|
}
|
|
|
|
}
|