pub struct NetDir { /* private fields */ }
Expand description

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

Abstractly, a NetDir is a set of usable public Relays, each of which has its own properties, identity, and correct weighted probability for use under different circumstances.

A NetDir is constructed by making a PartialNetDir from a consensus document, and then adding enough microdescriptors to that PartialNetDir so that it can be used to build paths. (Thus, if you have a NetDir, it is definitely adequate to build paths.)

Implementations

Return the declared lifetime of this NetDir.

Replace the overridden parameters in this netdir with new_replacement.

After this function is done, the netdir’s parameters will be those in the consensus, overridden by settings from new_replacement. Any settings in the old replacement parameters will be discarded.

Return an iterator over all Relay objects, including invalid ones that we can’t use.

Return an iterator over all usable Relays.

Return a relay matching a given Ed25519 identity, if we have a usable relay with that key.

(Does not return unusable relays.)

Note that if a microdescriptor is subsequently added for a relay with this ID, the ID may become usable.

Return a relay matching a given Ed25519 identity and RSA identity, if we have a usable relay with both keys.

(Does not return unusable relays.)

Note that if a microdescriptor is subsequently added for a relay with this ID, the ID may become usable.

Return the usable relay matching a given ChanTarget’s identities, if any.

(Does not return unusable relays.)

Return a boolean if this consensus definitely has (or does not have) a relay matching both the given Ed25519 and RSA identity.

If we can’t yet tell for sure, return None.

Once function has returned Some(b), it will always return that value for the same ed_id and rsa_id on this NetDir. A None answer may later become Some(b) if a microdescriptor arrives.

Return true if we are currently missing a micro descriptor for the given RSA identity.

A descriptor is missing only if it is listed in the consensus, but we don’t have it downloaded.

Return a (possibly unusable) relay with a given RSA identity.

Return the relay with a given RSA identity, if we have one and it is usable.

Return true if rsa_id is listed in this directory, even if it isn’t currently usable.

Return the parameters from the consensus, clamped to the correct ranges, with defaults filled in.

NOTE: that unsupported parameters aren’t returned here; only those values configured in the params module are available.

Choose a relay at random.

Each relay is chosen with probability proportional to its weight in the role role, and is only selected if the predicate usable returns true for it.

This function returns None if (and only if) there are no relays with nonzero weight where usable returned true.

Choose n relay at random.

Each relay is chosen with probability proportional to its weight in the role role, and is only selected if the predicate usable returns true for it.

Relays are chosen without replacement: no relay will be returned twice. Therefore, the resulting vector may be smaller than n if we happen to have fewer than n appropriate relays.

This function returns an empty vector if (and only if) there are no relays with nonzero weight where usable returned true.

Compute the weight with which relay will be selected for a given role.

Compute the total weight with which any relay matching usable will be selected for a given role.

Note: because this function is used to assess the total properties of the consensus, the usable predicate takes a RouterStatus rather than a Relay.

Compute the weight with which a relay with ID rsa_id would be selected for a given role.

Note that weight returned by this function assumes that the relay with that ID is actually usable; if it isn’t usable, then other weight-related functions will call its weight zero.

Return all relays in this NetDir known to be in the same family as relay.

This list of members will not necessarily include relay itself.

Limitations

Two relays only belong to the same family if each relay claims to share a family with the other. But if we are missing a microdescriptor for one of the relays listed by this relay, we cannot know whether it acknowledges family membership with this relay or not. Therefore, this function can omit family members for which there is not (as yet) any Relay object.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Return an iterator over the digests for all of the microdescriptors that this netdir is missing. Read more

Add a microdescriptor to this netdir, if it was wanted. Read more

Return the number of missing microdescriptors.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more