36 lines
647 B
Go
36 lines
647 B
Go
|
package stream
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
|
||
|
inet "github.com/libp2p/go-libp2p-net"
|
||
|
transport "github.com/libp2p/go-libp2p-transport"
|
||
|
smux "github.com/libp2p/go-stream-muxer"
|
||
|
)
|
||
|
|
||
|
type transportConn struct {
|
||
|
smux.Conn
|
||
|
inet.ConnMultiaddrs
|
||
|
inet.ConnSecurity
|
||
|
transport transport.Transport
|
||
|
}
|
||
|
|
||
|
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(),
|
||
|
)
|
||
|
}
|