tor: update arti-client to 0.30.0

This commit is contained in:
ardocrat
2025-05-31 17:08:39 +03:00
parent 918c5b4355
commit 8165fab326
4 changed files with 111 additions and 102 deletions
+4 -4
View File
@@ -19,10 +19,10 @@ use std::sync::Arc;
use std::task::{Context, Poll};
use arti_client::{DataStream, IntoTorAddr, TorClient};
use hyper::client::connect::{Connected, Connection};
use hyper::http::uri::Scheme;
use hyper::http::Uri;
use hyper::service::Service;
use hyper_tor::client::connect::{Connected, Connection};
use hyper_tor::http::uri::Scheme;
use hyper_tor::http::Uri;
use hyper_tor::service::Service;
use pin_project::pin_project;
use thiserror::Error;
use tls_api::TlsConnector as TlsConn; // This is different from tor_rtcompat::TlsConnector
+10 -11
View File
@@ -28,7 +28,6 @@ use curve25519_dalek::digest::Digest;
use ed25519_dalek::hazmat::ExpandedSecretKey;
use fs_mistrust::Mistrust;
use grin_util::secp::SecretKey;
use hyper::{Body, Uri};
use parking_lot::RwLock;
use sha2::Sha512;
use tls_api_native_tls::TlsConnector;
@@ -135,17 +134,17 @@ impl Tor {
// Create http tor-powered client to post data.
let tls_connector = TlsConnector::builder().unwrap().build().unwrap();
let tor_connector = ArtiHttpConnector::new(client, tls_connector);
let http = hyper::Client::builder().build::<_, Body>(tor_connector);
let http = hyper_tor::Client::builder().build::<_, hyper_tor::Body>(tor_connector);
// Create request.
let req = hyper::Request::builder()
.method(hyper::Method::POST)
let req = hyper_tor::Request::builder()
.method(hyper_tor::Method::POST)
.uri(url)
.body(Body::from(body))
.body(hyper_tor::Body::from(body))
.unwrap();
// Send request.
let mut resp = None;
match http.request(req).await {
Ok(r) => match hyper::body::to_bytes(r).await {
Ok(r) => match hyper_tor::body::to_bytes(r).await {
Ok(raw) => resp = Some(String::from_utf8_lossy(&raw).to_string()),
Err(_) => {}
},
@@ -276,12 +275,12 @@ impl Tor {
}
runtime
.spawn(async move {
let tls_connector =
let tls_conn =
TlsConnector::builder().unwrap().build().unwrap();
let tor_connector =
ArtiHttpConnector::new(client_check.clone(), tls_connector);
let tor_conn =
ArtiHttpConnector::new(client_check.clone(), tls_conn);
let http =
hyper::Client::builder().build::<_, Body>(tor_connector);
hyper_tor::Client::builder().build::<_, hyper_tor::Body>(tor_conn);
const MAX_ERRORS: i32 = 3;
let mut errors_count = 0;
@@ -295,7 +294,7 @@ impl Tor {
}
// Send request.
let duration = match http
.get(Uri::from_str(url.clone().as_str()).unwrap())
.get(hyper_tor::Uri::from_str(url.clone().as_str()).unwrap())
.await
{
Ok(_) => {