Merge branch 'todos-chanmgr' into 'main'
chanmgr: resolve several remaining "TODO pt-client" issues See merge request tpo/core/arti!897
This commit is contained in:
commit
7ef9dde99c
|
@ -110,7 +110,7 @@ pub enum Error {
|
|||
#[error("Channel request cancelled or superseded")]
|
||||
RequestCancelled,
|
||||
|
||||
/// We tried to create a channel with
|
||||
/// We tried to create a channel through a proxy, and encountered an error.
|
||||
#[error("Problem while connecting to Tor via a proxy")]
|
||||
Proxy(#[from] ProxyError),
|
||||
|
||||
|
|
|
@ -160,7 +160,7 @@ impl ChannelFactory for CompoundFactory {
|
|||
Some(mgr) => mgr
|
||||
.factory_for_transport(a.transport())
|
||||
.await
|
||||
.expect("TODO pt-client")
|
||||
.map_err(|e| crate::Error::Pt(e))?
|
||||
.ok_or_else(|| crate::Error::NoSuchTransport(a.transport().clone().into()))?,
|
||||
None => return Err(crate::Error::NoSuchTransport(a.transport().clone().into())),
|
||||
},
|
||||
|
|
|
@ -158,8 +158,6 @@ impl<CF: AbstractChannelFactory + Clone> AbstractChanMgr<CF> {
|
|||
) -> Result<(CF::Channel, ChanProvenance)> {
|
||||
use ChannelUsage as CU;
|
||||
|
||||
// TODO pt-client: This is not yet used.
|
||||
|
||||
let chan = self.get_or_launch_internal(target).await?;
|
||||
|
||||
match usage {
|
||||
|
|
|
@ -69,8 +69,10 @@ pub(crate) async fn connect_via_proxy<R: TcpProvider + Send + Sync>(
|
|||
protocol: &Protocol,
|
||||
target: &BridgeAddr,
|
||||
) -> Result<R::TcpStream, ProxyError> {
|
||||
// a different error type would be better TODO pt-client
|
||||
let mut stream = runtime.connect(proxy).await?;
|
||||
let mut stream = runtime
|
||||
.connect(proxy)
|
||||
.await
|
||||
.map_err(|e| ProxyError::ProxyConnect(Arc::new(e)))?;
|
||||
|
||||
let Protocol::Socks(version, auth) = protocol;
|
||||
|
||||
|
@ -161,7 +163,11 @@ pub(crate) async fn connect_via_proxy<R: TcpProvider + Send + Sync>(
|
|||
#[derive(Clone, Debug, thiserror::Error)]
|
||||
#[non_exhaustive]
|
||||
pub enum ProxyError {
|
||||
/// We had an IO error while talking to the proxy
|
||||
/// We had an IO error while trying to open a connection to the proxy.
|
||||
#[error("Problem while connecting to proxy")]
|
||||
ProxyConnect(#[source] Arc<std::io::Error>),
|
||||
|
||||
/// We had an IO error while talking to the proxy.
|
||||
#[error("Problem while communicating with proxy")]
|
||||
ProxyIo(#[source] Arc<std::io::Error>),
|
||||
|
||||
|
@ -214,7 +220,7 @@ impl tor_error::HasKind for ProxyError {
|
|||
use tor_error::ErrorKind as EK;
|
||||
use ProxyError as E;
|
||||
match self {
|
||||
E::ProxyIo(_) => EK::LocalNetworkError,
|
||||
E::ProxyConnect(_) | E::ProxyIo(_) => EK::LocalNetworkError,
|
||||
E::InvalidSocksAddr(_) | E::InvalidSocksRequest(_) => EK::BadApiUsage,
|
||||
E::UnrecognizedAddr => EK::NotImplemented,
|
||||
E::SocksProto(_) => EK::LocalProtocolViolation,
|
||||
|
@ -231,7 +237,7 @@ impl tor_error::HasRetryTime for ProxyError {
|
|||
use ProxyError as E;
|
||||
use SocksStatus as S;
|
||||
match self {
|
||||
E::ProxyIo(_) => RT::AfterWaiting,
|
||||
E::ProxyConnect(_) | E::ProxyIo(_) => RT::AfterWaiting,
|
||||
E::InvalidSocksAddr(_) => RT::Never,
|
||||
E::UnrecognizedAddr => RT::Never,
|
||||
E::InvalidSocksRequest(_) => RT::Never,
|
||||
|
|
Loading…
Reference in New Issue