summaryrefslogtreecommitdiff
path: root/crates/tor-dirmgr/src
Commit message (Collapse)AuthorAgeFilesLines
* clippy: Use Result::cloned in several placesIan Jackson2024-01-311-1/+1
|
* tor-dirmgr: Simplify a clone call (fmt)Ian Jackson2024-01-311-3/+1
|
* tor-dirmgr: Simplify a clone callIan Jackson2024-01-311-2/+1
| | | | Prompted by clippy.
* dirmgr: Make the `dir_mgr_config` method publicEmil Engler2024-01-091-2/+2
| | | | | | | | | | | This commit makes the `dir_mgr_config` method of the `TorClientConfig` struct public. It might be questionable whether we should make this function public or switch to a `TryInto` trait in general, which also seems like an even Rustier solution Rustier solution. Fixes #1175
* clippy nightly: For now, locally allow implied_bounds_in_implsIan Jackson2024-01-021-0/+2
| | | | | | Filed https://gitlab.torproject.org/tpo/core/arti/-/issues/1177 proposing a final fix.
* clippy nightly: For now, locally allow blocks_in_conditionsIan Jackson2024-01-021-0/+1
| | | | | | Filed https://gitlab.torproject.org/tpo/core/arti/-/issues/1176 proposing a final fix.
* clippy: Replace many calls to .get(0) with .first()Ian Jackson2024-01-021-1/+1
| | | | | FTR I don't think agree with clippy on this question, but then I often don't.
* tor-persist: Provide FsMistrustErrorExt, and use itIan Jackson2023-12-131-7/+2
| | | | | | | | | | | | | This code needs fs_mistrust::Error and tor_error::ErrorKind. I think we probably don't want fs_mistrust to depend on tor_error or vice versa. tor_persist is approximately the place where these two threads of thought come together, and it's currently the lowest place where this is needed. Use it in tor-dirmgr too, which is currently the other place that embodies this knowledge about fs_mistrust::Error.
* tor-dirmgr: Rename DirMgrConfig.cache_path to cache_dirIan Jackson2023-12-043-9/+9
| | | | | | This variable contains precisely the value of cache_dir from arti_client::config::StorageConfig and it should therefore have the same name.
* oneshot: Apply deferred rustfmt churnIan Jackson2023-10-111-1/+1
| | | | cargo fmt, precisely.
* oneshot: Use veneer in tor-dirmgrIan Jackson2023-10-112-2/+3
|
* tor-rtmock: Switch MockRuntime to SimpleMockSleepProviderIan Jackson2023-10-031-7/+7
| | | | | | | | | | | | | | | | For now we do this by changing the meaning of the name `MockSleepProvider` in runtime.rs. This is a bodge to reduce noise in this diff. Consequences at call sites: * If the type is named somehow, the other type must be used. * SimpleMockTimeProvider calls it jump_wallclock rather than jump_to, which is IMO a better name. (MockRuntime will change in a moment.) * SimpleMockTimeProvider's advance() function isn't async and doesn't yield. But none of the call sites actually mind that.
* Upgrade event_listener dependency to 3.0.0Nick Mathewson2023-09-281-1/+1
|
* 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
* Add cognitive-complexity exceptions for clippy.Nick Mathewson2023-09-051-0/+1
| | | | I have no idea why these became necessary.
* Run maint/add_warning to add lint block everywhereIan Jackson2023-08-2312-0/+12
|
* Resolve warnings about ambiguous/redundant doc linksNick Mathewson2023-08-221-1/+1
| | | | | Nightly rustdoc now warns if you have a link that isn't necessary, and if you have a link that might refer to two different things.
* tor-dirclient: Make Requestable return requests with String bodies.Gabriela Moldovan2023-08-161-1/+1
| | | | | It's simpler to always use a `String` to represent directory request bodies. We no longer need the `StringBody` trait.
* tor-dirclient: Make the body type of a `Requestable` type configurable.Gabriela Moldovan2023-08-161-1/+1
| | | | | | | | | Previously, the `Requestable` trait assumed the body of the request would always be empty (`http::Request<()>`). This change replaces the hardcoded `()` body type with the `Requestable::Body` associated type (which will allow implementors to create requests with non-empty bodies). This will enable us to reuse the `Requestable` trait for building `POST` requests for uploading descriptors.
* tor-dirclient: Rename download() to send_request() (fmt).Gabriela Moldovan2023-08-161-1/+5
|
* tor-dirclient: Rename download() to send_request().Gabriela Moldovan2023-08-161-2/+2
| | | | | | `download()` is actually a general-purpose function for sending HTTP requests on a stream. We will soon repurpose it for `POST`-ing descriptors, so let's rename it to `send_request`.
* Run add_warnings on all files.Nick Mathewson2023-08-041-2/+2
|
* Merge branch 'clippy-allow' into 'main'Ian Jackson2023-07-1112-0/+13
|\ | | | | | | | | 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-1012-0/+13
| |
* | 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-074-32/+23
|\ | | | | | | | | | | | | 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-074-32/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 `..`.
* Run add_warning to remove `missing_panics_doc` deny.Nick Mathewson2023-07-061-1/+0
| | | | Closes #950.
* tor-dirmgr: bridge descriptor tests: Add a missing #[traced_test]Ian Jackson2023-07-061-0/+1
| | | | This seems to have been overlooked.
* tor-dirmgr: bridge descriptor tests: Use MockRuntime (fmt)Ian Jackson2023-07-061-270/+271
| | | | Run rustfmt.
* tor-dirmgr: bridge descriptor tests: Use MockRuntimeIan Jackson2023-07-061-35/+25
| | | | This abolishes a bodge sleep. It should make the tests deterministic.
* tor-dirmgr: bridge descriptor tests: Fix a v. low prob. raceIan Jackson2023-07-061-2/+5
| | | | | | | | | | Drain a number of events, not just one. The stream might yield many events, as explained in this new comment. This fails every time with MockExecutor::try_test_with_various(). I think it might fail with the tokio exeuctor too, but evidently not with high probability or we would have noticed.
* dirmgr: use voting_period.Nick Mathewson2023-06-291-4/+1
|
* lints: Run maint/add_warning to actually apply new lintsIan Jackson2023-06-211-0/+2
|
* dirmgr: remove a needless .borrow()Nick Mathewson2023-05-111-4/+3
| | | | This fixes a warning from nightly clippy.
* Downgrade and clarify message about dir replacment time.Nick Mathewson2023-05-081-8/+12
| | | | Closes #839
* DirMgr: More logs in top-level bootstrapping code.Nick Mathewson2023-05-031-5/+12
| | | | Closes #803, I hope.
* 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.
* DirMgr: Log at trace! when starting a new "AttemptId".Nick Mathewson2023-05-031-1/+7
|
* 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.
* | s/BridgeDescManager/BridgeDescMgr/g in codebaseNeel Chauhan2023-04-121-2/+2
| |
* | Use bool::then_some() as appropriateNick Mathewson2023-04-112-8/+8
|/ | | | | | Now that we require a version of Rust that allows `b.then_some(v)`, clippy complains about our use of `b.then(|| v)`.
* Sort out some TODOs in bdtest.rsIan Jackson2023-03-211-5/+4
|
* Fix a bunch of needless-conversion warnings.Nick Mathewson2023-03-101-3/+2
| | | | | Apparently 1.68 now warns when you call into_iter() on something that's already an iterator. Fair enough. Let's stop doing that.
* tor-dirmgr: Don't try to mark consensus usable in a read-only store.Nick Mathewson2023-03-081-4/+6
| | | | | | | | | | | Doing this means that any attempt to use a read-only store would crash as soon as it found that the consensus was usable. It seems that this bug was introduced at some point doing all the dirmgr refactors we did over the past year. Perhaps there should be a test for running with a read-only store. Fixes #779
* tor-dirmgr: Work around an apparent regression in `time`.Nick Mathewson2023-02-171-3/+3
| | | | | | | Some code in our tests that worked fine with time 0.3.17 no longer works with 0.3.19, despite the semver. See https://github.com/time-rs/time/issues/552 for the upstream bug.
* 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-302-3/+11
| | | | Split off for ease of review and possible rebase.