Kubo (IPFS Reference Implementation)
repository·master·Indexed 12 days ago
https://github.com/ipfs/kuboThe reference implementation of the InterPlanetary File System (IPFS) protocol written in Go. Kubo provides a complete IPFS node featuring a CLI, WebUI, HTTP Gateway, and an HTTP RPC API. It supports content-addressing via CIDs and DAGs, and can be used as a standalone daemon or embedded as a Go library via the go-ipfs-core API to spawn ephemeral or persistent nodes.
What's inside Kubo
- The Kubo configuration file is used to manage the behavior of a Kubo node. It contains settings for various subsystems including networking (Swarm), data storage (Datastore), the API, the Gateway, and more. Configuration can be managed via the CLI or by editing the configuration file directly. The configuration structure is hierarchical, organized into top-level keys that correspond to specific Kubo components.
What is Kubo?
masterKubo is the primary implementation of IPFS (InterPlanetary File System) written in Go. It provides a complete IPFS node as a network service, supporting content-addressing via CIDs and DAGs.
Key features include:
- Network Service: Runs an IPFS node using LAN mDNS and WAN Amino DHT.
- CLI: A command-line interface for node interaction (
ipfs --help). - WebUI: A graphical interface for node management.
- HTTP Gateway: Supports both trusted and trustless content retrieval.
- HTTP RPC API: Allows programmatic control of the daemon.
- HTTP Routing V1: Supports delegated routing via client and server.
- FUSE Mounts: (Experimental) Allows mounting
/ipfs,/ipns, and/mfsas local filesystems. - Content Blocking: Allows public node operators to implement denylists.
Key changes in Kubo v0.5.0
masterKubo v0.5.0 introduced significant updates to its underlying networking stack, primarily through major version bumps of its
libp2pdependencies. Key highlights include:- Migration to
go-libp2p-core: The project migrated to usego-libp2p-corefor its interface. - Enhanced Security: Upgraded test key sizes to 2048 bits.
- Improved Networking (via
go-libp2pv0.8.2):- Default support for TLS.
- Improved NAT traversal with support for Autorelay on NAT events and clearer naming for NAT override options.
- Support for Private Networks using a Pre-Shared Key (PSK).
- Better handling of address changes and non-public address port mapping announcements.
- Improved DHT (via
go-libp2p-kad-dhtv0.7.10):- Introduction of a Dual DHT scaffold.
- Configurable latency tolerance for the Routing Table.
- Reduced stream idle timeout to 1 minute.
- New
WANActivefeature exposure.
- Migration to
Use Kubo as a Go library
masterInstead of running the Kubo daemon as a separate process, you can embed it directly into your Go applications using the
go-ipfs-coreAPI. This allows you to spawn an IPFS node that runs in-process, manage its lifecycle, and interact with the IPFS network directly through Go code.Key capabilities include:
- Spawning ephemeral or persistent nodes.
- Creating and managing IPFS repositories.
- Adding files and directories to the IPFS network.
- Retrieving content via
catandgetoperations. - Connecting to the DHT (Distributed Hash Table) to interact with the wider network.
Use IPFSWatch to monitor a directory and add changes to IPFS
masterIPFSWatch is a utility that monitors a specific directory for changes and automatically adds those changes to IPFS. It allows for a continuous synchronization of local file system updates to the IPFS network.New features in Kubo v0.18.0
masterKubo v0.18.0 introduced several significant features:
- Routing.Type=auto: Enables a combination of DHT and IPNI for routing.
- WebTransport: Enabled by default to improve connectivity.
- Fast Directory Listings: Added a
DAG Sizecolumn to speed up directory listing operations. - Gateway Enhancements: Added support for JSON and CBOR response formats (IPIP-328).
- Pubsub Configuration: Added
Pubsub.SeenMessagesTTLconfiguration option. - DHT Improvements:
go-libp2p-kad-dhtnow supports a 48h expiration. - Delegated Routing: Added support for HTTP delegated routing.
Introduction to the IPFS Core API
masterStarting with version 0.4.14, IPFS introduced the 'Core API'. This is intended to be the primary way to interact with IPFS using Go. The Core API provides a unified interface that works for both embedded nodes and nodes accessed over the HTTP API.
Initial implementations include interfaces for:
DagNameandKeyObjectBlockPin
Understand the change from CID to Multihash in DHT provider records
masterStarting with v0.5.0, Kubo announces data in the DHT using multihash instead of CID.
Why this change was made: Previously, using CIDs meant that if two different CIDs (e.g., CIDv0 and CIDv1) pointed to the same underlying bytes, a node searching for one might not find a node providing the other. Using multihash ensures that regardless of the CID version or codec used, peers can find the underlying content.
Warning: This change may impact finding content added with CIDv1. Kubo v0.5.0 announces and searches using the bare multihash (equivalent to v0 CID). Consequently, v0.5.0 nodes may be unable to find CIDv1 content published by nodes prior to v0.5.0, and vice-versa. Users are strongly encouraged to upgrade to the latest version to minimize impact.
Use Contexts in IPFS Sub-packages
masterA significant pattern across many IPFS sub-packages (including
go-ipfs-blockstore,go-ipfs-pinner,go-ipfs-provider,go-ipfs-routing,go-merkledag,go-namesys, andgo-path) is the plumbing ofcontext.Contextthrough interfaces and methods.When building with these libraries, ensure you are passing appropriate contexts to allow for proper cancellation, timeouts, and datastore context propagation.
Understand the Repo Format 2 changes
masterStarting with version 0.3.0, Kubo introduced 'Repo format 2', which includes several breaking changes to the repository structure:
- Default Location: The default repository location moved from
~/.go-ipfsto~/.ipfs. - Lock File: The lock filename was renamed from
daemon.locktorepo.lock. - Datastore: The system moved from using LevelDB to using a flat-file datastore for local blocks, which significantly improves performance.
- Default Location: The default repository location moved from
IPNS and Gateway improvements
masterIn versionv0.4.16-rc1, the gateway was updated to resolvednslinksonly once, improving performance. Additionally, record validation was added to offline routing.Handle 'Not Found' errors in IPFS libraries
masterSeveral core IPFS libraries have standardized their error handling to use
ipld.ErrNotFoundfor cases where a requested block, file, or node is not found. When building on top of these libraries, check for this specific error to distinguish between a missing resource and other operational errors.Libraries affected by this change include:
github.com/ipfs/go-filestoregithub.com/ipfs/go-ipfs-blockstoregithub.com/ipfs/go-ipld-formatgithub.com/ipfs/go-merkledag