Navigate:
go-libp2p
~$GOLI0.1%

go-libp2p: Go implementation of libp2p networking

A modular peer-to-peer networking stack for Go applications, providing transport protocols and network services.

LIVE RANKINGS • 03:09 AM • STEADY
OVERALL
#338
101
CRYPTO
#20
14
30 DAY RANKING TREND
ovr#338
·Crypt#20
STARS
6.7K
FORKS
1.2K
7D STARS
+9
7D FORKS
+1
Tags:
See Repo:
Share:

Learn more about go-libp2p

go-libp2p is the Go implementation of the libp2p networking stack, a modular protocol suite originally developed for IPFS. It provides a collection of protocols and components for building peer-to-peer applications, including transport layers, connection multiplexing, and peer discovery mechanisms. The library follows a modular architecture where applications can select only the protocols they need while maintaining interoperability. It serves as the foundation for distributed systems like IPFS, Filecoin, and various blockchain networks.

go-libp2p

1

Modular Architecture

Applications can compose only the networking protocols they need from a comprehensive suite of components. This approach reduces complexity while maintaining full interoperability with other libp2p implementations.

2

Protocol Agnostic

Supports multiple transport protocols including TCP, QUIC, and WebSockets with automatic protocol negotiation. The stack can adapt to different network conditions and requirements dynamically.

3

Production Ready

Used by major distributed systems including Kubo (IPFS), Filecoin's Lotus, and Ethereum's Prysm consensus client. Includes monitoring dashboards and comprehensive testing infrastructure for production deployments.


package main

import (
	"context"
	"fmt"
	"log"

	"github.com/libp2p/go-libp2p"
	"github.com/libp2p/go-libp2p/core/host"
	"github.com/libp2p/go-libp2p/core/peer"
	"github.com/multiformats/go-multiaddr"
)

func main() {
	ctx := context.Background()

	// Create a libp2p host with default settings
	node, err := libp2p.New(
		libp2p.ListenAddrStrings("/ip4/0.0.0.0/tcp/0"),
	)
	if err != nil {
		log.Fatal(err)
	}
	defer node.Close()

	// Print the node's peer ID and listening addresses
	fmt.Printf("Peer ID: %s\n", node.ID())
	fmt.Println("Listening addresses:")
	for _, addr := range node.Addrs() {
		fmt.Printf("  %s/p2p/%s\n", addr, node.ID())
	}

	// Connect to another peer (example address)
	targetAddr, _ := multiaddr.NewMultiaddr("/ip4/127.0.0.1/tcp/4001/p2p/QmSomePeerID")
	peerInfo, _ := peer.AddrInfoFromP2pAddr(targetAddr)
	
	err = node.Connect(ctx, *peerInfo)
	if err != nil {
		fmt.Printf("Failed to connect: %v\n", err)
	} else {
		fmt.Printf("Connected to peer: %s\n", peerInfo.ID)
	}

	// Keep the program running
	select {}
}


vv0.47.0

A relatively small release. The main changes are dependency updates and a couple of bug fixes. #3435 changes autonatv2 reachability logic, which shoul

  • fix(autonatv2): secondary addrs inherit reachability from primary by @lidel in
  • Update simnet by @MarcoPolo in
  • mod tidy test-plans package by @MarcoPolo in
  • fix(basic_host): `stream.Close()` blocks indefinitely on unresponsive peers by @lidel in
  • fix: handle error from mh.Sum in IDFromPublicKey by @MozirDmitriy in
vv0.46.0

v0.46.0: fix(webrtc): use debug level for pion errors by @lidel in

  • fix(webrtc): use debug level for pion errors by @lidel in
  • chore: update quic-go to v0.56.0 by @sukunrt in
  • fix(mdns): filter addresses to reduce packet size by @lidel in
  • chore: update quic-go to v0.57.1 by @sukunrt in
vv0.45.0

A small release that adjust some noisy logging levels and adds a method for dynamically change the slog Handler for better integration with applicatio

  • fix(websocket): use debug level for operational noise errors by @lidel in
  • chore: Update Drips ownedBy address in FUNDING.json by @p-shahi in
  • feat(gologshim): Add SetDefaultHandler by @lidel in


[ EXPLORE MORE ]

Related Repositories

Discover similar tools and frameworks used by developers