Expand description
Safe async wrapper around i2pd-sys: a Destination (an I2P eepsite identity, reachable at
a .b32.i2p address) and an I2pStream implementing
AsyncRead/AsyncWrite, with no external
i2pd process or SAM bridge.
Every unsafe call into libi2pd’s C shim lives in this crate; the public API exposes no raw
pointers and no pub unsafe fn. That safety rests on this crate’s reading of libi2pd’s
threading and ownership contracts, documented at each unsafe block and in
i2pd-sys/shim/shim.h, not on anything the compiler checks.
§Features
aws-lc (default) and fips pick the i2pd-sys crypto backend; at least one must be
enabled, and fips wins if both are (Cargo features are additive, so a dependent crate can
pull aws-lc back in). transit (default) compiles in libi2pd’s tunnel build-request path.
§Basic usage
use tachyon_i2p::{I2pRouter, SigType};
let router = I2pRouter::start("my-eepsite").await?;
let mut dest = router
// Empty slice: libi2pd's own hybrid encryption set. See `CryptoType` to narrow it down.
.destination_from_keys_file("my-eepsite.keys", true, SigType::default(), &[])
.await?;
println!("reachable at http://{}", dest.b32_address());
loop {
let _stream = dest.accept().await?; // implements AsyncRead + AsyncWrite
// ... spawn a task to serve it ...
}Only one I2pRouter may run per process at a time: libi2pd keeps its router context as a
process-wide global. Starting a new one after the previous router has been dropped works.
§Network participation
This crate runs a real I2P router, so it has a position in the network beyond hosting your own
destinations. By default it carries transit tunnels (other users’ traffic) at up to 256 KB/s
router-wide, and does not act as a floodfill. Transit defaults to on because a router that
relays nothing gives an observer no cover traffic: every byte crossing the link is then yours.
RouterConfig is the only way to change any of it – libi2pd reads these settings as the
router comes up, and never parses an i2pd.conf when embedded as a library.
Structs§
- Destination
- A local I2P destination – an eepsite’s identity, reachable at a stable
.b32.i2paddress for as long as this value is alive. - I2pRouter
- A running libi2pd router instance.
- I2pStream
- One stream-protocol connection over I2P – either accepted via
Destination::acceptor opened viaDestination::connect. - Router
Config - How this router participates in the wider I2P network – see
I2pRouter::start_with_config.
Enums§
- Crypto
Type - An encryption algorithm a destination’s LeaseSet2 can advertise as usable – see
I2pRouter::create_persistent_destination’sencryption_typesparameter. - I2pError
- Errors that can occur while starting the router, creating a destination, or using a stream.
- SigType
- The signature algorithm for a destination’s identity – see
I2pRouter::generate_keys.