Commit Graph

3221 Commits

Author SHA1 Message Date
Nick Mathewson 6e8c982ab5 dirmgr: fix bugs in algorithm for retrying downloads
The previous algorithm had two flaws:

  * It would wait even after the final attempt, when there were no
    more retries to do.
  * It would fail to wait between attempts if an error occurred.

This refactoring fixes both of these issues, and adds some comments.
2022-03-30 13:56:36 -04:00
Nick Mathewson 849371c1d3 README.md for arti-testing. 2022-03-30 13:41:04 -04:00
Ian Jackson c8d9ae4535 Merge branch 'fallback_status_v2' into 'main'
Refactor FallbackDir handling and implement a retry-after-delay mechanism.

Closes #406 and #220

See merge request tpo/core/arti!433
2022-03-30 16:25:37 +00:00
Ian Jackson 33399bed8b Merge branch 'fallback_status_v2' into main
Manual merge for just this branch as per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/433#note_2791982
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/433#note_2791993
2022-03-30 16:34:01 +01:00
Nick Mathewson 2bb3ba7886 Run cargo fmt one more time for good measure. 2022-03-30 10:41:57 -04:00
Nick Mathewson df3c51c8a0 Use derive_more to derive AsRef. 2022-03-30 10:41:40 -04:00
Nick Mathewson 5233d35223 Reformat tor-guardmgr/Cargo.toml. 2022-03-30 10:41:40 -04:00
Nick Mathewson 1feb7eecac Reformat several Cargo.toml files with 100-char-wide lines. 2022-03-30 10:41:40 -04:00
Nick Mathewson 3e92d30e49 Fix some Rustdoc links. 2022-03-30 10:41:40 -04:00
Nick Mathewson 6282df34fb Refactor FirstHopId into type-differentiated form
The FirstHopId type now records an enum that stores whether the hop
is a guard or a fallback.  This change addresses concerns about
remembering to check the type or source of an Id before passing it
down to the FallbackState or GuardSet.

Making this change required an API change, so that dirmgr can
report success/failure status without actually knowing whether it's
using a fallback or a guard.
2022-03-30 10:41:39 -04:00
Nick Mathewson 13af6134f6 Rename Guard=>FirstHop, GuardId=>FirstHopId
This is preparation for having separate GuardId and FirstHopId types
that distinguish which back-end they index.
2022-03-30 10:40:59 -04:00
Nick Mathewson 9803b645c0 FallbackState: Use itertools::merge_join_by.
This replaces a hand-coded replacement that was probably a little
less efficient.
2022-03-30 10:40:14 -04:00
Nick Mathewson b752c6c771 Fold fallback::Status::reset() into its (only) caller. 2022-03-30 10:40:14 -04:00
Nick Mathewson 9bf2fe3aca Rename FallbackState::lookup_mut => get_mut. 2022-03-30 10:40:14 -04:00
Nick Mathewson b1ccd3c7dc Rename FallbackSet => FallbackState. 2022-03-30 10:40:14 -04:00
Nick Mathewson 951b800988 DirPathBuilder::pick_path: re-order match cases for clarity. 2022-03-30 10:40:14 -04:00
Nick Mathewson 2cf00e63de Refactor select_guard_with_expand to use match and log errors. 2022-03-30 10:40:14 -04:00
Nick Mathewson 578f2925d9 ListKind: Use an exhaustive match to future-proof. 2022-03-30 10:40:14 -04:00
Nick Mathewson c721c8ee53 Clarify documentation about GuardUsable constructors 2022-03-30 10:40:14 -04:00
Nick Mathewson 16ce29ef59 Add a TODO about an unslightly type. 2022-03-30 10:40:14 -04:00
Ian Jackson 82ea251f3c Clean up a rustdoc link 2022-03-30 10:40:14 -04:00
Nick Mathewson b88789d1dd guardmgr::fallback::set: basic unit tests. 2022-03-30 10:40:14 -04:00
Nick Mathewson bdd129f230 Rename ExternalFailure => ExternalActivity. 2022-03-30 10:40:12 -04:00
Nick Mathewson d88e9d676e Replace the fallback directories when they change in the config.
The code here uses a new iterator type, since I couldn't find one of
these on crates.io.  I tried writing the code without it, but it was
harder to follow and test.
2022-03-30 10:39:09 -04:00
Nick Mathewson bfb2353a8f Add status tracking to FallbackDir.
We do this by creating a new FallbackSet type that includes status
information, and updating the GuardMgr APIs to record success and
failure about it when appropriate.  We can use this to mark
FallbackDirs retriable (or not).

With this change, FallbackDir is now stored internally as a Guard in
the GuardMgr crate.  That's fine: the FallbackDir type really only
matters for configuration.
2022-03-30 10:39:09 -04:00
Nick Mathewson ea520898fd Implement Ord for Ed25519Identity. 2022-03-30 10:39:09 -04:00
Nick Mathewson b28863f03d Update semver_status from recent round of movement. 2022-03-30 10:39:09 -04:00
Nick Mathewson e48f4f3a93 dirmgr: do not pass fallbacks to the CircMgr.
This is the final step in allowing the CircMgr to use the GuardMgr's
view of the fallbacks.

