Need help with arti-client

⚓ Rust    📅 2026-02-06    👤 surdeus    👁️ 6      

surdeus

Info

This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Need help with arti-client

There is my code for commnicate with onion http service

use arti_client::{TorClient, TorClientConfig};
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use anyhow::Result;

#[tokio::main]
async fn main() -> Result<()> {
    let config = TorClientConfig::default();
    
    let tor_client = TorClient::create_bootstrapped(config).await?;
    
    let onion_addr = "duckduckgogg42xjoc72x3sjasowoarfbgcmvfimaftt6twagswzczad.onion:80";
    
    let mut stream = tor_client.connect(onion_addr).await?;
    
    let request = "GET /html HTTP/1.1\r\nHost: duckduckgogg42xjoc72x3sjasowoarfbgcmvfimaftt6twagswzczad.onion\r\nConnection: close\r\n\r\n";
    stream.write_all(request.as_bytes()).await?;
    
    let mut response = Vec::new();
    stream.read_to_end(&mut response).await?;
    
    println!("resp len: {} b", response.len());
    println!("{}", String::from_utf8_lossy(&response[..500.min(response.len())]));
    
    Ok(())
}

arti-client with future onion-service-client. But I can't get response from http, response is null. What I do wrong?

2 posts - 2 participants

Read full topic

🏷️ Rust_feed