Commit Graph

547 Commits

Author SHA1 Message Date
Ian Jackson ad39873782 bridge descriptors: Improve and fix docs for consider_launching 2022-11-03 11:37:30 +00:00
Ian Jackson d44bc1d0f8 bridge descriptors: Add comments where StateGuard is dropped 2022-11-03 11:37:30 +00:00
Ian Jackson 54e51cdba5 bridge descriptors: Document `changed` and `earliest_timeout` Options 2022-11-03 11:37:30 +00:00
Ian Jackson fb4ffb76fd bridge descriptors: Document updates argument to timeout_task 2022-11-03 11:37:30 +00:00
Ian Jackson 48f48841e1 Require derive_more 0.99.3
0.99.[012] have a bug https://github.com/JelteF/derive_more/issues/114
which makes the Deref derive for bridgedesc::StateGuard not work
and therefore breaks minimal-versions CI.

It seems simpler to require the newer version everywhere.
2022-11-03 11:37:23 +00:00
Ian Jackson 8eb7c731a2 bridge descriptors: Tests 2022-11-03 11:37:05 +00:00
Ian Jackson 3a185d61df bridge descriptors: Provide a consistency check function
This is really part of the tests, but I put it here so that it can be
compiled-in if someone wants it during debugging.
2022-11-03 11:37:05 +00:00
Ian Jackson 51b4588cc0 bridge descriptors: Provide an implementation of BridgeDescProvider
Tests will come in a moment.
2022-11-03 11:37:05 +00:00
Ian Jackson 42f9651b8e Copy tor-netdoc/testdata/routerdesc1.txt into tor-dirmgr
This seems better than having tor_netdoc export a `#[cfg(test)]`
public constant.
2022-11-03 11:37:05 +00:00
trinity-1686a e6e064ac8a remove unused dependancies 2022-10-29 13:29:55 +02:00
Ian Jackson 4a59d384b6 tor-dirmgr: impl Default for FlagPublisher 2022-10-27 15:57:57 +01:00
Ian Jackson 94325cd456 tor-dirmgr: impl FlagEvent for BridgeDescEvent 2022-10-27 15:57:57 +01:00
Ian Jackson 9c9d82f6b8 Fix clippy false positive 2022-10-25 19:42:41 +01:00
Ian Jackson 9a175ee323 FlagEvent trait: Implement using macros
The explicit list of variant names, that needs to be kept in sync, and
is a test failure semver break hazard, is now gone.

All the necessary code is now generated automatically, and cannot be
wrong.

I want this because I find myself wanting to add a second
implementation of FlagEvent, for another type.
2022-10-25 10:33:28 +01:00
Ian Jackson a30e42a740 tor-circmgr: Make get_or_launch_dir_specific feature-specific 2022-10-21 15:19:18 +01:00
Ian Jackson f68591b923 tor-dirmgr README: Remove some redundant/duplicated headings 2022-10-21 15:18:41 +01:00
Ian Jackson d9375b2b8d tor-dirclient: Make RequestFailed its own error type
We're going to have functions on Response that fail by returning only
one of these.

Sadly this diff is quite noisy.
2022-10-20 17:24:53 +01:00
Ian Jackson 3b1af05851 tor-dirclient Response: Rename output methods
These don't check errors and are therefore quite hazardous.
I'm going to introduce a more cooked version in a moment.
2022-10-20 17:24:50 +01:00
Nick Mathewson 5786637b4f Fix various typos (using typos tool and hand-inspection) 2022-10-18 15:39:33 -04:00
Ian Jackson f84d8777db cargo fmt to remove blank lines
Apparently cargo fmt doesn't like these, which my perl rune didn't
delete.

This commit is precisely the result of `cargo fmt`.
2022-10-12 15:29:04 +01:00
Ian Jackson d9910dba08 Replace all README copies in src/lib.rs with includes
The feature we want is `#[doc = include_str!("README.md")]`, which is
stable since 1.54 and our MSRV is now 1.56.

