How purplei2p/i2pd works
Main Components
a. Daemon Component:
– Contains modules like HTTPServer, I2PControl, UPnP handling (found under the daemon/ folder).
– Manages the overall service lifecycle and network interactions.
b. Core Library (libi2pd):
– Implements the heart of I2P's functionality.
– Handles configuration, cryptography, network protocols (I2NP, NTCP2, SSU2), tunnel management, routing (e.g., RouterContext, RouterInfo, NetDb), and more.
c. Client Library (libi2pd_client):
– Provides APIs for client-facing interactions (e.g., BOB, SAM, SOCKS, I2PTunnel).
– Interfaces with the daemon or core library to set up sessions or tunnels.
d. Additional Components:
– Build and deployment scripts (Makefile, CMakeLists, workflows, etc.) and packaging tools.
– Documentation and internationalization files, which are support elements outside the runtime architecture.
Detailing the Core libi2pd Library
a. Classes and Their Roles:
– Base classes and configuration:
• Base.cpp/Base.h for fundamental characteristics.
• Config.cpp/Config.h for reading/parsing configuration files.
– Cryptography:
• Crypto.cpp/Crypto.h and related files (CryptoKey, Ed25519, Elligator) that provide encryption, key management, and signature verification.
– Networking/Protocols:
• I2NPProtocol.cpp/I2NPProtocol.h, which implement the I2P messaging protocol.
• Network-related implementations such as NTCP2 (NTCP2.cpp/NTCP2.h) and SSU2 (SSU2.cpp/SSU2.h, including related session classes like SSU2Session.cpp/SSU2Session.h and SSU2OutOfSession).
– Identity & Routing:
• Identity.cpp/Identity.h and Destination.cpp/Destination.h for representing node identities and destinations.
• Components for distributed hash tables and routing (e.g., KadDHT.cpp/KadDHT.h, RouterContext.cpp/RouterContext.h, RouterInfo.cpp/RouterInfo.h).
– Tunnel Management:
• Tunnel, TunnelConfig, TunnelGateway, TunnelPool, and related classes for managing encrypted tunnels.
– Show that many modules in libi2pd depend on a central configuration or initialization provided by Config.
– The Cryptography classes (Crypto, CryptoKey, Ed25519, Elligator) serve as a foundation for securing communications. Indicate that modules like Identity and RouterInfo leverage these routines.
– Networking classes (I2NPProtocol, NTCP2, SSU2) will interact with the tunnel management classes to send and receive encrypted data.
– Consider grouping these classes by functionality (e.g., Cryptographic layer, Protocol layer, Routing layer, Tunnel management layer).
– For example, the Daemon component passes configuration data to the libi2pd core library.
– The libi2pd library provides network services to both the daemon and the client library.
– External interfaces versus internal modules.
– Lower-level implementations (core library classes) from higher-level orchestration (daemon or client APIs).