Skip to main content

Module reactor

Module reactor 

Source
Expand description

Code to handle incoming cells on a circuit.

Β§On message validation

There are three steps for validating an incoming message on a stream:

  1. Is the message contextually appropriate? (e.g., no more than one CONNECTED message per stream.) This is handled by calling CmdChecker::check_msg.
  2. Does the message comply with flow-control rules? (e.g., no more SENDMEs than we’ve sent data for.) This is handled within the reactor by the StreamFlowCtrl. For half-closed streams which don’t send stream SENDMEs, an additional receive-window check is performed in the halfstream module.
  3. Does the message have an acceptable command type, and is the message well-formed? For open streams, the streams themselves handle this check. For half-closed streams, the reactor handles it by calling consume_checked_msg().

Re-exportsΒ§

use crate::circuit::circhop::ReactorStreamComponents; πŸ”’
use crate::circuit::circhop::SendRelayCell; πŸ”’
use crate::circuit::CircuitRxReceiver; πŸ”’
use crate::circuit::UniqId; πŸ”’
use crate::client::circuit::ClientCircChanMsg; πŸ”’
use crate::client::circuit::padding::PaddingController; πŸ”’
use crate::client::circuit::padding::PaddingEvent; πŸ”’
use crate::client::circuit::padding::PaddingEventStream; πŸ”’
use crate::client::HopLocation; πŸ”’
use crate::client::TargetHop; πŸ”’
use crate::crypto::cell::HopNum; πŸ”’
use crate::crypto::handshake::ntor_v3::NtorV3PublicKey; πŸ”’
use crate::memquota::CircuitAccount; πŸ”’
use crate::stream::CloseStreamBehavior; πŸ”’
use crate::streammap; πŸ”’
use crate::tunnel::TunnelId; πŸ”’
use crate::tunnel::TunnelScopedCircId; πŸ”’
use crate::util::err::ReactorError; πŸ”’
use crate::util::skew::ClockSkew; πŸ”’
use crate::util::timeout::TimeoutEstimator; πŸ”’
use crate::Error; πŸ”’
use crate::Result; πŸ”’
use circuit::Circuit; πŸ”’
use conflux::ConfluxSet; πŸ”’
use control::ControlHandler; πŸ”’
use std::cmp::Ordering; πŸ”’
use std::collections::BinaryHeap; πŸ”’
use tor_basic_utils::onionperf_types::OnionperfCircuitStatus; πŸ”’
use tor_basic_utils::onionperf_types::OnionperfEvent; πŸ”’
use tor_cell::relaycell::flow_ctrl::XonKBpsEwma; πŸ”’
use tor_cell::relaycell::msg::Sendme; πŸ”’
use tor_cell::relaycell::AnyRelayMsgOuter; πŸ”’
use tor_cell::relaycell::RelayCellFormat; πŸ”’
use tor_cell::relaycell::StreamId; πŸ”’
use tor_cell::relaycell::UnparsedRelayMsg; πŸ”’
use tor_error::Bug; πŸ”’
use tor_error::bad_api_usage; πŸ”’
use tor_error::debug_report; πŸ”’
use tor_error::internal; πŸ”’
use tor_error::into_bad_api_usage; πŸ”’
use tor_rtcompat::DynTimeProvider; πŸ”’
use tor_rtcompat::SleepProvider; πŸ”’
use cfg_if::cfg_if; πŸ”’
use futures::StreamExt; πŸ”’
use futures::channel::mpsc; πŸ”’
use futures::FutureExt as _; πŸ”’
use futures::select_biased; πŸ”’
use oneshot_fused_workaround as oneshot; πŸ”’
use std::result::Result as StdResult; πŸ”’
use std::sync::Arc; πŸ”’
use crate::channel::Channel; πŸ”’
use crate::conflux::msghandler::RemoveLegReason; πŸ”’
use crate::crypto::handshake::ntor::NtorClient; πŸ”’
use crate::crypto::handshake::ntor::NtorPublicKey; πŸ”’
use circuit::CircuitCmd; πŸ”’
use derive_more::From; πŸ”’
use smallvec::smallvec; πŸ”’
use tor_cell::chancell::CircId; πŸ”’
use tor_llcrypto::pk; πŸ”’
use tracing::debug; πŸ”’
use tracing::info; πŸ”’
use tracing::instrument; πŸ”’
use tracing::instrument; πŸ”’
use tracing::trace; πŸ”’
use tracing::warn; πŸ”’
use super::circuit::MutableState; πŸ”’
use super::circuit::TunnelMutableState; πŸ”’
use crate::circuit::reactor::ReactorResultChannel; πŸ”’
use crate::stream::incoming::IncomingStreamRequestHandler; πŸ”’
use crate::conflux::msghandler::ConfluxCmd; πŸ”’
use crate::conflux::msghandler::OooRelayMsg; πŸ”’
use crate::util::err::ConfluxHandshakeError; πŸ”’
pub(super) use control::CtrlCmd; πŸ”’
pub(super) use control::CtrlMsg; πŸ”’
pub(super) use control::FlowCtrlMsg; πŸ”’

ModulesΒ§

circuit πŸ”’
Module exposing types for representing circuits in the tunnel reactor.
conflux πŸ”’
Conflux-related functionality
control πŸ”’
Module providing CtrlMsg.

MacrosΒ§

unwrap_or_shutdown πŸ”’
Unwrap the specified Option, returning a ReactorError::Shutdown if it is None.

StructsΒ§

CellHandlers πŸ”’
Cell handlers, shared between the Reactor and its underlying Circuits.
ConfluxHandshakeCtx πŸ”’
The context for an on-going conflux handshake.
ConfluxHeapEntry πŸ”’
An out-of-order message buffered in Reactor::ooo_msgs.
NoHopsBuiltError πŸ”’
The tunnel does not have any hops.
NoJoinPointError πŸ”’
The tunnel does not have a join point.
Reactor
Object to handle incoming cells and background tasks on a circuit

EnumsΒ§

CircuitEvent πŸ”’
A command to execute at the end of Reactor::run_once.
CircuitHandshake πŸ”’
A handshake type, to be used when creating circuit hops.
MetaCellDisposition
A possible successful outcome of giving a message to a MsgHandler.
RunOnceCmd πŸ”’
One or more RunOnceCmdInner to run inside Reactor::run_once.
RunOnceCmdInner πŸ”’
Instructions for running something in the reactor loop.

TraitsΒ§

MetaCellHandler πŸ”’
An object that’s waiting for a meta cell (one not associated with a stream) in order to make progress.

FunctionsΒ§

send_conflux_outcome πŸ”’
Notify the conflux handshake initiator of the handshake outcome.

Type AliasesΒ§

ConfluxHandshakeResult πŸ”’
Contains a list of conflux handshake results.
ConfluxLinkResultChannel πŸ”’
The type of oneshot channel used to inform reactor users of the outcome of a client-side conflux handshake.