| Crates.io | tor-check |
| lib.rs | tor-check |
| version | 0.1.0 |
| created_at | 2025-01-02 11:22:22.385629+00 |
| updated_at | 2025-01-02 11:22:22.385629+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 | 11,820 |
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 client = ureq::AgentBuilder::new()
.proxy(ureq::Proxy::new("socks5://127.0.0.1:9050")?)
.build()
.tor_check()?;
// Ok, I am connected to Tor.
client.get("https://example.com/").call()?;
Ok(())
}
The check depends on TorButton Web page result.
If you suspect a Web page update or an issue in the parsing process, you can obtain debug information with the log feature.
use tor_check::{TorCheck, TorCheckError as Error};
fn main() -> Result<(), Error<ureq::Error>> {
// Enable logger output
env_logger::builder()
.filter_level(log::LevelFilter::Debug)
.init();
// Print the check result
match ureq::Agent::new().tor_check() {
Ok(_) => println!("Crongratulation!"),
Err(Error::HttpClient(err)) => println!("HTTP error: {err}"),
Err(Error::PageParsing(err)) => println!("I/O error: {err}"),
Err(err) => println!("Danger! {err}"),
};
Ok(())
}