summaryrefslogtreecommitdiff
path: root/crates/tor-guardmgr/src
Commit message (Collapse)AuthorAgeFilesLines
* config derive attrs: Make builders serde, and validated structs notIan Jackson2022-05-053-7/+5
| | | | | | | | | | | | | | | * 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-042-23/+28
|\ | | | | | | | | FallbackDir: orports: Introduce and use VecBuilder See merge request tpo/core/arti!474
| * FallbackDir: Use VecBuilder for orportsIan Jackson2022-05-042-13/+14
| | | | | | | | | | | | | | 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.
| * FallbackDir: Do orport validation after autogenerated buildIan Jackson2022-05-041-5/+11
| | | | | | | | This avoids it having to recapitulate defaulting logic.
| * FallbackDir: Do not consider defaulted-empty orport list to be validIan Jackson2022-05-041-7/+5
| |
* | GuardUsage: restrictions: Use list builderIan Jackson2022-05-042-38/+54
|/ | | | | | | | | | | | | | 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-041-10/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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-271-1/+1
|
* Merge branch 'main' into 'msrv_1_56'Nick Mathewson2022-04-261-48/+14
|\ | | | | | | | | | | # Conflicts: # crates/tor-config/Cargo.toml # crates/tor-dirmgr/src/state.rs # doc/semver_status.md
| * list_builder: Use $crate namespaced importsIan Jackson2022-04-251-1/+1
| | | | | | | | | | | | | | I don't think we need to bother with things in the prelude, but doing it for serde and ConfigBuildError seems nice. Noticed while writing a test case.
| * Document defaults for all the config listsIan Jackson2022-04-251-1/+4
| | | | | | | | | | | | | | 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.
| * Use better syntax for doc comment attributeIan Jackson2022-04-251-7/+5
| | | | | | | | | | As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/471#note_2798020
| * Introduce define_list_config_builder macroIan Jackson2022-04-251-48/+13
| | | | | | | | | | | | This replaces two almost-identical sets of structs and impls. More are on the way, as per https://gitlab.torproject.org/tpo/core/arti/-/issues/447
* | squash! Bump every crate's edition to 2021.Nick Mathewson2022-04-251-1/+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
|
* fallback list: Introduce and use FallbackListBuilderIan Jackson2022-04-222-9/+58
| | | | | | | | | 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.
* fallback list: Move default list into tor-guardmgrIan Jackson2022-04-222-0/+1728
| | | | | | | | | | 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.
* arti-client: Report clock skew when it is noteworthyNick Mathewson2022-04-121-0/+5
| | | | | (Also, blame clock skew when it is an explanation of why we cannot finish a connection.)
* circmgr: re-export clock skew estimates.Nick Mathewson2022-04-122-0/+4
|
* GuardMgr: publish skew estimates.Nick Mathewson2022-04-122-9/+85
| | | | | | Instead of just having a function that recalculates the latest clock skew, instead recalculate the clock skew when it may have changed, and notify other processes via a postage::watch.
* guardmgr: fix a unit test panic.Nick Mathewson2022-04-111-1/+5
| | | | | | | Apparently on OSX you are not allowed to construct an Instant that is a long time before the time when the test is running. Also, fix the length of a year in this test.
* Fold FallbackStatus into Entry.Nick Mathewson2022-04-111-44/+31
| | | | This simplifies the code a lot.
* Add a couple of TODO items to clock-skew estimator.Nick Mathewson2022-04-111-0/+7
|
* Implement a better clock skew estimator.Nick Mathewson2022-04-111-16/+306
| | | | | | | | This time, our estimator discards outliers, takes the mean of what's left, and uses the standard deviation to try to figure out how seriously to take our report of skew/not-skew. These estimates are still not actually used.
* Initial functions to determine and expose a clock skew estimate.Nick Mathewson2022-04-075-1/+110
| | | | | (This is just a placeholder; I'm going to make the functions smarter in the next commit.)
* GuardMgr: record clock skew information.Nick Mathewson2022-04-076-22/+106
| | | | (It is not yet actually used.)
* Create and use API to report guard/fallback skew.Nick Mathewson2022-04-072-3/+17
| | | | (The information is not yet recorded.)
* Merge branch 'main' into 'separate_dir_status'Nick Mathewson2022-04-061-0/+24
|\ | | | | | | # Conflicts: # doc/semver_status.md
| * guardmgr: implement HasRetryTime.Nick Mathewson2022-04-041-0/+24
| |
* | Fix a rustdoc linkNick Mathewson2022-04-051-5/+5
| |
* | GuardMgr: Tests for copy_status_from.Nick Mathewson2022-04-052-0/+65
| |
* | GuardMgr: Tests for note_external_{success,failure}.Nick Mathewson2022-04-051-0/+57
| |
* | Rewrite and fix Guard::copy_status_from.Nick Mathewson2022-04-053-21/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The old version of this function was error-prone, and in fact had errors: it was too easy to forget to add non-persistent fields, and that's exactly what we forgot in a few cases (`microdescriptor_missing`, `circ_history`, and `suspicious_behavior_warned`). The new version of this function consumes both of the incoming Guards, and constructs every field explicitly so that we can't forget to list any. Closes #429.
* | GuardMgr: Track directory status and circuit status separately.Nick Mathewson2022-04-054-69/+235
| | | | | | | | | | | | | | | | | | | | | | | | | | Previously, we treated successfully building a circuit to a guard as a "success", and any failure, including a directory cache failure, as a failure. With this change, guards now have separate success/failure and retry status for circuit usage and directory usage. This change is needed for guard-as-directory retry to have reasonable behavior. Otherwise, when a guard succeeds at building a circuit, that clears the directory-is-failing status and makes us retry the guards to quickly.
* | Allow DirStatus objects to have different timeout floorsNick Mathewson2022-04-042-21/+24
| | | | | | | | This will help when we give Guards a DirStatus as well.
* | Rename fallback::status::Status to DirStatus.Nick Mathewson2022-04-044-13/+13
|/ | | | It's about to be shared between fallbacks and guards.
* Use derive_more to derive AsRef.Nick Mathewson2022-03-301-12/+3
|
* Fix some Rustdoc links.Nick Mathewson2022-03-304-5/+5
|
* Refactor FirstHopId into type-differentiated formNick Mathewson2022-03-307-169/+322
| | | | | | | | | | | 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-306-70/+84
| | | | | This is preparation for having separate GuardId and FirstHopId types that distinguish which back-end they index.
* FallbackState: Use itertools::merge_join_by.Nick Mathewson2022-03-301-100/+8
| | | | | This replaces a hand-coded replacement that was probably a little less efficient.
* Fold fallback::Status::reset() into its (only) caller.Nick Mathewson2022-03-301-7/+2
|
* Rename FallbackState::lookup_mut => get_mut.Nick Mathewson2022-03-301-12/+12
|
* Rename FallbackSet => FallbackState.Nick Mathewson2022-03-303-15/+15
|
* Refactor select_guard_with_expand to use match and log errors.Nick Mathewson2022-03-301-10/+13
|
* ListKind: Use an exhaustive match to future-proof.Nick Mathewson2022-03-301-1/+4
|
* Clarify documentation about GuardUsable constructorsNick Mathewson2022-03-301-4/+10
|
* Add a TODO about an unslightly type.Nick Mathewson2022-03-301-0/+2
|
* Clean up a rustdoc linkIan Jackson2022-03-301-1/+1
|
* guardmgr::fallback::set: basic unit tests.Nick Mathewson2022-03-301-10/+190
|