summaryrefslogtreecommitdiff
path: root/crates/tor-dirmgr/src/state.rs
Commit message (Collapse)AuthorAgeFilesLines
* tor-netdoc: authcert: Make key_ids return owned AuthCertKeyIdsIan Jackson2026-01-061-4/+4
| | | | | AuthCert is about to lose its copy of H(KP_auth_sign_rsa) so it needs to return an owned value.
* tor-netdoc: Store n_authorities in usizeClara Engler2025-12-021-2/+1
| | | | | | | Previously, this value was stored in a u16. However, because this number is usually always derived from some sort of list type, such as `Vec`, it makes more sense to use usize for this, as it avoid unnecessary casting and error checking.
* Fix name of clippy lint to unchecked_time_subtraction (2)Ian Jackson2025-11-061-1/+1
| | | | Run maint/add_warning
* Remove one stray allow(deprecated)Neel Chauhan2025-11-041-1/+0
|
* Stop using MockSleepProvider in a few cratesNeel Chauhan2025-11-021-3/+2
| | | | Part of #1885.
* Fix new clippy nightly warning about subtracting Durations.Nick Mathewson2025-10-161-1/+3
|
* tor-dircommon: Implement proposal 330Clara Engler2025-09-161-20/+14
| | | | | | | This commit implements proposal 330 in the context of `tor-dircommon`, by replacing the single `Authority` structure used in a list context by a single structure called `AuthorityContacts` which contains all v3idents, upload, download, and vote endpoints in one central place.
* tor-dircommon: Use amplify and getters for configClara Engler2025-09-091-10/+11
|
* Move `DownloadSchedule` into `tor-dircommon`Clara Engler2025-09-081-3/+2
| | | | | This commit moves the `DowenloadSchedule` related types from `tor-dirmgr` into `tor-dircommon`.
* Move `NetworkStatus` to `tor-dircommon`Clara Engler2025-09-081-2/+5
| | | | | | This commit moves `NetworkStatus` from `tor-dirmgr::config` to `tor-dircommon::config` in order to start the work on a common place for configuration options shared by both directory implementations.
* tor-dircommon: Initial commitClara Engler2025-09-021-2/+3
| | | | | | | | | | | | | | This commit initializes the `tor-dircommon` crate: A crate serving the purpose to form an umbrella for the lowest common denominator primitives found across crates implementing (parts of) the directory specification. For now, the only such primitive is the found within the `authority` module, which has been refactored from `tor-dirmgr` into this crate, alongside additional getter functions due to the lack of `pub(crate)` in this context. In the future, we may move further primitives away from `tor-dirmgr` into `tor-dircommon`.
* Switch Cargo.toml files to edition 2024.Nick Mathewson2025-08-071-32/+42
| | | | | | | | | | | | | | First, run ``` git grep -l "^edition =" | xargs perl -i -pe 's/^edition *=.*/edition = "2024"/;' ``` Second, manually verify that all Cargo.toml files have changed, and nothing else has changed. Third, run cargo fmt again.
* Rename recommended_protocols to protocol_statuses.Nick Mathewson2025-04-161-8/+8
| | | | | This name reflects its purpose better than the original one, since it includes required protocols as well as recommended ones.
* dirmgr, netdir: Store protocol requirments as soon as they are validated.Nick Mathewson2025-04-161-1/+33
|
* squash! Upgrade rand dependency to 0.9.Nick Mathewson2025-03-181-1/+1
| | | | - `rand::thread_rng()` has been deprecated and renamed to `rand::rng()`
* netdoc: Make some parsing init functions fallible.Nick Mathewson2025-03-171-2/+7
| | | | | | | I'm about to make our parsers reject some strings at construction time, so it makes sense to have these functions become fallible. This is a breaking change.
* tor-rtmock: allow-Decorate every use of MockSleepProviderIan Jackson2025-03-061-0/+2
| | | | | | | MockSleepProvider and MockSleepRuntime have been declared deprecated by the docs for some time. We're about to mark them `#[deprecated]`. This commit has been split out for clarity of review.
* rtcompat: Add an extension trait for building modified RuntimesNick Mathewson2024-09-241-2/+3
| | | | | | | With this extension trait, we no longer need to construct `CompoundRuntime` directly outside of tor-rtcompat. This in turn will make it a little less painful when we have to add more generics to CompoundRuntime.
* tor-rtcompat: CompoundRuntime: Add a CoarseTimeProvider, and implIan Jackson2024-03-251-1/+1
| | | | | | In all the uses in-crate, this is just a RealCoarseTimeProvider. Now all the compound runtimes impl CoarseTimeProvider.
* Run maint/add_warning.Nick Mathewson2024-03-131-0/+1
|
* tor-dirmgr: Rename DirMgrConfig.cache_path to cache_dirIan Jackson2023-12-041-1/+1
| | | | | | This variable contains precisely the value of cache_dir from arti_client::config::StorageConfig and it should therefore have the same name.
* arti-client: add exit selection with GeoIP country codeseta2023-09-181-0/+8
| | | | | | | | | | | | | | | | | | | | This threads the country codes work through the rest of the codebase: - `tor-dirmgr` will now enable GeoIP with the embedded database when the `geoip` future is enabled - This can be extended later using the `DirMgrConfig` to allow specifying a custom database; this is not done here, though - `tor-circmgr`'s `SupportedCircUsage` and `TargetCircUsage` fields gain new `country_code` members to allow filtering circuits by country - These are `()` in builds where the `geoip` feature is not enabled -- doing it this way means we don't have to copy and paste huge swathes of code, since we can't use `#[cfg]` in patterns - `ExitPathBuilder` gains (hacked-in) support for choosing a relay with the correct country code - Due to the lack of conjuction, we just copy and paste a small bit, pending further refactoring - `StreamPrefs` now lets you specify a country code, letting embedders make use of the feature
* Run maint/add_warning to add lint block everywhereIan Jackson2023-08-231-0/+1
|
* Merge branch 'clippy-allow' into 'main'Ian Jackson2023-07-111-0/+1
|\ | | | | | | | | clippy: Allow some of our existing code patterns See merge request tpo/core/arti!1396
| * Run maint/add_warning to actually apply new lint allowsIan Jackson2023-07-101-0/+1
| |
* | rng ranges: Use gen_range_infallible() for Duration::ZERO..=TIan Jackson2023-07-101-3/+2
|/
* Merge branch 'event_report_everywhere' into 'main'Nick Mathewson2023-07-071-6/+2
|\ | | | | | | | | | | | | Throughout: Use event_report!() macros for reporting Errors. Closes #949 See merge request tpo/core/arti!1383
| * Throughout: Use *_report!() macros for reporting Errors.Nick Mathewson2023-07-071-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I identified the cases to replace by searching for the string `.report()`. There are a few that I didn't change: * A couple of cases that used anyhow::Error, * One case that reported two Errors. * Two cases in `tor_hsclient::err` that just did `error!("Bug: {}")`. I have also not audited the cases in `tor-hsclient` where we're using `tor_error::Report` manually. Nonetheless, closes #949.
* | rng ranges: Use inclusive Duration ranges in several placesIan Jackson2023-07-071-1/+1
|/ | | | | | | | | | | | | | Many of these call sites would panic if, somehow, the upper bound was zero. In most cases it is very complicated to see if whether this could happen. However, there is a better answer: Durations are (conceptually) dense, so picking the closed set (which includes its boundary) rather than the open one (which doesn't) will make little practical difference. So change four call sites to use `..=` instead of just `..`.
* dirmgr: use voting_period.Nick Mathewson2023-06-291-4/+1
|
* Downgrade and clarify message about dir replacment time.Nick Mathewson2023-05-081-8/+12
| | | | Closes #839
* Merge branch 'fix_802_core' into 'main'Ian Jackson2023-04-181-1/+6
|\ | | | | | | | | | | | | DirMgr: Detect that directory state is ready if it begins with all MDs Closes #802 See merge request tpo/core/arti!1126
| * DirMgr: Detect that directory state is ready if it begins with all MDsNick Mathewson2023-04-101-1/+6
| | | | | | | | | | | | | | | | | | | | | | Previously, we'd only call PendingNetDir::upgrade_if_necesessary when adding a microdescriptor. But if it began already having all of its descriptors (because we found them in the cache), we wouldn't actually upgrade it to a PendingNetDir::Yielding, which would make it unusable, and would make us schedule its reset time too far in the future. Fixes #802.
* | Use bool::then_some() as appropriateNick Mathewson2023-04-111-1/+1
|/ | | | | | Now that we require a version of Rust that allows `b.then_some(v)`, clippy complains about our use of `b.then(|| v)`.
* tor-netdoc: Change fill_from_previous_netdirIan Jackson2023-02-091-1/+1
| | | | | | | | | | | | | | | | * Remove the return value, which was not used anywhere. Also remove the code to calculate the return value. * Take an Arc<NetDir> rather than a reference. We are going to want this for HS support. This has no overall effect on the lifetime of the4 Arc, which was owned at the one call site and then imediately dropped. * Change the documentation to explain what the function's role is in the netdir API, rather than the fiddly details of what it actually does internally. Relegate the latter to a code comment. (When we have HS, this will do more, or, at least, make further arrangements.)
* Use ErrorReport - run rustfmtIan Jackson2023-01-301-1/+5
| | | | Split off for ease of review and possible rebase.
* Use ErrorReport for errors in warn! in tor-dirmgrIan Jackson2023-01-301-2/+2
|
* Allow clippy::unchecked_duration_subtraction in testsNick Mathewson2023-01-271-0/+1
| | | | | This panics on error, and we're fine with a panic on misbehavior in tests.
* Complete our migration to base64ct.Nick Mathewson2023-01-201-1/+2
| | | | | | | | | This is in lieu of upgrading to the latest base64 crate, which has a different API from the old one. Since we have to migrate either way, we might as well use base64ct everywhere. I don't think that most of these cases _require_ constant-time base64, but it won't hurt.
* test lint blocks: Do some semi-manuallyIan Jackson2022-12-121-0/+8
| | | | | | | This is the hunks from running the rune in maint/adhoc-add-lint-blocks but which require some subsequent manual fixup: usually, deleting now-superfluous outer allows, but in some cases manually putting back lints that the adhoc script deleted.
* Rename DirSkewTolerance to DirToleranceNick Mathewson2022-07-221-1/+1
| | | | | | This name is more accurate because we aren't only dealing with clock skew here: we're also trying to tolerate the case where the authorities fail to reach consensus for a while.
* Refactor most DirStatus users to use DirProgress.Nick Mathewson2022-06-131-16/+17
| | | | This is all crate-internal APIs, fortunately.
* Rename DirStatusInner to DirProgress.Nick Mathewson2022-06-131-4/+4
| | | | | | This is about to become only a _part_ of what defines a DirStatus: a DirStatus will also include a reset count, and some kind of info about how long we've gone without progress.
* DirMgr:: Remove Error::NoChange as redundant.Nick Mathewson2022-05-251-38/+16
| | | | | | | | Now that the relevant functions now report changed/not-changed status via a boolean out-parameter (see !527), there's no reason to have a separate NoChanged error case. Closes #484.
* Merge branch 'bug482' into 'main'eta2022-05-241-20/+105
|\ | | | | | | | | | | | | DirMgr: Stop load-from-cache process when there is no change. Closes #482 See merge request tpo/core/arti!527
| * DirMgr: Stop load-from-cache process when there is no change.Nick Mathewson2022-05-241-20/+105
| | | | | | | | | | | | | | | | | | | | | | | | Previously in !511 I had introduced a bug where, if there was an error more serious than "no change", that error would keep us from noticing that we had no change, and we'd loop until the safety counter ran out. Then we'd panic. This commit fixes the bug by reintroducing the `changed` boolean -- this time as an outparam for the add_from_* methods. Fixes #482.
* | fs-mistrust: make Mistrust have a corresponding Builder type.Nick Mathewson2022-05-241-1/+1
|/ | | | | This is an approximately minimal revision to get Builder in place; subsequent commits will clean up the API.
* Fix compilation with Rust 1.56.Nick Mathewson2022-05-171-3/+2
|
* DirMgr: Remove blocking_error return path.Nick Mathewson2022-05-171-26/+22
|
* DirMgr: Unify error return pathsNick Mathewson2022-05-171-84/+133
| | | | | | | | | | | | | | | | | We no longer have separate return paths for recoverable and fatal errors; instead, they are merged, and distinguished based on recovery actions. Since it is now possible for download() to give an error that should _not_ destroy the previous state, it takes `&mut Box<dyn DirState>`. This change unfortunately means that we can no longer call `state = state.advance()`, but instead have to do some mem::swap junk with poisoned values. Any better solution would be a good thing. Additionally, the reset() and advance() methods can no longer fail. There is still a separate return path for reset-triggering errors; I'm about to fix that.