1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//! Safe async wrapper around `i2pd-sys`: a [`Destination`] (an I2P eepsite identity, reachable at
//! a `.b32.i2p` address) and an [`I2pStream`] implementing
//! [`AsyncRead`](tokio::io::AsyncRead)/[`AsyncWrite`](tokio::io::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
//!
//! ```rust,no_run
//! # async fn example() -> Result<(), tachyon_i2p::I2pError> {
//! 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.
compile_error!;
/// Compiles the `README.md` usage example as a doctest so it can't drift from the real API.
;
pub use Destination;
pub use I2pError;
pub use ;
pub use I2pStream;