hyper_tor_connector/
lib.rs

1pub mod maybe;
2
3#[cfg(feature = "socks")]
4mod socks;
5#[cfg(feature = "socks")]
6pub use socks::*;
7
8#[cfg(feature = "arti")]
9mod arti;
10#[cfg(feature = "arti")]
11pub use arti::*;
12
13#[cfg(test)]
14mod tests {
15    use super::*;
16    use hyper::client::Client;
17    use hyper::Body;
18
19    #[tokio::test]
20    async fn get_torproject_page() {
21        #[cfg(feature = "socks")]
22        let tor = TorConnector::new(([127, 0, 0, 1], 9050).into()).unwrap();
23        #[cfg(feature = "arti")]
24        let tor = TorConnector::new().unwrap();
25        let client: Client<TorConnector, Body> = Client::builder().build(tor);
26        assert!(client
27            .get(
28                "http://2gzyxa5ihm7nsggfxnu52rck2vv4rvmdlkiu3zzui5du4xyclen53wid.onion"
29                    .parse()
30                    .unwrap(),
31            )
32            .await
33            .unwrap()
34            .status()
35            .is_success());
36    }
37}