summaryrefslogtreecommitdiff
path: root/crates/tor-circmgr/src/impls.rs
Commit message (Collapse)AuthorAgeFilesLines
* CircMgr: Start writing tests.Wesley Aptekar-Cassels2024-10-031-0/+16
|
* CircMgr: Make CircMgr and HsCircPool generic over builder type.Wesley Aptekar-Cassels2024-09-241-4/+56
| | | | | | | | | | This will allow for testing, as the CircuitBuilder can be replaced with a mocked version. This did require moving some of what was in the CircuitBuilder impl into the AbstractCircuitBuilder type, since Drop implementations can't be specialized, but that's fine, as we'll probably be doing more of that in the future anyways.
* tor-circmgr: Remove AbstractSpec and FakeSpec.Wesley Aptekar-Cassels2024-09-161-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | AbstractSpec and FakeSpec actually make testing more difficult, since they prevent using FakeBuilder in code that relies on the concrete TargetCircUsage and SupportedCircUsage types. Removing them means FakeBuilder can be used in more places, and also means that the test code is closer to the real code, since TargetCircUsage and SupportedCircUsage are now exercised directly in more tests. This did require making one change to a test, which I think was previously testing behaviour that was true for FakeSpec but not for the real code: The mgr::test::isolated test previously asserted that, in the case where three circuits were requested, two with isolation and one without, the non-isolated circuit would be shared with one of the isolated circuits. This was allowed by the FakeSpec::supports function. However, in the actual code, the path is as follows: * AbstractCircMgr::get_or_launch * AbstractCircMgr::prepare_action * CircList::find_open * AbstractSpec::find_supported * abstract_spec_find_supported * OpenEntry::supports * SupportedCircUsage::supports * StreamIsolation::compatible_same_type StreamIsolation::compatible_same_type checks owner_type, which is always zero for non-isolated streams and always non-zero for isolated streams, meaning that a isolated stream will never be compatible with a non-isolated stream. The seems like desirable behaviour, so I simply modified the test to make four connections, two isolated and two not, and checked that the isolated streams never share any circuits, and that the two non-isolated streams use the same circuit. As far as I can tell, this is the intended behaviour in the existing code.
* tor-circmgr: make `GuardMgr` mandatorySteven Engler2024-08-121-1/+1
| | | | | | | Functions that took `Option<&GuardMgr>` now take only `&GuardMgr`. Three unit tests were removed that covered behaviour when no guard manager was set.
* tor-circmgr: Remove addressed TODO.Gabriela Moldovan2024-04-051-2/+0
| | | | This was addressed in !2046, but I forgot to remove the TODO.
* tor-circmgr: Give pick_path a VanguardMgr.Gabriela Moldovan2024-03-201-0/+2
|
* tor-circmgr: Add more vanguards TODOs.Gabriela Moldovan2024-03-201-0/+2
|
* tor-circmgr: Add UniqId to Error::GuardNotUsable.Gabriela Moldovan2024-02-271-1/+1
| | | | Part of #1297
* Refactor ClientCirc APIs to use Arc<ClientCirc>.Nick Mathewson2023-05-161-1/+1
| | | | | | | | | | | | Now ClientCirc is no longer `Clone`, and the things that need it to be `Clone` instead return and use an Arc<ClientCirc> We're doing this so that ClientCirc can participate in the RPC system, and so that its semantics are more obvious. Closes #846. Thanks to the type system, this was a much simpler refactoring than I had feared it would be.
* Provide ChannelUsage and plumb it all the way downIan Jackson2022-08-161-2/+7
| | | | | | | | | | | | | Channel padding depends on what the channel is being used for. We therefore need to let the channel code know this information. The implementation of the per-channel padding control logic will be in the new note_usage function, which for now is simply a stub. A future commit will introduce a `PaddingControlState` which lives in the channel frontend; consult the doc comment for that type to see why the plumbing through the channel manager terminates in the channel frontend.
* 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.
* Merge branch 'no-system-time' into 'main'eta2022-03-301-0/+1
|\ | | | | | | | | | | | | Don't use SystemTime::now() Closes #306 See merge request tpo/core/arti!365
| * remove most usage of SystemTime::nowtrinity-1686a2022-02-251-0/+1
| |
* | Move skip_fmt into tor-basic-utilsIan Jackson2022-03-041-1/+1
| | | | | | | | | | | | | | Code motion and the minimal mechanical changes. As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/375#note_2783078
* | Replace manual Debug impl with educe in tor-circmgrIan Jackson2022-03-021-12/+5
| |
* | Fix two typosNick Mathewson2022-02-281-1/+1
| |
* | impl Debug for various internal typesIan Jackson2022-02-251-0/+12
|/ | | | | | | | I wanted this while debugging something. The ad-hoc impl Debug with f.debug_struct is getting repetitive and I've already perpetrated one copy-paste mistake. We should consider using something like the `educe` crate's Clone.
* circmgr: Port InternalError to use Bug.Nick Mathewson2022-02-161-1/+2
|
* tor-circmgr: Remove Arc around ClientCircIan Jackson2022-01-071-2/+2
| | | | | | See the new commentary text on `ClientCirc` for the rationale. Signed-off-by: Ian Jackson <[email protected]>
* De-Arc-ify Buildable for ClientCircNeel Chauhan2022-01-061-1/+1
|
* Remove a bunch of unused RNGsNeel Chauhan2021-12-251-3/+1
|
* Allow on-the-fly changing of path_rulesNick Mathewson2021-12-071-2/+6
| | | | | | | | | | | | And now the complexity begins: when the user changes the path_rules, they not only want new circuits to obey those rules: they want _all new requests_ to be put onto circuits that obey those rules. That means that when the path rules become more restrictive, we need to retire all the circuits, and make sure that currently pending circuits aren't used for any requests. If it's any comfort, doing this was even more complicated in C tor. ;)
* Merge remote-tracking branch 'origin/mr/102'Nick Mathewson2021-10-261-1/+3
|\
| * Overhaul the way WaitFor and the MockSleepProvider worketa2021-10-261-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of racily advancing time forward, this commit attempts to rework how WaitFor works, such that it makes advances when all sleeper futures that have been created have been polled (by handing the MockSleepRuntime a Waker with which to wake up the WaitFor). The above described mechanics work well enough for the double timeout test, but fail in the presence of code that spawns asynchronous / background tasks that must make progress before time is advanced for the test to work properly. In order to deal with these cases, a set of APIs are introduced in order to block time from being advanced until some code has run, and a carveout added in order to permit small advances in time where required. (In some cases, code needed to be hacked up a bit in order to be made properly testable using these APIs; the `MockablePlan` trait included in here is somewhat unfortunate.) This should fix arti#149.
* | Fix a typo in a comment.Nick Mathewson2021-10-251-1/+1
|/
* Use better reporting for guard status.Nick Mathewson2021-10-131-13/+18
| | | | | | | | | | | | | The previous code would report all failures to build a circuit as failures of the guard. But of course that's not right: If we fail to extend to the second or third hop, that might or might not be the guard's fault. Now we use the "pending status" feature of the GuardMonitor type so that an early failure is attributed to the guard, but a later failure is attributed as "Indeterminate". Only a complete circuit is called a success. We use a new "GuardStatusHandle" type here so that we can report the status early if there is a timeout.
* WIPNick Mathewson2021-10-111-1/+1
|
* Integrate GuardUsability and GuardMonitor into CircuitBuilder.Nick Mathewson2021-10-101-4/+54
| | | | | | (When we're building a path with a guard, we need to tell the guard manager whether the path succeeded, and we need to wait to hear whether the guard is usable.)
* Move all crates into a `crates` subdirectory.Nick Mathewson2021-08-271-0/+85
This will cause some pain for now, but now is really the best time to do this kind of thing.