Expand description

Represents a clients’-eye view of the Tor network.


The tor-netdir crate wraps objects from tor-netdoc, and combines them to provide a unified view of the relays on the network. It is responsible for representing a client’s knowledge of the network’s state and who is on it.

This crate is part of Arti, a project to implement Tor in Rust. Its purpose is to expose an abstract view of a Tor network and the relays in it, so that higher-level crates don’t need to know about the particular documents that describe the network and its properties.

There are two intended users for this crate. First, producers like [tor-dirmgr] create NetDir objects fill them with information from the Tor network directory. Later, consumers like [tor-circmgr] use NetDirs to select relays for random paths through the Tor network.


Only modern consensus methods and microdescriptor consensuses are supported.


Implements a usable view of Tor network parameters.


A view of the Tor directory, suitable for use in building circuits.

A partially build NetDir – it can’t be unwrapped until it has enough information to build safe paths.

A view of a relay on the Tor network, suitable for building circuits.

An opaque type representing the weight with which a relay or set of relays will be selected for a given role.

Configuration for determining when two relays have addresses “too close” in the network.

A relay that we haven’t checked for validity or usability in routing.


An event that a NetDirProvider can broadcast to indicate that a change in the status of its directory.

An error returned by the network directory code

How “timely” must a network directory be?

Possible ways to weight relays when selecting them a random.


A partial or full network directory that we can download microdescriptors for.

An object that can provide NetDirs, as well as inform consumers when they might have changed.

Helper trait: allows any Arc<X> to be upcast to a Arc<dyn NetDirProvider> if X is an implementation or supertrait of NetDirProvider.

Type Definitions

A Result using the Error type from the tor-netdir crate