Compilation is restored and tests pass.
2022-03-30 10:39:09 -04:00
Nick Mathewson ed6389acc7 circmgr: Use guard-manager's view of the fallbacks when possible.
If we're building a path with the guard manager involved, we now ask
the guard manager to pick our first hop no matter what.  We only
pick from the fallback list ourselves if we're using the API with no
guard manager.

This causes some follow-on changes where we have to remember an
OwnedChanTarget object in a TorPath we've built, and where we gain
the ability to say we're building a path "from nothing extra at
all."  Those are all internal to the crate, though.

Closes #220, by making sure that we use our guards to get a fresh
netdir (if we can) before falling back to any fallbacks, even if our
consensus is old.

Compilation should be fixed in the next commit.
2022-03-30 10:39:09 -04:00
Nick Mathewson 40c8232426 GuardMgr: Return fallback directories when appropriate.
We only do this when we fail to get a regular guard (e.g., because
they're all down), and when we have been asked for a guard for a
one-hop directory.

Most of the change in this commit is plumbing to make all of the
types match up.

As before, compilation may still be broken.
2022-03-30 10:39:09 -04:00
Nick Mathewson 9e31ee0c9b Fix typos in guardmgr/lib.rs 2022-03-30 10:39:09 -04:00
Nick Mathewson a4a5f2163d GuardMgr: some prep work for returning fallbacks as guards.
We need to extend our notion of "the origin of a guard" to include
"somewhere outside the guard list"; we need the ability to return a
FallbackDir as a Guard; and we need to remember a few more pieces of
information in each pending request.

As before, this commit may break compilation; it will be restored soon.
2022-03-30 10:39:09 -04:00
Nick Mathewson 9da43189f3 Turn FallbackList into a real type, and store one in GuardMgr.
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.
2022-03-30 10:39:06 -04:00
Nick Mathewson 6397b56317 Reformat tor-circmgr/Cargo.toml 2022-03-30 10:34:50 -04:00
Nick Mathewson 5b04e5a6b6 guardmgr: move error types into new err.rs module.
This is more in keeping with the rest of our code.
2022-03-30 10:34:50 -04:00
Nick Mathewson 80b65c3a4d Move fallback.rs into guardmgr.
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.
2022-03-30 10:34:48 -04:00
eta 5d27710ef1 Merge branch 'disallowed_lint' into 'main'
Remove allow(clippy::disallowed_methods) lint flag.

See merge request tpo/core/arti!437
2022-03-30 14:02:13 +00:00
eta a24fe1413b Merge branch 'daemon-separation' into 'main'
Make daemon tasks self-contained; introduce NetDirProvider

See merge request tpo/core/arti!436
2022-03-30 13:58:45 +00:00
eta ac64bdea27 Make daemon tasks self-contained; introduce NetDirProvider
The various background daemon tasks that `arti-client` used to spawn are
now handled inside their respective crates instead, with functions
provided to spawn them that return `TaskHandle`s.

This required introducing a new trait, `NetDirProvider`, which steals
some functionality from the `DirProvider` trait to enable `tor-circmgr`
to depend on it (`tor-circmgr` is a dependency of `tor-dirmgr`, so it
can't depend on `DirProvider` directly).

While we're at it, we also make some of the tasks wait for events from
the `NetDirProvider` instead of sleeping, slightly increasing
efficiency.
2022-03-30 14:26:43 +01:00
Nick Mathewson 537ff61ece Fix a let_and_return lint violation that had somehow slipped in. 2022-03-30 08:57:14 -04:00
Nick Mathewson 700e491813 Remove allow(clippy::disallowed_methods) lint. 2022-03-30 08:55:58 -04:00
eta fd081742fa Merge branch 'no-system-time' into 'main'
Don't use SystemTime::now()

Closes #306

See merge request tpo/core/arti!365
2022-03-30 12:44:25 +00:00
Nick Mathewson 6d7dcdc621 Update README.md files using readmes script 2022-03-29 13:30:17 -04:00
Nick Mathewson 3bab96f064 Upgrade to rusqlite 0.27.0 2022-03-29 13:27:08 -04:00
Nick Mathewson b0a978c23a Run cargo-update in preparation for Arti 0.2.0
(Doing this a few days ahead of time to give updated code time to
get testing)
2022-03-29 13:22:28 -04:00
Nick Mathewson 65b7751767 Start a changelog for Arti 0.2.0 2022-03-28 10:10:18 -04:00
Nick Mathewson 482b2e3256 Remove a now-irrelevant comment 2022-03-28 08:30:44 -04:00
Nick Mathewson 9177411951 Merge branch 'isolation-followup' into 'main'
implement IsolationHelper for StreamIsolation

See merge request tpo/core/arti!434
2022-03-28 12:29:25 +00:00
trinity-1686a 219ad39eca remove usage of 'token' where it's no longer a token 2022-03-27 13:49:08 +02:00
Ian Jackson 6e07ab1668 Merge branch 'main' into 'main'
Fixed typo on arti-client README.md

See merge request tpo/core/arti!432
2022-03-25 16:01:45 +00:00