https://github.com/hupe1980/hypertor
Hypertor is a Rust library for HTTP requests over Tor, supporting HTTP/HTTPS with configurable TLS via hyper and arti_client.
https://github.com/hupe1980/hypertor
http-client privacy tor
Last synced: 6 months ago
JSON representation
Hypertor is a Rust library for HTTP requests over Tor, supporting HTTP/HTTPS with configurable TLS via hyper and arti_client.
- Host: GitHub
- URL: https://github.com/hupe1980/hypertor
- Owner: hupe1980
- License: mit
- Created: 2024-09-08T11:39:08.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-08T22:10:27.000Z (about 1 year ago)
- Last Synced: 2025-04-16T00:17:26.573Z (6 months ago)
- Topics: http-client, privacy, tor
- Language: Rust
- Homepage:
- Size: 7.81 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# hypertor
`hypertor` is a Rust library that provides a client for making HTTP requests over the Tor network. It integrates with the Tor network and supports both HTTP and HTTPS protocols with configurable TLS support. Built on top of `hyper` and `arti_client`, it allows you to send GET, POST, and HEAD requests with custom configurations.
## Features
- **HTTP and HTTPS Support:** Send requests over both HTTP and HTTPS.
- **Tor Integration:** Connect through the Tor network.
- **Configurable TLS:** Customize TLS settings for secure connections.
- **Builder Pattern:** Easily configure clients with `ClientConfigBuilder`.## Installation
Add `hypertor` to your `Cargo.toml`:
```toml
[dependencies]
hypertor = "0.1" # Replace with the latest version
```## Usage
Here's a basic example of how to use hypertor to create a client and make HTTP requests:### Basic Example
```rust
use hypertor::Client;
use anyhow::Result;#[tokio::main]
async fn main() -> Result<()> {
// Create a new client with default configuration
let client = Client::new().await?;// Make a GET request
let response = client.get("http://httpbin.org/get").await?;
println!("GET response: {:?}", response);// Make a POST request with JSON body
let body = hyper::body::Bytes::from(r#"{"key":"value"}"#);
let response = client.post("http://httpbin.org/post", "application/json", body).await?;
println!("POST response: {:?}", response);// Make a HEAD request
let response = client.head("http://httpbin.org/get").await?;
println!("HEAD response: {:?}", response);Ok(())
}
```## Custom Configuration
You can also create a client with a custom configuration:
```rust
use hypertor::{Client, ClientConfig, ClientConfigBuilder};
use tokio_native_tls::native_tls::TlsConnector;
use arti_client::TorClientConfig;#[tokio::main]
async fn main() -> Result<()> {
// Create a custom TLS connector
let tls_config = TlsConnector::builder().build()?;// Create a custom Tor client configuration
let tor_config = TorClientConfig::builder()
.address_filter()
.allow_onion_addrs(true)
.build()?;// Build client configuration
let config = ClientConfigBuilder::new()
.tls_config(tls_config)
.tor_config(tor_config)
.build()?;// Create a client with the custom configuration
let client = Client::with_config(config).await?;// Use the client as shown in the basic example
Ok(())
}
```
## Error Handling
hypertor uses anyhow::Result for error handling, which provides a flexible way to handle and propagate errors. For more details, refer to the anyhow documentation.## Contributing
Contributions are welcome! Please open an issue or submit a pull request on GitHub.## License
This project is licensed under the MIT License. See the LICENSE file for details.