Commit fdd0c264 authored by Nick Mathewson's avatar Nick Mathewson 🤹
Browse files

chanmgr: report target address, not proxy address, in error

Also, change the address type in the error to String for now.
In reality we need a better representation of this error,
but that shouldn't block this.
parent 4c0f60c6
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
BREAKING: The Error type has been refactored; the ChannelBuild variant has
  been renamed to Connect, and Proxy has been removed.
  been renamed to Connect, its members have changed,
  and Proxy has been removed.
 
+4 −2
Original line number Diff line number Diff line
//! Declare error types for tor-chanmgr

use std::net::SocketAddr;
use std::sync::Arc;

use futures::task::SpawnError;
@@ -76,7 +75,10 @@ pub enum Error {
    Connect {
        /// The list of addresses we tried to connect to, coupled with
        /// the error we encountered connecting to each one.
        addresses: Vec<(ChanSensitive<SocketAddr>, ConnectError)>,
        ///
        /// These addresses are currently represented as strings; this
        /// type may change in the future if and when refactor this error type.
        addresses: Vec<(ChanSensitive<String>, ConnectError)>,
    },

    /// Unable to spawn task
+4 −1
Original line number Diff line number Diff line
@@ -158,7 +158,10 @@ async fn connect_to_one<R: Runtime>(
    drop(connections);

    ret.ok_or_else(|| Error::Connect {
        addresses: errors.into_iter().map(|(e, a)| (sv(a), e)).collect(),
        addresses: errors
            .into_iter()
            .map(|(e, a)| (sv(a.to_string()), e))
            .collect(),
    })
}

+2 −2
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ use base64ct::{Base64, Encoding};
use futures::io::{AsyncBufReadExt, BufReader};
use futures::{AsyncReadExt, AsyncWriteExt};
use httparse;
use safelog::Sensitive;
use safelog::{Sensitive, sensitive as sv};
use tor_linkspec::PtTargetAddr;
use tor_rtcompat::NetStreamProvider;
use tor_socksproto::{
@@ -457,7 +457,7 @@ impl<R: NetStreamProvider + Send + Sync> TransportImplHelper for ExternalProxyPl
        };

        let into_err = |e: ProxyError| crate::Error::Connect {
            addresses: vec![(self.proxy_addr.into(), e.into())],
            addresses: vec![(sv(pt_target.to_string()), e.into())],
        };
        let protocol =
            settings_to_protocol(self.proxy_version, encode_settings(pt_target.settings()))