aboutsummaryrefslogtreecommitdiff
path: root/crates/tor-dirmgr
Commit message (Collapse)AuthorAgeFilesLines
...
* tor-dirmgr: make DownloadScheduleBuilder publicIan Jackson2022-05-041-1/+1
| | | | | | This type was returned by the public DownloadSchedule::builder function. But the only thing that seems to have noticed that the type name itself wasn't exported, was rustdoc. Hmmm.
* Change builder list APIIan Jackson2022-05-044-21/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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).
* Rename NetworkConfig.fallback_cachesIan Jackson2022-05-041-8/+8
| | | | | | | | | Previously this field was differently named to its serde and to its accessors. We are about to introduce a macro_rules macro which will provide list accessors and we don't want that macro to have a field renaming feature. So stop renaming the field.
* Merge branch 'derive-builder-git-fixup' into 'main'eta2022-04-271-1/+1
|\ | | | | | | | | derive_builder: Use git dep everywhere, rather than cargo patch See merge request tpo/core/arti!477
| * derive_builder: Use git dep everywhere, rather than cargo patchIan Jackson2022-04-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The `[patch]` approach causes the tree not to build when used as a dependency, unless the `[patch]` is replicated into the depending project. Instead, replace our `derive_builer =` dependencies with a reference to a specific git commit: perl -i~ -pe 'next unless m/^derive_builder/; s#"(0\.11\.2)"#{ version = "$1", git = "https://github.com/ijackson/rust-derive-builder", rev = "ba0c1a5311bd9f93ddf5f5b8ec2a5f6f03b22fbe" }#' crates/*/Cargo.toml Note that the commitid has changed. This is because derive_builder is in fact a workspace of 4 crates. 3 of them are of interest to arti itself (the 4th exists only for testing). So the same "add git revision" treatment had to be done to the `derive_builder` and `derive_builder_macro` crates. Each dependency edge involves a new commit in the derive_builder workspace, since we can't create a git commit containing its own commitid. (We want to use commits, rather than a branch, so that what we are depending on is actually properly defined, and not subject to the whims of my personal github namespace.) There are no actual code changes in derive_builder.
* | Fix grammar and typosSamanta Navarro2022-04-273-3/+3
| |
* | Merge branch 'upgrade_dependencies' into 'main'eta2022-04-271-1/+1
|\ \ | |/ |/| | | | | | | | | Upgrade various dependencies, now that we are MSRV 1.56 Closes #313 and #334 See merge request tpo/core/arti!476
| * Upgrade to Postage 0.5.0Nick Mathewson2022-04-261-1/+1
| |
* | Merge branch 'download-schedule' into 'main'Nick Mathewson2022-04-264-137/+142
|\ \ | |/ |/| | | | | DownloadSchedule: Introduce Builder See merge request tpo/core/arti!473
| * Make DownloadScheduleBuilder "alternative" defaults pub(crate)Ian Jackson2022-04-261-2/+2
| | | | | | | | | | As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/473#note_2798464
| * Fix typo in messageNick Mathewson2022-04-261-1/+1
| |
| * DirMgrConfig: Remove unnecessary accessorsIan Jackson2022-04-263-28/+12
| | | | | | | | | | | | | | 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-262-10/+10
| | | | | | | | This entire struct is config. This is otiose.
| * DownloadSchedule: Rename field to "attempts"Ian Jackson2022-04-261-8/+8
| | | | | | | | | | | | | | This is actually a number of *attempts* not a number of *retries*. The setter method was already called "attempts". This chnages the deserialisation of the config.
| * DownloadSchedule: Abolish accessors in DownloadScheduleConfigIan Jackson2022-04-263-42/+19
| | | | | | | | We can just make the fields pub(crate).
| * DownloadSchudule: Have NetworkConfig contain BuildersIan Jackson2022-04-262-62/+48
| | | | | | | | | | | | | | | | | | | | | | Use sub_builder. We must do something special for defaults. This involves moving the actual default values for retry_bootstrap and retry_microdescs into config.rs, since they need to access the fields of the un-built version of the structure. (An alternative would be to generate "weak setters" which do not override previous settings, but derive_builder does not offer to generate them and that seems overkill.)
| * DownloadSchedule: Abolish new() methodIan Jackson2022-04-262-31/+50
| | | | | | | | | | | | | | | | | | | | Instead, everyone should use DownloadScheduleBuilder. The new() method would in any case be useless in a moment, since we're going to embed DownloadScheduleBuilder in the NetworkConfig, not DownloadSchedule. The call sites in the tests are all about to change again.
| * DownloadSchedule: tests: Do not try to set parallelism to 0Ian Jackson2022-04-262-13/+11
| | | | | | | | | | | | | | | | The current behaviour is to treat 0 as indicating "use the default", which is quite strange. We are going to get rid of that. The new way will be to reject zero, during DownloadScheduleBuilder::build, Add a test case for that.
| * DownloadSchedule: Provide builderIan Jackson2022-04-261-1/+42
| |
* | Merge branch 'main' into 'msrv_1_56'Nick Mathewson2022-04-264-32/+43
|\| | | | | | | | | | | # Conflicts: # crates/tor-config/Cargo.toml # crates/tor-dirmgr/src/state.rs # doc/semver_status.md
| * Document defaults for all the config listsIan Jackson2022-04-251-1/+4
| | | | | | | | | | | | | | And add an imprecation in define_list_config_builder's doc comment do do so in future for other invocations of the macro. Add add the missing full stops.
| * Rename ThingListBuilder::replace (from set)Ian Jackson2022-04-252-4/+4
| | | | | | | | | | As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/471#note_2798024
| * Use better syntax for doc comment attributeIan Jackson2022-04-251-3/+1
| | | | | | | | | | As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/471#note_2798020
| * Introduce AuthorityListBuilder in NetworkConfigBuilderIan Jackson2022-04-254-31/+39
| | | | | | | | | | | | | | | | | | 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.
| * Fix error return type of AuthorityBuilderIan Jackson2022-04-251-0/+2
| |
* | squash! Bump every crate's edition to 2021.Nick Mathewson2022-04-254-4/+0
| | | | | | | | | | Remove all `use` statements for `TryFrom` and `TryInto`. These are now redundant in Rust 2021.
* | Bump every crate's edition to 2021.Nick Mathewson2022-04-251-1/+1
| | | | | | | | | | | | | | | | | | | | This is an automated change made with a perl one-liner and verified with grep -L and grep -l. Some warnings are introduced with this change; they will be removed in subsequent commits. See arti#208 for older discussion on this issue.
* | Add 'rust-version = "1.56"' to every Cargo.toml file.Nick Mathewson2022-04-251-0/+1
| | | | | | | | | | | | | | This change was made automatically with a perl one-liner, and confirmed with `grep -L`. The `rust-version` field itself was introduced in 1.56.0.
* | Reformat all not-yet-reformatted Cargo.toml files.Nick Mathewson2022-04-251-12/+12
|/ | | | | There are no semantic changes here; only formatting. This is in preparation for other changes (wrt MSRV and edition)
* Merge branch 'experimental-v3ident-public' into 'main'Ian Jackson2022-04-251-0/+5
|\ | | | | | | | | Authority: make v3ident public under experimental-api See merge request tpo/core/arti!463
| * Authority: make v3ident public under experimental-apiChristian Grigis2022-04-221-0/+5
| |
* | fallback list: Introduce and use FallbackListBuilderIan Jackson2022-04-222-14/+11
| | | | | | | | | | | | | | | | | | 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.
* | fallback list: Move default list into tor-guardmgrIan Jackson2022-04-222-1729/+2
| | | | | | | | | | | | | | | | | | | | This is where the FallbackList type is. We are going to want to provide a builder too, which ought to impl Default. This means that the default value for the type must be next to the type. In any case, it was anomalous that it wasn't. This commit is pure code motion.
* | Use git source for derive_builder for now, for sub_builder featureIan Jackson2022-04-211-1/+1
|/ | | | | | | | | | | | | | | This commitid is the current head of my MR branch https://github.com/colin-kiegel/rust-derive-builder/pull/253 https://github.com/ijackson/rust-derive-builder/tree/field-builder Using the commitid prevents surprises if that branch is updated. We will require this newer version of derive_builder. The version will need to be bumped again later, assuming the upstream MR is merged and upstream do a release containing the needed changes. We will need the new version of not only `derive_builder_core` (the main macro implementation) but also`derive_builder` for a new error type.
* Fix typosSamanta Navarro2022-04-201-1/+1
| | | | Typos found with codespell.
* Treat expired/not-yet-valid directory objects as Errors.Nick Mathewson2022-04-053-18/+25
| | | | | | | | | | | | | 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.
* Bump all arti*, tor* crates to 0.2.0Nick Mathewson2022-04-011-14/+14
| | | | | | | | Not all of these strictly need to be bumped to 0.2.0; many could go to 0.1.1 instead. But since everything at the tor-rtcompat and higher layers has had breaking API changes, it seems not so useful to distinguish. (It seems unlikely that anybody at this stage is depending on e.g. tor-protover but not arti-client.)
* dirmgr: Use a different idiom in retry loopNick Mathewson2022-03-311-3/+2
| | | | | Replace the next delay field immediately rather than taking it and _then_ setting it. This way, it's never in an incorrect state.
* dirmgr: fix bugs in algorithm for retrying downloadsNick Mathewson2022-03-301-13/+22
| | | | | | | | | | The previous algorithm had two flaws: * It would wait even after the final attempt, when there were no more retries to do. * It would fail to wait between attempts if an error occurred. This refactoring fixes both of these issues, and adds some comments.
* Reformat several Cargo.toml files with 100-char-wide lines.Nick Mathewson2022-03-301-7/+2
|
* Refactor FirstHopId into type-differentiated formNick Mathewson2022-03-301-6/+4
| | | | | | | | | | | The FirstHopId type now records an enum that stores whether the hop is a guard or a fallback. This change addresses concerns about remembering to check the type or source of an Id before passing it down to the FallbackState or GuardSet. Making this change required an API change, so that dirmgr can report success/failure status without actually knowing whether it's using a fallback or a guard.
* Rename Guard=>FirstHop, GuardId=>FirstHopIdNick Mathewson2022-03-301-4/+4
| | | | | This is preparation for having separate GuardId and FirstHopId types that distinguish which back-end they index.
* Rename ExternalFailure => ExternalActivity.Nick Mathewson2022-03-301-4/+4
|
* Add status tracking to FallbackDir.Nick Mathewson2022-03-302-1/+17
| | | | | | | | | | | We do this by creating a new FallbackSet type that includes status information, and updating the GuardMgr APIs to record success and failure about it when appropriate. We can use this to mark FallbackDirs retriable (or not). With this change, FallbackDir is now stored internally as a Guard in the GuardMgr crate. That's fine: the FallbackDir type really only matters for configuration.
* dirmgr: do not pass fallbacks to the CircMgr.Nick Mathewson2022-03-301-6/+1
| | | | | | | This is the final step in allowing the CircMgr to use the GuardMgr's view of the fallbacks. Compilation is restored and tests pass.
* Turn FallbackList into a real type, and store one in GuardMgr.Nick Mathewson2022-03-301-9/+17
| | | | | | | | | | | | | | The guard manager is responsible for handing out the first hops of tor circuits, keeping track of their successes and failures, and remembering their states. Given that, it makes sense to store this information here. It is not yet used; I'll be fixing that in upcoming commits. Arguably, this information no longer belongs in the directory manager: I've added a todo about moving it. This commit will break compilation on its own in a couple of places; subsequent commits will fix it up.
* Move fallback.rs into guardmgr.Nick Mathewson2022-03-303-3/+4
| | | | | | | This is the logical place for it, I think: the GuardMgr's job is to pick the first hop for a circuit depending on remembered status for possible first hops. Making this change will let us streamline the code that interacts with these objects.
* Merge branch 'disallowed_lint' into 'main'eta2022-03-302-2/+0
|\ | | | | | | | | Remove allow(clippy::disallowed_methods) lint flag. See merge request tpo/core/arti!437
| * Remove allow(clippy::disallowed_methods) lint.Nick Mathewson2022-03-302-2/+0
| |
* | Make daemon tasks self-contained; introduce NetDirProvidereta2022-03-302-36/+12
|/ | | | | | | | | | | | | | | The various background daemon tasks that `arti-client` used to spawn are now handled inside their respective crates instead, with functions provided to spawn them that return `TaskHandle`s. This required introducing a new trait, `NetDirProvider`, which steals some functionality from the `DirProvider` trait to enable `tor-circmgr` to depend on it (`tor-circmgr` is a dependency of `tor-dirmgr`, so it can't depend on `DirProvider` directly). While we're at it, we also make some of the tasks wait for events from the `NetDirProvider` instead of sleeping, slightly increasing efficiency.