summaryrefslogtreecommitdiff
path: root/crates/tor-proto/src/client
diff options
context:
space:
mode:
Diffstat (limited to 'crates/tor-proto/src/client')
-rw-r--r--crates/tor-proto/src/client/circuit.rs8
-rw-r--r--crates/tor-proto/src/client/circuit/unique_id.rs50
-rw-r--r--crates/tor-proto/src/client/reactor.rs5
-rw-r--r--crates/tor-proto/src/client/reactor/circuit.rs19
-rw-r--r--crates/tor-proto/src/client/reactor/circuit/circhop.rs5
-rw-r--r--crates/tor-proto/src/client/reactor/circuit/extender.rs6
-rw-r--r--crates/tor-proto/src/client/reactor/conflux.rs8
-rw-r--r--crates/tor-proto/src/client/reactor/control.rs5
-rw-r--r--crates/tor-proto/src/client/stream/incoming.rs2
9 files changed, 28 insertions, 80 deletions
diff --git a/crates/tor-proto/src/client/circuit.rs b/crates/tor-proto/src/client/circuit.rs
index c9a55813a..b45e003da 100644
--- a/crates/tor-proto/src/client/circuit.rs
+++ b/crates/tor-proto/src/client/circuit.rs
@@ -44,10 +44,8 @@ pub mod handshake;
pub(crate) mod handshake;
pub(super) mod path;
-pub(crate) mod unique_id;
use crate::channel::Channel;
-use crate::circuit::handshake::RelayCryptLayerProtocol;
use crate::client::circuit::celltypes::*;
use crate::client::reactor::{CircuitHandshake, CtrlCmd, CtrlMsg, Reactor};
use crate::congestion::params::CongestionControlParams;
@@ -58,6 +56,7 @@ use crate::util::skew::ClockSkew;
use crate::{Error, Result};
use cfg_if::cfg_if;
use educe::Educe;
+use handshake::RelayCryptLayerProtocol;
use path::HopDetail;
use tor_cell::chancell::CircId;
use tor_cell::relaycell::RelayCellFormat;
@@ -66,9 +65,7 @@ use tor_linkspec::{CircTarget, LinkSpecType, OwnedChanTarget, RelayIdType};
use tor_protover::named;
use tor_rtcompat::DynTimeProvider;
-pub use crate::client::circuit::unique_id::UniqId;
-pub use crate::crypto::binding::CircuitBinding;
-pub use crate::memquota::StreamAccount;
+use crate::circuit::UniqId;
use super::{ClientTunnel, TargetHop};
@@ -82,6 +79,7 @@ use tor_memquota::mq_queue::{self, MpscSpec};
use crate::crypto::handshake::ntor::NtorPublicKey;
+pub use crate::crypto::binding::CircuitBinding;
pub use path::{Path, PathEntry};
/// The size of the buffer for communication between `ClientCirc` and its reactor.
diff --git a/crates/tor-proto/src/client/circuit/unique_id.rs b/crates/tor-proto/src/client/circuit/unique_id.rs
deleted file mode 100644
index c8778f36e..000000000
--- a/crates/tor-proto/src/client/circuit/unique_id.rs
+++ /dev/null
@@ -1,50 +0,0 @@
-//! Unique identifiers for circuits.
-
-use std::fmt::{Display, Formatter};
-
-use derive_deftly::Deftly;
-use tor_memquota::derive_deftly_template_HasMemoryCost;
-
-/// Process-unique identifier for a circuit.
-///
-/// We could use channel_id.circid here, but the circid can be reused
-/// over time. This won't ever repeat on a 64-bit architecture, and
-/// is super-unlikely to repeat on a 32-bit architecture. (If
-/// we're about to return a repeat value, we assert instead.)
-#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Deftly)]
-#[derive_deftly(HasMemoryCost)]
-pub struct UniqId {
- /// Channel that this circuit is on.
- chan: usize,
- /// ID for the circuit on the channel
- circ: usize,
-}
-
-impl UniqId {
- /// Construct a new circuit UniqId from its parts
- pub(crate) fn new(chan: usize, circ: usize) -> Self {
- UniqId { chan, circ }
- }
-
- /// A helper for displaying the process-unique identifiers of this circuit.
- ///
- /// Unlike the [`Display`] implementation, this does not display a `Circ` prefix.
- pub fn display_chan_circ(&self) -> impl Display + '_ {
- DisplayChanCirc(self)
- }
-}
-
-impl Display for UniqId {
- fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
- write!(f, "Circ {}", self.display_chan_circ())
- }
-}
-
-/// A helper for displaying the process-unique identifiers of this circuit.
-struct DisplayChanCirc<'a>(&'a UniqId);
-
-impl<'a> Display for DisplayChanCirc<'a> {
- fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
- write!(f, "{}.{}", self.0.chan, self.0.circ)
- }
-}
diff --git a/crates/tor-proto/src/client/reactor.rs b/crates/tor-proto/src/client/reactor.rs
index bd4f4dab1..fd9d2f3a8 100644
--- a/crates/tor-proto/src/client/reactor.rs
+++ b/crates/tor-proto/src/client/reactor.rs
@@ -21,17 +21,18 @@ mod conflux;
mod control;
pub(super) mod syncview;
+use crate::circuit::UniqId;
use crate::client::circuit::CircuitRxReceiver;
use crate::client::circuit::celltypes::ClientCircChanMsg;
-use crate::client::circuit::unique_id::UniqId;
use crate::client::stream::queue::StreamQueueReceiver;
use crate::client::stream::{AnyCmdChecker, StreamRateLimit};
#[cfg(feature = "hs-service")]
use crate::client::stream::{DrainRateRequest, IncomingStreamRequest, IncomingStreamRequestFilter};
-use crate::client::{HopLocation, TargetHop, TunnelId, TunnelScopedCircId, streammap};
+use crate::client::{HopLocation, TargetHop, streammap};
use crate::crypto::cell::HopNum;
use crate::crypto::handshake::ntor_v3::NtorV3PublicKey;
use crate::memquota::{CircuitAccount, StreamAccount};
+use crate::tunnel::{TunnelId, TunnelScopedCircId};
use crate::util::err::ReactorError;
use crate::util::notify::NotifyReceiver;
use crate::util::skew::ClockSkew;
diff --git a/crates/tor-proto/src/client/reactor/circuit.rs b/crates/tor-proto/src/client/reactor/circuit.rs
index 36445c388..944fe1a93 100644
--- a/crates/tor-proto/src/client/reactor/circuit.rs
+++ b/crates/tor-proto/src/client/reactor/circuit.rs
@@ -5,15 +5,13 @@ pub(super) mod create;
pub(super) mod extender;
use crate::channel::{Channel, ChannelSender};
-use crate::circuit::HopSettings;
-#[cfg(feature = "counter-galois-onion")]
-use crate::circuit::handshake::RelayCryptLayerProtocol;
-use crate::client::TunnelScopedCircId;
+use crate::circuit::UniqId;
use crate::client::circuit::celltypes::{ClientCircChanMsg, CreateResponse};
+#[cfg(feature = "counter-galois-onion")]
+use crate::client::circuit::handshake::RelayCryptLayerProtocol;
use crate::client::circuit::handshake::{BoxedClientLayer, HandshakeRole};
-use crate::client::circuit::path;
-use crate::client::circuit::unique_id::UniqId;
use crate::client::circuit::{CircuitRxReceiver, MutableState, StreamMpscReceiver};
+use crate::client::circuit::{HopSettings, path};
use crate::client::reactor::MetaCellDisposition;
use crate::client::stream::queue::{StreamQueueSender, stream_queue};
use crate::client::stream::{AnyCmdChecker, DrainRateRequest, StreamRateLimit, StreamStatus};
@@ -30,6 +28,7 @@ use crate::crypto::handshake::ntor::{NtorClient, NtorPublicKey};
use crate::crypto::handshake::ntor_v3::{NtorV3Client, NtorV3PublicKey};
use crate::crypto::handshake::{ClientHandshake, KeyGenerator};
use crate::memquota::{CircuitAccount, SpecificAccount as _, StreamAccount};
+use crate::tunnel::TunnelScopedCircId;
use crate::util::SinkExt as _;
use crate::util::err::ReactorError;
use crate::util::notify::NotifySender;
@@ -81,8 +80,8 @@ use {
use {
super::conflux::ConfluxMsgHandler,
super::conflux::{ConfluxAction, OooRelayMsg},
- crate::client::TunnelId,
crate::client::reactor::RemoveLegReason,
+ crate::tunnel::TunnelId,
};
pub(super) use circhop::{CircHop, CircHopList};
@@ -334,7 +333,7 @@ impl Circuit {
// TODO-CGO: Take HopSettings instead of CircParams.
// (Do this after we've got the virtual-hop refactorings done for
// virtual extending.)
- params: &crate::circuit::CircParameters,
+ params: &crate::client::circuit::CircParameters,
done: ReactorResultChannel<()>,
) {
use tor_protover::{Protocols, named};
@@ -350,7 +349,7 @@ impl Circuit {
let settings = HopSettings::from_params_and_caps(
// This is for testing only, so we'll assume full negotiation took place.
- crate::circuit::HopNegotiationType::Full,
+ crate::client::circuit::HopNegotiationType::Full,
params,
&[named::FLOWCTRL_CC].into_iter().collect::<Protocols>(),
)
@@ -798,7 +797,7 @@ impl Circuit {
use tor_error::into_internal;
use tor_log_ratelim::log_ratelim;
- use crate::{circuit::CIRCUIT_BUFFER_SIZE, client::reactor::StreamReqInfo};
+ use crate::client::{circuit::CIRCUIT_BUFFER_SIZE, reactor::StreamReqInfo};
// We need to construct this early so that we don't double-borrow &mut self
diff --git a/crates/tor-proto/src/client/reactor/circuit/circhop.rs b/crates/tor-proto/src/client/reactor/circuit/circhop.rs
index 34fb76534..298b4da2f 100644
--- a/crates/tor-proto/src/client/reactor/circuit/circhop.rs
+++ b/crates/tor-proto/src/client/reactor/circuit/circhop.rs
@@ -2,9 +2,7 @@
use super::CircuitCmd;
use super::{CloseStreamBehavior, SEND_WINDOW_INIT, SendRelayCell};
-use crate::circuit::HopSettings;
-use crate::client::TunnelScopedCircId;
-use crate::client::circuit::StreamMpscReceiver;
+use crate::client::circuit::{HopSettings, StreamMpscReceiver};
use crate::client::stream::queue::StreamQueueSender;
use crate::client::stream::{
AnyCmdChecker, DrainRateRequest, StreamFlowControl, StreamRateLimit, StreamStatus,
@@ -15,6 +13,7 @@ use crate::client::streammap::{
use crate::congestion::CongestionControl;
use crate::congestion::sendme;
use crate::crypto::cell::HopNum;
+use crate::tunnel::TunnelScopedCircId;
use crate::util::notify::NotifySender;
use crate::{Error, Result};
diff --git a/crates/tor-proto/src/client/reactor/circuit/extender.rs b/crates/tor-proto/src/client/reactor/circuit/extender.rs
index 0a88a9555..b30ad91ec 100644
--- a/crates/tor-proto/src/client/reactor/circuit/extender.rs
+++ b/crates/tor-proto/src/client/reactor/circuit/extender.rs
@@ -1,13 +1,13 @@
//! Module providing [`CircuitExtender`].
use super::{Circuit, ReactorResultChannel};
-use crate::circuit::HopSettings;
-use crate::circuit::handshake::HandshakeRole;
-use crate::client::TunnelScopedCircId;
+use crate::client::circuit::HopSettings;
+use crate::client::circuit::handshake::HandshakeRole;
use crate::client::reactor::MetaCellDisposition;
use crate::crypto::cell::HopNum;
use crate::crypto::handshake::fast::CreateFastClient;
use crate::crypto::handshake::ntor_v3::NtorV3Client;
+use crate::tunnel::TunnelScopedCircId;
use crate::{Error, Result};
use crate::{HopLocation, congestion};
use oneshot_fused_workaround as oneshot;
diff --git a/crates/tor-proto/src/client/reactor/conflux.rs b/crates/tor-proto/src/client/reactor/conflux.rs
index aeaa0a7d4..29d6b1ba3 100644
--- a/crates/tor-proto/src/client/reactor/conflux.rs
+++ b/crates/tor-proto/src/client/reactor/conflux.rs
@@ -22,11 +22,13 @@ use tor_cell::relaycell::{AnyRelayMsgOuter, RelayCmd};
use tor_error::{Bug, bad_api_usage, internal};
use tor_linkspec::HasRelayIds as _;
-use crate::circuit::path::HopDetail;
-use crate::circuit::{TunnelMutableState, UniqId};
+use crate::circuit::UniqId;
+use crate::client::circuit::TunnelMutableState;
+use crate::client::circuit::path::HopDetail;
use crate::client::reactor::circuit::ConfluxStatus;
-use crate::client::{TunnelId, streammap};
+use crate::client::streammap;
use crate::crypto::cell::HopNum;
+use crate::tunnel::TunnelId;
use crate::util::err::ReactorError;
use super::circuit::CircHop;
diff --git a/crates/tor-proto/src/client/reactor/control.rs b/crates/tor-proto/src/client/reactor/control.rs
index 1ed358acd..6ed91250f 100644
--- a/crates/tor-proto/src/client/reactor/control.rs
+++ b/crates/tor-proto/src/client/reactor/control.rs
@@ -6,9 +6,8 @@ use super::{
RunOnceCmdInner, SendRelayCell,
};
use crate::Result;
-use crate::circuit::HopSettings;
use crate::client::circuit::celltypes::CreateResponse;
-use crate::client::circuit::path;
+use crate::client::circuit::{HopSettings, path};
use crate::client::reactor::circuit::circ_extensions_from_settings;
use crate::client::reactor::{NoJoinPointError, NtorClient, ReactorError};
use crate::client::stream::queue::StreamQueueSender;
@@ -20,7 +19,7 @@ use crate::crypto::handshake::ntor_v3::{NtorV3Client, NtorV3PublicKey};
use crate::util::notify::NotifySender;
use crate::util::skew::ClockSkew;
#[cfg(test)]
-use crate::{circuit::CircParameters, circuit::UniqId, crypto::cell::HopNum};
+use crate::{circuit::UniqId, client::circuit::CircParameters, crypto::cell::HopNum};
use postage::watch;
use tor_cell::chancell::msg::HandshakeType;
use tor_cell::relaycell::flow_ctrl::XonKbpsEwma;
diff --git a/crates/tor-proto/src/client/stream/incoming.rs b/crates/tor-proto/src/client/stream/incoming.rs
index de5159f4e..a4e6040ff 100644
--- a/crates/tor-proto/src/client/stream/incoming.rs
+++ b/crates/tor-proto/src/client/stream/incoming.rs
@@ -3,8 +3,8 @@
use bitvec::prelude::*;
use super::{AnyCmdChecker, DataStream, StreamStatus};
-use crate::circuit::ClientCircSyncView;
use crate::client::StreamComponents;
+use crate::client::circuit::ClientCircSyncView;
use crate::client::reactor::CloseStreamBehavior;
use crate::{Error, Result};
use derive_deftly::Deftly;