summaryrefslogtreecommitdiff
path: root/crates/tor-dirmgr/src/config.rs
Commit message (Collapse)AuthorAgeFilesLines
* config derive attrs: Make builders serde, and validated structs notIan Jackson2022-05-051-8/+5
| | | | | | | | | | | | | | | * Builders additionally derive: Debug, Serialize, Deserialize. * Validated structs no longer derive: Serialize, Deserialize and all related attributes deleted. * As a consequence, all the `#[serde(deny_unknown_fields)]` are gone. That means that right now unknown fields are totally ignored. This is good for compatibility but poor for useability. Doing something better here is arti#417, in progress. * As a consequence, delete tor_dirmgr::retry::default_parallelism. (The default value was already duplicated into a builder attr.)
* FallbackDir: Use VecBuilder for orportsIan Jackson2022-05-041-6/+8
| | | | | | | And drop the ad-hoc orport() method. This brings FallbackDir's orports field in line with our list builder API. The general semver note in "configuation" seems to cover most of this.
* Change builder list APIIan Jackson2022-05-041-11/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* DirMgrConfig: Remove unnecessary accessorsIan Jackson2022-04-261-19/+3
| | | | | | | 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-9/+9
| | | | This entire struct is config. This is otiose.
* DownloadSchedule: Abolish accessors in DownloadScheduleConfigIan Jackson2022-04-261-35/+12
| | | | We can just make the fields pub(crate).
* DownloadSchudule: Have NetworkConfig contain BuildersIan Jackson2022-04-261-62/+27
| | | | | | | | | | | 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-261-7/+47
| | | | | | | | | | 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-261-2/+2
| | | | | | | | 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.
* 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-11/+11
| | | | | | | | | 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.
* fallback list: Introduce and use FallbackListBuilderIan Jackson2022-04-221-13/+10
| | | | | | | | | 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-221-28/+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.
* 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-301-2/+2
| | | | | | | 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.
* Abolish filter::DynFilter in favour of transparent DirFilterIan Jackson2022-03-251-1/+1
| | | | | | | | | | | | 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/+16
| | | | | | 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: NetworkConfig: Abolish accessorsIan Jackson2022-03-181-16/+8
| | | | Using accessors for crate-only fields is otiose.
* dirmgr: NetworkConfig: Rename fallbacks struct fieldIan Jackson2022-03-181-6/+9
| | | | | | Rename this to be named the same as its accessor, and use the rename feature of builder and serde. (The shorter name is nicer in the code IMO.)
* DirMgrConfig: abolish builder; make it transparent and exhaustiveIan Jackson2022-03-161-56/+32
| | | | See rationale in the comment.
* Follow-up from arti!318Nick Mathewson2022-03-111-1/+10
| | | | Make update_config only conditionally exported; add semver-status update.
* Merge branch 'add-flatfile-dirmgr' into 'main'Nick Mathewson2022-03-111-6/+6
|\ | | | | | | | | Add flatfile DirMgr See merge request tpo/core/arti!318
| * Expose APIs for external DirProviderChristian Grigis2022-03-111-6/+6
| |
* | Drop remaining conversion from FooConfig to FooConfigBuilderIan Jackson2022-03-071-22/+0
| |
* | Derive Deserialize for derive-builder-generated config buildersIan Jackson2022-03-071-0/+3
|/ | | | | | | | | | | | | I used git-grep -P '\#\[serde\((?!default|deny_unknown)' to find places where I needed to add additional attributes on the builder method fields. This is currently a bit duplicative, but when #371 is completely done, the validated (non-builder) configs won't need to be Deserialize any more. This is part of #371 and #372.
* Use RsaIdentity::from_hex() and hex::decode_to_slice in more placesNick Mathewson2022-03-041-3/+1
| | | | These aren't critical-path, but they do make the code a little nicer.
* dirmgr: add Store traittharvik2022-02-231-8/+8
|
* Make much of DirMgrConfig reconfigurable.Nick Mathewson2021-12-071-12/+54
| | | | | | | | | | 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.
* Sketch API for reconfiguration.Nick Mathewson2021-12-071-0/+5
| | | | | | | This patch doesn't actually make anything reconfigurable, but it does create an API that will tell you "you can't change the value of that!" If the API looks reasonable, I can start making it possible to change the values of individual items.
* More typo fixes that I forgot to save :(Nick Mathewson2021-11-241-1/+1
|
* Make every Config type implement Eq.Nick Mathewson2021-11-211-3/+3
| | | | | Doing this is necessary for reconfiguration support, and will help a lot with testing, too.
* Give every ConfigBuilder a From<Config> implementation.Nick Mathewson2021-11-211-6/+25
| | | | This will make it more convenient to reconfigure things.
* Use named fields for the elements of ConfigBuildErrorNick Mathewson2021-11-181-4/+4
|
* Rename RetryConfig to DownloadSchedule, fold in parallelism.Nick Mathewson2021-11-181-34/+23
|
* Move top-level configuration downwards from `arti` to `arti-config`.Nick Mathewson2021-11-181-5/+9
| | | | | | | | To do this at all neatly, I had to split out `tor-config` from `arti-config` again, and putting the lower level stuff (paths, builder errors) into tor-config. I also changed our use of derive_builder to always use a common error type, to avoid error type proliferation.
* Try writing a bit more documentation for configuration types.Nick Mathewson2021-10-281-2/+13
|
* Replace references to arti-client in the documentation.Nick Mathewson2021-10-211-2/+2
|
* Use unwrap in tests.Jani Monoses2021-10-181-9/+15
| | | | | | | | | For now, this avoids having to separately handle AuthorityBuilderError, DirMgrConfigBuilderError, DownloadScheduleConfigBuilderError, NetworkConfigBuilderError and FallbackDirBuilderError when anyhow is not used. Turn off a clippy warning.
* Lock down some dirmgr config functions.Nick Mathewson2021-10-091-11/+11
|
* Re-export configuration types from tor-client.Nick Mathewson2021-10-091-0/+5
|
* Do not use set_ prefix on derive_builder settersJani Monoses2021-09-161-3/+3
|
* Use derive_builder for Authority and FallbackDir.Nick Mathewson2021-09-101-34/+0
|
* Use derive_builder for the rest of tor_dirmgr::configNick Mathewson2021-09-091-80/+21
|
* Use derive_builder for DownloadScheduleConfigNick Mathewson2021-09-081-66/+7
|
* Use derive_builder for NetworkConfig.Nick Mathewson2021-09-081-97/+37
|
* fix/silence clippy lints in test modulesDaniel Eades2021-09-081-0/+1
|
* Move all crates into a `crates` subdirectory.Nick Mathewson2021-08-271-0/+594
This will cause some pain for now, but now is really the best time to do this kind of thing.