This commit is precisely the result of the following Perl rune:
  perl -i~ -0777 -pe 's{(^//!(?!.*\@\@).*\n)+}{#![doc = include_str!("../README.md")]\n}m' crates/*/src/lib.rs
2022-10-12 15:29:03 +01:00
Nick Mathewson 102e3c221d Bump minor version of tor-rtcompat and most of its dependents
(Since the APIs for the `Schedule::sleep*` functions changed, this
is a breaking change in tor-rtcompat.  Therefore, the Runtime trait
in tor-rtcompat is now a different trait.  Therefore, anything that
uses the Runtime trait in its APIs has also broken.)
2022-10-03 10:01:46 -04:00
Nick Mathewson 388e0cbab5 Bump crates that have had backward compatible API changes. 2022-10-03 09:52:34 -04:00
Nick Mathewson 4b61d778bd Update README.md files. 2022-09-30 15:19:48 -04:00
Nick Mathewson b146dacf1d Mark all bridge and pt features as experimental for now.
Also, document the features.

Closes #588.
2022-09-29 10:59:19 -04:00
Nick Mathewson 1196e1b680 GuardMgr/DirMgr: Add APIs for bridge descriptor lists 2022-09-26 11:23:21 -04:00
trinity-1686a 8e7a904260 fix clippy::needless_borrow 2022-09-10 14:39:47 +02:00
trinity-1686a dcbdd076eb fix clippy::unwrap_used and old TODO for msrv 1.56 2022-09-10 14:37:32 +02:00
Nick Mathewson 86e479ae13 `TaskSchedule`: give error on `sleep*()` if last handle is dropped
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.
2022-09-07 09:22:38 -04:00
Nick Mathewson a5f704f443 Remove semver.md from arti-1.0.0 2022-09-07 09:17:00 -04:00
Nick Mathewson 96875ea208 Bump crate versions in preparation for Arti 1.0.0 release.
Because we want to work more on ensuring that our semver stability
story is solid, we are _not_ bumping arti-client to 1.0.0 right now.

Here are the bumps we _are_ doing.  Crates with "minor" bumps have
had API breaks; crates with "patch" bumps have had new APIs added.

Note that `tor-congestion` is not bumped here: it's a new crate, and
hasn't been published before.

```
tor-basic-utils         minor
fs-mistrust             minor
tor-config              minor
tor-rtcompat            minor
tor-rtmock              minor
tor-llcrypto            patch
tor-bytes               patch
tor-linkspec            minor
tor-cell                minor
tor-proto               minor
tor-netdoc              patch
tor-netdir              minor
tor-persist             patch
tor-chanmgr             minor
tor-guardmgr            minor
tor-circmgr             minor
tor-dirmgr              minor
arti-client             minor
arti-hyper              minor
arti                    major
arti-bench              minor
arti-testing            minor
```
2022-09-01 08:59:49 -04:00
Nick Mathewson a9f19b0045 Use anonymize_home() when displaying various messages.
Closes #555
2022-08-31 09:38:35 -04:00
trinity-1686a 426a59b2ba add feature annotation not added by doc_auto_cfg 2022-08-24 18:22:41 +02:00
trinity-1686a 7f939fa480 enable doc_auto_cfg feature on every crate when documenting for docs.rs 2022-08-24 18:22:41 +02:00
Nick Mathewson 8a2a0ec1a0 Decrease the lifetimes for storing descriptors.
These values were chosen experimentally, based on those from Tor, to
save disk space without wasting much bandwidth.

Closes #527.
2022-08-09 09:30:22 -04:00
Nick Mathewson 760e2f7e95 Finish implementation of params() for DirMgr.
Now it maintains an up-to-date set of default parameters to be
handed out if there is no directory.

Closes #528.
2022-08-02 10:20:13 -04:00
Nick Mathewson 9d2fb92c37 Add params() method to NetDirProvider, and partial implementation
This method will let users get the latest `NetParameters`, with
user-configured overrides, even if there is no current directory at
all.

Part of #528
2022-08-02 09:50:39 -04:00
Nick Mathewson b16c042004 Now that versions have bumped, remove semver.md files. 2022-08-01 10:07:12 -04:00
Nick Mathewson 859ae4acd0 Bump patch versions on crates that have new APIs.
Do _not_ bump the dependency versions on crates that have had no
changes since arti 0.0.5, since those crates do not depend on the
new APIs.

```
cargo set-version -p tor-basic-utils   --bump patch
cargo set-version -p tor-llcrypto      --bump patch
git restore crates/tor-checkable
git restore crates/tor-consdiff
git restore crates/tor-rtmock
```
2022-08-01 09:56:29 -04:00
Nick Mathewson 511cb46997 Bump minor version on crates with deps with breaking changes.
This performs the transitive closure of the last operation:
everything that depends on a crate with a breaking change gets the
version which it depends on bumped.

```
cargo set-version -p tor-proto         --bump minor
cargo set-version -p tor-netdoc        --bump minor
cargo set-version -p arti-hyper        --bump minor
cargo set-version -p arti-bench        --bump minor
cargo set-version -p arti-testing      --bump minor
cargo set-version -p tor-config        --bump minor
```
2022-08-01 09:49:13 -04:00
Nick Mathewson f5dcb98f06 Bump minor versions on all crates that have had breaking changes.
Done with these commands:

```
cargo set-version -p fs-mistrust       --bump minor
cargo set-version -p tor-bytes         --bump minor
cargo set-version -p tor-socksproto    --bump minor
cargo set-version -p tor-cert          --bump minor
cargo set-version -p tor-linkspec      --bump minor
cargo set-version -p tor-cell          --bump minor
cargo set-version -p tor-netdir        --bump minor
cargo set-version -p tor-persist       --bump minor
cargo set-version -p tor-chanmgr       --bump minor
cargo set-version -p tor-guardmgr      --bump minor
cargo set-version -p tor-circmgr       --bump minor
cargo set-version -p tor-dirclient     --bump minor
cargo set-version -p tor-dirmgr        --bump minor
cargo set-version -p arti-client       --bump minor
cargo set-version -p arti              --bump minor
```
2022-08-01 09:43:09 -04:00
Nick Mathewson 14cd423630 tor-dirmgr: Remove opt_netdir entirely.
Its existence tended to hide bugs, and was just asking for trouble.
2022-07-26 10:41:38 +01:00
Nick Mathewson de460b0668 Remove unused DirMgr::netdir method, make opt_netdir private. 2022-07-26 10:41:06 +01:00
Nick Mathewson c39aa5de73 Add new APIs to NetDirProvider to better support timeliness.
Over the years we've found that most callers who want a netdir want
what C Tor calls a "reasonably live" network directory: One that is
not expired by too much, or too far in the future. But a few want a
_strictly_ live directory: one that says it is valid now, with no
tolerances.  And a few want _any_ directory, no matter how expired
it is.

This commit adds net methods to NetDirProvider to provide these
directories.  I think that most use cases will want to explicitly
think about what kind of directory they want, so I've made `netdir`
the simplest method.  I might remove `timely_netdir` by the end of
this branch; see TODO comments.

Part of #518.
2022-07-26 10:40:53 +01:00
Nick Mathewson 41104137b1 Rename DirSkewTolerance to DirTolerance
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.
2022-07-22 10:04:25 -04:00
Nick Mathewson 052f3089ca Bump to rusqlite 0.28. 2022-07-19 16:49:44 -04:00
Nick Mathewson 8d66f8ecd0 Merge branch 'dirmgr_error_cleanup' into 'main'
Clean up some errors in tor-dirmgr

Closes #521

See merge request tpo/core/arti!628
2022-07-18 14:40:11 +00:00
Nick Mathewson 3c424c82d7 dirmgr: Add a helper to create LockFile errors. 2022-07-18 10:10:28 -04:00
Nick Mathewson 9d3beb34a3 Bump tor-dirmgr to version 0.5.1.
This does not require a change in any other crate, since
the change here does not affect tor-dirmgr's APIs.
2022-07-14 12:00:42 -04:00
Nick Mathewson c983987782 dirmgr: Make UnrecognizedSchema more helpful 2022-07-14 09:53:17 -04:00
Nick Mathewson 8cbc740d90 dirmgr: Add an instance of BadUtf8InCache 2022-07-14 09:32:01 -04:00
Nick Mathewson d1e9d4ce84 dirmgr: Clarify disk IO errors. 2022-07-14 09:27:29 -04:00
Nick Mathewson c1101f13f3 dirmgr: style edits to error messages. 2022-07-14 08:40:42 -04:00
feelingnothing 171dd5eb63 Fix illegal formatting in cache filenames 2022-07-14 15:27:52 +03:00
Nick Mathewson 1dda69af2b Remove semver.md files now that 0.5.0 is out 2022-06-24 13:31:38 -04:00
Nick Mathewson 20435aea75 Bump crate and dependency versions.
These were done with the following commands:

```
cargo set-version -p tor-basic-utils   --bump patch
cargo set-version -p fs-mistrust       --bump minor
cargo set-version -p tor-error         --bump patch
cargo set-version -p tor-config        --bump patch
cargo set-version -p tor-units         --bump patch
cargo set-version -p tor-rtcompat      --bump minor
cargo set-version -p tor-llcrypto      --bump patch
cargo set-version -p tor-bytes         --bump minor
cargo set-version -p tor-socksproto    --bump minor
cargo set-version -p tor-cert          --bump minor
cargo set-version -p tor-cell          --bump minor
cargo set-version -p tor-proto         --bump minor
cargo set-version -p tor-netdoc        --bump patch
cargo set-version -p tor-netdir        --bump minor
cargo set-version -p tor-persist       --bump patch
cargo set-version -p tor-chanmgr       --bump minor
cargo set-version -p tor-guardmgr      --bump minor
cargo set-version -p tor-circmgr       --bump patch
cargo set-version -p tor-dirclient     --bump patch
cargo set-version -p tor-dirmgr        --bump minor
cargo set-version -p arti-client       --bump patch
cargo set-version -p arti              --bump minor
cargo set-version -p arti-bench        --bump minor
cargo set-version -p arti-testing      --bump minor
```
2022-06-24 12:00:22 -04:00
Ian Jackson 4831f9d38c Merge branch 'clippy' into 'main'
Fix clippy nightly again

See merge request tpo/core/arti!603
2022-06-24 14:13:58 +00:00
Nick Mathewson 1f8f24dbcb Merge branch 'dirmgr' into 'main'
dirmgr: followups to !587, mostly using iterators

Closes #468

See merge request tpo/core/arti!599
2022-06-24 13:46:52 +00:00
Nick Mathewson ea3160737c Fix a couple of typos in rustdoc comments. 2022-06-24 08:18:15 -04:00
Ian Jackson 589c6e52bb Run maint/add_warning crates/*/src/{lib,main}.rs
Update all lint blocks
2022-06-23 19:15:42 +01:00
Ian Jackson 6c110a232c dirmgr: Use ... .find().is_none() rather than clippy's suggestion 2022-06-23 18:42:33 +01:00
Ian Jackson d2bd71c5f0 dirmgr: DirBootstrapStatus: Refactor mut_status_for using entries_mut
IMO this is rather less confusing.
2022-06-22 10:53:02 +01:00
Ian Jackson d36c433b36 dirmgr: Use new statuses() helper method
The two call sites become clearer, IMO.
2022-06-22 10:53:02 +01:00
Ian Jackson 24d43f83fd dirmgr: DirBootstrapStatus: Provide statuses and entries_mut
We're going to use these in a moment.

