1
1
//! Coding and decoding for the cell types that make up Tor's protocol
2
//!
3
//! # Overview
4
//!
5
//! Tor's primary network protocol is oriented around a set of
6
//! messages called "Cells".  They exist at two primary layers of the
7
//! protocol: the channel-cell layer, and the relay-cell layer.
8
//!
9
//! [Channel cells](chancell::ChanCell) are sent between relays, or
10
//! between a client and a relay, over a TLS connection.  Each of them
11
//! encodes a single [Channel Message](chancell::msg::ChanMsg).
12
//! Channel messages can affect the channel itself (such as those used
13
//! to negotiate and authenticate the channel), but more frequently are
14
//! used with respect to a given multi-hop circuit.
15
//!
16
//! Channel message that refer to a circuit do so with a channel-local
17
//! identifier called a [Circuit ID](chancell::CircId).  These
18
//! messages include CREATE2 (used to extend a circuit to a first hop)
19
//! and DESTROY (used to tear down a circuit).  But the most
20
//! frequently used channel message is RELAY, which is used to send a
21
//! message to a given hop along a circuit.
22
//!
23
//! Each RELAY cell is encrypted and decrypted (according to protocols
24
//! not implemented in this crate) until it reaches its target.  When
25
//! it does, it is decoded into a single [Relay
26
//! Message](relaycell::msg::RelayMsg).  Some of these relay messages
27
//! are used to manipulate circuits (e.g., by extending the circuit to
28
//! a new hop); others are used to manipulate anonymous data-streams
29
//! (by creating them, ending them, or sending data); and still others
30
//! are used for protocol-specific purposes (like negotiating with an
31
//! onion service.)
32
//!
33
//! For a list of _most_ of the cell types used in Tor, see
34
//! [tor-spec.txt](https://spec.torproject.org/tor-spec).  Other cell
35
//! types are defined in [rend-spec-v3.txt (for onion
36
//! services)](https://spec.torproject.org/tor-spec) and
37
//! [padding-spec.txt (for padding
38
//! negotiation)](https://spec.torproject.org/padding-spec).
39
//!
40
//! This crate is part of
41
//! [Arti](https://gitlab.torproject.org/tpo/core/arti/), a project to
42
//! implement [Tor](https://www.torproject.org/) in Rust.
43
//!
44
//! # Futureproofing note
45
//!
46
//! There are two pending proposals to remove the one-to-one
47
//! correspondence between relay cells and relay messages.
48
//!
49
//! [Proposal 319](https://gitlab.torproject.org/tpo/core/torspec/-/blob/master/proposals/319-wide-everything.md)
50
//! would add a "RELAY_FRAGMENT" command that would allow larger relay
51
//! messages to span multiple RELAY cells.
52
//!
53
//! [Proposal 325](https://gitlab.torproject.org/tpo/core/torspec/-/blob/master/proposals/325-packed-relay-cells.md),
54
//! on the other hand, would allow multiple relay messages to be
55
//! packed into a single RELAY cell.
56
//!
57
//! The distinction between RelayCell and RelayMsg is meant in part
58
//! to future-proof arti against these proposals if they are adopted.
59

            
60
#![deny(missing_docs)]
61
#![warn(noop_method_call)]
62
#![deny(unreachable_pub)]
63
#![warn(clippy::all)]
64
#![deny(clippy::await_holding_lock)]
65
#![deny(clippy::cargo_common_metadata)]
66
#![deny(clippy::cast_lossless)]
67
#![deny(clippy::checked_conversions)]
68
#![warn(clippy::cognitive_complexity)]
69
#![deny(clippy::debug_assert_with_mut_call)]
70
#![deny(clippy::exhaustive_enums)]
71
#![deny(clippy::exhaustive_structs)]
72
#![deny(clippy::expl_impl_clone_on_copy)]
73
#![deny(clippy::fallible_impl_from)]
74
#![deny(clippy::implicit_clone)]
75
#![deny(clippy::large_stack_arrays)]
76
#![warn(clippy::manual_ok_or)]
77
#![deny(clippy::missing_docs_in_private_items)]
78
#![deny(clippy::missing_panics_doc)]
79
#![warn(clippy::needless_borrow)]
80
#![warn(clippy::needless_pass_by_value)]
81
#![warn(clippy::option_option)]
82
#![warn(clippy::rc_buffer)]
83
#![deny(clippy::ref_option_ref)]
84
#![warn(clippy::semicolon_if_nothing_returned)]
85
#![warn(clippy::trait_duplication_in_bounds)]
86
#![deny(clippy::unnecessary_wraps)]
87
#![warn(clippy::unseparated_literal_suffix)]
88
#![deny(clippy::unwrap_used)]
89

            
90
pub mod chancell;
91
mod err;
92
pub mod relaycell;
93

            
94
pub use err::Error;
95

            
96
/// An error type for this crate.
97
pub type Result<T> = std::result::Result<T, Error>;