Crate tor_dirclient

Source
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

Modules§

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§

DirResponse
A successful (or at any rate, well-formed) response to a directory request.
HeaderStatus 🔒
Return value from read_headers
RequestFailedError
An error that has occurred after we have contacted a directory cache and made a circuit to it.
SourceInfo
Information about the source of a directory response.

Enums§

AnonymizedRequest
Flag to declare whether a request is anonymized or not.
Error
An error originating from the tor-dirclient crate.
RequestError
An error originating from the tor-dirclient crate.

Functions§

downloadDeprecated
Fetch a Tor directory object from a provided stream.
get_decoder 🔒
Wrap stream in an appropriate type to undo the content encoding as described in encoding.
get_resource
Fetch the resource described by req over the Tor network.
read_and_decompress 🔒
Helper: download directory information from stream and decompress it into a result buffer. Assumes that buf is empty.
read_headers 🔒
Read and parse HTTP/1 headers from stream.
read_until_limited 🔒
As AsyncBufReadExt::read_until, but stops after reading max bytes.
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 result holds an error indicating that we should retire the circuit used for the corresponding request.

Type Aliases§

RequestResult
Type for internal results containing a RequestError.
Result
Type for results returned in this crate.