One returns entries and the other statuses simply because that's
what's actually going to be wanted.
2022-06-22 10:53:02 +01:00
Ian Jackson 5c51d03efb dirmgr: Remove a TODO comment
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/587#note_2815945
2022-06-22 10:53:02 +01:00
eta 4e3537746f Merge branch 'display_source_cleanup' into 'main'
Do not include error source() in display() format.

See merge request tpo/core/arti!598
2022-06-21 19:34:27 +00:00
Ian Jackson 9b4ba4893e Merge branch 'stalled_directory' into 'main'
Detect and report stalled directory downloads

Closes #468

See merge request tpo/core/arti!587
2022-06-21 19:13:40 +00:00
Nick Mathewson 08d9bbf33b Do not include error source() in display() format.
According to doc/Errors.md, and in keeping with current best
practices, we should not include display an error's `source()` as
part of that error's display method.  Instead, we should let the
caller decide to call source() and display that error in turn.

Part of #323.
2022-06-21 14:14:14 -04:00
Nick Mathewson 9b7849a293 Refactor DirStatus data structures.
AttemptId is now linked to DirStatus in StatusEntry.

DirBootstrapStatus now has an inner enum to make invalid status
unrepresentable.
2022-06-21 10:26:53 -04:00
Nick Mathewson 5509bd0269 Merge branch 'config-fix2' into 'main'
Use impl_standard_builder more and remove manual Default/builder impls

See merge request tpo/core/arti!594
2022-06-16 20:30:34 +00:00
Ian Jackson db51bdcbc1 Merge branch 'config-fix' into 'main'
Config handling and logging fixes

Closes #480

