summaryrefslogtreecommitdiff
path: root/crates/tor-proto/src/client.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/tor-proto/src/client.rs')
-rw-r--r--crates/tor-proto/src/client.rs53
1 files changed, 2 insertions, 51 deletions
diff --git a/crates/tor-proto/src/client.rs b/crates/tor-proto/src/client.rs
index aebae337b..398cd2e9c 100644
--- a/crates/tor-proto/src/client.rs
+++ b/crates/tor-proto/src/client.rs
@@ -10,14 +10,13 @@ pub(crate) mod reactor;
mod streammap;
use derive_deftly::Deftly;
-use derive_more::Display;
use futures::SinkExt as _;
use oneshot_fused_workaround as oneshot;
use std::net::IpAddr;
use std::pin::Pin;
use std::sync::Arc;
-use std::sync::atomic::{AtomicU64, Ordering};
+use crate::circuit::UniqId;
use crate::client::stream::queue::stream_queue;
use crate::client::stream::xon_xoff::XonXoffReaderCtrl;
use crate::client::stream::{
@@ -29,7 +28,7 @@ use crate::crypto::cell::HopNum;
use crate::memquota::{SpecificAccount as _, StreamAccount};
use crate::util::notify::NotifySender;
use crate::{Error, ResolveError, Result};
-use circuit::{CIRCUIT_BUFFER_SIZE, ClientCirc, Path, StreamMpscSender, UniqId};
+use circuit::{CIRCUIT_BUFFER_SIZE, ClientCirc, Path, StreamMpscSender};
use reactor::{
CtrlCmd, CtrlMsg, FlowCtrlMsg, MetaCellHandler, RECV_WINDOW_INIT, STREAM_READER_BUFFER,
};
@@ -53,54 +52,6 @@ use {
#[cfg(feature = "send-control-msg")]
use msghandler::{MsgHandler, UserMsgHandler};
-/// The unique identifier of a tunnel.
-#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash, Display)]
-#[display("{}", _0)]
-#[cfg_attr(feature = "relay", visibility::make(pub))]
-#[allow(unreachable_pub)] // TODO(#1447): use in ChanMgr's ChannelProvider impl
-pub(crate) struct TunnelId(u64);
-
-impl TunnelId {
- /// Create a new TunnelId.
- ///
- /// # Panics
- ///
- /// Panics if we have exhausted the possible space of u64 IDs.
- pub(crate) fn next() -> TunnelId {
- /// The next unique tunnel ID.
- static NEXT_TUNNEL_ID: AtomicU64 = AtomicU64::new(1);
- let id = NEXT_TUNNEL_ID.fetch_add(1, Ordering::Relaxed);
- assert!(id != 0, "Exhausted Tunnel ID space?!");
- TunnelId(id)
- }
-}
-
-/// The identifier of a circuit [`UniqId`] within a tunnel.
-///
-/// This type is only needed for logging purposes: a circuit's [`UniqId`] is
-/// process-unique, but in the logs it's often useful to display the
-/// owning tunnel's ID alongside the circuit identifier.
-#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash, Display)]
-#[display("Circ {}.{}", tunnel_id, circ_id.display_chan_circ())]
-pub(crate) struct TunnelScopedCircId {
- /// The identifier of the owning tunnel
- tunnel_id: TunnelId,
- /// The process-unique identifier of the circuit
- circ_id: UniqId,
-}
-
-impl TunnelScopedCircId {
- /// Create a new [`TunnelScopedCircId`] from the specified identifiers.
- pub(crate) fn new(tunnel_id: TunnelId, circ_id: UniqId) -> Self {
- Self { tunnel_id, circ_id }
- }
-
- /// Return the [`UniqId`].
- pub(crate) fn unique_id(&self) -> UniqId {
- self.circ_id
- }
-}
-
/// Handle to use during an ongoing protocol exchange with a circuit's last hop
///
/// This is obtained from [`ClientTunnel::start_conversation`],