1
//! Directory streams
2

            
3
use futures::SinkExt as _;
4
use futures::channel::mpsc;
5
use tor_cell::relaycell::msg::Connected;
6
use tor_proto::stream::IncomingStream;
7

            
8
// TODO(#2570): once we dust settles on the implementation,
9
// we need to factor this out of the client module.
10
use tor_proto::client::stream::DataStream;
11

            
12
/// Handle an incoming directory stream
13
pub(super) async fn handle_begin_dir(
14
    incoming: IncomingStream,
15
    mut begin_dir_tx: mpsc::Sender<tor_proto::Result<DataStream>>,
16
) -> anyhow::Result<()> {
17
    // TODO(relay): we unconditionally accept all BEGIN_DIR requests,
18
    // because we don't currently have configuration options for disabling directory mirroring
19
    // (and we may never do).
20
    //
21
    // See https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/4107#note_3426447
22
    let data = incoming.accept_data(Connected::new_empty()).await;
23
    let _ = begin_dir_tx.send(data).await;
24

            
25
    Ok(())
26
}