blob: 5ab8edf21342cd4425be1119f67dc0d322c45fa2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
//! Tor stream handling.
//!
//! A stream is an anonymized conversation; multiple streams can be
//! multiplexed over a single circuit.
pub(crate) mod cmdcheck;
pub(crate) mod flow_ctrl;
#[cfg(any(feature = "hs-service", feature = "relay"))]
pub(crate) mod incoming;
pub(crate) mod queue;
use tor_cell::relaycell::msg::End;
use tor_memquota::mq_queue::{self, MpscSpec};
/// MPSC queue relating to a stream (either inbound or outbound), sender
pub(crate) type StreamMpscSender<T> = mq_queue::Sender<T, MpscSpec>;
/// MPSC queue relating to a stream (either inbound or outbound), receiver
pub(crate) type StreamMpscReceiver<T> = mq_queue::Receiver<T, MpscSpec>;
/// A behavior to perform when closing a stream.
///
/// We don't use `Option<End>` here, since the behavior of `SendNothing` is so surprising
/// that we shouldn't let it pass unremarked.
#[derive(Clone, Debug)]
pub(crate) enum CloseStreamBehavior {
/// Send nothing at all, so that the other side will not realize we have
/// closed the stream.
///
/// We should only do this for incoming onion service streams when we
/// want to black-hole the client's requests.
SendNothing,
/// Send an End cell, if we haven't already sent one.
SendEnd(End),
}
impl Default for CloseStreamBehavior {
fn default() -> Self {
Self::SendEnd(End::new_misc())
}
}
|