See merge request tpo/core/arti!589
2022-06-16 15:46:18 +00:00
Ian Jackson 2ca2c03059 impl_standard_builder: Use for tor_dirmgr::Authority 2022-06-16 15:42:06 +01:00
Ian Jackson 17caebd284 impl_standard_builder: Use for tor_dirmgr::DownloadSchedule 2022-06-16 15:42:06 +01:00
Ian Jackson 8b724d40f8 impl_standard_builder: Use for tor_dirmgr::DownloadScheduleConfig 2022-06-16 15:27:00 +01:00
Ian Jackson 2ab5c0861e impl_standard_builder: Use for tor_dirmgr::NetworkConfig 2022-06-16 15:27:00 +01:00
Ian Jackson e32210a398 impl_standard_builder: Use for tor_dirmgr::DirSkewTolerance 2022-06-16 15:27:00 +01:00
Nick Mathewson 0223c91b26 Merge branch 'high-level-features' into 'main'
Add "full" and "experimental" features to arti, arti-client, and below.

Closes #499

See merge request tpo/core/arti!584
2022-06-16 12:24:47 +00:00
Ian Jackson 4c65e9994d Add some missing `serde(default)` to uses of humantime_serde::option
Without this, if the substructure is provided, these fields are
mandatory within it.
2022-06-16 11:08:16 +01:00
Nick Mathewson 647d4410bb Fix clippy::significant_drop_in_scrutinee warnings
This is apparently a new warning from clippy nightly, documented in
https://rust-lang.github.io/rust-clippy/master/index.html#significant_drop_in_scrutinee .

I'm not in love with the temporary variables that this warning wants
me to introduce, but it does seem like a decent way to avoid some
kinds of deadlock.
2022-06-15 11:52:30 -04:00
Nick Mathewson 425af9db91 Work around an erroneous warning from nightly clippy 2022-06-15 11:52:30 -04:00
Nick Mathewson 331578d19c Make display formats work with older derive_more. 2022-06-14 14:10:18 -04:00
Nick Mathewson c74c268c8b tor-dirmgr: Make DirStatus non-public.
I believe this type was made public in error: No other crate uses it,
and no API exposes it.
2022-06-14 11:02:29 -04:00
Nick Mathewson e3dced360b Add a blockage-reporting mechanism to tor-dirmgr.
The `DirBootstrapStatus` type now exposes a blockage() method to
return an `Option<DirBlockage>`.

The blockage types reported are more low-level than I'd like, but
they are IMO good enough for now: we'll want to get experience with
actual vs hypothetical problems before we refine them.
2022-06-14 10:42:18 -04:00
Nick Mathewson 25bbdd5f25 Add a couple of TODO items. 2022-06-14 10:05:27 -04:00
Nick Mathewson 660b3104a9 Do not update_progress on load if nothing happened.
If there was no partial information, then calling update_progress
will now report a stall in this case, which is not what we want.
2022-06-14 09:58:58 -04:00
Nick Mathewson 13c152d2ac DirMgr: Track errors, stalls, and resets as part of status.
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.
2022-06-13 13:58:31 -04:00
Nick Mathewson 2a2afaa7c2 Refactor our logic for distinguishing download attempts
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.
2022-06-13 13:21:09 -04:00
Nick Mathewson 68ea880b84 Refactor most DirStatus users to use DirProgress.
This is all crate-internal APIs, fortunately.
2022-06-13 12:22:04 -04:00
Nick Mathewson 238f2b5637 Move `at_least_as_new_as` to DirProgress. 2022-06-13 12:02:30 -04:00
Nick Mathewson 6c9d30681f Turn the DirProgress in DirStatus into a named field. 2022-06-13 10:53:46 -04:00
Nick Mathewson f581feb0ac Rename DirStatusInner to DirProgress.
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.
2022-06-13 10:49:09 -04:00
Nick Mathewson d44dd6f44f Merge branch 'dormant_directory' into 'main'
Use TaskSchedule to sleep in directory bootstrapping

Closes #497

See merge request tpo/core/arti!571
2022-06-13 13:59:26 +00:00
Nick Mathewson 2129aee6cd DirMgr: Use scopeguard crate in place of ad hoc RAII substitutes 2022-06-13 08:28:41 -04:00
Nick Mathewson a7b406e69f Put the task schedule back when the dl task exits.
This will allow somebody else to call bootstrap() if bootstrap() fails
the first time.
2022-06-13 08:28:41 -04:00
Nick Mathewson 430f4ffb86 New API to expose and use TaskHandle from DirMgr.
This change also means that we need to create the handle and scheduler
earlier in the process of creating the DirMgr.  If we don't, we won't
have a way to manage the task before bootstrap() returns.
2022-06-13 08:28:41 -04:00
Nick Mathewson 8a586a40fa Add "full" and "experimental" features to arti-client and below.
The "full" feature is a catch-all for all features, _except_:

   * Those that select a particular implementation (like
     tor-llcrypto/with-openssl) or build flag (like "static")
   * Those that are experimental or unstable (like "experimental-api")
   * Those that are testing-only.
2022-06-10 15:32:21 -04:00
Nick Mathewson 171b406b00 DirMgr: Refactor bootstrap to use a TaskSchedule for sleeping.
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.
2022-06-10 13:59:30 -04:00
Nick Mathewson 5854e4bbd9 Merge branch 'use-testing-rng' 2022-06-07 19:02:12 -04:00
Nick Mathewson 7f785b66c2 Upgrade float_eq dev-dependency to 1.0.0 2022-06-07 08:03:55 -04:00
Nick Mathewson 967ea67b7d Use testing_rng() in tests throughout our crates.
This only affects uses of thread_rng(), and affects them all more or
less indiscriminately.  One test does not work with
ARTI_TEST_PRNG=deterministic; the next commit will fix it.
2022-06-02 14:56:42 -04:00
Ian Jackson 98ccd7e7e2 Merge branch 'lint' into 'main'
lints: Make lint blocks consistent and ensure they stay that way

Closes #469

