Loading Cargo.lock +1 −0 Original line number Diff line number Diff line Loading @@ -3463,6 +3463,7 @@ dependencies = [ "derive_more", "educe", "futures", "humantime 2.1.0", "humantime-serde", "itertools", "pin-project", Loading crates/tor-guardmgr/Cargo.toml +1 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ derive_builder = "0.11" derive_more = "0.99" educe = "0.4.6" futures = "0.3.14" humantime = "2" humantime-serde = "1.1.1" itertools = "0.10.1" pin-project = "1" Loading crates/tor-guardmgr/src/fallback/set.rs +7 −0 Original line number Diff line number Diff line Loading @@ -215,6 +215,13 @@ impl FallbackState { entry.status.clock_skew = Some(observation); } } /// Return an iterator over all the clock skew observations we've made for fallback directories pub(crate) fn skew_observations(&self) -> impl Iterator<Item = &SkewObservation> { self.fallbacks .iter() .filter_map(|fb| fb.status.clock_skew.as_ref()) } } #[cfg(test)] Loading crates/tor-guardmgr/src/guard.rs +6 −0 Original line number Diff line number Diff line Loading @@ -673,6 +673,12 @@ impl Guard { self.clock_skew = Some(observation); } /// Return the most recent clock skew observation for this guard, if we have /// made one. pub(crate) fn skew(&self) -> Option<&SkewObservation> { self.clock_skew.as_ref() } /// Testing only: Return true if this guard was ever contacted successfully. #[cfg(test)] pub(crate) fn confirmed(&self) -> bool { Loading crates/tor-guardmgr/src/lib.rs +17 −0 Original line number Diff line number Diff line Loading @@ -163,6 +163,7 @@ pub use err::{GuardMgrError, PickGuardError}; pub use filter::GuardFilter; pub use ids::FirstHopId; pub use pending::{GuardMonitor, GuardStatus, GuardUsable}; pub use skew::SkewEstimate; use pending::{PendingRequest, RequestId}; use sample::GuardSet; Loading Loading @@ -568,6 +569,14 @@ impl<R: Runtime> GuardMgr<R> { ); } /// Return our best estimate of our current clock skew, based on reports from the /// guards and fallbacks we have contacted. pub fn skew_estimate(&self) -> Option<SkewEstimate> { let inner = self.inner.lock().expect("Poisoned lock"); let now = self.runtime.now(); SkewEstimate::estimate_skew(inner.skew_observations(), now) } /// Ensure that the message queue is flushed before proceeding to /// the next step. Used for testing. #[cfg(test)] Loading Loading @@ -835,6 +844,14 @@ impl GuardMgrInner { } } /// Return an iterator over all of the clock skew observations we've made /// for guards or fallbacks. fn skew_observations(&self) -> impl Iterator<Item = &skew::SkewObservation> { self.fallbacks .skew_observations() .chain(self.guards.active_guards().skew_observations()) } /// If the circuit built because of a given [`PendingRequest`] may /// now be used (or discarded), return `Some(true)` or /// `Some(false)` respectively. Loading Loading
Cargo.lock +1 −0 Original line number Diff line number Diff line Loading @@ -3463,6 +3463,7 @@ dependencies = [ "derive_more", "educe", "futures", "humantime 2.1.0", "humantime-serde", "itertools", "pin-project", Loading
crates/tor-guardmgr/Cargo.toml +1 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ derive_builder = "0.11" derive_more = "0.99" educe = "0.4.6" futures = "0.3.14" humantime = "2" humantime-serde = "1.1.1" itertools = "0.10.1" pin-project = "1" Loading
crates/tor-guardmgr/src/fallback/set.rs +7 −0 Original line number Diff line number Diff line Loading @@ -215,6 +215,13 @@ impl FallbackState { entry.status.clock_skew = Some(observation); } } /// Return an iterator over all the clock skew observations we've made for fallback directories pub(crate) fn skew_observations(&self) -> impl Iterator<Item = &SkewObservation> { self.fallbacks .iter() .filter_map(|fb| fb.status.clock_skew.as_ref()) } } #[cfg(test)] Loading
crates/tor-guardmgr/src/guard.rs +6 −0 Original line number Diff line number Diff line Loading @@ -673,6 +673,12 @@ impl Guard { self.clock_skew = Some(observation); } /// Return the most recent clock skew observation for this guard, if we have /// made one. pub(crate) fn skew(&self) -> Option<&SkewObservation> { self.clock_skew.as_ref() } /// Testing only: Return true if this guard was ever contacted successfully. #[cfg(test)] pub(crate) fn confirmed(&self) -> bool { Loading
crates/tor-guardmgr/src/lib.rs +17 −0 Original line number Diff line number Diff line Loading @@ -163,6 +163,7 @@ pub use err::{GuardMgrError, PickGuardError}; pub use filter::GuardFilter; pub use ids::FirstHopId; pub use pending::{GuardMonitor, GuardStatus, GuardUsable}; pub use skew::SkewEstimate; use pending::{PendingRequest, RequestId}; use sample::GuardSet; Loading Loading @@ -568,6 +569,14 @@ impl<R: Runtime> GuardMgr<R> { ); } /// Return our best estimate of our current clock skew, based on reports from the /// guards and fallbacks we have contacted. pub fn skew_estimate(&self) -> Option<SkewEstimate> { let inner = self.inner.lock().expect("Poisoned lock"); let now = self.runtime.now(); SkewEstimate::estimate_skew(inner.skew_observations(), now) } /// Ensure that the message queue is flushed before proceeding to /// the next step. Used for testing. #[cfg(test)] Loading Loading @@ -835,6 +844,14 @@ impl GuardMgrInner { } } /// Return an iterator over all of the clock skew observations we've made /// for guards or fallbacks. fn skew_observations(&self) -> impl Iterator<Item = &skew::SkewObservation> { self.fallbacks .skew_observations() .chain(self.guards.active_guards().skew_observations()) } /// If the circuit built because of a given [`PendingRequest`] may /// now be used (or discarded), return `Some(true)` or /// `Some(false)` respectively. Loading