aboutsummaryrefslogtreecommitdiff
path: root/crates/tor-circmgr/src/preemptive.rs
Commit message (Collapse)AuthorAgeFilesLines
* 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.