tor-chanmgr: Replace OwnedChanTarget with LoggedChanTarget in errors

This
 1. Makes the errors smaller
 2. Redacts (currently, scrubs) the chantarget when safe logging is enabled

This commit doesn't treat other should-be-sensitive inforemation in
errors just yet.  That will come in a moment.
This commit is contained in:
Ian Jackson 2022-11-23 15:20:01 +00:00
parent 45a79bf725
commit 32357b3de7
2 changed files with 9 additions and 9 deletions

View File

@ -9,7 +9,7 @@ use crate::{event::ChanMgrEventSender, Error};
use std::time::Duration;
use tor_error::internal;
use tor_linkspec::{HasChanMethod, OwnedChanTarget};
use tor_linkspec::{HasChanMethod, IntoOwnedChanTarget, OwnedChanTarget};
use tor_proto::channel::params::ChannelPaddingInstructionsUpdates;
use tor_rtcompat::{tls::TlsConnector, Runtime, TlsProvider};
@ -85,7 +85,7 @@ where
.timeout(delay, connect_future)
.await
.map_err(|_| Error::ChanTimeout {
peer: target.clone(),
peer: target.to_logged(),
})?
}
}
@ -177,7 +177,7 @@ where
.record_handshake_done_with_skewed_clock();
Error::Proto {
source,
peer: using_target,
peer: using_target.to_logged(),
clock_skew,
}
}
@ -185,7 +185,7 @@ where
})?;
let (chan, reactor) = chan.finish().await.map_err(|source| Error::Proto {
source,
peer: target.clone(),
peer: target.to_logged(),
clock_skew,
})?;

View File

@ -8,7 +8,7 @@ use thiserror::Error;
use crate::factory::AbstractPtError;
use tor_error::{internal, ErrorKind};
use tor_linkspec::{ChanTarget, OwnedChanTarget, PtTargetAddr};
use tor_linkspec::{ChanTarget, IntoOwnedChanTarget, LoggedChanTarget, PtTargetAddr};
use tor_proto::ClockSkew;
use crate::transport::proxied::ProxyError;
@ -25,14 +25,14 @@ pub enum Error {
#[error("Pending channel for {peer} failed to launch")]
PendingFailed {
/// Who we were talking to
peer: OwnedChanTarget,
peer: LoggedChanTarget,
},
/// It took too long for us to establish this connection.
#[error("Channel for {peer} timed out")]
ChanTimeout {
/// Who we were trying to talk to
peer: OwnedChanTarget,
peer: LoggedChanTarget,
},
/// A protocol error while making a channel
@ -42,7 +42,7 @@ pub enum Error {
#[source]
source: tor_proto::Error,
/// Who we were trying to talk to
peer: OwnedChanTarget,
peer: LoggedChanTarget,
/// An authenticated ClockSkew (if available) that we received from the
/// peer.
clock_skew: Option<ClockSkew>,
@ -225,7 +225,7 @@ impl Error {
) -> Self {
Error::Proto {
source,
peer: OwnedChanTarget::from_chan_target(peer),
peer: peer.to_logged(),
clock_skew: None,
}
}