package transport

Import Path
	github.com/libp2p/go-libp2p/core/transport (on go.dev)

Dependency Relation
	imports 8 packages, and imported by 14 packages

Involved Source Files Package transport provides the Transport interface, which represents the devices and network protocols used to send and receive data.
Package-Level Type Names (total 11)
/* sort by: | */
A CapableConn represents a connection that has offers the basic capabilities required by libp2p: stream multiplexing, encryption and peer authentication. These capabilities may be natively provided by the transport, or they may be shimmed via the "connection upgrade" process, which converts a "raw" network connection into one that supports such capabilities by layering an encryption channel and a stream multiplexer. CapableConn provides accessors for the local and remote multiaddrs used to establish the connection and an accessor for the underlying Transport. AcceptStream accepts a stream opened by the other side. ( CapableConn) Close() error CloseWithError closes the connection with errCode. The errCode is sent to the peer. ConnState returns information about the connection state. IsClosed returns whether a connection is fully closed, so it can be garbage collected. LocalMultiaddr returns the local Multiaddr associated with this connection LocalPeer returns our peer ID OpenStream creates a new stream. RemoteMultiaddr returns the remote Multiaddr associated with this connection RemotePeer returns the peer ID of the remote peer. RemotePublicKey returns the public key of the remote peer. Scope returns the user view of this connection's resource scope Transport returns the transport to which this connection belongs. CapableConn : github.com/libp2p/go-libp2p/core/network.ConnMultiaddrs CapableConn : github.com/libp2p/go-libp2p/core/network.ConnScoper CapableConn : github.com/libp2p/go-libp2p/core/network.ConnSecurity CapableConn : github.com/libp2p/go-libp2p/core/network.MuxedConn CapableConn : github.com/prometheus/common/expfmt.Closer CapableConn : io.Closer func DialUpdater.DialWithUpdates(context.Context, ma.Multiaddr, peer.ID, chan<- DialUpdate) (CapableConn, error) func Listener.Accept() (CapableConn, error) func Transport.Dial(ctx context.Context, raddr ma.Multiaddr, p peer.ID) (CapableConn, error) func Upgrader.Upgrade(ctx context.Context, t Transport, maconn manet.Conn, dir network.Direction, p peer.ID, scope network.ConnManagementScope) (CapableConn, error) func github.com/libp2p/go-libp2p/p2p/protocol/circuitv2/client.(*Client).Dial(ctx context.Context, a ma.Multiaddr, p peer.ID) (CapableConn, error) func github.com/libp2p/go-libp2p/p2p/transport/tcp.(*TcpTransport).Dial(ctx context.Context, raddr ma.Multiaddr, p peer.ID) (CapableConn, error) func github.com/libp2p/go-libp2p/p2p/transport/tcp.(*TcpTransport).DialWithUpdates(ctx context.Context, raddr ma.Multiaddr, p peer.ID, updateChan chan<- DialUpdate) (CapableConn, error) func github.com/libp2p/go-libp2p/p2p/transport/webrtc.(*WebRTCTransport).Dial(ctx context.Context, remoteMultiaddr ma.Multiaddr, p peer.ID) (CapableConn, error) func github.com/libp2p/go-libp2p/p2p/transport/websocket.(*WebsocketTransport).Dial(ctx context.Context, raddr ma.Multiaddr, p peer.ID) (CapableConn, error) func github.com/pancsta/asyncmachine-go/pkg/pubsub/uds.(*UdsTransport).Dial(ctx context.Context, raddr ma.Multiaddr, p peer.ID) (CapableConn, error) func github.com/pancsta/asyncmachine-go/pkg/pubsub/uds.(*UdsTransport).DialWithUpdates(ctx context.Context, raddr ma.Multiaddr, p peer.ID, updateChan chan<- DialUpdate) (CapableConn, error)
DialUpdate is used by DialUpdater to provide dial updates. Addr is the peer's address. Conn is the resulting connection on success. Err is the reason for dial failure. Kind is the kind of update event. func DialUpdater.DialWithUpdates(context.Context, ma.Multiaddr, peer.ID, chan<- DialUpdate) (CapableConn, error) func github.com/libp2p/go-libp2p/p2p/transport/tcp.(*TcpTransport).DialWithUpdates(ctx context.Context, raddr ma.Multiaddr, p peer.ID, updateChan chan<- DialUpdate) (CapableConn, error) func github.com/pancsta/asyncmachine-go/pkg/pubsub/uds.(*UdsTransport).DialWithUpdates(ctx context.Context, raddr ma.Multiaddr, p peer.ID, updateChan chan<- DialUpdate) (CapableConn, error)
DialUpdateKind indicates the type of DialUpdate event. ( DialUpdateKind) String() string DialUpdateKind : expvar.Var DialUpdateKind : fmt.Stringer const UpdateKindDialFailed const UpdateKindDialSuccessful const UpdateKindHandshakeProgressed
DialUpdater provides updates on in progress dials. DialWithUpdates dials a remote peer and provides updates on the passed channel. *github.com/libp2p/go-libp2p/p2p/transport/tcp.TcpTransport *github.com/pancsta/asyncmachine-go/pkg/pubsub/uds.UdsTransport
GatedMaListener is listener that listens for raw(unsecured and non-multiplexed) incoming connections, gates them with a `connmgr.ConnGater`and creates a resource management scope for them. It can be upgraded to a full libp2p transport listener by the Upgrader. Compared to manet.Listener, this listener creates the resource management scope for the accepted connection. Accept waits for and returns the next connection to the listener. Addr returns the net.Listener's network address. Close closes the listener. Any blocked Accept operations will be unblocked and return errors. Multiaddr returns the listener's (local) Multiaddr. GatedMaListener : github.com/multiformats/go-multiaddr.Multiaddrer GatedMaListener : github.com/prometheus/common/expfmt.Closer GatedMaListener : io.Closer func Upgrader.GateMaListener(manet.Listener) GatedMaListener func github.com/libp2p/go-libp2p/p2p/transport/tcpreuse.(*ConnMgr).DemultiplexedListen(laddr ma.Multiaddr, connType tcpreuse.DemultiplexedConnType) (GatedMaListener, error) func Upgrader.UpgradeGatedMaListener(Transport, GatedMaListener) Listener
Listener is an interface closely resembling the net.Listener interface. The only real difference is that Accept() returns Conn's of the type in this package, and also exposes a Multiaddr method as opposed to a regular Addr method ( Listener) Accept() (CapableConn, error) ( Listener) Addr() net.Addr ( Listener) Close() error ( Listener) Multiaddr() ma.Multiaddr Listener : github.com/multiformats/go-multiaddr.Multiaddrer Listener : github.com/prometheus/common/expfmt.Closer Listener : io.Closer func Transport.Listen(laddr ma.Multiaddr) (Listener, error) func Upgrader.UpgradeGatedMaListener(Transport, GatedMaListener) Listener func Upgrader.UpgradeListener(Transport, manet.Listener) Listener func github.com/libp2p/go-libp2p/p2p/protocol/circuitv2/client.(*Client).Listen(addr ma.Multiaddr) (Listener, error) func github.com/libp2p/go-libp2p/p2p/transport/tcp.(*TcpTransport).Listen(laddr ma.Multiaddr) (Listener, error) func github.com/libp2p/go-libp2p/p2p/transport/webrtc.(*WebRTCTransport).Listen(addr ma.Multiaddr) (Listener, error) func github.com/libp2p/go-libp2p/p2p/transport/websocket.(*WebsocketTransport).Listen(a ma.Multiaddr) (Listener, error) func github.com/pancsta/asyncmachine-go/pkg/pubsub/uds.(*UdsTransport).Listen(laddr ma.Multiaddr) (Listener, error)
Resolver can be optionally implemented by transports that want to resolve or transform the multiaddr. ( Resolver) Resolve(ctx context.Context, maddr ma.Multiaddr) ([]ma.Multiaddr, error) github.com/libp2p/go-libp2p/p2p/net/swarm.ResolverFromMaDNS *github.com/libp2p/go-libp2p/p2p/transport/websocket.WebsocketTransport *github.com/multiformats/go-multiaddr-dns.Resolver
SkipResolver can be optionally implemented by transports that don't want to resolve or transform the multiaddr. Useful for transports that indirectly wrap other transports (e.g. p2p-circuit). This lets the inner transport specify how a multiaddr is resolved later. ( SkipResolver) SkipResolve(ctx context.Context, maddr ma.Multiaddr) bool *github.com/libp2p/go-libp2p/p2p/protocol/circuitv2/client.Client
Transport represents any device by which you can connect to and accept connections from other peers. The Transport interface allows you to open connections to other peers by dialing them, and also lets you listen for incoming connections. Connections returned by Dial and passed into Listeners are of type CapableConn, which means that they have been upgraded to support stream multiplexing and connection security (encryption and authentication). If a transport implements `io.Closer` (optional), libp2p will call `Close` on shutdown. NOTE: `Dial` and `Listen` may be called after or concurrently with `Close`. In addition to the Transport interface, transports may implement Resolver or SkipResolver interface. When wrapping/embedding a transport, you should ensure that the Resolver/SkipResolver interface is handled correctly. For a conceptual overview, see https://docs.libp2p.io/concepts/transport/ CanDial returns true if this transport knows how to dial the given multiaddr. Returning true does not guarantee that dialing this multiaddr will succeed. This function should *only* be used to preemptively filter out addresses that we can't dial. Dial dials a remote peer. It should try to reuse local listener addresses if possible, but it may choose not to. Listen listens on the passed multiaddr. Protocol returns the set of protocols handled by this transport. See the Network interface for an explanation of how this is used. Proxy returns true if this is a proxy transport. See the Network interface for an explanation of how this is used. TODO: Make this a part of the go-multiaddr protocol instead? *github.com/libp2p/go-libp2p/p2p/protocol/circuitv2/client.Client *github.com/libp2p/go-libp2p/p2p/transport/tcp.TcpTransport *github.com/libp2p/go-libp2p/p2p/transport/webrtc.WebRTCTransport *github.com/libp2p/go-libp2p/p2p/transport/websocket.WebsocketTransport *github.com/pancsta/asyncmachine-go/pkg/pubsub/uds.UdsTransport func CapableConn.Transport() Transport func github.com/libp2p/go-libp2p/p2p/net/swarm.(*Swarm).TransportForDialing(a ma.Multiaddr) Transport func github.com/libp2p/go-libp2p/p2p/net/swarm.(*Swarm).TransportForListening(a ma.Multiaddr) Transport func github.com/libp2p/go-libp2p/p2p/transport/quic.NewTransport(key ic.PrivKey, connManager *quicreuse.ConnManager, psk pnet.PSK, gater connmgr.ConnectionGater, rcmgr network.ResourceManager) (Transport, error) func github.com/libp2p/go-libp2p/p2p/transport/webtransport.New(key ic.PrivKey, psk pnet.PSK, connManager *quicreuse.ConnManager, gater connmgr.ConnectionGater, rcmgr network.ResourceManager, opts ...libp2pwebtransport.Option) (Transport, error) func TransportNetwork.AddTransport(t Transport) error func Upgrader.Upgrade(ctx context.Context, t Transport, maconn manet.Conn, dir network.Direction, p peer.ID, scope network.ConnManagementScope) (CapableConn, error) func Upgrader.UpgradeGatedMaListener(Transport, GatedMaListener) Listener func Upgrader.UpgradeListener(Transport, manet.Listener) Listener func github.com/libp2p/go-libp2p/p2p/net/swarm.(*Swarm).AddTransport(t Transport) error
TransportNetwork is an inet.Network with methods for managing transports. AddTransport adds a transport to this Network. When dialing, this Network will iterate over the protocols in the remote multiaddr and pick the first protocol registered with a proxy transport, if any. Otherwise, it'll pick the transport registered to handle the last protocol in the multiaddr. When listening, this Network will iterate over the protocols in the local multiaddr and pick the *last* protocol registered with a proxy transport, if any. Otherwise, it'll pick the transport registered to handle the last protocol in the multiaddr. CanDial returns whether the dialer can dial peer p at addr ( TransportNetwork) Close() error ClosePeer closes the connection to a given peer Connectedness returns a state signaling connection capabilities Conns returns the connections in this Network ConnsToPeer returns the connections in this Network for given peer. DialPeer establishes a connection to a given peer InterfaceListenAddresses returns a list of addresses at which this network listens. It expands "any interface" addresses (/ip4/0.0.0.0, /ip6/::) to use the known local interfaces. Listen tells the network to start listening on given multiaddrs. ListenAddresses returns a list of addresses at which this network listens. LocalPeer returns the local peer associated with this network NewStream returns a new stream to given peer p. If there is no connection to p, attempts to create one. Notify/StopNotify register and unregister a notifiee for signals Peers returns the peers connected Peerstore returns the internal peerstore This is useful to tell the dialer about a new address for a peer. Or use one of the public keys found out over the network. ResourceManager returns the ResourceManager associated with this network SetStreamHandler sets the handler for new streams opened by the remote side. This operation is thread-safe. ( TransportNetwork) StopNotify(network.Notifiee) *github.com/libp2p/go-libp2p/p2p/net/swarm.Swarm TransportNetwork : github.com/libp2p/go-libp2p/core/network.Dialer TransportNetwork : github.com/libp2p/go-libp2p/core/network.Network TransportNetwork : github.com/prometheus/common/expfmt.Closer TransportNetwork : io.Closer
Upgrader is a multistream upgrader that can upgrade an underlying connection to a full transport connection (secure and multiplexed). GateMaListener creates a GatedMaListener from a manet.Listener. It gates the accepted connection and creates a resource scope for it. Upgrade upgrades the multiaddr/net connection into a full libp2p-transport connection. UpgradeGatedMaListener upgrades the passed GatedMaListener into a full libp2p-transport listener. UpgradeListener upgrades the passed multiaddr-net listener into a full libp2p-transport listener. Deprecated: Use UpgradeGatedMaListener(upgrader.GateMaListener(manet.Listener)) instead. func github.com/libp2p/go-libp2p/p2p/net/upgrader.New(security []sec.SecureTransport, muxers []upgrader.StreamMuxer, psk ipnet.PSK, rcmgr network.ResourceManager, connGater connmgr.ConnectionGater, opts ...upgrader.Option) (Upgrader, error) func github.com/libp2p/go-libp2p/p2p/protocol/circuitv2/client.AddTransport(h host.Host, upgrader Upgrader) error func github.com/libp2p/go-libp2p/p2p/protocol/circuitv2/client.New(h host.Host, upgrader Upgrader) (*client.Client, error) func github.com/libp2p/go-libp2p/p2p/transport/tcp.NewTCPTransport(upgrader Upgrader, rcmgr network.ResourceManager, sharedTCP *tcpreuse.ConnMgr, opts ...tcp.Option) (*tcp.TcpTransport, error) func github.com/libp2p/go-libp2p/p2p/transport/tcpreuse.NewConnMgr(enableReuseport bool, upgrader Upgrader) *tcpreuse.ConnMgr func github.com/libp2p/go-libp2p/p2p/transport/websocket.New(u Upgrader, rcmgr network.ResourceManager, sharedTCP *tcpreuse.ConnMgr, opts ...websocket.Option) (*websocket.WebsocketTransport, error) func github.com/pancsta/asyncmachine-go/pkg/pubsub/uds.NewUDSTransport(upgrader Upgrader, rcmgr network.ResourceManager, opts ...func(*uds.UdsTransport) error) (*uds.UdsTransport, error)
Package-Level Variables (only one)
ErrListenerClosed is returned by Listener.Accept when the listener is gracefully closed.
Package-Level Constants (total 3)
UpdateKindDialFailed indicates dial failed.
UpdateKindDialSuccessful indicates dial succeeded.
UpdateKindHandshakeProgressed indicates successful completion of the TCP 3-way handshake