summaryrefslogtreecommitdiff
path: root/crates/tor-dirmgr
Commit message (Collapse)AuthorAgeFilesLines
* Bump all arti*, tor* crates to 0.2.0Nick Mathewson2022-04-011-14/+14
| | | | | | | | 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.)
* dirmgr: Use a different idiom in retry loopNick Mathewson2022-03-311-3/+2
| | | | | Replace the next delay field immediately rather than taking it and _then_ setting it. This way, it's never in an incorrect state.
* dirmgr: fix bugs in algorithm for retrying downloadsNick Mathewson2022-03-301-13/+22
| | | | | | | | | | 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.
* Reformat several Cargo.toml files with 100-char-wide lines.Nick Mathewson2022-03-301-7/+2
|
* Refactor FirstHopId into type-differentiated formNick Mathewson2022-03-301-6/+4
| | | | | | | | | | | 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.
* Rename Guard=>FirstHop, GuardId=>FirstHopIdNick Mathewson2022-03-301-4/+4
| | | | | This is preparation for having separate GuardId and FirstHopId types that distinguish which back-end they index.
* Rename ExternalFailure => ExternalActivity.Nick Mathewson2022-03-301-4/+4
|
* Add status tracking to FallbackDir.Nick Mathewson2022-03-302-1/+17
| | | | | | | | | | | 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.
* dirmgr: do not pass fallbacks to the CircMgr.Nick Mathewson2022-03-301-6/+1
| | | | | | | This is the final step in allowing the CircMgr to use the GuardMgr's view of the fallbacks. Compilation is restored and tests pass.
* Turn FallbackList into a real type, and store one in GuardMgr.Nick Mathewson2022-03-301-9/+17
| | | | | | | | | | | | | | 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.
* Move fallback.rs into guardmgr.Nick Mathewson2022-03-303-3/+4
| | | | | | | 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.
* Merge branch 'disallowed_lint' into 'main'eta2022-03-302-2/+0
|\ | | | | | | | | Remove allow(clippy::disallowed_methods) lint flag. See merge request tpo/core/arti!437
| * Remove allow(clippy::disallowed_methods) lint.Nick Mathewson2022-03-302-2/+0
| |
* | Make daemon tasks self-contained; introduce NetDirProvidereta2022-03-302-36/+12
|/ | | | | | | | | | | | | | | 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.
* Merge branch 'no-system-time' into 'main'eta2022-03-304-21/+27
|\ | | | | | | | | | | | | Don't use SystemTime::now() Closes #306 See merge request tpo/core/arti!365
| * use wallclock where possible in teststrinity-1686a2022-02-263-14/+17
| |
| * remove most usage of SystemTime::nowtrinity-1686a2022-02-252-7/+10
| |
* | Upgrade to rusqlite 0.27.0Nick Mathewson2022-03-291-1/+1
| |
* | DirFilter: Move nil default impls to trait default methodsIan Jackson2022-03-251-10/+7
| | | | | | | | | | | | | | This means you can write a DirFilter and only write code to mess with the bits you want to. Also, it is less code here.
* | Abolish filter::DynFilter in favour of transparent DirFilterIan Jackson2022-03-254-52/+13
| | | | | | | | | | | | | | | | | | | | | | | | There are two reasons why the DynFilter newtype might be needed: 1. To impl Default. But we don't need it to impl Default since we can have an accessor which does the defaulting. 2. To hide the API. But this is usrely an unstable API. Just writing Arc<dyn> gets rid of a lot of unnecessary boilerplate and conversion code.
* | Make DirFilter be Debug + Send + SyncIan Jackson2022-03-251-8/+4
| | | | | | | | | | Abolish the handwritten Debug impl for DynFilter, which is no longer needed.
* | dirmgr: Initial DirFilter code.Nick Mathewson2022-03-245-0/+140
| | | | | | | | | | | | This code sits behind a feature flag, and can be used to modify directories before storing them. This is part of the implementation for #397.
* | Reformat {arti-client,tor-dirmgr}/Cargo.tomlNick Mathewson2022-03-241-13/+16
| |
* | Expand some comments based on review from @diziet.Nick Mathewson2022-03-212-0/+10
| |
* | Fix build with Rust 1.53.Nick Mathewson2022-03-211-6/+9
| | | | | | | | Pattern bindings after `@` weren't stabilized then :/
* | dirmgr: Note errors and inform the circmgr about them.Nick Mathewson2022-03-213-7/+115
| | | | | | | | | | | | Some error types indicate that the guard has failed as a dircache. We should treat these errors as signs to close the circuit, and to mark the guard as having failed.
* | circmgr: Change API for using FallbackDirsNick Mathewson2022-03-211-1/+5
| | | | | | | | | | | | It'll soon more convenient to pass in FallbackDirs as a slice of references, rather than just a slice of FallbackDirs: I'm going to be changing how we handle these in tor-dirmgr.
* | dirmgr: Authority: Abolish v3ident accessorIan Jackson2022-03-182-11/+3
| | | | | | | | | | This makes this information crate-private. The crate can reasonably just access it.
* | dirmgr: Authority: Move a method used only for testingIan Jackson2022-03-181-6/+9
| |
* | dirmgr: Authority: Abolish two unused accessorsIan Jackson2022-03-181-9/+1
| |
* | dirmgr: NetworkConfig: Abolish accessorsIan Jackson2022-03-181-16/+8
| | | | | | | | Using accessors for crate-only fields is otiose.
* | dirmgr: NetworkConfig: Rename fallbacks struct fieldIan Jackson2022-03-181-6/+9
| | | | | | | | | | | | Rename this to be named the same as its accessor, and use the rename feature of builder and serde. (The shorter name is nicer in the code IMO.)
* | Merge branch 'md_allocation' into 'main'Nick Mathewson2022-03-171-20/+54
|\ \ | | | | | | | | | | | | | | | | | | Use less space in hashtables for microdescriptors Closes #386 See merge request tpo/core/arti!415
| * | Run rustfmtIan Jackson2022-03-171-5/+6
| | |
| * | GetMicrodescsState: Abolish separate n_missing field inIan Jackson2022-03-171-12/+12
| | |
| * | GetMicrodescsState: Break out with_mdreceiver_for_missingIan Jackson2022-03-171-13/+23
| | |
| * | GetMicrodescsState: Dedupe slightlyIan Jackson2022-03-171-8/+9
| | |
| * | tor-dirmgr: Remove redundant hashtable.Nick Mathewson2022-03-161-22/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | We were using a hashtable to keep track of missing microdescriptor digests. But this information is redundant with the NetDir state, and there's now no longer any performance benefit to keeping a separate copy. Part of #386.
* | | Merge branch 'config-partials-transparent' into 'main'Ian Jackson2022-03-173-67/+43
|\ \ \ | | | | | | | | | | | | | | | | Absolish builders for CircMgrConfig and DirMgrConfig See merge request tpo/core/arti!417
| * | | DirMgrConfig: abolish builder; make it transparent and exhaustiveIan Jackson2022-03-163-67/+43
| | | | | | | | | | | | | | | | See rationale in the comment.
* | | | Merge branch 'always-ims' into 'main'eta2022-03-161-10/+49
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | dirmgr: Always send if-modified-since on consensus documents. Closes #403 See merge request tpo/core/arti!412
| * | | | dirmgr: Always send if-modified-since on consensus documents.Nick Mathewson2022-03-161-10/+49
| | |/ / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We never want a consensus document that's super-old, since we would reject it immediately for being too old. Also, never send an if-modified-since that's so old that we'd reject the response. Closes #403
* | | | Merge branch 'derive-builder' into 'main'Ian Jackson2022-03-161-1/+1
|\ \ \ \ | |_|/ / |/| | | | | | | | | | | derive_builder: Switch to upstream 0.11 See merge request tpo/core/arti!414
| * | | derive_builder: Switch to upstream 0.11Ian Jackson2022-03-161-1/+1
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | This has the different syntax for builder field attributes than what I originally proposed in my MR, and which therefore is in the pinned branch. My upstream MR for the field attributes feature was morged: https://github.com/colin-kiegel/rust-derive-builder/issues/239
* | | RetryDelay: remove accessors.Nick Mathewson2022-03-161-7/+9
| | | | | | | | | | | | Instead, check initial_delay in dirmgr directly.
* | | Remove re-export of retry-schedule in tor-dirmgr.Nick Mathewson2022-03-161-1/+1
| | | | | | | | | | | | It wasn't necessary.
* | | Fix up documentation on RetryDelay.Nick Mathewson2022-03-161-6/+3
| | | | | | | | | | | | | | | It's no longer about downloads; it's about whatever you need to retry.
* | | Move RetryDelay from dirmgr to basic-utils.Nick Mathewson2022-03-161-155/+1
| | | | | | | | | | | | | | | This (almost) a pure code-movement commit: it also makes one public function private in order to suppress a warning.
* | | RetryDelay: add accessors for stateNick Mathewson2022-03-161-5/+22
|/ / | | | | | | | | We'll need these for our unit tests in tor-dirmgr once we move RetryDelay into tor-basic-utils.
* | Merge branch 'missing_shrink_to_fit' into 'main'eta2022-03-141-0/+7
|\ \ | | | | | | | | | | | | | | | | | | dirmgr: Call shrink_to_fit on missing-microdesc hashtable Closes #388 See merge request tpo/core/arti!399