summaryrefslogtreecommitdiff
path: root/crates/tor-dirmgr/src/bootstrap.rs
Commit message (Collapse)AuthorAgeFilesLines
* dirmgr: Remove unnecessary Arc::clone (fmt)Gabriela Moldovan2026-01-271-2/+1
|
* dirmgr: Remove unnecessary Arc::cloneGabriela Moldovan2026-01-271-3/+3
| | | | | Now that `load` is no longer `async`, this triggers a lint about the unnecessary clone.
* dirmgr: Make various functions synchronousGabriela Moldovan2026-01-271-5/+4
| | | | To fix `clippy::unused_async`.
* opentelemetry: Instrument a bunch of functions.Wesley Aptekar-Cassels2025-11-241-1/+5
| | | | | These are all aimed at figuring out in more detail what's going on in #2079 and related issues.
* Fix name of clippy lint to unchecked_time_subtraction (2)Ian Jackson2025-11-061-1/+1
| | | | Run maint/add_warning
* tor-dircommon: Use amplify and getters for configClara Engler2025-09-091-2/+2
|
* Move `DownloadSchedule` into `tor-dircommon`Clara Engler2025-09-081-1/+1
| | | | | This commit moves the `DowenloadSchedule` related types from `tor-dirmgr` into `tor-dircommon`.
* misc: cleanup now that `_report!` macros support fieldsSteven Engler2025-08-181-2/+1
|
* Switch Cargo.toml files to edition 2024.Nick Mathewson2025-08-071-5/+6
| | | | | | | | | | | | | | 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.
* tor-dirmgr: Removed dependency on `once_cell`hashcatHitman2025-06-141-2/+2
| | | | | | - Replaced `once_cell::sync::Lazy` with `std::sync::LazyLock`. Signed-off-by: hashcatHitman <[email protected]>
* *: suppress cognitive_complexity warnings from nightlyNick Mathewson2025-05-291-0/+4
| | | | | | | | | | | | | Apparently clippy nightly is better (or worse?) about detecting complex functions than before, so I'm suppressing these warnings where they occur. I have mixed feelings about these warnings: On the plus side, they really do help to detect functions that are twistier than they need to be. On the minus side, they get confused by tracing macros, and the "allows" do pile up. But on the plus side, those "allows" do provide a way to find functions that need to be refactored, and they are never uglier than the functions they decorate.
* dirmgr: Always apply changes before advancing consensus.Nick Mathewson2025-04-161-6/+6
| | | | | | | | | | | In the directory code, we have functionality to advance the consensus download state whenever possible, even if there is more we could download in the current state. That's fine, but when we're in this position, we need to be sure that we're taking any action based on the current state (such as installing notably parameters or, notably, protocol recommendations) before we move on.
* squash! Upgrade rand dependency to 0.9.Nick Mathewson2025-03-181-1/+1
| | | | - `rand::thread_rng()` has been deprecated and renamed to `rand::rng()`
* Upgrade to derive_more version 1.0.0Nick Mathewson2024-09-251-1/+1
| | | | | | The `derive_more` crate broke backward compatibility with this version, so this change involved quite a few manual fixups. With luck, they'll keep compatibility for some while in the future.
* extract tor_async_utils::oneshot into ::oneshot-fused-workaroundJim Newsome2024-08-281-1/+1
| | | | | | | | | | | | | | Having this in the `tor-async-utils` crate prevents us from doing both of the following without introducing a circular dependency: * using it in `tor-rtmock` (which we currently do, particularly in tests). * using `tor-rtmock` to test things in `tor-async-utils`. We don't do this yet, but it is generally sensible to do so. In particular we want to move the `stream_peak` module there, which is currently tested with `tor-rtmock`. Moving this into its own crate avoids this circular dependency.
* dirmgr: Limit the number of mds that we will fetch from sqlite at once.Nick Mathewson2024-06-121-6/+14
| | | | | | This should help limit our memory usage when restarting from cache. Possible (imperfect) solution for #1027.
* dirmgr: split out the loading part of load_once into a new function.Nick Mathewson2024-06-121-6/+17
|
* properly report bootstrap readiness without cachetrinity-1686a2024-04-291-0/+3
|
* Run maint/add_warning.Nick Mathewson2024-03-131-0/+1
|
* clippy: Use Result::cloned in several placesIan Jackson2024-01-311-1/+1
|
* oneshot: Apply deferred rustfmt churnIan Jackson2023-10-111-1/+1
| | | | cargo fmt, precisely.
* oneshot: Use veneer in tor-dirmgrIan Jackson2023-10-111-1/+1
|
* Run maint/add_warning to add lint block everywhereIan Jackson2023-08-231-0/+1
|
* Run maint/add_warning to actually apply new lint allowsIan Jackson2023-07-101-0/+1
|
* Throughout: Use *_report!() macros for reporting Errors.Nick Mathewson2023-07-071-7/+8
| | | | | | | | | | | | | | | 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.
* DirMgr: more trace!() logs and information in download/load functions.Nick Mathewson2023-05-031-8/+30
| | | | | | | My goal here is to make sure that we can't confuse one download operation and another, and that we actually know what's going on. Previously, not all state transitions or attempts to fetch information actually corresponded to a log.
* Use ErrorReport for errors in warn! in tor-dirmgrIan Jackson2023-01-301-5/+5
|
* Use ErrorReport for errors in info! in tor-dirmgrIan Jackson2023-01-301-1/+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.
* test lint blocks: Add many many automaticallyIan Jackson2022-12-121-0/+8
| | | | | This is precisely the result of running the rune in maint/adhoc-add-lint-blocks.
* dirmgr Store: Use `**` syntax and deref to trait objectsIan Jackson2022-11-141-11/+6
| | | | This will allow us to get rid of a needless trait impl.
* tor-dirclient: Make RequestFailed its own error typeIan Jackson2022-10-201-5/+5
| | | | | | | We're going to have functions on Response that fail by returning only one of these. Sadly this diff is quite noisy.
* tor-dirclient Response: Rename output methodsIan Jackson2022-10-201-1/+1
| | | | | These don't check errors and are therefore quite hazardous. I'm going to introduce a more cooked version in a moment.
* fix clippy::unwrap_used and old TODO for msrv 1.56trinity-1686a2022-09-101-9/+6
|
* `TaskSchedule`: give error on `sleep*()` if last handle is droppedNick Mathewson2022-09-071-1/+1
| | | | | | | | | | | | | | | | | | This fixes an busy-loop. When the last `TaskHandle` on a `TaskSchedule` is dropped, the schedule is permanently canceled: whatever operation it was scheduling should no longer be performed. But our code was broken: the `sleep()` and `sleep_until_wallclock()` functions don't verify whether the handles are dropped or not. This breakage caused an CPU-eating busy-loop in `sleep_until_wallclock`. With this patch, we now return a `Result<(), SleepError>` from these functions. Fixes #572.
* tor-dirmgr: Remove opt_netdir entirely.Nick Mathewson2022-07-261-3/+3
| | | | Its existence tended to hide bugs, and was just asking for trouble.
* Make display formats work with older derive_more.Nick Mathewson2022-06-141-1/+1
|
* Do not update_progress on load if nothing happened.Nick Mathewson2022-06-141-6/+10
| | | | | If there was no partial information, then calling update_progress will now report a stall in this case, which is not what we want.
* DirMgr: Track errors, stalls, and resets as part of status.Nick Mathewson2022-06-131-1/+9
| | | | | | | | | | | | | | A "reset" happens whenever we have to start a download attempt over -- either because we ran out of retries, or we found something wrong with the consensus after fetching certificates. An "error" happens when we have a recoverable error from one or more directory sources. A "stall" happens whenever a round of downloads or cache loads leads to no change in the status. We don't yet use this as part of our status reporting.
* Refactor our logic for distinguishing download attemptsNick Mathewson2022-06-131-6/+47
| | | | | | | | | | | | | Previously we used the "if-modified-since" time associated with the consensus download, and/or the "valid-after" time in the consensus attempt, to put multiple attempts into sequence, and to tell one from another. But that approach was always a kludge, and will soon get more unreliable as the DirStatus logic gets a bit more complex. With this commit, we change separate download attempts to be identified with an AttemptId that increments whenever we decide to get a different directory from the one we have. IMO this new code is _much_ cleaner.
* Refactor most DirStatus users to use DirProgress.Nick Mathewson2022-06-131-4/+4
| | | | This is all crate-internal APIs, fortunately.
* DirMgr: Refactor bootstrap to use a TaskSchedule for sleeping.Nick Mathewson2022-06-101-18/+36
| | | | | | This change (not yet exposed as an API) will let the TorClient have a `TaskHandle` corresponding to the directory task, letting it make the directory task dormant as needed.
* DirMgr:: Remove Error::NoChange as redundant.Nick Mathewson2022-05-251-22/+7
| | | | | | | | 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.
* DirMgr: Stop load-from-cache process when there is no change.Nick Mathewson2022-05-241-9/+28
| | | | | | | | | | | | 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.
* Simplify advance and reset functions with mem::replace.Nick Mathewson2022-05-191-8/+4
|
* Explain why we call update_status unconditionally.Nick Mathewson2022-05-191-0/+3
|
* Remove BootstrapAction::ImpossibleNick Mathewson2022-05-191-1/+1
| | | | It does nothing that Fatal does not. Suggested by @eta in review.
* DirMgr: Remove blocking_error return path.Nick Mathewson2022-05-171-27/+7
|
* DirMgr: Unify error return pathsNick Mathewson2022-05-171-73/+106
| | | | | | | | | | | | | | | | | 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.
* DirMgr: Remove special handling of "changed" booleanNick Mathewson2022-05-171-31/+26
|