Loading crates/tor-dirmgr/src/lib.rs +15 −3 Original line number Diff line number Diff line Loading @@ -429,12 +429,24 @@ impl<R: Runtime> DirMgr<R> { return Ok(()); } let params_changed = new_config.override_net_params() != config.override_net_params(); self.config .map_and_replace(|cfg| cfg.update_config(new_config)); // TODO(nickm): If the override_net_params field has changed, we should // update it on our current netdir and tell everybody who cares that // there is a new netdir. if params_changed { let _ignore_err = self.netdir.mutate(|netdir| { netdir.replace_overridden_parameters(new_config.override_net_params()); Ok(()) }); // (It's okay to ignore the error, since it just means that there // was no current netdir.) self.netdir_consensus_changed.store(true, Ordering::SeqCst); // TODO(nickm): need to make sure that notify gets called. But // first I should probably refactor notify() to be more like the // backend for tor-events. } Ok(()) } Loading crates/tor-dirmgr/src/state.rs +4 −1 Original line number Diff line number Diff line Loading @@ -541,9 +541,12 @@ impl<DM: WriteNetDir> GetMicrodescsState<DM> { fn consider_upgrade(&mut self) -> bool { if let Some(p) = self.partial.take() { match p.unwrap_if_sufficient() { Ok(netdir) => { Ok(mut netdir) => { self.reset_time = pick_download_time(netdir.lifetime()); if let Some(wd) = Weak::upgrade(&self.writedir) { // We re-set the parameters here, in case they have been // reconfigured. netdir.replace_overridden_parameters(wd.config().override_net_params()); wd.netdir().replace(netdir); wd.netdir_consensus_changed(); wd.netdir_descriptors_changed(); Loading crates/tor-netdir/src/lib.rs +18 −0 Original line number Diff line number Diff line Loading @@ -421,6 +421,7 @@ impl PartialNetDir { } loaded } /// Return true if this are enough information in this directory /// to build multihop paths. pub fn have_enough_paths(&self) -> bool { Loading Loading @@ -500,6 +501,23 @@ impl NetDir { }; UncheckedRelay { rs, md } } /// Replace the overridden parameters in this netdir with `new_replacement`. /// /// After this function is done, the netdir's parameters will be those in /// the consensus, overridden by settings from `new_replacement`. Any /// settings in the old replacement parameters will be discarded. pub fn replace_overridden_parameters(&mut self, new_replacement: &netstatus::NetParams<i32>) { // TODO(nickm): This is largely duplicate code from PartialNetDir::new(). let mut new_params = NetParameters::default(); let _ = new_params.saturating_update(self.consensus.params().iter()); for u in new_params.saturating_update(new_replacement.iter()) { warn!("Unrecognized option: override_net_params.{}", u); } self.params = new_params; } /// Return an iterator over all Relay objects, including invalid ones /// that we can't use. pub fn all_relays(&self) -> impl Iterator<Item = UncheckedRelay<'_>> { Loading Loading
crates/tor-dirmgr/src/lib.rs +15 −3 Original line number Diff line number Diff line Loading @@ -429,12 +429,24 @@ impl<R: Runtime> DirMgr<R> { return Ok(()); } let params_changed = new_config.override_net_params() != config.override_net_params(); self.config .map_and_replace(|cfg| cfg.update_config(new_config)); // TODO(nickm): If the override_net_params field has changed, we should // update it on our current netdir and tell everybody who cares that // there is a new netdir. if params_changed { let _ignore_err = self.netdir.mutate(|netdir| { netdir.replace_overridden_parameters(new_config.override_net_params()); Ok(()) }); // (It's okay to ignore the error, since it just means that there // was no current netdir.) self.netdir_consensus_changed.store(true, Ordering::SeqCst); // TODO(nickm): need to make sure that notify gets called. But // first I should probably refactor notify() to be more like the // backend for tor-events. } Ok(()) } Loading
crates/tor-dirmgr/src/state.rs +4 −1 Original line number Diff line number Diff line Loading @@ -541,9 +541,12 @@ impl<DM: WriteNetDir> GetMicrodescsState<DM> { fn consider_upgrade(&mut self) -> bool { if let Some(p) = self.partial.take() { match p.unwrap_if_sufficient() { Ok(netdir) => { Ok(mut netdir) => { self.reset_time = pick_download_time(netdir.lifetime()); if let Some(wd) = Weak::upgrade(&self.writedir) { // We re-set the parameters here, in case they have been // reconfigured. netdir.replace_overridden_parameters(wd.config().override_net_params()); wd.netdir().replace(netdir); wd.netdir_consensus_changed(); wd.netdir_descriptors_changed(); Loading
crates/tor-netdir/src/lib.rs +18 −0 Original line number Diff line number Diff line Loading @@ -421,6 +421,7 @@ impl PartialNetDir { } loaded } /// Return true if this are enough information in this directory /// to build multihop paths. pub fn have_enough_paths(&self) -> bool { Loading Loading @@ -500,6 +501,23 @@ impl NetDir { }; UncheckedRelay { rs, md } } /// Replace the overridden parameters in this netdir with `new_replacement`. /// /// After this function is done, the netdir's parameters will be those in /// the consensus, overridden by settings from `new_replacement`. Any /// settings in the old replacement parameters will be discarded. pub fn replace_overridden_parameters(&mut self, new_replacement: &netstatus::NetParams<i32>) { // TODO(nickm): This is largely duplicate code from PartialNetDir::new(). let mut new_params = NetParameters::default(); let _ = new_params.saturating_update(self.consensus.params().iter()); for u in new_params.saturating_update(new_replacement.iter()) { warn!("Unrecognized option: override_net_params.{}", u); } self.params = new_params; } /// Return an iterator over all Relay objects, including invalid ones /// that we can't use. pub fn all_relays(&self) -> impl Iterator<Item = UncheckedRelay<'_>> { Loading