See merge request tpo/core/arti!557
2022-05-31 18:27:53 +00:00
Ian Jackson 4f42101554 lints: Add let_unit_value allow to all crates
From running add_warning, with manual picking of the right
hunks/lines.
2022-05-31 15:23:52 +01:00
Ian Jackson ba0843da4a lints: Add lint block delimiters to every crate
This was the result of:
  maint/add_warning crates/*/src/{lib,main}.rs
and then manually curating the results.
2022-05-31 13:00:31 +01:00
Ian Jackson 017906cdc7 tor-dirmgr: Fix DirSkewTolerance
This was upposed to be one day, I presume!

Also complete a truncated sentence in the docs.
2022-05-30 16:00:45 +01:00
Orhun Parmaksız bfd41ddb5f
Lexically sort Cargo.toml dependencies
Utilize cargo-sort: https://github.com/DevinR528/cargo-sort

Signed-off-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
2022-05-28 20:05:51 +03:00
Nick Mathewson 4326aa1de9 Regenerate version bump from previous commit.
This commit was made by reverting the previous commit, then
re-running the script I used to generate it.  In theory there should
be no semantic changes: only changes due to improved formatting from
cargo edit.
2022-05-27 10:18:52 -04:00
Nick Mathewson b232365a75 Semantic version changes for Arti 0.4.0 release
I followed the following procedure to make these changes:

* I used maint/changed_crates to find out which crates had changed
  since 0.3.0.
* I used grep and maint/list_crates to sort those crates in
  topological (dependency) order.
* I looked through semver_status to find which crates were listed as
  having semver-relevant changes (new APIs and breaking changes).
* I scanned through the git logs of the crates with no
  semver-relevant changes listed to confirm that, indeed, they had
  no changes.  For those crates, I incremented their patch-level
  version _without_ changing the version that other crates depend on.
* I scanned through the git logs of the crates with no
  semver-relevant changes listed to confirm that, indeed, they had
  no obvious breaking changes.
* I treated all crates that depend on `arti` and/or `arti-client` as
  having breaking changes.
* I identified crates that depend on crates that have changed, even
  if they have not changed themselves, and identified them as having
  a non-breaking change.
* For all of the crates, I used `cargo set-version -p $CRATE --bump
  $STATUS` (where `STATUS` is `patch` or `minor`) to update the
  versions, and the depended-upon versions.
2022-05-27 09:01:20 -04:00
Nick Mathewson 0caa5bcba5 DirMgr:: Remove Error::NoChange as redundant.
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.
2022-05-25 08:58:37 -04:00
eta 608d0cbcc2 Merge branch 'bug482' into 'main'
DirMgr: Stop load-from-cache process when there is no change.

Closes #482

See merge request tpo/core/arti!527
2022-05-24 19:33:42 +00:00
Nick Mathewson 95200383b5 fs-mistrust: make Mistrust have a corresponding Builder type.
This is an approximately minimal revision to get Builder in place;
subsequent commits will clean up the API.
2022-05-24 10:54:02 -04:00
Nick Mathewson 8e15c97f56 DirMgr: Stop load-from-cache process when there is no change.
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.
2022-05-24 08:50:20 -04:00
Nick Mathewson 5b5b4bbbea Simplify advance and reset functions with mem::replace. 2022-05-19 08:09:05 -04:00
Nick Mathewson eab0046d0e Explain why we call update_status unconditionally. 2022-05-19 08:04:57 -04:00
Nick Mathewson 6aebb18e64 Remove BootstrapAction::Impossible
It does nothing that Fatal does not.  Suggested by @eta in review.
2022-05-19 08:00:41 -04:00
Nick Mathewson c70916c0d9 Fix compilation with Rust 1.56. 2022-05-17 14:58:36 -04:00
Nick Mathewson 5de1b93195 DirMgr: Remove blocking_error return path. 2022-05-17 12:25:32 -04:00
Nick Mathewson 53ed5f40cf DirMgr: Unify error return paths
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.
2022-05-17 12:25:32 -04:00
Nick Mathewson d7a3fd2c17 DirMgr: Remove special handling of "changed" boolean 2022-05-17 10:16:15 -04:00
Nick Mathewson 6bacf3b303 DirMgr: Start refactoring error handling.
This commit adds a couple of new error types that we will soon want
to distinguish, and a new way of classifying errors.  These are not
yet all used.
2022-05-17 09:52:44 -04:00
Nick Mathewson e37e37a31c Give an error if the cache violates If-Modified-Since.
This should be sufficient to detect several kinds of nefariousness
that we'd previously overlooked.
2022-05-16 12:49:49 -04:00
Nick Mathewson 37f6730077 Add missing extend_tolerance to add_consensus_text.
This should have gone in when we fixed #412
2022-05-16 12:49:49 -04:00
Nick Mathewson ffc864015a DirMgr: Blame the correct cache for consensus validation failure 2022-05-16 12:49:49 -04:00
Nick Mathewson c55738e745 Move consensus signature verification to add-document code.
Previously, we did this in `advance()`, but that wasn't so great: it
meant that we could fail in the advance() code, whereas the calls to
`advance()` treated errors as fatal.

This treats failed verification as a blocking error that requires a
reset.

Fixes one aspect of #439.
2022-05-16 12:49:49 -04:00
Nick Mathewson d1af40e638 On a blocking error, blame the appropriate directory cache
Fortunately, the only error type that we need to handle blocking
errors with actually has a DirSource in it already.
2022-05-16 12:49:49 -04:00
Nick Mathewson 40539cb25e DirMgr: Add a way for a state to report a blocking error.
(A blocking error is one that means that the current bootstrap
attempt has failed, and must be restarted.)
2022-05-16 12:42:25 -04:00
Nick Mathewson b94f56d6f5 Implement nonfatal errors in add_from_* 2022-05-16 12:42:25 -04:00
Nick Mathewson d8bd862f2b DirMgr: Let add_from_* distinguish non-fatal errors
Previously all errors were treated as non-fatal.

The add_from_* implementations don't yet behave properly;
I'll fix them in subsequent commits.
2022-05-16 12:42:25 -04:00
Nick Mathewson f70ad60e65 DirMgr: Improve display for DocSource
(Also, implement Display for tor_dirclient::SourceInfo).
2022-05-16 12:42:25 -04:00
Nick Mathewson ef2640acfa DirMgr: make DocSource useful by having it include dirserver info.
Previously DocSource would tell you whether the document was from
a local store or a cache server, but it wouldn't tell you _which_
server it came from.

This change required adding DocSource as an argument to
DirState::add_from_download.
2022-05-16 12:42:25 -04:00
Nick Mathewson fb432924a3 Merge branch 'main' into 'ticket_466'
# Conflicts:
#   doc/semver_status.md
2022-05-16 15:10:00 +00:00
Nick Mathewson f0eac61838 Merge branch 'network-config-error' into 'main'
Delete tor_dirmgr::Error::BadNetworkConfig

See merge request tpo/core/arti!506
2022-05-12 16:43:26 +00:00
Ian Jackson d847d49858 Delete tor_dirmgr::Error::BadNetworkConfig
This was anomalous, in that it contains &'static str, rather than a
proper nested error (eg a config::ConfigError, maybe).

But in fact it tursn out it is now not constructed.  The last
construction site was removed a long time ago in
  Use derive_builder for Authority and FallbackDir.
2022-05-12 16:49:06 +01:00
Nick Mathewson 24c7dea38d Resolve DOCDOC comments in tor-dirmgr. 2022-05-12 09:45:05 -04:00
Nick Mathewson 2e99c9fe64 dirmgr: use set_skew_limit.
With this API we can now stop consensus download attempts early if
any consensus that the directory cache gave us would be necessarily
too far in the future or in the past.

This saves wasted bandwidth for clients with skewed clocks.

Closes #466.
2022-05-11 13:52:07 -04:00
Nick Mathewson 9e040e7809 Adjust if-modified-since field on the basis of tolerated skew
If we're happy with a directory from 3 days ago, we should say
"if-modified-since 3 days ago".

This patch is larger than I'd like, since I had to add &DirMgrConfig
as an argument to the functions that make a  consensus request.

Closes #467.
2022-05-11 12:36:51 -04:00
Nick Mathewson db8bdbf924 tor-dirmgr: update status reporting to consider skew tolerance
In our status reporting code, we consider an
expired-but-still-usable directory still bootstrapped, but not 100%
bootstrapped.
2022-05-11 12:11:30 -04:00
Nick Mathewson 1dafba706d Make reset_time() for incomplete directories more generous.
Since we want to be willing to use older consensuses, we don't
necessarily want to reset a download just because the consensus is
expired.

This new behavior isn't ideal either; I've added a TODO that relates
to #433.

Related of #412
2022-05-11 12:11:17 -04:00
Nick Mathewson 7dec007d63 Add DirSkewTolerance section to DirMgr configuration.
This new section describes how much variance we accept when it comes
to expired and not-yet-valid directory documents.  (Currently, the
only ones where this matters for are consensus documents and
authority certificates.)  A document that is invalid by no more than
these tolerances is not _live_, but it can still be used.

These tolerances serve two purposes:

 * First, they allow clients to run with a little more clock skew
   than they would tolerate otherwise.
 * Second, they allow clients to survive the situation where the
   authorities are unable to reach a consensus for a day or two.

Compare with Tor's REASONABLY_LIVE_TIME and NETWORKSTATUS_ALLOW_SKEW
constants; also compare with proposal 212.

Closes #412.
2022-05-11 12:11:17 -04:00
eta 33b2b428bd tor-dirmgr: move apply_netdir_changes() to be a DirMgr method 2022-05-10 13:29:39 +01:00
eta 27f4657ff1 tor-dirmgr: small fixups for the bootstrapping refactor
- Some FIXMEs got removed or amended.
- AddMicrodescs now yields a mutable reference, so we can use .drain()
  and reuse the allocation.
- Some panics were downgraded to debug_asserts.
2022-05-10 13:29:39 +01:00
eta 8347f8cb7e tor-dirmgr/bootstrap.rs: error on older netdirs, add log line
- We don't want to inadvertently replace our netdir with one that's
  actually older, so detect and error on this condition.
- Also, print a debug line when we get a new netdir without enough
  guards.
- (An unrelated TODO was also added.)
2022-05-10 13:29:39 +01:00
eta 2c28e217dd tor-dirmgr/state.rs: take an object to get a netdir, not a netdir
- Taking a previous netdir directly and keeping it around before we need
  it is a bit of a waste of memory, and also doesn't mesh well with how
  SharedMutArc works.
- To remedy this, introduce a new trait `PreviousNetDir` and have the
  state machines take that instead. (I was a bit tempted to just pass in
  the SharedMutArc directly. Maybe I should've done that.)
2022-05-10 13:29:39 +01:00
eta 27073a5d23 tor-dirmgr/state.rs: remove GetConsensusState::bodge_new
- (Also fixes up some dirfilter stuff, whoops.)
2022-05-10 11:50:07 +01:00
eta 7b5fad3130 tor-dirmgr/state.rs: remove WriteNetDir, use filters directly
- The only purpose of WriteNetDir was to provide a filter, which isn't
  necessary any more. Refactor to provide the filter directly.
2022-05-10 11:50:07 +01:00
eta 8b0166970e tor-dirmgr/state.rs: use the NetDirChange API instead of WriteNetDir
- GetMicrodescsState now uses the NetDirChange API to propagate netdir
  changes, instead of modifying the netdir directly.
- PendingNetDir was refactored in order to support this use case.
- As a result, the netdir-related methods in WriteNetDir can be removed,
  leaving only the DirFilter for now.
- add_from_cache() no longer takes a store, because nothing uses it.
- (bodge: apply_netdir_changes() was put in a few places missed
  previously)
2022-05-10 11:50:06 +01:00
eta 7a52e77e45 tor-dirmgr/state.rs: add new NetDirChange API, consume it
- The new DirState::get_netdir_change() API lets the state machine
  export a NetDirChange: a request to either replace the current netdir,
  or add microdescs to it.
- bootstrap.rs now consumes this new API, even though nothing implements
  it yet.
- This will let us implement GetMicrodescsState without having to
  directly mutate the netdir. The calling code also handles checking the
  netdir against the circmgr for sufficiency, and updating the consensus
  metadata in the store, meaning the revised GetMicrodescsState will not
  have to perform these tasks.
2022-05-10 11:48:57 +01:00
eta cad815e31d tor-dirmgr/state.rs: feed through additional parameters, use them
- The additional parameters passed to GetConsensusState are now passed
  through all the states, and used as well.
- WriteNetDir doesn't have a now() or config() method any more, since
  the states now get this from the runtime or the config parameters.
- This required modifying the tests to make a mocked runtime and custom
  config directly, instead of using DirRcv for this purpose.
- Additionally, because we don't have to upgrade a weak reference for
  DirState::dl_config(), that function no longer wraps its return value
  in Result.
- (A bunch of the FIXMEs from the previous commit that introduced the
  additional parameters have now been rectified as a result.)
2022-05-10 11:48:56 +01:00
eta a9bae9adfe tor-dirmgr/state.rs: refactor GetConsensusState::new
- GetConsensusState::new now takes a set of parameters matching what it
  actually needs, instead of just taking a writedir. (It still *does*
  take a writedir, and indeed still uses it for basically everything,
  but that will eventually go away.)
- Its call sites were updated.
  - Some tests now need to take a runtime, and got indented a lot as a
    result.
  - Resetting was made non-functional, because we need to thread through
    the parameters passed to GetConsensusState to all of the other
    states, too. This will happen in a later commit.
2022-05-10 11:42:50 +01:00
eta 62ece0ea21 tor-dirmgr: move DirState to state.rs
- Given that this is effectively an implementation detail, it doesn't
  really make sense to have it be in the crate root...
- (also, we're going to change it a bunch now)
2022-05-10 11:39:32 +01:00
eta 72ea9e3438 tor-dirmgr/bootstrap.rs: refactor fetch_single
- fetch_single now takes what it needs, instead of an Arc<DirMgr<R>>.
- This required refactoring the CANNED_RESPONSE mechanism, given the
  test would otherwise fail due to not having a CircMgr to pass to
  fetch_single.
2022-05-10 11:39:32 +01:00
eta 2fd03564b9 tor-dirmgr: make note_request_* functions standalone
- DirMgr::note_request_outcome and friends are now just standalone
  functions, taking a CircMgr.
2022-05-10 11:39:32 +01:00
eta 8b44569b5f tor-dirmgr/bootstrap.rs: refactor query_into_requests, make it used
- query_into_requests is now called make_requests_for_documents, and
  does the &[DocId] -> DocQuery conversion internally instead.
- DirMgr::make_consensus_request and DirMgr::query_into_requests are now
  gone. The tests use the new functions, as does fetch_multiple.
2022-05-10 11:39:32 +01:00
eta 4a98ed1301 tor-dirmgr: move query_into_requests into bootstrap.rs
- There's no good reason these functions needed to be part of the
  dirmgr, apart from needing a runtime and a store.
- However, we can just add those as arguments and copy them over. This
  commit does that.
2022-05-10 11:39:32 +01:00
eta 13446ac65a tor-dirmgr/bootstrap.rs: refactor load_all -> load_documents_from_store
- Function renamed & docs tidied up a bit
- Function signature now takes what it needs (immutable &dyn Store
  instead of mutex, slice instead of Vec) and nothing more
- DocQuery::load_documents_into was also renamed
  DocQuery::load_from_store_into and given similar treatment
2022-05-10 11:39:32 +01:00
eta 0dfac00842 tor-dirmgr/storage.rs: impl Store for Box<dyn Store>
Annoyingly, Rust doesn't automatically generate this sort of `impl` for
you, and I'd like to reduce the usage of Mutex<DynStore> everywhere else
in favour of either &dyn Store or &mut dyn Store.

(This is for two reasons: firstly, we might have a Store implementation
that doesn't use a mutex as above, or similar refactors; secondly,
passing the raw trait object reference lets us encode mutability into
the function signature, which I believe is quite valuable.)
2022-05-10 11:39:30 +01:00
eta d7f2718a8b tor-dirmgr/lib.rs: move DirMgr::load_documents_into to DocQuery
Move the function out of DirMgr, giving it a new &Mutex<DynStore>
argument instead.
2022-05-10 11:38:00 +01:00
Nick Mathewson 4262e9d0ec Merge branch 'use-fs-mistrust' 2022-05-09 15:27:25 -04:00
Nick Mathewson 20a85061b6 Update tor-dirmgr to use fs-mistrust. 2022-05-09 14:40:29 -04:00
Nick Mathewson 7b93091f57 Bump the version of every* crate to 0.3.0
* Except for safelog and fs-mistrust, which are new.
2022-05-06 10:03:15 -04:00
Ian Jackson 030289481f Switch to derive_builder_arti_fork
For reference, the git source for this crate (and the others in its
workspace) currently lives in my personal github account (ijackson).
If this fork turns out to be long-lived and gains features and/or
users, it would be good to move it to a gitlab somewhere.

I have granted Nick crate ownership on the crates.io system.
2022-05-06 13:36:40 +01:00
Ian Jackson d47e94b459 config derive attrs: Make builders serde, and validated structs not
* 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.)
2022-05-05 10:35:52 +01:00
Ian Jackson 4ad4cae418 FallbackDir: Use VecBuilder for orports
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.
2022-05-04 17:18:55 +01:00
Ian Jackson 9214eb5db2 tor-dirmgr: make DownloadScheduleBuilder public
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.
2022-05-04 13:50:12 +01:00
Ian Jackson 4bca912715 Change builder list API
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).
2022-05-04 13:50:10 +01:00
Ian Jackson ff624f6081 Rename NetworkConfig.fallback_caches
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.
2022-05-04 13:41:39 +01:00
eta 6f787e1e77 Merge branch 'derive-builder-git-fixup' into 'main'
derive_builder: Use git dep everywhere, rather than cargo patch

See merge request tpo/core/arti!477
2022-04-27 14:31:08 +00:00
Ian Jackson a97ad69855 derive_builder: Use git dep everywhere, rather than cargo patch
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.
2022-04-27 14:57:59 +01:00
Samanta Navarro c53818d496 Fix grammar and typos 2022-04-27 13:52:13 +01:00
eta 8509dbc920 Merge branch 'upgrade_dependencies' into 'main'
Upgrade various dependencies, now that we are MSRV 1.56

Closes #313 and #334

See merge request tpo/core/arti!476
2022-04-27 12:27:28 +00:00
Nick Mathewson 5484bcc21f Merge branch 'download-schedule' into 'main'
DownloadSchedule: Introduce Builder

See merge request tpo/core/arti!473
2022-04-26 18:47:08 +00:00
Ian Jackson 4a32bcd4d3 Make DownloadScheduleBuilder "alternative" defaults pub(crate)
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/473#note_2798464
2022-04-26 19:01:20 +01:00
Nick Mathewson 4643e1dd24 Fix typo in message 2022-04-26 17:40:05 +00:00
Nick Mathewson 5586f0d039 Upgrade to Postage 0.5.0 2022-04-26 12:16:22 -04:00
Ian Jackson 72eaa9fc30 DirMgrConfig: Remove unnecessary accessors
These fields are pub.

Retain two convenience accessor functions that access sub-fields of
network.
2022-04-26 15:32:20 +01:00
Ian Jackson 20d61dd4d4 DirMgrConfig: Rename two fields that contained a _config
This entire struct is config.  This is otiose.
2022-04-26 15:29:33 +01:00
Ian Jackson ed71858123 DownloadSchedule: Rename field to "attempts"
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.
2022-04-26 15:16:32 +01:00
Ian Jackson cb303cefb3 DownloadSchedule: Abolish accessors in DownloadScheduleConfig
We can just make the fields pub(crate).
2022-04-26 15:16:32 +01:00
Ian Jackson eb35555330 DownloadSchudule: Have NetworkConfig contain Builders
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.)
2022-04-26 15:16:32 +01:00
Ian Jackson f4a1e34bee DownloadSchedule: Abolish new() method
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.
2022-04-26 15:16:32 +01:00
Ian Jackson e1d1fe6569 DownloadSchedule: tests: Do not try to set parallelism to 0
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.
2022-04-26 15:16:03 +01:00
Ian Jackson a720205d35 DownloadSchedule: Provide builder 2022-04-26 15:16:03 +01:00
Nick Mathewson c1ea419477 Merge branch 'main' into 'msrv_1_56'
# Conflicts:
#   crates/tor-config/Cargo.toml
#   crates/tor-dirmgr/src/state.rs
#   doc/semver_status.md
2022-04-26 12:45:16 +00:00
Ian Jackson ce877e4421 Document defaults for all the config lists
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.
2022-04-25 18:22:54 +01:00
Ian Jackson 1f215da1a3 Rename ThingListBuilder::replace (from set)
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/471#note_2798024
2022-04-25 18:15:25 +01:00
Nick Mathewson 2f6bc6bdc4 squash! Bump every crate's edition to 2021.
Remove all `use` statements for `TryFrom` and `TryInto`.  These are
now redundant in Rust 2021.
2022-04-25 13:06:26 -04:00
Nick Mathewson b60b0a266a Bump every crate's edition to 2021.
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.
2022-04-25 13:05:31 -04:00
Nick Mathewson ca05b0904c Add 'rust-version = "1.56"' to every Cargo.toml file.
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.
2022-04-25 13:04:31 -04:00
Nick Mathewson 0069fd2206 Reformat all not-yet-reformatted Cargo.toml files.
There are no semantic changes here; only formatting.  This is in
preparation for other changes (wrt MSRV and edition)
2022-04-25 13:04:31 -04:00
Ian Jackson dca4f3ede1 Use better syntax for doc comment attribute
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/471#note_2798020
2022-04-25 17:05:30 +01:00
Ian Jackson 4ad9e5e4b0 Introduce AuthorityListBuilder in NetworkConfigBuilder
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.
2022-04-25 12:54:51 +01:00
Ian Jackson 166af2c3f6 Fix error return type of AuthorityBuilder 2022-04-25 12:41:39 +01:00
Ian Jackson 0d4c53bb2d Merge branch 'experimental-v3ident-public' into 'main'
Authority: make v3ident public under experimental-api

See merge request tpo/core/arti!463
2022-04-25 09:31:05 +00:00
Christian Grigis 08bce9b6db
Authority: make v3ident public under experimental-api 2022-04-22 19:33:36 +02:00
Ian Jackson 962b6c32e1 fallback list: Introduce and use FallbackListBuilder
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.
2022-04-22 17:48:03 +01:00
Ian Jackson 61425a96bd fallback list: Move default list into tor-guardmgr
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.
2022-04-22 17:39:58 +01:00
Ian Jackson 6da7a2e3e2 Use git source for derive_builder for now, for sub_builder feature
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.
2022-04-21 14:07:28 +01:00
Samanta Navarro 142e57b03a Fix typos
Typos found with codespell.
2022-04-20 11:48:43 +00:00
Nick Mathewson d05022dea4 Treat expired/not-yet-valid directory objects as Errors.
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.
2022-04-05 15:54:37 -04:00
Nick Mathewson 5b2fc118df Bump all arti*, tor* crates to 0.2.0
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.)
2022-04-01 09:15:18 -04:00
Nick Mathewson c5e5fc1553 dirmgr: Use a different idiom in retry loop
Replace the next delay field immediately rather than taking it and
_then_ setting it.  This way, it's never in an incorrect state.
2022-03-31 08:07:50 -04:00