summaryrefslogtreecommitdiff
path: root/crates/tor-circmgr/src/preemptive.rs
Commit message (Collapse)AuthorAgeFilesLines
* Allow clippy::unchecked_duration_subtraction in testsNick Mathewson2023-01-271-0/+1
| | | | | This panics on error, and we're fine with a panic on misbehavior in tests.
* test lint blocks: Add many many automaticallyIan Jackson2022-12-121-0/+8
| | | | | This is precisely the result of running the rune in maint/adhoc-add-lint-blocks.
* Shorten the duration needed in preemptive::test::does_not_predict_old_ports.Alexander Færøy2022-08-311-2/+3
| | | | | | | | | | | This patch shortens the duration of the `does_not_predict_old_ports` test in the preemptive module. AppVeyor spawns its VMs/containers per build, so the `Instant::now()` call returns a value smaller than `60 * 60 + 1` which causes the subtraction to overflow and thus panic. Thanks to @trinity-1686a for the help here. See: tpo/core/arti#563.
* Change builder list APIIan Jackson2022-05-041-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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).
* 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
* Introduce PredictedPortsListBuilderIan Jackson2022-04-251-25/+16
| | | | | | 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.
* move isolation in separate moduletrinity-1686a2022-03-241-1/+1
|
* add trait to help test isolation related codetrinity-1686a2022-03-161-19/+29
|
* fix existing teststrinity-1686a2022-03-161-32/+20
|
* preemptive.rs: Use Instant::checked_add instead of raw subtractioneta2021-12-201-2/+12
| | | | | | | | | | | The implementations of `Add` / `Sub` (et al.) on `std::time::Instant` can panic if the underlying OS structure can't represent the result (like arti#266). Use Instant::checked_add and print a warning instead, to prevent panicking. Also, we now add instead of subtracting; I suspect it's reasonable that you might not be able to go backward past the first `Instant` created on some platforms, but going *forward* should probably work?
* Minor circuit predictor tweaks and comments.Nick Mathewson2021-12-071-3/+11
| | | | | | Most notably, make min_exit_circs_for_port actually get used. Also add a couple of comments.
* Make preemptive circuits reconfigurable.Nick Mathewson2021-12-071-22/+56
| | | | | | This required re-centralizing the configuration object for preemptive circuits, since previously the settings from it were a bit spread out over the crate.
* Allow configurability on preemptive circuitsNeel Chauhan2021-12-071-20/+44
|
* Add a semicolon.Nick Mathewson2021-11-301-1/+1
|
* Add tests & address review commentaryeta2021-11-301-3/+76
|
* Actually build preemptive circuits (and minor fixes)eta2021-11-291-0/+2
| | | | | | The new CircMgr::build_circuits_preemptively function actually causes preemptive circuits to be built; it gets called from arti-client, like the other daemon tasks the CircMgr has.
* Introduce PreemptiveCircuitPredictor and TargetCircUsage::Preemptiveeta2021-11-231-0/+42
In preparation for making Arti build circuits preemptively, this commit introduces `TargetCircUsage::Preemptive`, a circuit usage that works somewhat differently from other ones: it requires at least 2 circuits to exist that can exit the port it contains in order for an existing circuit to match against it (path-spec.txt § 2.1.1); if that's not the case, that usage will require building new circuits (in order that we build enough to have 2 available). This required refactoring how circuit reuse worked; now, `CircList::find_open` uses the new `AbstractSpec::find_supported` trait method, which we customize to implement the above check in the case of `Preemptive` circuit usages. To make that work, `OpenEntry` now takes two type parameters (the spec and circuit types), instead of taking a builder type parameter and using its associated types. (We also got rid of type constraints on that struct, yay!) A WIP implementation of a preemptive circuit predictor that implements path-spec.txt § 2.1.1 is also included, but this will require additional effort to wire it up with the `CircMgr` properly.