Report directory blockage problems from arti-client.

Closes #468.
This commit is contained in:
Nick Mathewson 2022-06-14 10:51:04 -04:00
parent e3dced360b
commit bdcbf1982a
1 changed files with 16 additions and 1 deletions

View File

@ -9,7 +9,7 @@ use futures::{Stream, StreamExt};
use tor_basic_utils::skip_fmt;
use tor_chanmgr::{ConnBlockage, ConnStatus, ConnStatusEvents};
use tor_circmgr::{ClockSkewEvents, SkewEstimate};
use tor_dirmgr::DirBootstrapStatus;
use tor_dirmgr::{DirBlockage, DirBootstrapStatus};
use tracing::debug;
/// Information about how ready a [`crate::TorClient`] is to handle requests.
@ -85,6 +85,10 @@ impl BootstrapStatus {
} else {
Some(Blockage { kind, message })
}
} else if let Some(b) = self.dir_status.blockage(SystemTime::now()) {
let message = b.to_string().into();
let kind = b.into();
Some(Blockage { kind, message })
} else {
None
}
@ -140,6 +144,11 @@ pub enum BlockageKind {
/// successfully with relays and/or from finding a directory that we trust.
#[display(fmt = "Clock is skewed.")]
ClockSkewed,
/// We've encounted some kind of problem downloading directory
/// information, and it doesn't seem to be caused by any particular
/// connection problem.
#[display(fmt = "Can't bootstrap a Tor directory.")]
CantBootstrap,
}
impl From<ConnBlockage> for BlockageKind {
@ -153,6 +162,12 @@ impl From<ConnBlockage> for BlockageKind {
}
}
impl From<DirBlockage> for BlockageKind {
fn from(_: DirBlockage) -> Self {
BlockageKind::CantBootstrap
}
}
impl fmt::Display for BootstrapStatus {
/// Format this [`BootstrapStatus`].
///