aboutsummaryrefslogtreecommitdiff
path: root/crates/tor-guardmgr/src/vanguards/set.rs
Commit message (Collapse)AuthorAgeFilesLines
* Upgrade rand crates to 0.10.Wesley Aptekar-Cassels2026-05-121-5/+5
| | | | | | | | | | | When the circ-padding feature is enabled, we use maybenot, which does not yet support rand 0.10. In the meantime, enabling this feature pulls in rand 0.9. This is not ideal, but should be okay as a temporary situation. This also replaces the use of ReseedingRng (which was removed in 0.10) with the reseeding_rng crate. This is somewhat less performant, but it should be okay.
* Fix word duplicate typosTobias Stoeckmann2026-03-151-1/+1
|
* Conditionalise a test-only `use`Ian Jackson2025-11-061-1/+4
|
* Switch Cargo.toml files to edition 2024.Nick Mathewson2025-08-071-2/+2
| | | | | | | | | | | | | | First, run ``` git grep -l "^edition =" | xargs perl -i -pe 's/^edition *=.*/edition = "2024"/;' ``` Second, manually verify that all Cargo.toml files have changed, and nothing else has changed. Third, run cargo fmt again.
* guardmgr, circmgr: Make vanguard selection take a RelaySelector.Nick Mathewson2025-05-201-2/+2
| | | | | | This is the preferred type for choosing a relay, since unlike a RelayExclusion, it lets us add multiple restrictions, and a relay usage.
* squash! Upgrade rand dependency to 0.9.Nick Mathewson2025-03-181-1/+1
| | | | - Several methods have been moved out of SliceRandom.
* squash! Upgrade rand dependency to 0.9.Nick Mathewson2025-03-181-1/+1
| | | | - `rand::thread_rng()` has been deprecated and renamed to `rand::rng()`
* tor-guardmgr: Convert a TODO into a NOTE.Gabriela Moldovan2024-09-101-1/+2
| | | | | | | | | This behavior is OK, so this doesn't need to be a TODO. See the discussion at https://gitlab.torproject.org/tpo/core/arti/-/issues/1352#note_3015217 Closes #1352
* Fix typosDimitris Apostolou2024-09-031-1/+1
|
* tor-guardmgr: Return a BootstrapRequired error if all the sets are empty.Gabriela Moldovan2024-05-091-0/+5
| | | | | | | | | Previously, `select_vanguard` returned a `NoSuitableRelay` error if it was unable to select a relay to use as a vanguard. We now distunguish the "there are no suitable relays in the vanguard sets" (`NoSuitableRelays`) error case from the "our vanguard sets are empty" (`BootstrapRequired`) one.
* tor-guardmgr: Remove TODO about removing Vanguard abstraction.Gabriela Moldovan2024-05-091-3/+0
| | | | | I think it's alright to keep it: it gives us the flexibility to extend it later on, if needed.
* tor-guardmgr: Remove a TODO HS-VANGUARDS.Gabriela Moldovan2024-05-091-3/+0
| | | | | | This TODO doesn't really need to be implemented: we can test the `VanguardMgr` just the same without it (`GuardMgrInner` is similar, in that it doesn't mock the rng).
* tor-guardmgr: Make remove_unlisted return the number of unlisted vanguards.Gabriela Moldovan2024-04-301-2/+4
| | | | For symmetry with remove_expired.
* tor-guardmgr: Make remove_expired return the number of expired vanguards.Gabriela Moldovan2024-04-301-17/+23
| | | | Prompted by https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2109#note_3024672
* tor-guardmgr: Prevent misleading logs when not rotating vanguards.Gabriela Moldovan2024-04-291-0/+10
| | | | | `rotate_expired()` now only logs that it is rotating the vanguards if some existing vanguards have actually expired.
* tor-guardmgr: Remove unnecessary clippy allows.Gabriela Moldovan2024-04-291-1/+0
| | | | None of these should be unused anymore.
* tor-guardmgr: Remove unnecessary VanguardSetsTrackedMut contraption.Gabriela Moldovan2024-04-221-163/+16
| | | | | | | | The VanguardMgr now unconditionally flushes the vanguard sets to disk each time there's a consensus change, and every time a vanguard expires. Prompted by https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2090#note_3021013
* tor-guardmgr: Remove pick_{l2,l3}_relay, add l2(), l3() accessors.Gabriela Moldovan2024-04-221-25/+10
| | | | Prompted by https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2090#note_3021016
* tor-guardmgr: Make vanguard logs begin with an uppercase letter for consistency.Gabriela Moldovan2024-04-221-1/+1
| | | | | Our log messages begin with an uppercase letter in the rest of the code base.
* tor-guardmgr: Add logging around vanguard rotation.Gabriela Moldovan2024-04-221-3/+19
|
* tor-guardmgr: Derive PartialEq for VanguardSets.Gabriela Moldovan2024-04-221-3/+3
| | | | This will be useful for testing.
* tor-guardmgr: Make VanguardSet private.Gabriela Moldovan2024-04-221-18/+10
| | | | | | This doesn't need to be `pub(super)` anymore, `VanguardMgr` now manipulates the `VanguardSets` exclusively through `VanguardSetsTrackedMut`.
* tor-guardmgr: Move vanguard set replenishing logic to VanguardSetsTrackedMut.Gabriela Moldovan2024-04-221-13/+272
| | | | | | A lot of this is code motion: the code added to `VanguardSetsTrackedMut` was copied from the `VanguardMgr` impl, so I recommend reviewing this with `git diff --color-moved=zebra`.
* tor-guardmgr: Add VanguardSetsTrackedMut for mutating VanguardSets.Gabriela Moldovan2024-04-221-0/+54
| | | | | | | | | This enables us to track when `VanguardMgr`'s `VanguardSets` is *actually* mutated. This will soon be useful because we only want to flush the `VanguardSets` to storage if we actually added or removed some relays from the set.
* tor-guardmgr: Add some accessors for VanguardSets.Gabriela Moldovan2024-04-221-0/+43
| | | | | These will be useful later, when we place the `l2_vanguards` and `l3_vanguards` from `VanguardMgr` with a `VanguardSets`.
* tor-guardmgr: VanguardSet::remove_{unlisted,expired} returns whether the set ↵Gabriela Moldovan2024-04-221-5/+14
| | | | | | | | | changed. The two removal functions now return whether any values were removed from the `VanguardSet`. Their return values are currently ignored, but will soon be used for deciding whether to flush the `VanguardSet`s to disk (if full vanguards are enabled).
* tor-guardmgr: Introduce an abstraction over the two vanguard sets.Gabriela Moldovan2024-04-221-0/+19
| | | | | | | `VanguardSets` (not to be confused with `VanguardSet`) will soon be used as: * a helper for serializing the L2 and L3 `VanguardSet`s * an abstraction over the two vanguard sets
* tor-guardmgr: Derive Default for VanguardSet.Gabriela Moldovan2024-04-221-1/+6
| | | | | | | | | | We will soon replace `VanguardSet::new` with `VanguardSet::default`: `new()` currently expects a set of `VanguardParams` (from which the target size of the set is derived), but we don't have a `VanguardParams` until we obtain a `NetDir`. Moreover, it doesn't make sense to attempt to set the target size of the `VanguardSet` before obtaining a `NetDir`, because we can't actually populate the set without a `NetDir` (we can't select relays).
* tor-guardmgr: Remove unnecessary mutable reference.Gabriela Moldovan2024-04-151-1/+1
|
* tor-guardmgr: Remove outdated documentation.Gabriela Moldovan2024-04-151-3/+0
| | | | | This is no longer true because of !2082. The `VanguardSet` *does* own its `TimeBoundVanguards`.
* tor-guardmgr: Remove unused TimeBoundVanguard implementations.Gabriela Moldovan2024-04-151-24/+0
| | | | These are not used anymore as of !2082, so we can remove them now.
* tor-guardmgr: Replace vanguard heap with a simpler approach.Gabriela Moldovan2024-04-101-27/+25
| | | | | | | | | | | | | | | | | | As mentioned in https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2075#note_3016306 using a heap isn't the best way to manage the vanguards: * in the default case, which will apply to most users, the L2 and L3 set sizes are 4 and 8 respectively. Using a heap doesn't make sense for such small sets * the use of `Weak<TimeBoundVanguard>`s will be an inconvenience later on, when we implement vanguard set persistence, since `Weak` isn't serializable or deserializable This switches to a simpler apporach, where the `VanguardMgr` computes the soonest expiration timestamp of its `VanguardSet`s by iterating over all the vanguards in each set. Closes #1366
* tor-guardmgr: Remove unnecessary call to discard_expired().Gabriela Moldovan2024-04-101-1/+0
|
* tor-guardmgr: Explain why we're making a uniform choice.Gabriela Moldovan2024-04-091-0/+3
|
* tor-guardmgr: Add tests for the vanguard manager.Gabriela Moldovan2024-04-051-0/+16
|
* tor-guardmgr: Replenish the vanguard sets as needed.Gabriela Moldovan2024-04-051-0/+24
|
* tor-guardmgr: Implement From<&VanguardSet> for RelayIdSet.Gabriela Moldovan2024-04-051-1/+20
|
* tor-guardmgr: Implement VanguardSet::pick_relay.Gabriela Moldovan2024-04-051-9/+32
| | | | Closes #1340
* tor-guardmgr: Make TimeboundVanguard fields pub(super).Gabriela Moldovan2024-04-051-2/+2
|
* tor-guardmgr: Store the TimeboundVanguards in a binary heap.Gabriela Moldovan2024-04-051-5/+29
|
* tor-guardmgr: Give VanguardSets a target set size.Gabriela Moldovan2024-04-051-1/+11
| | | | | The target is the number of vanguards the `VanguardMgr`s will try to maintain in the `VanguardSet`.
* tor-guardmgr: Pass an rng to select_vanguard.Gabriela Moldovan2024-04-051-1/+3
| | | | | This function will need to randomly select a vanguard, so it needs an `Rng`.
* tor-guardmgr: Fix typo in VanguardSet docs.Gabriela Moldovan2024-04-051-1/+1
|
* tor-circmgr: Fix a clippy warning.Gabriela Moldovan2024-03-211-1/+1
|
* tor-guardmgr: Explain what neighbor_exclusion is for.Gabriela Moldovan2024-03-211-1/+4
|
* tor-guardmgr: Make Vanguard::select_relay take a RelayExclusion.Gabriela Moldovan2024-03-211-1/+6
| | | | | | | This enables us to prevent the same relay from being picked in consecutive positions in a path. Part of #1340
* tor-guardmgr: Derive getters for Vanguard.Gabriela Moldovan2024-03-201-2/+1
|
* tor-guardmgr: Move the VanguardSets into the inner mutable state.Gabriela Moldovan2024-03-111-1/+1
|
* tor-guardmgr: Say more about TimeBoundVanguards.Gabriela Moldovan2024-03-111-0/+8
|
* tor-guardmgr: Add vanguards API skeleton.Gabriela Moldovan2024-03-111-0/+45
Part of #1275