Categorygithub.com/libp2p/go-libp2p
modulepackage
0.41.0
Repository: https://github.com/libp2p/go-libp2p.git
Documentation: pkg.go.dev

# README

libp2p hex logo

The Go implementation of the libp2p Networking Stack.

Go Reference

Table of Contents

Background

libp2p is a networking stack and library modularized out of The IPFS Project, and bundled separately for other tools to use.

libp2p is the product of a long, and arduous quest of understanding -- a deep dive into the internet's network stack, and plentiful peer-to-peer protocols from the past. Building large-scale peer-to-peer systems has been complex and difficult in the last 15 years, and libp2p is a way to fix that. It is a "network stack" -- a protocol suite -- that cleanly separates concerns, and enables sophisticated applications to only use the protocols they absolutely need, without giving up interoperability and upgradeability. libp2p grew out of IPFS, but it is built so that lots of people can use it, for lots of different projects.

To learn more, check out the following resources:

Usage

This repository (go-libp2p) serves as the entrypoint to the universe of packages that compose the Go implementation of the libp2p stack.

You can start using go-libp2p in your Go application simply by adding imports from our repos, e.g.:

import "github.com/libp2p/go-libp2p"

Examples

Examples can be found in the examples folder.

Dashboards

We provide prebuilt Grafana dashboards so that applications can better monitor libp2p in production. You can find the dashboard JSON files here.

We also have live Public Dashboards that you can check out to see real time monitoring in action.

Contribute

go-libp2p is MIT-licensed open source software. We welcome contributions big and small! Take a look at the community contributing notes. Please make sure to check the issues. Search the closed ones before reporting things, and help us with the open ones.

Guidelines:

  • read the libp2p spec
  • ask questions or talk about things in our discussion forums, or open an issue for bug reports, or #libp2p-implementers on Filecoin slack.
  • ensure you are able to contribute (no legal issues please -- we use the DCO)
  • get in touch with @libp2p/go-libp2p-maintainers about how best to contribute
  • No drive-by contributions seeking to collect airdrops.
    • Many projects aim to reward contributors to common goods. Great. However, this creates an unfortunate incentive for low-effort PRs, submitted solely to claim rewards. These PRs consume maintainers’ time and energy to triage, with little to no impact on end users. If we suspect this is the intent of a PR, we may close it without comment. If you believe this was done in error, contact us via email. Reference this README section and explain why your PR is not a “drive-by contribution.”
  • have fun!

There's a few things you can do right now to help out:

  • Perform code reviews.
  • Add tests. There can never be enough tests.
  • Go through the modules below and check out existing issues. This would be especially useful for modules in active development. Some knowledge of IPFS/libp2p may be required, as well as the infrastructure behind it - for instance, you may need to read up on p2p and more complex operations like muxing to be able to help technically.

Supported Go Versions

We test against and support the two most recent major releases of Go. This is informed by Go's own security policy.

Notable Users

Some notable users of go-libp2p are:

  • Kubo - The original Go implementation of IPFS
  • Lotus - An implementation of the Filecoin protocol
  • Drand - A distributed random beacon daemon
  • Prysm - An Ethereum Beacon Chain consensus client built by Prysmatic Labs
  • Berty - An open, secure, offline-first, peer-to-peer and zero trust messaging app.
  • Wasp - A node that runs IOTA Smart Contracts built by the IOTA Foundation
  • Mina - A lightweight, constant-sized blockchain that runs zero-knowledge smart contracts
  • Polygon Edge - A modular, extensible framework for building Ethereum compatible networks
  • Celestia Node - The Go implementation of Celestia's data availability nodes
  • Status go - Status bindings for go-ethereum, built by Status.im
  • Flow - A blockchain built to support games, apps, and digital assets built by Dapper Labs
  • Swarm Bee - A client for connecting to the Swarm network
  • MultiversX Node - The Go implementation of the MultiversX network protocol
  • Sonr - A platform to integrate DID Documents, WebAuthn, and IPFS and manage digital identity and assets.
  • EdgeVPN - A decentralized, immutable, portable VPN and reverse proxy over p2p.
  • Kairos - A Kubernetes-focused, Cloud Native Linux meta-distribution.
  • Oasis Core - The consensus and runtime layers of the Oasis protocol.
  • Spacemesh - The Go implementation of the Spacemesh protocol, a novel layer one blockchain
  • Tau - Open source distributed Platform as a Service (PaaS)

Please open a pull request if you want your project (min. 250 GitHub stars) to be added here.

# Packages

Package core provides convenient access to foundational, central go-libp2p primitives via type aliases.

