pub struct GuardMgr<R: Runtime> { /* private fields */ }
Expand description

A “guard manager” that selects and remembers a persistent set of guard nodes.

Implementations

Create a new “empty” guard manager and launch its background tasks.

It won’t be able to hand out any guards until GuardMgr::update_network has been called.

Install a NetDirProvider for use by this guard manager.

It will be used to keep the guards up-to-date with changes from the network directory, and to find new guards when no NetDir is provided to select_guard().

TODO: we should eventually return some kind of a task handle from this task, even though it is not strictly speaking periodic.

Flush our current guard state to the state manager, if there is any unsaved state.

Reload state from the state manager.

We only call this method if we don’t have the lock on the state files. If we have the lock, we only want to save.

Switch from having an unowned persistent state to having an owned one.

Requires that we hold the lock on the state files.

Return true if netdir has enough information to safely become our new netdir.

Mark every guard as potentially retriable, regardless of how recently we failed to connect to it.

Update the state of this GuardMgr based on a new or modified NetDir object.

This method can add new guards, or notice that existing guards have become unusable. It needs a NetDir so it can identify potential candidate guards.

Call this method whenever the NetDir changes, unless you have used install_netdir_provider.

Replace the fallback list held by this GuardMgr with new_list.

Replace the current GuardFilter used by this GuardMgr.

Select a guard for a given GuardUsage.

On success, we return a FirstHop object to identify which guard we have picked, a GuardMonitor object that the caller can use to report whether its attempt to use the guard succeeded or failed, and a GuardUsable future that the caller can use to decide whether a circuit built through the guard is actually safe to use.

That last point is important: It’s okay to build a circuit through the guard returned by this function, but you can’t actually use it for traffic unless the GuardUsable future yields “true”.

Limitations

This function will never return a guard that isn’t listed in the most recent NetDir.

That’s usually what you’d want, but when we’re trying to bootstrap we might want to use all guards as possible directory caches. That’s not implemented yet. (See ticket #220).

This function only looks at netdir when all of the known guards are down; to force an update, use GuardMgr::update_network.

Record that after we built a circuit with a guard, something described in external_failure went wrong with it.

Record that after we built a circuit with a guard, some activity described in external_activity was successful with it.

Return a stream of events about our estimated clock skew; these events are None when we don’t have enough information to make an estimate, and Some(SkewEstimate) otherwise.

Note that this stream can be lossy: if the estimate changes more than one before you read from the stream, you might only get the most recent update.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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