summaryrefslogtreecommitdiff
path: root/crates/tor-circmgr/src
Commit message (Collapse)AuthorAgeFilesLines
* Resolve the new `derive_partial_eq_without_eq` lint.Nick Mathewson2022-05-233-5/+5
| | | | It's a little overzealous sometimes, but it's mostly to the good.
* impl_standard_builder: Have it generate FooConfig::builderIan Jackson2022-05-121-18/+0
| | | | | This deletes many handcoded impls. It also generates lots of impls that we previously didn't have.
* Merge branch 'builder-default-bis' into 'main'eta2022-05-121-26/+4
|\ | | | | | | | | impl_standard_builder followup See merge request tpo/core/arti!505
| * Rename impl_standard_builder from impl_default_via_builderIan Jackson2022-05-121-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | I have Plans for this macro. In particular: * I have a wip branch which tests that the Builder can be deserialised from an empty config (ie, that config reading of a config with a blank section for this item works). * I think we should autogenerate $Config::builder(), and promote that, rather than $ConfigBuilder::default(). This macro could do that.
| * config: Replace more handwritten impl DefaultIan Jackson2022-05-121-26/+4
| |
* | Merge branch 'ticket_412_467' into 'main'Nick Mathewson2022-05-121-0/+6
|\ \ | |/ |/| | | | | | | | | Teach DirMgr to use slightly untimely directories Closes #467 and #412 See merge request tpo/core/arti!500
| * Note a TODO in exitpath construction.Nick Mathewson2022-05-111-0/+6
| |
* | Add correct serde(default) attrs for humantime_serde::optionIan Jackson2022-05-121-4/+4
|/ | | | | | | | | Discovered by a test case in my local tree. The test case was macro-generated by an extension of impl_standard_builder (which macro istself currently awaiting review, arti!499) Have also sent an MR to update the upstream docs https://github.com/jean-airoldie/humantime-serde/pull/8
* config derive attrs: Make builders serde, and validated structs notIan Jackson2022-05-051-19/+7
| | | | | | | | | | | | | | | * 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.)
* Merge branch 'socket-addr-list-builder' into 'main'Ian Jackson2022-05-041-12/+16
|\ | | | | | | | | FallbackDir: orports: Introduce and use VecBuilder See merge request tpo/core/arti!474
| * FallbackDir: Use VecBuilder for orportsIan Jackson2022-05-041-12/+16
| | | | | | | | | | | | | | 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.
* | GuardUsage: restrictions: Use list builderIan Jackson2022-05-041-1/+2
|/ | | | | | | | | | | | | | Although these do not appear in the config, it does have a builder. It seems sensible to get rid of this ad-hoc list manipulation site, and replace it with our standard list builder API. define_list_builder_helper requires that the builder element type be Deserialize. Currently GuardUsageRestriction is a transparent, public enum, so we aren't really exposing anything. We could introduce GuardUsageRestrictionBuilder now, but since it's not in the config and thereofore only in the public API of the lower crates, we can definitely put that off.
* Change builder list APIIan Jackson2022-05-042-11/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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).
* Fix grammar and typosSamanta Navarro2022-04-272-2/+2
|
* Merge branch 'main' into 'msrv_1_56'Nick Mathewson2022-04-262-29/+34
|\ | | | | | | | | | | # Conflicts: # crates/tor-config/Cargo.toml # crates/tor-dirmgr/src/state.rs # doc/semver_status.md
| * Document defaults for all the config listsIan Jackson2022-04-251-1/+3
| | | | | | | | | | | | | | 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.
| * Rename ThingListBuilder::replace (from set)Ian Jackson2022-04-251-4/+4
| | | | | | | | | | As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/471#note_2798024
| * Use better syntax for doc comment attributeIan Jackson2022-04-251-3/+1
| | | | | | | | | | As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/471#note_2798020
| * Introduce PredictedPortsListBuilderIan Jackson2022-04-252-29/+34
| | | | | | | | | | | | This means that `NetworkConfig::initial_predicted_ports` is now like the other list-like things, returning `&mut list_builder` with the same `set()` and `append()` methods.
* | squash! Bump every crate's edition to 2021.Nick Mathewson2022-04-259-11/+0
|/ | | | | Remove all `use` statements for `TryFrom` and `TryInto`. These are now redundant in Rust 2021.
* fix typo in doctrinity-1686a2022-04-251-1/+1
|
* Merge branch 'report-skew' into 'main'eta2022-04-131-0/+12
|\ | | | | | | | | Report skew estimates from arti-client See merge request tpo/core/arti!455
| * circmgr: re-export clock skew estimates.Nick Mathewson2022-04-121-0/+12
| |
* | circmgr: back off on preemptive circuits if they fail consistentlyNick Mathewson2022-04-122-8/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | Rather than running preemptive circuit construction every 10 seconds, we change it to back off when it is "failing". (We define "failing" as creating no new circuits, and as giving at least one error.) This change means that we'll have one less reason to hammer the network when our connectivity is failed for some reason. Closes #437. Part of #329.
* | circmgr: Remove now-unused scheduled entry points.Nick Mathewson2022-04-121-18/+8
| | | | | | | | | | Now that we have TaskSchedule, we don't need to expose these any longer.
* | circmgr: Report CircProvenance from AbstractCircMgr.Nick Mathewson2022-04-122-23/+34
|/ | | | | | | This feature is similar to ChanProvenance from ChanMgr, except that we don't yet need to report it outside the crate. I'm going to use it to distinguish newly created circuits from existing circuits in the preemptive circuit builder.
* Create and use API to report guard/fallback skew.Nick Mathewson2022-04-072-12/+51
| | | | (The information is not yet recorded.)
* ChanMgr: Return provenance information from get_or_launchNick Mathewson2022-04-071-7/+8
| | | | | | We need this since we want to report certain conditions only when they happen on a new channel, not if we observe them on a preexisting channel.
* Distinguish UsageMismatch cases by whether a race is possibleNick Mathewson2022-04-042-7/+33
| | | | | | | This lets us say that the UsageMismatch cases in some parts of the code reflect a programming error (RetryTime::Never), whereas in other case it reflects another circuit request getting to the circuit first (RetryTime::Immediate).
* circmgr: Improve retry-and-or-delay logic.Nick Mathewson2022-04-041-26/+36
| | | | | | | | | Use the new RetryTime type and its associates to decide how long to wait (if at all) between attempts to build a circuit. Closes #421. Part of #329.
* circmgr: implement HasRetryTime.Nick Mathewson2022-04-041-2/+80
|
* circmgr: Improve reporting of error origins.Nick Mathewson2022-04-043-28/+77
| | | | | | | Previously we did not distinguish errors that came from pending circuits from errors that came from the circuits we were building. We also reported errors as coming from "Left" or "Right", instead of a more reasonable description.
* circmgr: Avoid a race condition in circuit usage restrictionNick Mathewson2022-04-043-11/+34
| | | | | | | | | | | | | | | | | | | | | | We were treating restrict_mut() failures as internal errors, and using internal errors to represent them. But in fact, these failures are entirely possible based on timing. Here's how it happens: * Two different circuit requests arrive at the same time, and both notice a pending circuit that they could use. * The pending circuit completes; both pending requests are notified. * The first request calls restrict_mut(), and restricts the request in such a way that the second couldn't use it. * The second request calls restrict_mut(), and gets a failure. Because of this issue, we treat these errors as transient failures and just wait for another circuit. Closes #427. (This is not a breaking API change, since `AbstractSpec` is a crate-private trait.)
* Use a lower default for max_retries.Nick Mathewson2022-03-301-1/+1
| | | | | | | | | | The older default seems (experimentally) to be ridiculously high. Generally, if we can't build a circuit within a handful attempts, that circuit has already timed out... unless there is a fast-failure condition, in which case we're just hammering the network (or our view of it.) Found with `arti-testing` for #329.
* circmgr: limit circuit attempts when launch_parallelism > 1.Nick Mathewson2022-03-301-1/+21
| | | | | | | | | | | Previously, if we had launch_parallelism > 1, and we were willing to retry building a circuit max_retries times, then we'd launch up to max_retries * launch_parallelism circuits before giving up. Ouch! With this patch, we try to keep the total number of circuits planned and attempted to the actual max_retries limit. Part of #329; found with arti-testing.
* Run cargo fmt one more time for good measure.Nick Mathewson2022-03-301-2/+2
|
* Refactor FirstHopId into type-differentiated formNick Mathewson2022-03-301-10/+22
| | | | | | | | | | | 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-3/+3
| | | | | This is preparation for having separate GuardId and FirstHopId types that distinguish which back-end they index.
* DirPathBuilder::pick_path: re-order match cases for clarity.Nick Mathewson2022-03-301-16/+18
|
* Rename ExternalFailure => ExternalActivity.Nick Mathewson2022-03-301-3/+3
|
* Replace the fallback directories when they change in the config.Nick Mathewson2022-03-301-0/+5
| | | | | | 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.
* Add status tracking to FallbackDir.Nick Mathewson2022-03-301-0/+9
| | | | | | | | | | | 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.
* circmgr: Use guard-manager's view of the fallbacks when possible.Nick Mathewson2022-03-304-14/+49
| | | | | | | | | | | | | | | | | | 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.
* Turn FallbackList into a real type, and store one in GuardMgr.Nick Mathewson2022-03-305-23/+30
| | | | | | | | | | | | | | 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-304-4/+6
| | | | | | | 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-5/+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-5/+0
| |
* | Make daemon tasks self-contained; introduce NetDirProvidereta2022-03-301-3/+251
|/ | | | | | | | | | | | | | | 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-18/+44
|\ | | | | | | | | | | | | Don't use SystemTime::now() Closes #306 See merge request tpo/core/arti!365
| * typotrinity-1686a2022-02-281-1/+1
| |