Artiqwest is a simple HTTP client that routes *all (except localhost connects where it fallbacks to reqwest) requests through the Tor network using the arti_client and hyper.
It provides two basic primitives: get and post, functions.
Artiqwest also provides a ws function to create a websocket connection to a hidden service using tokio-tungstenite. ~~~Currently websockets only work over tor and are untested over clearnet.~~~
- NEW! Websockets no work over both Tor and clearnet! Fully tested!!!
- NEW! You can now optionally pass in an existing arti
TorClient. If you don't have one don't worry, Atriqwest will handle the Tor stuff for you automatically.
- NEW! If you
TorClient expires or loses connection we will auto-reload your Torclient up to five times before failing.
Example
use artiqwest::get;
use artiqwest::post;
use artiqwest::ws;
use futures_util::future;
use futures_util::pin_mut;
use futures_util::SinkExt;
use tokio_tungstenite::tungstenite::Message;
#[tokio::main]
async fn main() {
let response = get("https://httpbin.org/get", None, None).await.unwrap();
assert_eq!(response.status(), 200);
let body = r#"{"test": "testing"}"#;
let headers = vec![("Content-Type", "application/json")];
let response = post("http://vpns6exmqmg5znqmgxa5c6rgzpt6imy5yzrbsoszovgfipdjypnchpyd.onion/echo", body, Some(headers), None).await.unwrap();
assert_eq!(response.to_string(), body);
let (mut write, read) = ws("wss://ydrkehoqxt2q5atkmiyw7gmphvrmp6fkaufvt525cjr4hma3pb75nyid.onion/events", None).await.unwrap();
let write_messages = {
async {
loop {
write.send(Message::Text("Hello WebSocket".to_string())).await.unwrap();
tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;
}
}
};
let read_messages = {
read.for_each(|message| async {
let data = message.unwrap().into_data();
let text = String::from_utf8(data).unwrap();
println!("Received: {text}");
})
};
pin_mut!(read_messages, write_messages);
future::select(read_messages, write_messages).await;
}