Expand description
§tor-dirclient
Implements a minimal directory client for Tor.
§Overview
Tor makes its directory requests as HTTP/1.0 requests tunneled over Tor circuits. For most objects, Tor uses a one-hop tunnel. Tor also uses a few strange and ad-hoc HTTP headers to select particular functionality, such as asking for diffs, compression, or multiple documents.
This crate provides an API for downloading Tor directory resources over a Tor circuit.
This crate is part of Arti, a project to implement Tor in Rust.
§Features
xz – enable XZ compression. This can be expensive in RAM and CPU,
but it saves a lot of bandwidth. (On by default.)
zstd – enable ZSTD compression. (On by default.)
routerdesc – Add support for downloading router descriptors.
License: MIT OR Apache-2.0
Re-exports§
pub use err::Error;pub use err::RequestError;pub use err::RequestFailedError;pub use response::DirResponse;pub use response::SourceInfo;pub(crate) use CircMgr;🔒pub(crate) use DirInfo;🔒pub(crate) use tor_error::bad_api_usage;🔒pub(crate) use Runtime;🔒pub(crate) use SleepProvider;🔒pub(crate) use SleepProviderExt;🔒pub(crate) use async_compression::futures::bufread::XzDecoder;🔒pub(crate) use async_compression::futures::bufread::ZlibDecoder;🔒pub(crate) use async_compression::futures::bufread::ZstdDecoder;🔒pub(crate) use futures::FutureExt;🔒pub(crate) use AsyncBufRead;🔒pub(crate) use AsyncBufReadExt;🔒pub(crate) use AsyncRead;🔒pub(crate) use AsyncReadExt;🔒pub(crate) use AsyncWrite;🔒pub(crate) use AsyncWriteExt;🔒pub(crate) use BufReader;🔒pub(crate) use std::sync::Arc;🔒pub(crate) use std::time::Duration;🔒pub(crate) use info;🔒pub(crate) use instrument;🔒pub(crate) use instrument;🔒
Modules§
- body 🔒
- Declare a type to represent the encoding of a request or its body.
- err 🔒
- Declare dirclient-specific errors.
- request
- Descriptions objects for different kinds of directory requests that we can make.
- response 🔒
- Define a response type for directory requests.
- util 🔒
- Helper functions for the directory client code
Macros§
- decoder 🔒
- Helper: Return a boxed decoder object that wraps the stream $s.
Structs§
- Header
Status 🔒 - Return value from read_headers
Enums§
- Anonymized
Request - Flag to declare whether a request is always anonymized or not.
Constants§
- LZMA_
DICT_ 🔒MEM_ LIMIT - Memory limit of the LZMA dictionary we are willing to allocate.
- MAX_
HEADERS_ 🔒LEN - Maximum length for the HTTP headers in a single request or response.
Functions§
- download
Deprecated - Fetch a Tor directory object from a provided stream.
- get_
decoder 🔒 - Wrap
streamin an appropriate type to undo the content encoding as described inencoding. - get_
resource - Fetch the resource described by
reqover the Tor network. - read_
and_ 🔒decompress - Helper: download directory information from
streamand decompress it into a result buffer. Assumes thatbufis empty. - read_
headers 🔒 - Read and parse HTTP/1 headers from
stream. - read_
headers_ 🔒internal - Internal version of
read_headers()without a timeout. - retire_
circ 🔒 - Retire a directory circuit because of an error we’ve encountered on it.
- send_
request - Fetch or upload a Tor directory object using the provided stream.
- should_
retire_ 🔒circ - Return true if
resultholds an error indicating that we should retire the circuit used for the corresponding request.
Type Aliases§
- Request
Result - Type for internal results containing a RequestError.
- Result
- Type for results returned in this crate.