tor_client_lib/lib.rs
1//! # Tor Client Lib
2//! This is a client library for [Tor](https://www.torproject.org/), which allows you to interact programmatically with a Tor server, using its [API](https://github.com/torproject/torspec/blob/main/control-spec.txt).
3//! ## Installation
4//! To add it to your existing project:
5//! ```bash
6//! cargo add tor_client_lib
7//! ```
8//! ## Commands Supported
9//! This library currently supports a small (but useful) subset of the full API, namely:
10//! - AUTHENTICATE
11//! - AUTHCHALLENGE
12//! - GETINFO
13//! - PROTOCOLINFO
14//! - ADD_ONION
15//! - DEL_ONION
16//!
17//! If you'd like to see more functions supported, please either submit an issue request or a PR.
18//!
19//! ## Example Code
20//! ```no_run
21//! # use tokio;
22//! use tor_client_lib::{
23//! control_connection::TorControlConnection,
24//! error::TorError,
25//! auth::TorAuthentication
26//! };
27//!
28//! # #[tokio::main]
29//! # async fn main() -> Result<(), TorError> {
30//! // Connect to the Tor service running locally
31//! let mut control_connection = TorControlConnection::connect("127.0.0.1:9051").await?;
32//!
33//! // Authenticate to the Tor server
34//! control_connection.authenticate(&TorAuthentication::SafeCookie(None)).await?;
35//!
36//! // Call the "GETINFO" command to get the Tor version number
37//! let tor_version = control_connection.get_info("version").await?;
38//! # Ok(())
39//! # }
40//! ```
41
42pub mod auth;
43pub mod base64;
44pub mod control_connection;
45pub mod error;
46pub mod key;
47
48pub use crate::auth::TorAuthentication;
49pub use crate::control_connection::{OnionService, OnionServiceMapping, TorControlConnection};
50pub use crate::error::TorError;
51pub use crate::key::{TorEd25519SigningKey, TorServiceId};