Skip to main content

Module circuit

Module circuit 

Source
Expand description

Multi-hop paths over the Tor network.

Right now, we only implement “client circuits” – also sometimes called “origin circuits”. A client circuit is one that is constructed by this Tor instance, and used in its own behalf to send data over the Tor network.

Each circuit has multiple hops over the Tor network: each hop knows only the hop before and the hop after. The client shares a separate set of keys with each hop.

To build a circuit, first create a crate::channel::Channel, then call its crate::channel::Channel::new_tunnel method. This yields a PendingClientTunnel object that won’t become live until you call one of the methods (typically PendingClientTunnel::create_firsthop) that extends it to its first hop. After you’ve done that, you can call ClientCirc::extend on the tunnel to build it into a multi-hop tunnel. Finally, you can use ClientTunnel::begin_stream to get a Stream object that can be used for anonymized data.

§Implementation

Each open circuit has a corresponding Reactor object that runs in an asynchronous task, and manages incoming cells from the circuit’s upstream channel. These cells are either RELAY cells or DESTROY cells. DESTROY cells are handled immediately. RELAY cells are either for a particular stream, in which case they get forwarded to a StreamReceiver object, or for no particular stream, in which case they are considered “meta” cells (like EXTENDED2) that should only get accepted if something is waiting for them.

§Limitations

This is client-only.

Re-exports§

use crate::channel::Channel; 🔒
use crate::circuit::circhop::HopNegotiationType; 🔒
use crate::circuit::circhop::HopSettings; 🔒
use crate::circuit::CircuitRxReceiver; 🔒
use crate::client::CircuitPadder; 🔒
use crate::client::circuit::padding::PaddingController; 🔒
use crate::client::circuit::padding::PaddingEventStream; 🔒
use crate::client::reactor::CircuitHandshake; 🔒
use crate::client::reactor::CtrlCmd; 🔒
use crate::client::reactor::CtrlMsg; 🔒
use crate::client::reactor::Reactor; 🔒
use crate::crypto::cell::HopNum; 🔒
use crate::crypto::handshake::ntor_v3::NtorV3PublicKey; 🔒
use crate::memquota::CircuitAccount; 🔒
use crate::util::skew::ClockSkew; 🔒
use crate::Error; 🔒
use crate::Result; 🔒
use derive_deftly::Deftly; 🔒
use educe::Educe; 🔒
use path::HopDetail; 🔒
use tor_cell::chancell::CircId; 🔒
use tor_cell::chancell::msg as chanmsg; 🔒
use tor_error::bad_api_usage; 🔒
use tor_error::internal; 🔒
use tor_error::into_internal; 🔒
use tor_linkspec::CircTarget; 🔒
use tor_linkspec::LinkSpecType; 🔒
use tor_linkspec::OwnedChanTarget; 🔒
use tor_linkspec::RelayIdType; 🔒
use tor_protover::named; 🔒
use tor_rtcompat::DynTimeProvider; 🔒
use web_time_compat::Instant; 🔒
use crate::circuit::UniqId; 🔒
use super::ClientTunnel; 🔒
use super::TargetHop; 🔒
use futures::channel::mpsc; 🔒
use oneshot_fused_workaround as oneshot; 🔒
use futures::FutureExt as _; 🔒
use std::collections::HashMap; 🔒
use std::sync::Arc; 🔒
use std::sync::Mutex; 🔒
use tor_memquota::derive_deftly_template_HasMemoryCost; 🔒
use crate::crypto::handshake::ntor::NtorPublicKey; 🔒
pub use crate::crypto::binding::CircuitBinding;
pub use path::Path;
pub use path::PathEntry;
pub use crate::circuit::CircParameters;
pub use crate::util::timeout::TimeoutEstimator;
use crate::circuit::celltypes::*; 🔒

Modules§

halfcirc 🔒
A “receive-only” view of a circuit, as a placeholder for circuits that have closed.
handshake
Features for manual invocation of Tor’s cryptographic circuit handshakes.
padding 🔒
Definitions for circuit padding.
path 🔒
Tracking for the path of a client circuit.

Structs§

CircuitState 🔒
The shared state of a circuit.
ClientCirc
A circuit that we have constructed over the Tor network.
MutableState 🔒
The mutable state of a circuit.
PendingClientTunnel
A ClientCirc that needs to send a create cell and receive a created* cell.
TunnelMutableState 🔒
The mutable state of a tunnel, shared between ClientCirc and Reactor.

Enums§

ClientCircChanMsg 🔒
A subclass of ChanMsg that can correctly arrive on a live client circuit (one where a CREATED* has been received).