summaryrefslogtreecommitdiff
path: root/crates/tor-dirmgr/src/state.rs
Commit message (Collapse)AuthorAgeFilesLines
* Change builder list APIIan Jackson2022-05-041-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | The new API is (roughly) as discussed in https://gitlab.torproject.org/tpo/core/arti/-/issues/451 This is quite a large commit and it is not convenient to split it up. It contains the following changes: * Redo the list builder and accessor macros implemnetation, including docs and tests. * Change uses of define_list_config_builder. In each case: - Move the docs about the default value to the containing field. - Remove the other docs (which were just recapitulations, and are now not needed since the ListBuilder is no longer public). - Rewmove or replace `pub` in the define_list_builder_helper call, so that the builder is no longer public. - Change the main macro call site to use define_list_builder_helper. - Add a call to define_list_builder_accessors. * Make the module `list_builder` pub so that we have somewhere to put the overview documentation. * Consequential changes: - Change `outer.inner().replace(X)` to `outer.set_inner(X)` - Consequential changes to imports (`use` statements).
* Merge branch 'download-schedule' into 'main'Nick Mathewson2022-04-261-9/+9
|\ | | | | | | | | DownloadSchedule: Introduce Builder See merge request tpo/core/arti!473
| * DirMgrConfig: Remove unnecessary accessorsIan Jackson2022-04-261-5/+5
| | | | | | | | | | | | | | These fields are pub. Retain two convenience accessor functions that access sub-fields of network.
| * DirMgrConfig: Rename two fields that contained a _configIan Jackson2022-04-261-1/+1
| | | | | | | | This entire struct is config. This is otiose.
| * DownloadSchedule: Abolish accessors in DownloadScheduleConfigIan Jackson2022-04-261-6/+6
| | | | | | | | We can just make the fields pub(crate).
* | Merge branch 'main' into 'msrv_1_56'Nick Mathewson2022-04-261-11/+7
|\| | | | | | | | | | | # Conflicts: # crates/tor-config/Cargo.toml # crates/tor-dirmgr/src/state.rs # doc/semver_status.md
| * Rename ThingListBuilder::replace (from set)Ian Jackson2022-04-251-2/+2
| | | | | | | | | | As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/471#note_2798024
| * Introduce AuthorityListBuilder in NetworkConfigBuilderIan Jackson2022-04-251-10/+6
| | | | | | | | | | | | | | | | | | NetworkConfigBuilder needs to not contain any validated structs, so that its serde does not expose the validated details. AuthorityListBuilder is what ought to go here - and it contains Vec<AuthorityBuilder>, not Vec<Authority>. As a consequence, many places now deal with AuthorityBuilder, rather than Authority.
* | squash! Bump every crate's edition to 2021.Nick Mathewson2022-04-251-1/+0
|/ | | | | Remove all `use` statements for `TryFrom` and `TryInto`. These are now redundant in Rust 2021.
* fallback list: Introduce and use FallbackListBuilderIan Jackson2022-04-221-1/+1
| | | | | | | | | Now the network fallbacks configuration wants to Deserialize a Vec<FallbackDirBuilder>, rather than validated Vec<FallbackDir>. Methods on FallbackListBuilder are as per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/462#note_2797697 mutatis mutandi for the fact that this struct has only fallbacks in it.
* Treat expired/not-yet-valid directory objects as Errors.Nick Mathewson2022-04-051-16/+9
| | | | | | | | | | | | | Doing this will make us treat caches that send us these objects as not-working, and close circuits to them instead of trying over and over. The case where we add a document from the cache requires special handling: it isn't actually a error to find an expired document in our cache (unless the passage of time itself is erroneous, which is a debatable proposition at best). Fixes #431.
* Merge branch 'no-system-time' into 'main'eta2022-03-301-1/+1
|\ | | | | | | | | | | | | Don't use SystemTime::now() Closes #306 See merge request tpo/core/arti!365
| * remove most usage of SystemTime::nowtrinity-1686a2022-02-251-1/+1
| |
* | Abolish filter::DynFilter in favour of transparent DirFilterIan Jackson2022-03-251-7/+5
| | | | | | | | | | | | | | | | | | | | | | | | There are two reasons why the DynFilter newtype might be needed: 1. To impl Default. But we don't need it to impl Default since we can have an accessor which does the defaulting. 2. To hide the API. But this is usrely an unstable API. Just writing Arc<dyn> gets rid of a lot of unnecessary boilerplate and conversion code.
* | dirmgr: Initial DirFilter code.Nick Mathewson2022-03-241-0/+29
| | | | | | | | | | | | This code sits behind a feature flag, and can be used to modify directories before storing them. This is part of the implementation for #397.
* | dirmgr: Authority: Abolish v3ident accessorIan Jackson2022-03-181-1/+1
| | | | | | | | | | This makes this information crate-private. The crate can reasonably just access it.
* | Merge branch 'md_allocation' into 'main'Nick Mathewson2022-03-171-20/+54
|\ \ | | | | | | | | | | | | | | | | | | Use less space in hashtables for microdescriptors Closes #386 See merge request tpo/core/arti!415
| * | Run rustfmtIan Jackson2022-03-171-5/+6
| | |
| * | GetMicrodescsState: Abolish separate n_missing field inIan Jackson2022-03-171-12/+12
| | |
| * | GetMicrodescsState: Break out with_mdreceiver_for_missingIan Jackson2022-03-171-13/+23
| | |
| * | GetMicrodescsState: Dedupe slightlyIan Jackson2022-03-171-8/+9
| | |
| * | tor-dirmgr: Remove redundant hashtable.Nick Mathewson2022-03-161-22/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | We were using a hashtable to keep track of missing microdescriptor digests. But this information is redundant with the NetDir state, and there's now no longer any performance benefit to keeping a separate copy. Part of #386.
* | | DirMgrConfig: abolish builder; make it transparent and exhaustiveIan Jackson2022-03-161-5/+5
|/ / | | | | | | See rationale in the comment.
* | dirmgr: Call shrink_to_fit on missing-microdesc hashtableNick Mathewson2022-03-101-0/+7
| | | | | | | | | | | | | | | | | | | | This hashtable starts out pretty large, but it can spend most of our runtime (when we aren't downloading) being small. To avoid doing too much work, I've made it so we only call shrink_to_fit twice per consensus: once when we're no longer pending, and once when we're complete. Closes #388.
* | Use RsaIdentity::from_hex() and hex::decode_to_slice in more placesNick Mathewson2022-03-041-2/+1
|/ | | | These aren't critical-path, but they do make the code a little nicer.
* dirmgr::Store.expire_all takes configtharvik2022-02-231-2/+2
|
* dirmgr: add Store traittharvik2022-02-231-16/+24
|
* dirmgr: Remember where netdocs came from.Nick Mathewson2022-02-161-12/+20
| | | | | This isn't complete (see TODO), but it's enough to let us report the right ErrorKind if something fails to parse.
* dirmgr: eliminate StringParsingError.Nick Mathewson2022-02-161-3/+4
| | | | | | | | It had too many possible Kinds depending on what kind of string had failed to parse. I decided to use #[source] here instead of #[from], so that we would have to explicitly convert these errors where they show up.
* dirmgr: HasKind for internal and sqlite errorsNick Mathewson2022-02-161-2/+3
| | | | | At first I had thought that all sqlite errors would be internal, but that's not the case.
* Fix test failure in tor_dirmgr::state::test::get_microdescs_stateNick Mathewson2022-01-271-1/+12
| | | | | | | | | This failure occurred because our tests use canned data to exercise the directory state functionality, and the canned consensus has suddenly become very expired. There are better fixes possible, but this is a minimal one that should get CI working on main again.
* bootstrap reporting: Documentation fixups from review.Nick Mathewson2022-01-191-1/+2
|
* tor-dirmgr: Create a bootstrap-status exporting mechanism.Nick Mathewson2022-01-181-3/+69
| | | | | | | | | | | | | | | | | | | | | | The interface is similar to the one exposed by `arti-client`: it internally uses postage::watch to give a series of events showing when a bootstrap status is changing. Thanks to the existing state/driver separation in the DirMgr design we don't need much new logic: each download state needs to expose (internally) how far along it is in its download, which the bootstrap code passes to the DirMgr if it has changed. I believe that in the long run, we'll probably want to expose more (or different) information here, and we'll want to process it differently. With that in mind, I've made the API for `DirBootstrapStatus` deliberately narrow, so that we can change its of its internal later on without breaking code that depends on it. (The information exposed by this commit is not yet summarized in `arti-client`.) Part of #96.
* Fixup broken doc comment from arti!220eta2022-01-101-1/+1
| | | | That's what I get for blindly trusting @nickm :p
* Merge branch 'ticket_178' into 'main'eta2022-01-101-9/+73
|\ | | | | | | | | | | | | Fix ticket 178: Don't use a NetDir until we have microdescriptors for all of our primary guards. Closes #178 See merge request tpo/core/arti!220
| * Only replace netdir once we have enough guard MDs.Nick Mathewson2022-01-061-9/+73
| | | | | | | | | | | | | | | | This prevents a security-failure condition that could happen if our directory caches don't give us these microdescriptors, but we nevertheless decide that the directory is usable. Closes #178
* | Fix busy-loop when consensus is near expiring.Nick Mathewson2022-01-071-1/+14
|/ | | | | | | | | | | | | | When our current consensus is getting close to being invalid (but it isn't invalid yet), we try to get a new one. So far, so good. But we had a bug: when we went to get a new consensus, we'd see that we had a perfectly fine not-yet-invalid consensus in our cache, reload it, find that it was ready, and continue! This patch fixes our behavior: If we have a usable consensus, then when we reset the bootstrapping process, we ignore any cached consensus. Fixes bug #274.
* tor-dirmgr: retain cache_usage on reset.Nick Mathewson2021-12-161-4/+19
| | | | | | | Previously we didn't retain the value of our cache_usage field when calling reset() from GetMicrodescsState. This resolves an XXXX comment.
* Merge branch 'flag-publish-2' into 'main'eta2021-12-161-5/+3
|\ | | | | | | | | Refactor directory events to use a new FlagPublisher mechanism. See merge request tpo/core/arti!188
| * Refactor directory events to use a FlagPublisher mechanism.Nick Mathewson2021-12-141-5/+3
| | | | | | | | | | | | | | | | This approach tries to preserve the current interface, but uses a counter-based event backend to implement a coalescing stream of events that can be represented as small integers. The advantage here is that publishing events no longer needs to be a blocking operation, since there is no queue to fill up.
* | tor-dirmgr: Warn on a bug case.Nick Mathewson2021-12-161-2/+1
|/ | | | | | | | This warning occurs if we ask for microdescriptors from our local cache, and our cache gives us something we didn't ask for. It shouldn't be possible, so let's warn when it occurs. This patch resolves an XXXX.
* Make override_net_params take effect sooner.Nick Mathewson2021-12-071-1/+4
| | | | | This is still not as soon as I'd like: a real change here will require refactoring DirMgr::notify().
* Make much of DirMgrConfig reconfigurable.Nick Mathewson2021-12-071-8/+10
| | | | | | | | | | We can't change the authorities while in-flight: that would be pretty miserable to implement. Similarly we can't change the cache while in-flight. Everything else should be fair game, though there are a couple of tricky bits. I've tried to document those.
* deglob some enums, use concise iteration syntaxDaniel Eades2021-11-251-1/+1
|
* More typo fixes that I forgot to save :(Nick Mathewson2021-11-241-1/+1
|
* Rename RetryConfig to DownloadSchedule, fold in parallelism.Nick Mathewson2021-11-181-19/+10
|
* Fix typosDimitris Apostolou2021-11-121-1/+1
|
* More tests on tor-dirmgr::stateNick Mathewson2021-11-081-25/+111
| | | | | These test our download schedules, resetting to the original state, and storing downloaded objects.
* Remove one more test println!().Nick Mathewson2021-11-041-1/+0
|
* Remove some dbg!() calls in real code.Nick Mathewson2021-11-021-1/+0
|