Categorygithub.com/dms3-p2p/go-p2p-net
modulepackage
3.0.8+incompatible
Repository: https://github.com/dms3-p2p/go-p2p-net.git
Documentation: pkg.go.dev

# README

go-libp2p-net

Network interfaces for go-libp2p

The IPFS Network package handles all of the peer-to-peer networking. It connects to other hosts, it encrypts communications, it muxes messages between the network's client services and target hosts. It has multiple subcomponents:

  • Conn - a connection to a single Peer
    • MultiConn - a set of connections to a single Peer
    • SecureConn - an encrypted (tls-like) connection
  • Swarm - holds connections to Peers, multiplexes from/to each MultiConn
  • Muxer - multiplexes between Services and Swarm. Handles Request/Reply.
    • Service - connects between an outside client service and Network.
    • Handler - the client service part that handles requests

It looks a bit like this:

[]

Install

go get libp2p/go-libp2p-net

Contribute

Feel free to join in. All welcome. Open an issue!

Check out our contributing document for more information on how we work, and about contributing in general. Please be aware that all interactions related to libp2p are subject to the IPFS Code of Conduct.

Small note: If editing the README, please conform to the standard-readme specification.

Want to hack on IPFS?

License

MIT © 2016 Jeromy Johnson

# Functions

AwaitEOF waits for an EOF on the given stream, returning an error if that fails.
FullClose closes the stream and waits to read an EOF from the other side.
GetDialPeerTimeout returns the current DialPeer timeout (or the default).
WithDialPeerTimeout returns a new context with the DialPeer timeout applied.

# Constants

CanConnect means recently connected to peer, terminated gracefully.
CannotConnect means recently attempted connecting but failed to connect.
Connected means has an open, live connection to peer.
DirInbound is for when the remote peer initiated a connection.
DirOutbound is for when the local peer initiated a connection.
DirUnknown is the default direction.
4 MB.
NotConnected means no connection to peer, and no extra information (default).

# Variables

DialPeerTimeout is the default timeout for a single call to `DialPeer`.
EOFTimeout is the maximum amount of time to wait to successfully observe an EOF on the stream.
ErrExpectedEOF is returned when we read data while expecting an EOF.

# Structs

NotifyBundle implements Notifiee by calling any of the functions set on it, and nop'ing if they are unset.
Stat stores metadata pertaining to a given Stream/Conn.

# Interfaces

Conn is a connection to a remote peer.
ConnMultiaddrs is an interface mixin for connection types that provide multiaddr addresses for the endpoints.
ConnSecurity is the interface that one can mix into a connection interface to give it the security methods.
Dialer represents a service that can dial out to peers (this is usually just a Network, but other services may not need the whole stack, and thus it becomes easier to mock).
Network is the interface used to connect to the outside world.
Notifiee is an interface for an object wishing to receive notifications from a Network.
Stream represents a bidirectional channel between two agents in the IPFS network.

# Type aliases

Connectedness signals the capacity for a connection with a given node.
ConnHandler is the type of function used to listen for connections opened by the remote side.
Direction represents which peer in a stream initiated a connection.
StreamHandler is the type of function used to listen for streams opened by the remote side.