1// Use your own instance of an `arti_client::TorClient` with arti-ureq to make a GET request.
23use anyhow::Context;
45const TEST_URL: &str = "https://check.torproject.org/api/ip";
67fn main() -> anyhow::Result<()> {
8// Create your own instance of a Tor client.
9let tor_client = arti_ureq::arti_client::TorClient::with_runtime(
10 arti_ureq::tor_rtcompat::PreferredRuntime::create().context("Failed to create runtime.")?,
11 )
12 .create_unbootstrapped()
13 .context("Error creating Tor Client.")?;
1415// Make a Connector and get ureq agent.
16let ureq_agent = arti_ureq::Connector::with_tor_client(tor_client).agent();
1718// Make request.
19let mut request = ureq_agent
20 .get(TEST_URL)
21 .call()
22 .context("Failed to make request.")?;
2324// Get response body.
25let response = request
26 .body_mut()
27 .read_to_string()
28 .context("Failed to read body.")?;
2930// Will output if request was made using Tor.
31println!("Response: {}", response);
3233Ok(())
34}