#![doc = include_str!("../../../../README.md")]
#![allow(renamed_and_removed_lints)] #![allow(unknown_lints)] #![allow(clippy::cognitive_complexity)] #![allow(clippy::collapsible_if)] #![allow(clippy::let_unit_value)] #![allow(clippy::needless_lifetimes)] #![allow(clippy::needless_raw_string_hashes)] #![allow(clippy::result_large_err)] #![allow(clippy::significant_drop_in_scrutinee)] #![allow(clippy::uninlined_format_args)]
#![allow(mismatched_lifetime_syntaxes)] #![warn(noop_method_call)]
#![warn(unreachable_pub)]
#![warn(clippy::manual_ok_or)]
#![warn(clippy::needless_borrow)]
#![warn(clippy::needless_pass_by_value)]
#![warn(clippy::option_option)]
#![warn(clippy::rc_buffer)]
#![warn(clippy::semicolon_if_nothing_returned)]
#![warn(clippy::trait_duplication_in_bounds)]
#![warn(clippy::unseparated_literal_suffix)]
#![deny(clippy::all)]
#![deny(clippy::await_holding_lock)]
#![deny(clippy::cargo_common_metadata)]
#![deny(clippy::cast_lossless)]
#![deny(clippy::checked_conversions)]
#![deny(clippy::debug_assert_with_mut_call)]
#![deny(clippy::exhaustive_enums)]
#![deny(clippy::exhaustive_structs)]
#![deny(clippy::expl_impl_clone_on_copy)]
#![deny(clippy::fallible_impl_from)]
#![deny(clippy::implicit_clone)]
#![deny(clippy::large_stack_arrays)]
#![deny(missing_docs)]
#![deny(clippy::missing_docs_in_private_items)]
#![deny(clippy::mod_module_files)]
#![deny(clippy::print_stderr)]
#![deny(clippy::print_stdout)]
#![deny(clippy::ref_option_ref)]
#![deny(clippy::string_slice)] #![deny(clippy::unchecked_time_subtraction)]
#![deny(clippy::unnecessary_wraps)]
#![deny(clippy::unused_async)]
#![deny(clippy::unwrap_used)]
#![deny(clippy::pedantic)] #[doc(hidden)]
pub use derive_deftly;
use derive_deftly::Deftly;
use thiserror::Error;
mod macros;
#[derive(Debug, Error)]
#[non_exhaustive]
#[allow(unused)] pub enum ExtOrPortError {
#[error("The stream is `None`. Therefore, we cannot receive the server's reply")]
StreamMissing,
#[error("AuthTypes is greater than limit:{0}")]
AuthTypesTooMuch(String),
#[error("Invalid StaticHeader it should be \"! Extended ORPort Auth Cookie !\x0a\"")]
InvalidStaticHeader,
#[error("Unsupported auth types: {0}")]
UnsupportedAuthTypes(String),
#[error("server closed the connection during the ExtOrPort handshake: {0}")]
ServerClosedConnection(String),
#[error("Invalid USERADDR: {0}")]
InvalidUserAddr(String),
#[error("EndAuthTypeUnfound")]
EndAuthTypeUnfoundWithCandidates(Vec<u8>),
#[error("EndAuthTypeUnfound")]
EndAuthTypeUnfound,
#[error("Invalid Server Message: {0}")]
InvalidServerMsg(String),
#[error("Invalid server hash")]
InvalidServerHash,
#[error("Insufficient cookie file length")]
InsufficientCookieFile,
#[error("Server sent a message which indicates that Client hash validation failed")]
InvalidClientHash,
#[error("PT name is longer than 65535 bytes: {0}")]
PtNameTooLong(String),
#[error(transparent)]
Io(#[from] std::io::Error),
#[error(transparent)]
Other(#[from] anyhow::Error),
}
#[derive(Debug, Error, Deftly)]
#[derive_deftly(OtherFromError)]
#[non_exhaustive]
pub enum PtError {
#[error("Config poisoned: {0}")]
PtConfigPoisoned(String),
#[error("ORPort and ExtORPort are only provided by a server-side Tor")]
ClientOrPortUnavailable,
#[error("PtNotInitialized {0}")]
PtNotInitialized(String),
#[error("ExtOrPort unfound {0}")]
ExtOrPortNotAvailable(String),
#[error("ExtOrPortError: {0}")]
ExtOrPort(#[from] ExtOrPortError),
#[error("Connection is not ExtOrPort or not inited: {0}")]
NotExtOrPort(String),
#[error("Connection is not OrPort or not inited: {0}")]
NotOrPort(String),
#[error("Not in server: {0}")]
NotInServer(String),
#[error("Not in client: {0}")]
NotInClient(String),
#[error("{0}")]
Other(String),
}
#[derive(Debug, Error, PartialEq, Deftly)]
#[derive_deftly(OtherFromError)]
#[non_exhaustive]
pub enum ConfigError {
#[error("Invalid Config: {message}")]
InvalidConfigErr {
message: String,
},
#[error("Unsupported Version {message}")]
UnsupportedVer {
message: String,
},
#[error("Error: {0}")]
Other(String),
}
#[derive(Debug, Error, PartialEq)]
#[non_exhaustive]
pub enum VariantError {
#[error("Variant Unfound {message}")]
UnfoundError {
message: String,
},
}
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum SocksError {
#[error("unsupported CMD: {0:?}")]
CommandNotSupported(Option<u8>),
#[error("unsupported ATYP: {0:?}")]
AddrTypeNotSupported(Option<u8>),
#[error("RSV must be 0x00, got {0:?}")]
BadReserved(Option<u8>),
#[error("Socks connection setting poisoned: {0}")]
PoisonedSetting(String),
#[error("Socks version unfound from the setting")]
SocksVerUnfound,
#[error("Version does not match with before")]
SocksVerNoMatching,
#[error("There is not supported auth_methods")]
NoSupportedAuthMethod,
#[error("Socks message has invalid format: {0}")]
InvalidFormMsg(String),
#[error("unsupported socks version")]
UnsupportedVersion,
#[error("variant error")]
VariantError(#[from] VariantError),
#[error("std io error: {0}")]
Io(#[from] std::io::Error),
#[error("Error: {0}")]
Other(#[from] anyhow::Error),
}