Kubo (IPFS Reference Implementation)

repository·master·Indexed 12 days ago

https://github.com/ipfs/kubo

The 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.

Tokens
149.7K
Snippets
530
Records
1K
Agent score
97%

What's inside Kubo

  1. Overview of the Kubo configuration file

    master
    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.
  2. What is Kubo?

    master

    Kubo 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 /mfs as local filesystems.
    • Content Blocking: Allows public node operators to implement denylists.
  3. Key changes in Kubo v0.5.0

    master

    Kubo v0.5.0 introduced significant updates to its underlying networking stack, primarily through major version bumps of its libp2p dependencies. Key highlights include:

    • Migration to go-libp2p-core: The project migrated to use go-libp2p-core for its interface.
    • Enhanced Security: Upgraded test key sizes to 2048 bits.
    • Improved Networking (via go-libp2p v0.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-dht v0.7.10):
      • Introduction of a Dual DHT scaffold.
      • Configurable latency tolerance for the Routing Table.
      • Reduced stream idle timeout to 1 minute.
      • New WANActive feature exposure.
  4. Use Kubo as a Go library

    master

    Instead of running the Kubo daemon as a separate process, you can embed it directly into your Go applications using the go-ipfs-core API. 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 cat and get operations.
    • Connecting to the DHT (Distributed Hash Table) to interact with the wider network.
  5. Use IPFSWatch to monitor a directory and add changes to IPFS

    master
    IPFSWatch 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.
  6. New features in Kubo v0.18.0

    master

    Kubo 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 Size column to speed up directory listing operations.
    • Gateway Enhancements: Added support for JSON and CBOR response formats (IPIP-328).
    • Pubsub Configuration: Added Pubsub.SeenMessagesTTL configuration option.
    • DHT Improvements: go-libp2p-kad-dht now supports a 48h expiration.
    • Delegated Routing: Added support for HTTP delegated routing.
  7. Introduction to the IPFS Core API

    master

    Starting 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:

    • Dag
    • Name and Key
    • Object
    • Block
    • Pin
  8. Understand the change from CID to Multihash in DHT provider records

    master

    Starting 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.

  9. Use Contexts in IPFS Sub-packages

    master

    A significant pattern across many IPFS sub-packages (including go-ipfs-blockstore, go-ipfs-pinner, go-ipfs-provider, go-ipfs-routing, go-merkledag, go-namesys, and go-path) is the plumbing of context.Context through interfaces and methods.

    When building with these libraries, ensure you are passing appropriate contexts to allow for proper cancellation, timeouts, and datastore context propagation.

  10. Understand the Repo Format 2 changes

    master

    Starting 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-ipfs to ~/.ipfs.
    • Lock File: The lock filename was renamed from daemon.lock to repo.lock.
    • Datastore: The system moved from using LevelDB to using a flat-file datastore for local blocks, which significantly improves performance.
  11. Handle 'Not Found' errors in IPFS libraries

    master

    Several core IPFS libraries have standardized their error handling to use ipld.ErrNotFound for 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-filestore
    • github.com/ipfs/go-ipfs-blockstore
    • github.com/ipfs/go-ipld-format
    • github.com/ipfs/go-merkledag