use thiserror::Error;
use tor_linkspec::ChannelMethod;
#[derive(Error, Clone, Debug)]
#[non_exhaustive]
pub enum BridgeParseError {
#[cfg(feature = "bridge-client")]
#[error("Bridge line was empty")]
Empty,
#[cfg(feature = "bridge-client")]
#[error("Cannot parse {word:?} as PT name ({pt_error}), nor as direct bridge IpAddress:ORPort")]
InvalidPtOrAddr {
word: String,
pt_error: tor_linkspec::TransportIdError,
},
#[cfg(feature = "bridge-client")]
#[error(
"Cannot parse {word:?} as direct bridge IpAddress:ORPort ({addr_error}), nor as PT name"
)]
InvalidIpAddrOrPt {
word: String,
addr_error: std::net::AddrParseError,
},
#[cfg(feature = "pt-client")]
#[error("Cannot parse {word:?} as pluggable transport Host:ORPort")]
InvalidIPtHostAddr {
word: String,
#[source]
source: tor_linkspec::BridgeAddrError,
},
#[cfg(feature = "bridge-client")]
#[error("Cannot parse {word:?} as identity key ({id_error}), or PT key=value")]
InvalidIdentityOrParameter {
word: String,
id_error: tor_linkspec::RelayIdError,
},
#[cfg(feature = "pt-client")]
#[error("Expected PT key=value parameter, found {word:?} (which lacks an equals sign)")]
InvalidPtKeyValue {
word: String,
},
#[cfg(feature = "pt-client")]
#[error("Cannot parse {word:?} as a PT key=value parameter")]
InvalidPluggableTransportSetting {
word: String,
#[source]
source: tor_linkspec::PtTargetInvalidSetting,
},
#[cfg(feature = "bridge-client")]
#[error("More than one identity of the same type specified, at {word:?}")]
MultipleIdentitiesOfSameType {
word: String,
},
#[cfg(feature = "bridge-client")]
#[error("Identity specified but not of supported type, at {word:?}")]
UnsupportedIdentityType {
word: String,
},
#[error("Channel method specified but not of supported type ({method:?})")]
UnsupportedChannelMethod {
method: Box<ChannelMethod>,
},
#[cfg(feature = "bridge-client")]
#[error("Parameters supplied but not valid without a pluggable transport")]
DirectParametersNotAllowed,
#[cfg(feature = "bridge-client")]
#[error("Bridge line lacks specification of RSA identity key")]
NoRsaIdentity,
#[cfg(feature = "bridge-client")]
#[error(
"Pluggable transport requested ({word:?} is not an IpAddress:ORPort), but support disabled in cargo features"
)]
PluggableTransportsNotSupported {
word: String,
},
#[error("Bridge requested, but support disabled in cargo features")]
BridgesNotSupported,
}