# Functions

AddrsFactory configures libp2p to use the given address factory.
AutoNATServiceRateLimit changes the default rate limiting configured in helping other peers determine their reachability status.
BandwidthReporter configures libp2p to use the given bandwidth reporter.
ChainOptions chains multiple options into a single option.
ConnectionGater configures libp2p to use the given ConnectionGater to actively reject inbound/outbound connections based on the lifecycle stage of the connection.
ConnectionManager configures libp2p to use the given connection manager.
DialRanker configures libp2p to use d as the dial ranker.
DisableIdentifyAddressDiscovery disables address discovery using peer provided observed addresses in identify.
DisableMetrics configures libp2p to disable prometheus metrics.
DisableRelay configures libp2p to disable the relay transport.
EnableAutoNATv2 enables autonat v2.
EnableAutoRelay configures libp2p to enable the AutoRelay subsystem.
EnableAutoRelayWithPeerSource configures libp2p to enable the AutoRelay subsystem using the provided PeerSource callback to get more relay candidates.
EnableAutoRelayWithStaticRelays configures libp2p to enable the AutoRelay subsystem using the provided relays as relay candidates.
Experimental EnableHolePunching enables NAT traversal by enabling NATT'd peers to both initiate and respond to hole punching attempts to create direct/NAT-traversed connections with other peers.
EnableNATService configures libp2p to provide a service to peers for determining their reachability status.
EnableRelay configures libp2p to enable the relay transport.
EnableRelayService configures libp2p to run a circuit v2 relay, if we detect that we're publicly reachable.
ForceReachabilityPrivate overrides automatic reachability detection in the AutoNAT subsystem, forceing the local node to believe it is behind a NAT and not reachable externally.
ForceReachabilityPublic overrides automatic reachability detection in the AutoNAT subsystem, forcing the local node to believe it is reachable externally.
Identity configures libp2p to use the given private key to identify itself.
IPv6BlackHoleSuccessCounter configures libp2p to use f as the black hole filter for IPv6 addrs.
ListenAddrs configures libp2p to listen on the given addresses.
ListenAddrStrings configures libp2p to listen on the given (unparsed) addresses.
MultiaddrResolver sets the libp2p dns resolver.
Muxer configures libp2p to use the given stream multiplexer.
NATManager will configure libp2p to use the requested NATManager.
NATPortMap configures libp2p to use the default NATManager.
New constructs a new libp2p node with the given options, falling back on reasonable defaults.
NewWithoutDefaults constructs a new libp2p node with the given options but *without* falling back on reasonable defaults.
Peerstore configures libp2p to use the given peerstore.
Ping will configure libp2p to support the ping service; enable by default.
PrivateNetwork configures libp2p to use the given private network protector.
PrometheusRegisterer configures libp2p to use reg as the Registerer for all metrics subsystems.
ProtocolVersion sets the protocolVersion string required by the libp2p Identify protocol.
ResourceManager configures libp2p to use the given ResourceManager.
Routing will configure libp2p to use routing.
Security configures libp2p to use the given security transport (or transport constructor).
SetDefaultServiceLimits sets the default limits for bundled libp2p services.
ShareTCPListener shares the same listen address between TCP and Websocket transports.
SwarmOpts configures libp2p to use swarm with opts.
Transport configures libp2p to use the given transport (or transport constructor).
UDPBlackHoleSuccessCounter configures libp2p to use f as the black hole filter for UDP addrs.
UserAgent sets the libp2p user-agent sent along with the identify protocol.
WithFxOption adds a user provided fx.Option to the libp2p constructor.

# Variables

DefaultConnectionManager creates a default connection manager.
DefaultEnableRelay enables relay dialing and listening by default.
DefaultListenAddrs configures libp2p to use default listen address.
DefaultMuxers configures libp2p to use the stream connection multiplexers.
DefaultPeerstore configures libp2p to use the default peerstore.
DefaultPrivateTransports are the default libp2p transports when a PSK is supplied.
DefaultPrometheusRegisterer configures libp2p to use the default registerer.
Defaults configures libp2p to use the default options.
DefaultSecurity is the default security option.
DefaultTransports are the default libp2p transports.
FallbackDefaults applies default options to the libp2p node if and only if no other relevant options have been applied.
NoListenAddrs will configure libp2p to not listen by default.
NoSecurity is an option that completely disables all transport security.
NoTransports will configure libp2p to not enable any transports.
RandomIdentity generates a random identity.

# Type aliases

Config describes a set of settings for a libp2p node.
Option is a libp2p config option that can be given to the libp2p constructor (`libp2p.New`).