Crates.io | tor-client-lib |
lib.rs | tor-client-lib |
version | |
source | src |
created_at | 2024-01-22 00:49:38.14232 |
updated_at | 2025-02-02 18:11:56.705248 |
description | A client library for the Tor API |
homepage | |
repository | |
max_upload_size | |
id | 1108110 |
Cargo.toml error: | TOML parse error at line 17, column 1 | 17 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
This is a client library for Tor, which allows you to interact programmatically with a Tor server, using its API.
To add it to your existing project:
cargo add tor_client_lib
This library currently supports a small (but useful) subset of the full API, namely:
AUTHENTICATE
AUTHCHALLENGE
GETINFO
PROTOCOLINFO
ADD_ONION
DEL_ONION
If you’d like to see more functions supported, please either submit an issue request or a PR.
use tor_client_lib::{
control_connection::TorControlConnection,
error::TorError,
auth::TorAuthentication
};
// Connect to the Tor service running locally
let mut control_connection = TorControlConnection::connect("127.0.0.1:9051").await?;
// Authenticate to the Tor server
control_connection.authenticate(TorAuthentication::SafeCookie(None)).await?;
// Call the "GETINFO" command to get the Tor version number
let tor_version = control_connection.get_info("version").await?;
The repo includes a simple CLI for sending commands to Tor. To use it, run:
cargo run
For example:
% cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.07s
Running `target/debug/tor-cli`
Welcome to Tor CLI v0.1.0
Tor CLI> connect
Connected to localhost:9051
Tor CLI> authenticate cookie
Authenticated
Tor CLI> get_info version
["0.4.6.10"]