Hacking on i2pd
This document contains notes compiled from hacking on i2pd
This guide assumes:
- a decent understanding of c++
- basic understanding of how I2P works at i2np level and up
Notes on multithreading
every component runs in its own thread
each component (usually) has a public function
GetService()which can be used to obtain the
boost::asio::io_servicethat it uses.
when talking between components/threads, always use
GetService().post()and be mindful of stack allocated memory.
i2p::data::netdb is a
i2p::data::NetDb instance processes and dispatches inbound i2np messages passed in from transports.
global singleton at
i2p::data::netdb as of 2.10.1
For Pending RouterInfo/LeaseSet lookup and store requests
i2p::client::ClientContext spawns all destinations used by the I2P router including the shared local destination.
global singleton at
i2p::client::context as of 2.10.1
i2p::util::Daemon_Singleton_Private subclasses implement the daemon start-up and tear-down, creates Http Webui and I2P control server.
each destination runs in its own thread
Destination capable of creating (tcp/i2p) streams and datagram sessions.
Does not implement any destination related members, the name is a bit misleading.
i2p::client::ClientDestination and runs in the destination thread.
Anyone creating or using streams outside of the destination thread MUST be aware of the consequences of multithreaded c++ :^)
If you use streaming please consider running all code within the destination thread using
Provides Inter-Destination routing primitives.
i2p::client::LeaseSetDestination for sending messages down shared routing paths.
a point to point conversation between us and 1 other destination.
A routing path currently used by a routing session. specifies which outbound tunnel to use and which remote lease set to use for
IBGW inter tunnel communication.
- outboundTunnel (OBEP)
- remoteLease (IBGW)
- rtt (round trip time)
- updatedTime (last time this path's IBGW/OBEP was updated)
- numTimesUsesd (number of times this path was used)
each transport runs in its own thread
i2p::transport::Transports contains NTCP and SSU transport instances