/ crates / tor-socksproto / src / lib.rs
lib.rs
 1  #![cfg_attr(docsrs, feature(doc_auto_cfg, doc_cfg))]
 2  #![doc = include_str!("../README.md")]
 3  // @@ begin lint list maintained by maint/add_warning @@
 4  #![allow(renamed_and_removed_lints)] // @@REMOVE_WHEN(ci_arti_stable)
 5  #![allow(unknown_lints)] // @@REMOVE_WHEN(ci_arti_nightly)
 6  #![warn(missing_docs)]
 7  #![warn(noop_method_call)]
 8  #![warn(unreachable_pub)]
 9  #![warn(clippy::all)]
10  #![deny(clippy::await_holding_lock)]
11  #![deny(clippy::cargo_common_metadata)]
12  #![deny(clippy::cast_lossless)]
13  #![deny(clippy::checked_conversions)]
14  #![warn(clippy::cognitive_complexity)]
15  #![deny(clippy::debug_assert_with_mut_call)]
16  #![deny(clippy::exhaustive_enums)]
17  #![deny(clippy::exhaustive_structs)]
18  #![deny(clippy::expl_impl_clone_on_copy)]
19  #![deny(clippy::fallible_impl_from)]
20  #![deny(clippy::implicit_clone)]
21  #![deny(clippy::large_stack_arrays)]
22  #![warn(clippy::manual_ok_or)]
23  #![deny(clippy::missing_docs_in_private_items)]
24  #![warn(clippy::needless_borrow)]
25  #![warn(clippy::needless_pass_by_value)]
26  #![warn(clippy::option_option)]
27  #![deny(clippy::print_stderr)]
28  #![deny(clippy::print_stdout)]
29  #![warn(clippy::rc_buffer)]
30  #![deny(clippy::ref_option_ref)]
31  #![warn(clippy::semicolon_if_nothing_returned)]
32  #![warn(clippy::trait_duplication_in_bounds)]
33  #![deny(clippy::unchecked_duration_subtraction)]
34  #![deny(clippy::unnecessary_wraps)]
35  #![warn(clippy::unseparated_literal_suffix)]
36  #![deny(clippy::unwrap_used)]
37  #![deny(clippy::mod_module_files)]
38  #![allow(clippy::let_unit_value)] // This can reasonably be done for explicitness
39  #![allow(clippy::uninlined_format_args)]
40  #![allow(clippy::significant_drop_in_scrutinee)] // arti/-/merge_requests/588/#note_2812945
41  #![allow(clippy::result_large_err)] // temporary workaround for arti#587
42  #![allow(clippy::needless_raw_string_hashes)] // complained-about code is fine, often best
43  #![allow(clippy::needless_lifetimes)] // See arti#1765
44  //! <!-- @@ end lint list maintained by maint/add_warning @@ -->
45  
46  mod err;
47  mod handshake;
48  mod msg;
49  
50  pub use err::Error;
51  pub use handshake::Action;
52  
53  #[cfg(feature = "proxy-handshake")]
54  #[cfg_attr(docsrs, doc(cfg(feature = "proxy-handshake")))]
55  pub use handshake::proxy::SocksProxyHandshake;
56  
57  #[cfg(feature = "client-handshake")]
58  #[cfg_attr(docsrs, doc(cfg(feature = "client-handshake")))]
59  pub use handshake::client::SocksClientHandshake;
60  
61  #[cfg(any(feature = "proxy-handshake", feature = "client-handshake"))]
62  #[cfg_attr(
63      docsrs,
64      doc(cfg(any(feature = "proxy-handshake", feature = "client-handshake")))
65  )]
66  pub use handshake::framework::{
67      Buffer, Finished, Handshake, NextStep, PreciseReads, ReadPrecision, RecvStep,
68  };
69  
70  #[deprecated(since = "0.5.2", note = "Use SocksProxyHandshake instead.")]
71  #[cfg(feature = "proxy-handshake")]
72  #[cfg_attr(docsrs, doc(cfg(feature = "proxy-handshake")))]
73  pub use SocksProxyHandshake as SocksHandshake;
74  
75  pub use msg::{
76      SocksAddr, SocksAuth, SocksCmd, SocksHostname, SocksReply, SocksRequest, SocksStatus,
77      SocksVersion,
78  };
79  pub use tor_error::Truncated;
80  
81  /// A Result type for the tor_socksproto crate.
82  pub type Result<T> = std::result::Result<T, Error>;
83  
84  /// A Result type for the tor_socksproto crate, including the possibility of a
85  /// truncated message.
86  ///
87  /// This is a separate type from Result because a truncated message is not a
88  /// true error: it just means that you need to read more bytes and try again.
89  pub type TResult<T> = std::result::Result<Result<T>, Truncated>;
90  
91  /// Suggested buffer length for socks handshakes.
92  //
93  // Note: This is chosen somewhat arbitrarily,
94  // to be large enough for any SOCKS handshake Tor will ever want to consume.
95  pub const SOCKS_BUF_LEN: usize = 1024;