| Crates.io | tor-check |
| lib.rs | tor-check |
| version | 0.2.2 |
| created_at | 2025-01-02 11:22:22.385629+00 |
| updated_at | 2025-12-16 11:35:24.159351+00 |
| description | Extend your favorite HTTP client with a Tor verification feature |
| homepage | |
| repository | https://github.com/Joffr3y/tor_check |
| max_upload_size | |
| id | 1501444 |
| size | 55,841 |
Extend your favorite HTTP client with a Tor verification feature.
Configure your client to use the Tor proxy and call tor_check before any other requests.
The reqwest feature is required.
use tor_check::{TorCheck, TorCheckError};
#[tokio::main]
async fn main() -> Result<(), TorCheckError<reqwest::Error>> {
let client = reqwest::Client::builder()
.proxy(reqwest::Proxy::all("socks5://127.0.0.1:9050")?)
.build()?
.tor_check()
.await?;
// Ok, I am connected to Tor.
client.get("https://example.com/").send().await?;
Ok(())
}
The ureq feature is required.
use tor_check::{TorCheck, TorCheckError};
fn main() -> Result<(), TorCheckError<ureq::Error>> {
let config = ureq::Agent::config_builder()
.proxy(Some(ureq::Proxy::new("socks5://127.0.0.1:9050")?))
.build();
let client = ureq::Agent::from(config).tor_check()?;
// Ok, I am connected to Tor.
client.get("https://example.com/").call()?;
Ok(())
}
This crate use check.torproject.org API result.
Possible errors returned.
use tor_check::{TorCheck, TorCheckError as Error};
match ureq::agent().tor_check() {
Ok(_) => println!("Crongratulation!"),
Err(err) if err.is_decode() => {
eprintln!("Malformed response: {err}");
eprintln!("Check https://check.torproject.org/api/ip");
}
Err(Error::HttpClient(err)) => {
eprintln!("HTTP error: {err}");
eprintln!("Check Tor services https://status.torproject.org/");
}
Err(err @ Error::YouAreNotUsingTor) => eprintln!("Danger! {err}"),
}